|
|
|
@ -0,0 +1,320 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Web.UI; |
|
|
|
using System.Web.UI.HtmlControls; |
|
|
|
using System.Web.UI.WebControls; |
|
|
|
using BWP.B3Frameworks; |
|
|
|
using BWP.B3Frameworks.BO.NamedValueTemplate; |
|
|
|
using BWP.B3Frameworks.Utils; |
|
|
|
using BWP.B3Sale.BL; |
|
|
|
using BWP.B3Sale.BO; |
|
|
|
using BWP.B3Sale.Utils; |
|
|
|
using BWP.Web.Layout; |
|
|
|
using BWP.Web.Utils; |
|
|
|
using BWP.Web.WebControls; |
|
|
|
using Forks.EnterpriseServices; |
|
|
|
using Forks.EnterpriseServices.BusinessInterfaces; |
|
|
|
using Forks.EnterpriseServices.DataForm; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
using Forks.Utils; |
|
|
|
using Forks.Utils.Collections; |
|
|
|
using TSingSoft.WebControls2; |
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
using TSingSoft.WebPluginFramework.Controls; |
|
|
|
using TSingSoft.WebPluginFramework.Security; |
|
|
|
|
|
|
|
namespace BWP.Web.Pages.B3YunKen { |
|
|
|
|
|
|
|
class B3YunKenSaleOutStoreToCustomerAccept : AppBasePage { |
|
|
|
|
|
|
|
QueryContainer _queryContainer; |
|
|
|
readonly DFInfo _dFInfo = DFInfo.Get(typeof(SaleOutStore)); |
|
|
|
DFBrowseGrid _grid; |
|
|
|
private DFCheckBox _hideFinishedBill; |
|
|
|
private DFEditGrid _detailGrid; |
|
|
|
|
|
|
|
private int ActiveTabIndex { |
|
|
|
get { |
|
|
|
if (string.IsNullOrEmpty(Request.QueryString["index"])) |
|
|
|
return 0; |
|
|
|
return int.Parse(Request.QueryString["index"]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SaleOutStore Dmo { |
|
|
|
get { return (SaleOutStore)ViewState["Dmo"]; } |
|
|
|
set { ViewState["Dmo"] = value; } |
|
|
|
} |
|
|
|
|
|
|
|
protected override void FrameworkInitialize() { |
|
|
|
if (!BLContext.User.IsInRole("B3Sale.客户验收.新建")) |
|
|
|
throw new AppSecurityException("你没有权限访问此页面"); |
|
|
|
base.FrameworkInitialize(); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void InitForm(HtmlForm form) { |
|
|
|
var type = GetType(); |
|
|
|
_queryContainer = QueryContainer.FromResource(type.FullName + ".xml", type.Assembly); |
|
|
|
form.EAdd(new PageTitle("销售出库转验收单")); |
|
|
|
var vPanel = new VLayoutPanel(); |
|
|
|
_pageView = new ClientPageView { |
|
|
|
TabPosition = TabPosition.Top, |
|
|
|
}; |
|
|
|
vPanel.Add(_pageView); |
|
|
|
_pageView.Tabs.Add(CreateSaleOutStoreTab()); |
|
|
|
_pageView.Tabs.Add(CreateCustomerAcceptTab()); |
|
|
|
|
|
|
|
form.Controls.Add(vPanel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private Control CreateSaleOutStoreTab() { |
|
|
|
var result = new ClientTab("销售出库列表"); |
|
|
|
CreateQueryPanel(result); |
|
|
|
CreateSaleOutStoreList(result.EAdd(new TitlePanel("销售出库列表"))); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private Control CreateCustomerAcceptTab() { |
|
|
|
var result = new ClientTab("转验收信息"); |
|
|
|
|
|
|
|
CustomerAcceptInfo(result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private DFChoiceBox _cusInput; |
|
|
|
private ClientPageView _pageView; |
|
|
|
private readonly DFContainer<SaleOutStore> _dFContainer = new DFContainer<SaleOutStore>(); |
|
|
|
|
|
|
|
private void CustomerAcceptInfo(ClientTab titlePanel) { |
|
|
|
var vPanel = new VLayoutPanel(); |
|
|
|
titlePanel.Controls.Add(vPanel); |
|
|
|
var layoutManager = new LayoutManager("main", _dFInfo, _dFContainer); |
|
|
|
var config = new AutoLayoutConfig { Cols = 6 }; |
|
|
|
config.Add("ID"); |
|
|
|
config.Add("Customer_ID"); |
|
|
|
config.Add("AccountCustomer_Name"); |
|
|
|
config.Add("CustomerDealer_Name"); |
|
|
|
config.Add("Department_ID"); |
|
|
|
config.Add("OrderDate"); |
|
|
|
config.Add("AccountingUnit_ID"); |
|
|
|
config.Add("Employee_ID"); |
|
|
|
config.Add("LoadTime"); |
|
|
|
config.Add("Store_ID"); |
|
|
|
config.Add("Remark").ColSpan = 4; |
|
|
|
layoutManager.Config = config; |
|
|
|
_dFContainer.Readonly = true; |
|
|
|
|
|
|
|
var buildButton = new TSButton(); |
|
|
|
buildButton.Text = "创建客户验收单"; |
|
|
|
|
|
|
|
vPanel.Add(layoutManager.CreateLayout()); |
|
|
|
var hPanel = vPanel.Add(new HLayoutPanel()); |
|
|
|
hPanel.Add(buildButton); |
|
|
|
|
|
|
|
hPanel.Add(new SimpleLabel("验收日期")); |
|
|
|
var dateInput = hPanel.Add(new DFDateInput()); |
|
|
|
dateInput.Value = BLContext.Today; |
|
|
|
|
|
|
|
hPanel.Add(new SimpleLabel("客户")); |
|
|
|
_cusInput = hPanel.Add(new DFChoiceBox()); |
|
|
|
_cusInput.EnableInputArgument = true; |
|
|
|
_cusInput.DataKind = B3SaleDataSources.经销商所属客户; |
|
|
|
_cusInput.EnableTopItem = true; |
|
|
|
_cusInput.Width = 150; |
|
|
|
|
|
|
|
buildButton.Click += delegate { |
|
|
|
_detailGrid.GetFromUI(); |
|
|
|
Dmo.Customer_ID = long.Parse(_cusInput.Value); |
|
|
|
var customer = SaleUtil.GetDmoByID<Customer>(Dmo.Customer_ID.Value, "AccountCustomer_ID", "AccountCustomer_Name"); |
|
|
|
Dmo.AccountCustomer_ID = customer.AccountCustomer_ID; |
|
|
|
Dmo.AccountCustomer_Name = customer.AccountCustomer_Name; |
|
|
|
|
|
|
|
var details = new List<SaleOutStore_Detail>(); |
|
|
|
foreach (SaleOutStore_Detail detail in _detailGrid.GetSelectedItems()) { |
|
|
|
detail.UnitNum = detail.AcceptUnitNum; |
|
|
|
detail.SecondNumber = detail.AcceptSecondNumber; |
|
|
|
details.Add(detail); |
|
|
|
} |
|
|
|
|
|
|
|
BIFactory.Create<ISaleOutStoreBL>().CreateCustomerAccept(Dmo,details); |
|
|
|
AspUtil.Alert(this, BIFactory.GetLastMessage()); |
|
|
|
InitDmo(); |
|
|
|
_pageView.ActiveTabIndex = 0; |
|
|
|
}; |
|
|
|
|
|
|
|
var detailEditor = new DFCollectionEditor<SaleOutStore_Detail>(() => Dmo.Details); |
|
|
|
detailEditor.IsEditableFunc = (field, detail) => true; |
|
|
|
detailEditor.CanSelectFunc = (detail) => true; |
|
|
|
_detailGrid = vPanel.Add(new DFEditGrid(detailEditor) { Width = Unit.Percentage(100) }); |
|
|
|
_detailGrid.ShowLineNo = true; |
|
|
|
_detailGrid.MultiSelectionEnabled = true; |
|
|
|
|
|
|
|
_detailGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Goods_Name")); |
|
|
|
|
|
|
|
_detailGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Goods_Spec")); |
|
|
|
|
|
|
|
_detailGrid.Columns.EAdd(new DFEditGridColumn<DFValueLabel>("SecondNumber")).SumMode = SumMode.Sum; |
|
|
|
_detailGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Goods_SecondUnit")); |
|
|
|
_detailGrid.Columns.EAdd(new DFEditGridColumn<DFValueLabel>("UnitNum")).SumMode = SumMode.Sum; |
|
|
|
var unitColumn = new DFEditGridColumn<DFValueLabel>("Unit"); |
|
|
|
_detailGrid.Columns.Add(unitColumn); |
|
|
|
_detailGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Price")); |
|
|
|
_detailGrid.Columns.EAdd(new DFEditGridColumn<DFValueLabel>("Money")).SumMode = SumMode.Sum; |
|
|
|
|
|
|
|
_detailGrid.Columns.EAdd(new DFEditGridColumn<DFValueLabel>("AlreadyAcceptSecondNumber")).SumMode = SumMode.Sum; |
|
|
|
_detailGrid.Columns.EAdd(new DFEditGridColumn<DFValueLabel>("AlreadyAcceptUnitNum")).SumMode = SumMode.Sum; |
|
|
|
|
|
|
|
_detailGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("AcceptSecondNumber")).SumMode = SumMode.Sum; |
|
|
|
_detailGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("AcceptUnitNum")).SumMode = SumMode.Sum; |
|
|
|
_detailGrid.ValueColumns.Add("SaleGoods_ID"); |
|
|
|
_detailGrid.ValueColumns.Add("Goods_UnitConvertDirection"); |
|
|
|
_detailGrid.ValueColumns.Add("Goods_MainUnitRatio"); |
|
|
|
_detailGrid.ValueColumns.Add("Goods_SecondUnitRatio"); |
|
|
|
_detailGrid.ValueColumns.Add("LeftRatio"); |
|
|
|
_detailGrid.ValueColumns.Add("RightRatio"); |
|
|
|
new MainToSecondConvertRowMangerWithMoneyChange(_detailGrid, "AcceptUnitNum", "AcceptSecondNumber"); |
|
|
|
} |
|
|
|
|
|
|
|
private void InitDmo() { |
|
|
|
Dmo = new SaleOutStore(); |
|
|
|
_dFContainer.DFObject = Dmo; |
|
|
|
_dFContainer.ApplyToUI(); |
|
|
|
_detailGrid.DataBind(); |
|
|
|
_grid.DataBind(); |
|
|
|
} |
|
|
|
|
|
|
|
private void CreateSaleOutStoreList(TitlePanel titlePanel) { |
|
|
|
_grid = titlePanel.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { |
|
|
|
Width = Unit.Percentage(100), |
|
|
|
}); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("ID")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("Order_ID")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("OrderDate")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("LoadTime")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("AccountingUnit_Name")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("Customer_Name")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("Department_Name")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("Employee_Name")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("SaleKind_Name")); |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("Store_Name")); |
|
|
|
|
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("AllUnitNum")).SumMode = SumMode.Sum; |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("Money")).SumMode = SumMode.Sum; |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("已验收数量")).SumMode = SumMode.Sum; |
|
|
|
_grid.Columns.EAdd(new DFBrowseGridColumn("Remark")); |
|
|
|
|
|
|
|
_grid.SingleSelection += GridSingleSelection; |
|
|
|
} |
|
|
|
|
|
|
|
private void GridSingleSelection(object sender, DFBrowseGridItemEventArgs e) { |
|
|
|
var bl = BIFactory.Create<ISaleOutStoreBL>(); |
|
|
|
var id = (long)e.Row["ID"]; |
|
|
|
Dmo = bl.Load(id); |
|
|
|
var dom = new DmoQuery(typeof(SaleOutStore_DetailToCustomerAcceptNumber)); |
|
|
|
dom.Where.Conditions.Add(DQCondition.EQ("SaleOutStore_ID", id)); |
|
|
|
var list = dom.EExecuteList(); |
|
|
|
foreach (SaleOutStore_DetailToCustomerAcceptNumber d in list) { |
|
|
|
var detail = Dmo.Details.FirstOrDefault(x => x.ID == d.SaleOutStore_Detail_ID); |
|
|
|
if (detail != null) { |
|
|
|
detail.AlreadyAcceptUnitNum = d.AlreadyAcceptUnitNum; |
|
|
|
detail.AlreadyAcceptNumber = d.AlreadyAcceptNumber; |
|
|
|
detail.AlreadyAcceptSecondNumber = d.AlreadyAcceptSecondNumber; |
|
|
|
} |
|
|
|
} |
|
|
|
foreach (var detail in Dmo.Details) { |
|
|
|
detail.AcceptNumber = detail.Number - (detail.AlreadyAcceptNumber ?? 0); |
|
|
|
detail.AcceptUnitNum = detail.UnitNum - (detail.AlreadyAcceptUnitNum ?? 0); |
|
|
|
detail.AcceptSecondNumber = detail.SecondNumber - (detail.AlreadyAcceptSecondNumber ?? 0); |
|
|
|
} |
|
|
|
_cusInput.Value = Dmo.Customer_ID.ToString(); |
|
|
|
_cusInput.DisplayValue = Dmo.Customer_Name; |
|
|
|
_cusInput.CodeArgument = Dmo.Customer_ID.ToString(); |
|
|
|
_dFContainer.DFObject = Dmo; |
|
|
|
_dFContainer.ApplyToUI(); |
|
|
|
_pageView.ActiveTabIndex = 1; |
|
|
|
_detailGrid.DataBind(); |
|
|
|
} |
|
|
|
|
|
|
|
private void CreateQueryPanel(ClientTab titlePanel) { |
|
|
|
var layer = new LayoutManager("", _dFInfo, _queryContainer); |
|
|
|
layer.Add("ID", QueryCreator.DFTextBox(_dFInfo.Fields["ID"])); |
|
|
|
|
|
|
|
layer.Add("OrderDate", QueryCreator.TimeRange(_dFInfo.Fields["OrderDate"], _queryContainer, "MinOrderDate", "MaxOrderDate")); |
|
|
|
layer.Add("LoadTime", QueryCreator.TimeRange(_dFInfo.Fields["LoadTime"], _queryContainer, "MinLoadTime", "MaxLoadTime")); |
|
|
|
DFChoiceBox accInput; |
|
|
|
layer.Add("AccountingUnit_ID", accInput = QueryCreator.DFChoiceBox(_dFInfo.Fields["AccountingUnit_ID"], B3FrameworksConsts.DataSources.授权会计单位全部)); |
|
|
|
layer.Add("Department_ID", QueryCreator.DFChoiceBox(_dFInfo.Fields["Department_ID"], B3FrameworksConsts.DataSources.授权部门全部)); |
|
|
|
layer.Add("Employee_ID", QueryCreator.DFChoiceBox(_dFInfo.Fields["Employee_ID"], B3FrameworksConsts.DataSources.授权员工全部)); |
|
|
|
layer.Add("Customer_ID", QueryCreator.DFChoiceBox(_dFInfo.Fields["Customer_ID"], B3SaleDataSources.客户全部)); |
|
|
|
DFChoiceBox storeInput; |
|
|
|
layer.Add("Store_ID", storeInput = QueryCreator.DFChoiceBox(_dFInfo.Fields["Store_ID"], B3FrameworksConsts.DataSources.授权仓库全部)); |
|
|
|
storeInput.CodeArgumentReferenceTo = accInput; |
|
|
|
layer.Add("Car", QueryCreator.DFTextBox(_dFInfo.Fields["Car"])); |
|
|
|
|
|
|
|
layer.CreateDefaultConfig(8); |
|
|
|
titlePanel.Controls.Add(layer.CreateLayout()); |
|
|
|
var hPanel = titlePanel.EAdd(new HLayoutPanel()); |
|
|
|
_hideFinishedBill = new DFCheckBox { |
|
|
|
Text = "隐藏已转单据", |
|
|
|
Checked = true |
|
|
|
}; |
|
|
|
|
|
|
|
hPanel.Add(new TSButton("开始查询", delegate { StartQuery(); })); |
|
|
|
hPanel.Add(new RedirectTSButton("清除条件")); |
|
|
|
hPanel.Add(_hideFinishedBill); |
|
|
|
} |
|
|
|
|
|
|
|
private void StartQuery() { |
|
|
|
_grid.Reset(); |
|
|
|
_grid.Query = GetQueryDom(); |
|
|
|
_grid.DataBind(); |
|
|
|
} |
|
|
|
|
|
|
|
private DQueryDom GetQueryDom() { |
|
|
|
var query = _queryContainer.Build(); |
|
|
|
var aready = new JoinAlias(typeof(AreadyTo)); |
|
|
|
var bill = query.From.RootSource.Alias; |
|
|
|
query.RegisterQueryTable(typeof(AreadyTo), new string[] { "ID", "AlreadyAcceptUnitNum" }, AreadyTo.Get()); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(aready), DQCondition.EQ(bill, "ID", aready, "ID")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(aready, "AlreadyAcceptUnitNum"), "已验收数量")); |
|
|
|
|
|
|
|
if (_hideFinishedBill.Checked) { |
|
|
|
query.Where.Conditions.Add( |
|
|
|
DQCondition.LessThan( |
|
|
|
DQExpression.IfNull(DQExpression.Field(aready, "AlreadyAcceptUnitNum"), DQExpression.ConstValue(0)), |
|
|
|
DQExpression.Field(bill, "AllUnitNum"))); |
|
|
|
} else { |
|
|
|
query.Columns.Add(DQSelectColumn.Field("CustomerAcceptID")); |
|
|
|
} |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.已审核)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID)); |
|
|
|
return query; |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnLoad(EventArgs e) { |
|
|
|
base.OnLoad(e); |
|
|
|
if (!IsPostBack) |
|
|
|
StartQuery(); |
|
|
|
} |
|
|
|
|
|
|
|
class AreadyTo { |
|
|
|
public long ID { get; set; } |
|
|
|
|
|
|
|
[LogicName("已转验收报价数量")] |
|
|
|
public Money<decimal>? AlreadyAcceptUnitNum { get; set; } |
|
|
|
|
|
|
|
public static DQueryDom Get() { |
|
|
|
var dom = new DQueryDom(new JoinAlias(typeof(SaleOutStore_DetailToCustomerAcceptNumber))); |
|
|
|
dom.Columns.Add(DQSelectColumn.Field("SaleOutStore_ID")); |
|
|
|
dom.GroupBy.Expressions.Add(DQExpression.Field("SaleOutStore_ID")); |
|
|
|
dom.Columns.Add(DQSelectColumn.Sum("AlreadyAcceptUnitNum")); |
|
|
|
return dom; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |