using BWP.B3ProcurementInterface.Utils;
|
|
using BWP.B3SheepButcherManage.BL;
|
|
using BWP.B3SheepButcherManage.BO;
|
|
using BWP.Web.CustomPageLayout;
|
|
using BWP.Web.Layout;
|
|
using BWP.Web.Utils;
|
|
using BWP.Web.WebControls;
|
|
using Forks.EnterpriseServices.DataForm;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using TSingSoft.WebControls2;
|
|
using Forks.Utils.Collections;
|
|
using Forks.EnterpriseServices.BusinessInterfaces;
|
|
using BWP.B3SheepButcherManage.Utils;
|
|
using BWP.B3ProduceUnitedInfos.NamedValueTemplate;
|
|
using BWP.Web.Pages.B3CowButcherManage.Dialogs;
|
|
using BWP.B3CowButcherManage;
|
|
|
|
namespace BWP.Web.Pages.B3SheepButcherManage.Bills.WeightBill_
|
|
{
|
|
class WeightBillEdit : DepartmentWorkFlowBillEditPage<WeightBill, IWeightBillBL>
|
|
{
|
|
private DFEditGrid _weightGrid, _abnormalGrid;
|
|
|
|
protected override void BuildBasePropertiesEditor(TitlePanel titlePanel, PageLayoutSection section)
|
|
{
|
|
var layoutManager = new LayoutManager("main", mDFInfo, mDFContainer);
|
|
var supplierInpput = InputCreator.DFChoiceBox(B3ProcurementInterfaceDataSources.供应商, "Supplier_Name");
|
|
layoutManager.Add("Supplier_ID", supplierInpput);
|
|
|
|
var config = new AutoLayoutConfig();
|
|
config.Add("AccountingUnit_ID");
|
|
config.Add("Department_ID");
|
|
config.Add("Employee_ID");
|
|
config.Add("WeighTime");
|
|
config.Add("Supplier_ID");
|
|
config.Add("Supplier_Tel");
|
|
config.Add("Supplier_Card_ID");
|
|
config.Add("BuyNum");
|
|
config.Add("BuyWeigh1");
|
|
config.Add("Zone_ID");
|
|
config.Add("ValuationArea_ID");
|
|
config.Add("MoneyCountMethod");
|
|
config.Add("QuarantineNumber");
|
|
config.Add("Remark");
|
|
layoutManager.Config = config;
|
|
section.ApplyLayout(layoutManager, config, mPageLayoutManager, mDFInfo);
|
|
titlePanel.Controls.Add(layoutManager.CreateLayout());
|
|
if (layoutManager.Contains("ValuationArea_ID"))
|
|
{
|
|
var valuationAreaInput = layoutManager["ValuationArea_ID"].InputControl as DFChoiceBox;
|
|
if (valuationAreaInput != null)
|
|
{
|
|
valuationAreaInput.OnBeforeDrop = "this.codeArgument = __DFContainer.getValue('AccountingUnit_ID');";
|
|
}
|
|
}
|
|
AddSupplierScript(layoutManager);
|
|
}
|
|
|
|
void AddSupplierScript(LayoutManager layoutManager)
|
|
{
|
|
if (layoutManager.Contains("Supplier_ID"))
|
|
{
|
|
var supplierInput = layoutManager["Supplier_ID"].InputControl as DFChoiceBox;
|
|
|
|
var script = @"
|
|
var txtValue =parseInt(__DFContainer.getValue('Supplier_ID'));
|
|
simpleRestCall('/MainSystem/B3CowButcherManage/Rpcs/SupplierRpc/GetBySupplierID',[txtValue,['Tel','Card_ID','Employee_ID','Employee_Name']],
|
|
function(result){
|
|
if(typeof(result.Tel)!='undefined')
|
|
{
|
|
__DFContainer.setValue('Supplier_Tel',result.Tel);
|
|
}
|
|
else
|
|
{
|
|
__DFContainer.setValue('Supplier_Tel','');
|
|
}
|
|
|
|
if(typeof(result.Card_ID)!='undefined')
|
|
{
|
|
__DFContainer.setValue('Supplier_Card_ID',result.Card_ID);
|
|
}
|
|
else
|
|
{
|
|
__DFContainer.setValue('Supplier_Card_ID','');
|
|
}
|
|
if(typeof(result.Employee_ID)!='undefined')
|
|
{
|
|
__DFContainer.getControl('Employee_ID').fill(result.Employee_ID,result.Employee_Name);
|
|
}
|
|
else
|
|
{
|
|
__DFContainer.getControl('Employee_ID').fill('','');
|
|
}
|
|
},{ });";
|
|
supplierInput.OnClientSelected = script;
|
|
}
|
|
}
|
|
|
|
protected override void BuildBody(Control form)
|
|
{
|
|
base.BuildBody(form);
|
|
CreateWeighInfoPanel(form.EAdd(new TitlePanel("过磅记录")));
|
|
CreateAbnormalItemPanel(form.EAdd(new TitlePanel("异常记录")));
|
|
}
|
|
|
|
private void CreateWeighInfoPanel(TitlePanel titlePanel)
|
|
{
|
|
var vPanel = new VLayoutPanel();
|
|
titlePanel.Controls.Add(vPanel);
|
|
if (CanSave)
|
|
{
|
|
var hPanel = vPanel.Add(new HLayoutPanel(), new VLayoutOption(HorizontalAlign.Left));
|
|
var addBtn = new TSButton() { Text = "新增" };
|
|
|
|
addBtn.Click += (sender, e) =>
|
|
{
|
|
_weightGrid.GetFromUI();
|
|
WeightBill_Record w = new WeightBill_Record();
|
|
|
|
Dmo.WeighRecords.Add(w);
|
|
|
|
_weightGrid.DataBind();
|
|
};
|
|
hPanel.Add(addBtn);
|
|
|
|
|
|
var input1 = hPanel.Add(new DFWebSocketInput(8181));
|
|
input1.Width = 100;
|
|
input1.Height = 35;
|
|
input1.Font.Bold = true;
|
|
input1.Font.Size = 16;
|
|
#if DEBUG
|
|
input1.Text = "15.5";
|
|
#endif
|
|
//input1.Text = "15";
|
|
mDFContainer.AddNonDFControl(input1, "$WebSocketInput");
|
|
|
|
TSButton readBtn = hPanel.Add(new TSButton()
|
|
{
|
|
Text = "载入重量数据"
|
|
});
|
|
|
|
readBtn.OnClientClick = "$('#GridRowIndex').val(__DFContainer.getControl('$Details').behind.mSelectedRowIndex);";
|
|
|
|
readBtn.Click += delegate
|
|
{
|
|
_weightGrid.GetFromUI();
|
|
var index = int.Parse(Request.Form["GridRowIndex"]) - 1;
|
|
var detail = Dmo.WeighRecords[index];
|
|
if (detail.Weight == null)
|
|
{
|
|
detail.Weight = 0;
|
|
}
|
|
decimal inputWeight;
|
|
if (decimal.TryParse(input1.Text, out inputWeight))
|
|
{
|
|
detail.Weight += inputWeight;
|
|
}
|
|
WeightUtil.InsertRecord(Dmo, detail, decimal.Round(decimal.Parse(input1.Text), 2), "电子称");
|
|
_weightGrid.DataBind();
|
|
};
|
|
|
|
var weight = hPanel.Add(new DialogButton { Text = "称重记录" });
|
|
weight.Click += queryWInforBtn_Click;
|
|
weight.Url = AspUtil.AddParamToUrl(AspUtil.AddParamToUrl(AspUtil.AddParamToUrl("~/B3CowButcherManage/Dialogs/WeightRecordDialog.aspx", "BillType", "'+3139+'"), "DetailID", "'+__DFContainer.getControl('$Details').behind.selectedRow().dfContainer.getValue('ID')+'"), "BillID", "'+" + MinDmo.ID + "+'");
|
|
|
|
}
|
|
|
|
var detailEditor = new DFCollectionEditor<WeightBill_Record>(() => Dmo.WeighRecords);
|
|
detailEditor.AllowDeletionFunc = () => CanSave;
|
|
detailEditor.CanDeleteFunc = (detail) => CanSave;
|
|
detailEditor.IsEditableFunc = (field, detail) => CanSave;
|
|
_weightGrid = vPanel.Add(new DFEditGrid(detailEditor) { Width = Unit.Percentage(100) });
|
|
var liveVarieties = new DFEditGridColumn<DFChoiceBox>("LiveVarieties_ID");
|
|
_weightGrid.Columns.Add(liveVarieties);
|
|
liveVarieties.InitEditControl += (sender, e) =>
|
|
{
|
|
e.Control.DataKind = B3ProduceUnitedInfos.B3ProduceUnitedInfosDataSources.活体品种;
|
|
e.Control.DFDisplayField = "LiveVarieties_Name";
|
|
e.Control.Width = Unit.Pixel(150);
|
|
e.Control.EnableInputArgument = true;
|
|
e.Control.CodeArgument = 生物资产属性.羊.Value.ToString();
|
|
};
|
|
_weightGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("Number")).InitEditControl += (sender, e) =>
|
|
{
|
|
e.Control.Style["width"] = "160px";
|
|
};
|
|
_weightGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("Weight")).InitEditControl += (sender, e) =>
|
|
{
|
|
e.Control.Style["width"] = "160px";
|
|
};
|
|
_weightGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("AvgWeight"));
|
|
_weightGrid.Columns.EAdd(new DFEditGridColumn<DFChoiceBox>("LiveColonyHouse_ID")).InitEditControl += (sender, e) =>
|
|
{
|
|
e.Control.DataKind = B3ProduceUnitedInfos.B3ProduceUnitedInfosDataSources.活体圈舍;
|
|
e.Control.CodeArgument = 生物资产属性.羊.Value.ToString();
|
|
e.Control.DFDisplayField = "LiveColonyHouse_Name";
|
|
e.Control.Width = Unit.Pixel(150);
|
|
};
|
|
_weightGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("Remark")).InitEditControl += (sender, e) =>
|
|
{
|
|
e.Control.Style["width"] = "360px";
|
|
};
|
|
_weightGrid.ValueColumns.Add("ID");
|
|
var section2 = mPageLayoutManager.AddSection("detailColumns1", "明细");
|
|
section2.ApplyLayout(_weightGrid, mPageLayoutManager, DFInfo.Get(typeof(WeightBill_Record)));
|
|
titlePanel.SetPageLayoutSetting(mPageLayoutManager, section2.Name);
|
|
mDFContainer.AddNonDFControl(_weightGrid, "$Details");
|
|
}
|
|
|
|
void queryWInforBtn_Click(object sender, EventArgs e)
|
|
{
|
|
_weightGrid.GetFromUI();
|
|
var vInfor = DialogUtil.GetCachedObj(this) as SumWInfor;
|
|
var detail = Dmo.WeighRecords.First(x => x.ID == vInfor.DetailID);
|
|
detail.Weight = vInfor.Weight;
|
|
_weightGrid.DataBind();
|
|
GetFromUI();
|
|
DmoSave2(detail.ID);
|
|
}
|
|
private void DmoSave2(long detailID = 0)
|
|
{
|
|
GetFromUI();
|
|
if (IsNew)
|
|
{
|
|
mBL.Insert(Dmo);
|
|
}
|
|
else
|
|
{
|
|
mBL.Update(Dmo);
|
|
}
|
|
var blMessage = BIFactory.GetLastMessage();
|
|
var url = Request.RawUrl;
|
|
if (IsNew)
|
|
{
|
|
url = AspUtil.RemoveUrlParam(url, "ReferToID");
|
|
url = AspUtil.AddParamToUrl(url, "ID", Dmo.ID.ToString());
|
|
}
|
|
var message = "保存成功!";
|
|
if (!string.IsNullOrEmpty(blMessage))
|
|
{
|
|
message += "\r\n" + blMessage;
|
|
}
|
|
|
|
url = AspUtil.RemoveUrlParam(url, "detailID");
|
|
if (detailID == 0)
|
|
AspUtil.RedirectAndAlert(this, url, message);
|
|
else
|
|
AspUtil.Redirect(AspUtil.UpdateUrlParam(Request.RawUrl, "detailID", detailID.ToString()));
|
|
}
|
|
|
|
private void CreateAbnormalItemPanel(TitlePanel titlePanel)
|
|
{
|
|
var vPanel = new VLayoutPanel();
|
|
titlePanel.Controls.Add(vPanel);
|
|
if (CanSave)
|
|
{
|
|
var hPanel = vPanel.Add(new HLayoutPanel(), new VLayoutOption(HorizontalAlign.Left));
|
|
var addBtn = new TSButton() { Text = "新增" };
|
|
addBtn.Click += (sender, e) =>
|
|
{
|
|
_abnormalGrid.GetFromUI();
|
|
Dmo.WeighAbnormalRecording.Add(new WeightBill_AbnormalRecording());
|
|
_abnormalGrid.DataBind();
|
|
};
|
|
hPanel.Add(addBtn);
|
|
}
|
|
var detailEditor = new DFCollectionEditor<WeightBill_AbnormalRecording>(() => Dmo.WeighAbnormalRecording);
|
|
detailEditor.AllowDeletionFunc = () => CanSave;
|
|
detailEditor.CanDeleteFunc = (detail) => CanSave;
|
|
detailEditor.IsEditableFunc = (field, detail) => CanSave;
|
|
_abnormalGrid = vPanel.Add(new DFEditGrid(detailEditor) { Width = Unit.Percentage(100), ShowLineNo = true });
|
|
_abnormalGrid.Columns.EAdd(new DFEditGridColumn<DFChoiceBox>("RewardItem_ID")).InitEditControl += (sender, e) =>
|
|
{
|
|
e.Control.DataKind = B3CowButcherManageConsts.DataSources.奖罚项目;
|
|
e.Control.DFDisplayField = "RewardItem_Name";
|
|
e.Control.Width = Unit.Pixel(150);
|
|
};
|
|
_abnormalGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("Number")).InitEditControl += (sender, e) =>
|
|
{
|
|
e.Control.Style["width"] = "160px";
|
|
};
|
|
_abnormalGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("Price")).InitEditControl += (sender, e) =>
|
|
{
|
|
e.Control.Style["width"] = "160px";
|
|
};
|
|
_abnormalGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Abnormal_Money"));
|
|
_abnormalGrid.PreferWidthGridSet = new Dictionary<string, Unit> { { "序号", Unit.Pixel(80) }, { "奖罚项目", Unit.Percentage(20) }, { "头数", Unit.Percentage(20) }, { "单价", Unit.Percentage(20) }, { "金额", Unit.Percentage(20) } };
|
|
var section3 = mPageLayoutManager.AddSection("detailColumns2", "明细");
|
|
section3.ApplyLayout(_abnormalGrid, mPageLayoutManager, DFInfo.Get(typeof(WeightBill_AbnormalRecording)));
|
|
titlePanel.SetPageLayoutSetting(mPageLayoutManager, section3.Name);
|
|
}
|
|
|
|
protected override void OnPreRender(EventArgs e)
|
|
{
|
|
base.OnPreRender(e);
|
|
Page.ClientScript.RegisterHiddenField("LastAction", Page.Request.Form["LastAction"]);
|
|
Page.ClientScript.RegisterHiddenField("GridRowIndex", "");
|
|
if (!IsPostBack)
|
|
{
|
|
var detailID = Request.QueryString["detailID"];
|
|
if (!string.IsNullOrEmpty(detailID))
|
|
{
|
|
int index = 0;
|
|
foreach (var detail in Dmo.WeighRecords)
|
|
{
|
|
if (detail.ID.ToString() == detailID)
|
|
{
|
|
break;
|
|
}
|
|
index++;
|
|
}
|
|
|
|
if (index >= 0)
|
|
{
|
|
_weightGrid.CurrentPageIndex = index / _weightGrid.PageSize;
|
|
var selectedrow = (index - _weightGrid.CurrentPageIndex * _weightGrid.PageSize).ToString();
|
|
Page.ClientScript.RegisterStartupScript(GetType(), "FocusToRow", @"
|
|
$(function(){
|
|
if (browserContext && browserContext.Browser == ""IE"") {
|
|
__DFContainer.getControl(""$Details"").rows({row}).scrollIntoView();
|
|
}else {
|
|
__DFContainer.getControl(""$Details"").rows[{row}].scrollIntoView();
|
|
}
|
|
});".Replace("{row}", selectedrow.ToString()), true);
|
|
_weightGrid.DataBind();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
if (!IsPostBack)
|
|
DataBind();
|
|
}
|
|
|
|
public override void GetFromUI()
|
|
{
|
|
base.GetFromUI();
|
|
_weightGrid.GetFromUI();
|
|
_abnormalGrid.GetFromUI();
|
|
}
|
|
|
|
protected override bool EnableReferToCreate
|
|
{
|
|
get { return false; }
|
|
}
|
|
}
|
|
}
|