using BWP.B3SubstituteKill.BL;
|
|
using BWP.B3SubstituteKill.BO;
|
|
using BWP.Web.Layout;
|
|
using BWP.Web.WebControls;
|
|
using Forks.EnterpriseServices.DataForm;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web.UI.WebControls;
|
|
using TSingSoft.WebControls2;
|
|
using Forks.Utils.Collections;
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
using BWP.B3SubstituteKill.Utils;
|
|
using TSingSoft.WebPluginFramework;
|
|
using Forks.EnterpriseServices.BusinessInterfaces;
|
|
|
|
namespace BWP.Web.Pages.B3SubstituteKill.Bills.StatPay_
|
|
{
|
|
class StatPayEdit : DepartmentWorkFlowBillEditPage<StatPay, IStatPayBL>
|
|
{
|
|
protected override void BuildBasePropertiesEditor(TitlePanel titlePanel, CustomPageLayout.PageLayoutSection pageLayoutSection)
|
|
{
|
|
var layoutManager = new LayoutManager("", mDFInfo, mDFContainer);
|
|
if (MinDmo.SourceBillID.HasValue)
|
|
layoutManager.Add("SourceBillID", new DFEntityLink(DmoTypeIDAttribute.ResolveID(MinDmo.SourceBillType.Value)));
|
|
else
|
|
layoutManager.Add("SourceBillID", new DFValueLabel());
|
|
var config = new AutoLayoutConfig();
|
|
config.Add("AccountingUnit_ID");
|
|
config.Add("Department_ID");
|
|
config.Add("Employee_ID");
|
|
config.Add("Date");
|
|
config.Add("Supplier_ID");
|
|
config.Add("Supplier_Tel");
|
|
config.Add("Supplier_Card_ID");
|
|
config.Add("Supplier_Address");
|
|
config.Add("Number");
|
|
config.Add("Weight");
|
|
config.Add("PriceBill_ID");
|
|
config.Add("ReceiveMoney");
|
|
config.Add("SourceBillType");
|
|
config.Add("SourceBillID");
|
|
config.Add("Remark");
|
|
layoutManager.Config = config;
|
|
pageLayoutSection.ApplyLayout(layoutManager, config, mPageLayoutManager, mDFInfo);
|
|
titlePanel.Controls.Add(layoutManager.CreateLayout());
|
|
if (layoutManager.Contains("Supplier_ID"))
|
|
{
|
|
var supplierInput = layoutManager["Supplier_ID"].InputControl as DFChoiceBox;
|
|
|
|
if (supplierInput != null)
|
|
{
|
|
var script = @"
|
|
var txtValue =parseInt(__DFContainer.getValue('Supplier_ID'));
|
|
|
|
simpleRestCall('/MainSystem/B3SubstituteKill/Rpcs/SupplierRpc/GetSupplierAndPriceBillID',[txtValue,__DFContainer.getControl('Date').value],
|
|
function(result){
|
|
if(typeof(result.Address)!='undefined')
|
|
{
|
|
__DFContainer.setValue('Supplier_Address',result.Address);
|
|
}
|
|
else
|
|
{
|
|
__DFContainer.setValue('Supplier_Address','');
|
|
}
|
|
|
|
if(typeof(result.Tel)!='undefined')
|
|
{
|
|
__DFContainer.setValue('Supplier_Tel',result.Tel);
|
|
}
|
|
else
|
|
{
|
|
__DFContainer.setValue('Supplier_Tel','');
|
|
}
|
|
|
|
if(typeof(result.Supplier_Card_ID)!='undefined')
|
|
{
|
|
__DFContainer.setValue('Supplier_Card_ID',result.Card_ID);
|
|
}
|
|
else
|
|
{
|
|
__DFContainer.setValue('Supplier_Card_ID','');
|
|
}
|
|
|
|
if(typeof(result.SupplierApply_ID)!='undefined')
|
|
{
|
|
__DFContainer.setValue('PriceBill_ID',result.SupplierApply_ID);
|
|
}
|
|
else
|
|
{
|
|
__DFContainer.setValue('PriceBill_ID','');
|
|
}
|
|
|
|
},{ });";
|
|
|
|
supplierInput.OnClientSelected = script;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void BuildBody(System.Web.UI.Control parent)
|
|
{
|
|
base.BuildBody(parent);
|
|
AddCostDetail(parent.EAdd(new TitlePanel("代宰费用", "代宰费用")));
|
|
AddCallbackPayDetail(parent.EAdd(new TitlePanel("回收应付", "回收应付")));
|
|
}
|
|
|
|
|
|
DFEditGrid _costDetail;
|
|
private void AddCostDetail(TitlePanel titlePanel)
|
|
{
|
|
if (CanSave)
|
|
titlePanel.EAdd(new TSButton("载入", delegate
|
|
{
|
|
GetFromUI();
|
|
if (Dmo.PriceBill_ID == null)
|
|
throw new Exception("没有定价单号");
|
|
Dmo.CostDetails.Clear();
|
|
LoadCostItemDetail();
|
|
_costDetail.DataBind();
|
|
}));
|
|
var editor = new DFCollectionEditor<StatPay_CostDetail>(() => Dmo.CostDetails);
|
|
editor.AllowDeletionFunc = () => CanSave;
|
|
editor.CanDeleteFunc = detail => CanSave;
|
|
editor.IsEditableFunc = (field, detail) =>
|
|
{
|
|
return CanSave && field.Name == "Number";
|
|
};
|
|
_costDetail = titlePanel.EAdd(new DFEditGrid(editor) { Width = Unit.Percentage(100) });
|
|
_costDetail.Columns.Add(new DFEditGridColumn("SubKillProductLine_Name"));
|
|
_costDetail.Columns.Add(new DFEditGridColumn("GenerationCostItem_Name"));
|
|
_costDetail.Columns.Add(new DFEditGridColumn("Number"));
|
|
_costDetail.Columns.Add(new DFEditGridColumn("Price"));
|
|
_costDetail.Columns.EAdd(new DFEditGridColumn("Money"));
|
|
var section = mPageLayoutManager.AddSection("CostDetail", "代宰费用");
|
|
titlePanel.SetPageLayoutSetting(mPageLayoutManager, section.Name);
|
|
|
|
section.ApplyLayout(_costDetail, mPageLayoutManager, DFInfo.Get(typeof(StatPay_CostDetail)));
|
|
}
|
|
|
|
DFEditGrid _callbackPayDetail;
|
|
private void AddCallbackPayDetail(TitlePanel titlePanel)
|
|
{
|
|
if (CanSave)
|
|
titlePanel.EAdd(new TSButton("载入", delegate
|
|
{
|
|
GetFromUI();
|
|
if (Dmo.PriceBill_ID == null)
|
|
throw new Exception("没有定价单号");
|
|
Dmo.CallbackPayDetails.Clear();
|
|
LoadCallBackDetail();
|
|
_callbackPayDetail.DataBind();
|
|
}));
|
|
var editor = new DFCollectionEditor<StatPay_CallbackPayDetail>(() => Dmo.CallbackPayDetails);
|
|
editor.AllowDeletionFunc = () => CanSave;
|
|
editor.CanDeleteFunc = detail => CanSave;
|
|
editor.IsEditableFunc = (field, detail) =>
|
|
{
|
|
return CanSave && field.Name == "Number";
|
|
};
|
|
_callbackPayDetail = titlePanel.EAdd(new DFEditGrid(editor) { Width = Unit.Percentage(100) });
|
|
_callbackPayDetail.Columns.Add(new DFEditGridColumn("SubKillCallBack_Name"));
|
|
_callbackPayDetail.Columns.Add(new DFEditGridColumn("Number"));
|
|
_callbackPayDetail.Columns.Add(new DFEditGridColumn("Price"));
|
|
_callbackPayDetail.Columns.EAdd(new DFEditGridColumn("Money"));
|
|
var section = mPageLayoutManager.AddSection("CallbackPayDetail", "回收应付");
|
|
titlePanel.SetPageLayoutSetting(mPageLayoutManager, section.Name);
|
|
|
|
section.ApplyLayout(_callbackPayDetail, mPageLayoutManager, DFInfo.Get(typeof(StatPay_CallbackPayDetail)));
|
|
}
|
|
|
|
public override void AppToUI()
|
|
{
|
|
base.AppToUI();
|
|
_costDetail.DataBind();
|
|
_callbackPayDetail.DataBind();
|
|
}
|
|
|
|
public override void GetFromUI()
|
|
{
|
|
base.GetFromUI();
|
|
_costDetail.GetFromUI();
|
|
_callbackPayDetail.GetFromUI();
|
|
}
|
|
|
|
void LoadCallBackDetail()
|
|
{
|
|
var details = GetDetails();
|
|
var num = details.Sum(x => x.Item2);
|
|
if (num == 0)
|
|
return;
|
|
var price = BIFactory.Create<ISubKillPriceBillBL>().Load(Dmo.PriceBill_ID.Value);
|
|
if (price == null)
|
|
return;
|
|
foreach (var detail in price.CallBackDetails)
|
|
{
|
|
var d = new StatPay_CallbackPayDetail();
|
|
d.Number = num;
|
|
d.SubKillCallBack_ID = detail.SubKillCallBack_ID;
|
|
d.SubKillCallBack_Name = detail.SubKillCallBack_Name;
|
|
d.Price = detail.Price;
|
|
d.Money = d.Price * d.Number;
|
|
Dmo.CallbackPayDetails.Add(d);
|
|
}
|
|
}
|
|
|
|
void LoadCostItemDetail()
|
|
{
|
|
var price = BIFactory.Create<ISubKillPriceBillBL>().Load(Dmo.PriceBill_ID.Value);
|
|
if (price == null)
|
|
return;
|
|
var details = GetDetails();
|
|
foreach (var detail in details)
|
|
{
|
|
var tags = price.CostItemDetails.Where(x => x.SubKillProductLine_ID == detail.Item1);
|
|
foreach (var t in tags)
|
|
{
|
|
var d = new StatPay_CostDetail();
|
|
d.GenerationCostItem_ID = t.GenerationCostItem_ID;
|
|
d.GenerationCostItem_Name = t.GenerationCostItem_Name;
|
|
d.SubKillProductLine_ID = t.SubKillProductLine_ID;
|
|
d.SubKillProductLine_Name = t.SubKillProductLine_Name;
|
|
d.Number = detail.Item2;
|
|
d.Price = t.Price;
|
|
d.Money = d.Price * d.Number;
|
|
Dmo.CostDetails.Add(d);
|
|
}
|
|
}
|
|
}
|
|
|
|
List<Tuple<long, int>> GetDetails()
|
|
{
|
|
Type t = null;
|
|
string join = string.Empty;
|
|
var config = new B3SubstituteKillOnlineConfig();
|
|
if (config.ButcherOrderCreateStatPay && Dmo.SourceBillType == DmoTypeIDAttribute.GetID(typeof(SubKillButcherOrder)))
|
|
{
|
|
t = typeof(SubKillButcherOrder_Detail);
|
|
join = "SubKillButcherOrder_ID";
|
|
}
|
|
else if (!config.ButcherOrderCreateStatPay && Dmo.SourceBillType == DmoTypeIDAttribute.GetID(typeof(SubKillWeightBill)))
|
|
{
|
|
t = typeof(SubKillWeightBill_Detail);
|
|
join = "SubKillWeightBill_ID";
|
|
}
|
|
else
|
|
return new List<Tuple<long, int>>();
|
|
var query = new DQueryDom(new JoinAlias(t));
|
|
query.Columns.Add(DQSelectColumn.Field("SubKillProductLine_ID"));
|
|
query.Columns.Add(DQSelectColumn.Field("Number"));
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("Number")), DQCondition.EQ(join, Dmo.SourceBillID)));
|
|
return query.EExecuteList<long, int>();
|
|
}
|
|
}
|
|
}
|