diff --git a/BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj b/BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj
index 34827b4..2bba259 100644
--- a/BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj
+++ b/BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj
@@ -101,6 +101,9 @@
ASPXCodeBehind
+
+ ASPXCodeBehind
+
ASPXCodeBehind
@@ -131,6 +134,9 @@
ASPXCodeBehind
+
+ ASPXCodeBehind
+
ASPXCodeBehind
diff --git a/BWP.B3_YunKen.Web/Pages/B3YunKen/Dialogs/SelectBillDialog.cs b/BWP.B3_YunKen.Web/Pages/B3YunKen/Dialogs/SelectBillDialog.cs
new file mode 100644
index 0000000..ffdf786
--- /dev/null
+++ b/BWP.B3_YunKen.Web/Pages/B3YunKen/Dialogs/SelectBillDialog.cs
@@ -0,0 +1,472 @@
+using BWP.B3Frameworks;
+using BWP.B3Frameworks.BO.MoneyTemplate;
+using BWP.B3Frameworks.Utils;
+using BWP.B3Sale.BO;
+using BWP.B3Sale.Utils;
+using BWP.Web.Layout;
+using BWP.Web.Utils;
+using BWP.Web.WebControls;
+using Forks.EnterpriseServices.BusinessInterfaces;
+using Forks.EnterpriseServices.DomainObjects2;
+using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using Forks.Utils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Web.UI;
+using System.Web.UI.HtmlControls;
+using System.Web.UI.WebControls;
+using TSingSoft.WebControls2;
+using TSingSoft.WebPluginFramework;
+
+namespace BWP.Web.Pages.B3YunKen.Dialogs
+{
+ class SelectBillDialog : AppBasePage
+ {
+ private DFBrowseGrid _browseGrid;
+
+ string Ids
+ {
+ get { return Request.QueryString["ids"]; }
+ }
+
+ string CusID
+ {
+ get { return Request.QueryString["cusID"]; }
+ }
+
+ private bool _someError;
+ private Label _moneyLabel;
+ private Label _selectMoneyLabel;
+
+
+ long CustomerID
+ {
+ get
+ {
+ if (ViewState["CustomerID"] != null)
+ return (long)ViewState["CustomerID"];
+ return 0;
+ }
+ set { ViewState["CustomerID"] = value; }
+ }
+
+ long AccountingUnit_ID
+ {
+ get
+ {
+ if (ViewState["AccountingUnit_ID"] != null)
+ return (long)ViewState["AccountingUnit_ID"];
+ return 0;
+ }
+ set { ViewState["AccountingUnit_ID"] = value; }
+ }
+
+ decimal ThisMoney
+ {
+ get
+ {
+ if (ViewState["thisMoney"] != null)
+ return (decimal)ViewState["thisMoney"];
+ return 0;
+ }
+ set { ViewState["thisMoney"] = value; }
+ }
+
+ private readonly B3SaleOnlineConfiguration _config = new B3SaleOnlineConfiguration();
+
+ protected override void InitForm(HtmlForm form)
+ {
+ var zone = new TitlePanelZone();
+ _moneyLabel = new Label();
+ _selectMoneyLabel = new Label();
+ _someError = !Before();
+ if (_someError)
+ return;
+ form.Controls.Add(zone);
+ AddQueryControls(zone);
+ CreateQueryGrid(zone);
+ }
+
+
+ private DFDateInput _minInput, _maxInput;
+ private void AddQueryControls(TitlePanelZone zone)
+ {
+ var titlePanel = new TitlePanel(B3FrameworksConsts.PageLayouts.QueryConditions, B3FrameworksConsts.PageLayouts.QueryConditions_DisplayName);
+ titlePanel.Style.Add(HtmlTextWriterStyle.BackgroundColor, "white");
+ titlePanel.SetPageLayoutSetting(mPageLayoutManager, B3FrameworksConsts.PageLayouts.QueryConditions);
+ zone.Add(titlePanel);
+ var vbox = AddChild(titlePanel, new VLayoutPanel());
+
+ var layoutManager = new LayoutManager("");
+ _minInput = new DFDateInput();
+ _maxInput = new DFDateInput();
+ _maxInput.DefaultTime = DateInputDefaultTime.maxValue;
+ _minInput.DefaultTime = DateInputDefaultTime.minValue;
+
+ var panel = new Panel();
+ panel.Controls.Add(_minInput);
+ panel.Controls.Add(new LiteralControl("→"));
+ panel.Controls.Add(_maxInput);
+
+ layoutManager.Add("单据日期", new SimpleLabel("单据日期"), panel);
+ var bt = new TSButton("开始查询", delegate { StartQuery(); });
+ layoutManager.Add("开始查询", bt, false, true);
+ var config = new AutoLayoutConfig();
+ config.Cols = 6;
+ config.Add("单据日期");
+ layoutManager.Config = config;
+ vbox.Add(layoutManager.CreateLayout(), new VLayoutOption(HorizontalAlign.Left));
+ var hPanel = vbox.Add(new HLayoutPanel(), new VLayoutOption(HorizontalAlign.Left));
+ hPanel.Add(new TSButton("开始查询", delegate {
+ StartQuery();
+ }));
+ var label1 = new Label();
+ label1.Text = "金额:";
+
+ _moneyLabel.ID = "moneyLabel";
+ _moneyLabel.Font.Size = 12;
+ _moneyLabel.Font.Bold = true;
+
+ var label2 = new Label();
+ label2.Text = "本次核销金额:";
+
+ _selectMoneyLabel.ID = "selectMoneyLabel";
+ _selectMoneyLabel.Font.Size = 12;
+ _selectMoneyLabel.Font.Bold = true;
+
+ var verficationbt = hPanel.Add(new TSButton("核销"));
+ verficationbt.Click += delegate {
+ _browseGrid.GetFromUI();
+ using (var context = new TransactionContext())
+ {
+ var selectItems = _browseGrid.GetSelectedItems();
+ var money = selectItems.Sum(x => (((decimal?)x["本次核销金额"]) ?? 0));
+
+ if (money > ThisMoney)
+ throw new ApplicationException("本次核销金额大于收款单金额");
+
+ var ids = Ids.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(long.Parse).ToList();
+ var nextID = VerificationUtil.GetNextID(context);
+
+ foreach (var id in ids)
+ {
+ var gathering = new Gathering();
+ var gatheringMoney = InnerBLUtil.GetDmoPropertyByID?>(context.Session, "GatheringMoney", id);
+ var verificationMoney = InnerBLUtil.GetDmoPropertyByID?>(context.Session, "VerificationMoney", id);
+ var tMoney = (gatheringMoney ?? 0) - (verificationMoney ?? 0);
+ if (tMoney <= 0)
+ continue;
+ if (money <= 0)
+ continue;
+ if (money < tMoney)
+ {
+ tMoney = money;
+ }
+ money -= tMoney;
+ gathering.ID = id;
+ VerificationUtil.Insert(context, gathering, tMoney, nextID);
+ }
+
+ foreach (var row in _browseGrid.GetSelectedItems())
+ {
+ BWP.B3Frameworks.BO.Bill dmo;
+ var billType = row["单据类型"] == null ? "销售出库单" : row["单据类型"].ToString();
+ if (billType == "销售发票")
+ {
+ dmo = new Invoice();
+ }
+ else if (billType == "客户验收单")
+ {
+ dmo = new CustomerAccept();
+ }
+ else if (billType == "其他应收款")
+ {
+ dmo = new OtherReceivables();
+ }
+ else
+ {
+ dmo = new SaleOutStore();
+ }
+
+ dmo.ID = (long)row["ID"];
+ var billMoney = (Money<金额>?)row["金额"];
+ var verMoney = (Money<金额>?)row["VerificationMoney"];
+ var thisMoney = ((decimal?)row["本次核销金额"]) ?? 0m;
+ var tMoney = (billMoney ?? 0) - (verMoney ?? 0);
+ if (thisMoney == 0)
+ continue;
+ if (billMoney > 0 && thisMoney > tMoney)
+ throw new ApplicationException("单据No." + dmo.ID + " 本次核销金额大于未核销金额");
+ if (billMoney < 0 && thisMoney < tMoney)
+ throw new ApplicationException("单据No." + dmo.ID + " 本次核销金额小于未核销金额(本单据金额为负)");
+
+ if (billType == "销售发票")
+ {
+ VerificationUtil.Insert(context, (Invoice)dmo, thisMoney, nextID);
+ }
+ else if (billType == "客户验收单")
+ {
+ VerificationUtil.Insert(context, (CustomerAccept)dmo, thisMoney, nextID);
+ }
+ else if (billType == "其他应收款")
+ {
+ VerificationUtil.Insert(context, (OtherReceivables)dmo, thisMoney, nextID);
+ }
+ else
+ {
+ VerificationUtil.Insert(context, (SaleOutStore)dmo, thisMoney, nextID);
+ }
+ }
+ context.Commit();
+ }
+ DialogUtil.SetCachedObj(this, "", "核销成功");
+ };
+ hPanel.Add(new LiteralControl(" "));
+ hPanel.Add(label1);
+ hPanel.Add(_moneyLabel);
+ hPanel.Add(new LiteralControl(" "));
+ hPanel.Add(label2);
+ hPanel.Add(_selectMoneyLabel);
+ }
+
+ private void CreateQueryGrid(TitlePanelZone zone)
+ {
+ var result = new TitlePanel(B3FrameworksConsts.PageLayouts.QueryResult, B3FrameworksConsts.PageLayouts.QueryResult_DisplayName);
+ result.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#ebebeb");
+ result.SetPageLayoutSetting(mPageLayoutManager, B3FrameworksConsts.PageLayouts.QueryResult);
+ var editor = new DFDataTableEditor();
+
+ _browseGrid = new DFBrowseGrid(editor);
+ result.Controls.Add(_browseGrid);
+ _browseGrid.DFGridSetEnabled = false;
+ _browseGrid.IgnoreItemsCount = true;
+ _browseGrid.EnableRowID = true;
+ _browseGrid.MultiSelectionEnabled = true;
+ _browseGrid.Width = Unit.Percentage(100);
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("单据类型"));
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("ID"));
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("AccountingUnit_Name"));
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("结账客户"));
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("单据日期"));
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("金额") { SumMode = SumMode.Sum });
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("VerificationMoney") { SumMode = SumMode.Sum });
+ var col = new DFEditGridColumn("本次核销金额");
+ col.InitEditControl += (sender, e) => {
+ var str = e.Control.Attributes["onchange"] ?? string.Empty;
+ e.Control.Attributes["onchange"] = str + "_SumMoney();";
+ };
+ _browseGrid.Columns.Add(col);
+
+ var hbox = new HLayoutPanel();
+ hbox.CssClass += " LeftPaddingWrapper";
+ result.Controls.Add(hbox);
+ zone.Add(result);
+ }
+
+ void StartQuery()
+ {
+ _browseGrid.Query = GetQueryDom();
+ _browseGrid.Reset();
+ _browseGrid.DataBind();
+ }
+
+ private DQueryDom GetQueryDom()
+ {
+ var doms = _config.VerificationBillTypeSet.Value.Select(x => GetQueryDom(x));
+ if (doms == null)
+ {
+ return GetQueryDom("销售出库单");
+ }
+ var dom = doms.ElementAt(0);
+ var current = dom;
+ for (int i = 1; i < doms.Count(); i++)
+ {
+ var next = doms.ElementAt(i);
+ current.UnionNext.Select = next;
+ current = next;
+ }
+ return dom;
+ }
+
+ private DQueryDom GetQueryDom(string billType)
+ {
+ DQueryDom dom;
+ string customerField;
+ string moneyField;
+ string customerNameField;
+ string dateField;
+ if (billType == "销售发票")
+ {
+ customerField = "Customer_ID";
+ moneyField = "Money";
+ customerNameField = "Customer_Name";
+ dom = new DQueryDom(new JoinAlias(typeof(Invoice)));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.ConstValue("销售发票"), "单据类型"));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field("Date"), "单据日期"));
+ dateField = "Date";
+ }
+ else if (billType == "客户验收单")
+ {
+ customerField = "Customer_ID";
+ moneyField = "Money";
+ customerNameField = "Customer_Name";
+ dom = new DQueryDom(new JoinAlias(typeof(CustomerAccept)));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.ConstValue("客户验收单"), "单据类型"));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field("BillDate"), "单据日期"));
+ dateField = "BillDate";
+ }
+ else if (billType == "其他应收款")
+ {
+ customerField = "AccountCustomer_ID";
+ moneyField = "OtherMoney";
+ customerNameField = "AccountCustomer_Name";
+ dom = new DQueryDom(new JoinAlias(typeof(OtherReceivables)));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.ConstValue("其他应收款"), "单据类型"));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field("OtherReceivablesTime"), "单据日期"));
+ dateField = "OtherReceivablesTime";
+ }
+ else
+ {
+ customerField = "Customer_ID";
+ moneyField = "Money";
+ customerNameField = "Customer_Name";
+ dom = new DQueryDom(new JoinAlias(typeof(SaleOutStore)));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.ConstValue("销售出库单"), "单据类型"));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field("LoadTime"), "单据日期"));
+ dateField = "LoadTime";
+ }
+ dom.Columns.Add(DQSelectColumn.Field("ID"));
+ dom.Columns.Add(DQSelectColumn.Field("AccountingUnit_Name"));
+ dom.Columns.Add(DQSelectColumn.Field("VerificationMoney"));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(customerNameField), "结账客户"));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(moneyField), "金额"));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(moneyField).ESubtract(DQExpression.Field("VerificationMoney")), "本次核销金额"));
+ dom.Where.Conditions.Add(DQCondition.EQ(customerField, CustomerID));
+ if (AccountingUnit_ID > 0)
+ dom.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", AccountingUnit_ID));
+ dom.EAddCheckedCondition(dom.From.RootSource.Alias);
+ if (_minInput.Value.HasValue)
+ {
+ dom.Where.Conditions.Add(DQCondition.GreaterThanOrEqual(dateField, _minInput.Value));
+ }
+ if (_maxInput.Value.HasValue)
+ {
+ dom.Where.Conditions.Add(DQCondition.LessThanOrEqual(dateField, _maxInput.Value));
+ }
+
+ dom.Where.Conditions.Add(DQCondition.Or(DQCondition.And(DQCondition.LessThan(moneyField, 0), DQCondition.LessThan(DQExpression.Field(moneyField), DQExpression.IfNull(DQExpression.Field("VerificationMoney"), DQExpression.ConstValue(0)))), DQCondition.GreaterThan(DQExpression.Field(moneyField), DQExpression.IfNull(DQExpression.Field("VerificationMoney"), DQExpression.ConstValue(0)))));
+ return dom;
+ }
+
+ private bool Before()
+ {
+ if (string.IsNullOrEmpty(Ids))
+ {
+ if (string.IsNullOrEmpty(CusID))
+ {
+ AspUtil.Alert(this, "请选择收款单据或者结转客户");
+ return false;
+ }
+ CustomerID = long.Parse(CusID);
+ ThisMoney = 0;
+ _moneyLabel.Text = (0).ToString();
+ return true;
+ }
+ var dom = new DQueryDom(new JoinAlias(typeof(Gathering)));
+ dom.Columns.Add(DQSelectColumn.Field("AccountCustomer_ID"));
+ dom.Columns.Add(DQSelectColumn.Field("AccountCustomer_Name"));
+ dom.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Field("GatheringMoney").ESubtract(DQExpression.Field("VerificationMoney"))), "money"));
+ dom.Columns.Add(DQSelectColumn.Field("AccountingUnit_ID"));
+ dom.GroupBy.Expressions.Add(DQExpression.Field("AccountCustomer_ID"));
+ dom.GroupBy.Expressions.Add(DQExpression.Field("AccountCustomer_Name"));
+ dom.GroupBy.Expressions.Add(DQExpression.Field("AccountingUnit_ID"));
+ var ids = Ids.Split(',').Select(long.Parse).ToList();
+ dom.Where.Conditions.EFieldInList("ID", ids);
+ var tuples = dom.EExecuteList();
+ if (tuples.Count > 1)
+ {
+ AspUtil.Alert(this, "选择的客户不一致");
+ return false;
+ }
+ CustomerID = tuples[0].Item1 ?? 0;
+ ThisMoney = (tuples[0].Item3 ?? 0);
+ AccountingUnit_ID = (tuples[0].Item4 ?? 0);
+ _moneyLabel.Text = (tuples[0].Item3 ?? 0).ToString();
+ return true;
+ }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ if (!IsPostBack && !_someError)
+ {
+ StartQuery();
+ }
+ }
+
+ protected override void OnPreRender(EventArgs e)
+ {
+ base.OnPreRender(e);
+ if (!_someError)
+ {
+ string script = @"var defaultGrid=document.all." + _browseGrid.ClientID + @";
+ $(function(){
+ var grid = defaultGrid.behind;
+ var itemEndIndex = grid.mItemEndIndex - 1;
+ for (i = 0; i <= itemEndIndex; i++) {
+ var row = grid.front.rows[i];
+ var chkbox = row.cells[0].getElementsByTagName(""INPUT"")[0];
+ if (chkbox) {
+ if(i==0)
+ $(chkbox).change(function() {
+ _SumMoney(this.checked?'1':'0');
+ });
+ else
+ $(chkbox).change(function() {
+ _SumMoney();
+ });
+ }
+ }
+ });
+function _SumMoney(allCheck)
+{
+ var grid = defaultGrid.behind;
+ var itemEndIndex = grid.mItemEndIndex - 1;
+ var sumM = 0.0;
+ for (i = 1; i <= itemEndIndex; i++) {
+ var row = grid.front.rows[i];
+ var chkbox = row.cells[0].getElementsByTagName(""INPUT"")[0];
+ if (!chkbox)
+ continue;
+
+ if (allCheck){
+ if(allCheck == '0')
+ continue;
+ } else{
+ if (!chkbox.checked)
+ continue;
+ }
+
+ var m = row.dfContainer.getValue('本次核销金额');
+ if (m != null && m != '') {
+ sumM = sumM + 1 * m;
+ }
+ }
+ var label = document.getElementById('{selectMoneyLabel}')
+ label.innerText = sumM.toFixed(2);
+ if( sumM > {thisMoney}){
+ label.style.color = 'red';
+ } else {
+ label.style.color = 'black';
+ }
+} ";
+ script = script.Replace("{thisMoney}", ThisMoney.ToString());
+ script = script.Replace("{selectMoneyLabel}", _selectMoneyLabel.ClientID);
+ Page.ClientScript.RegisterStartupScript(GetType(), "Startup", script, true);
+ }
+
+ }
+ }
+}
diff --git a/BWP.B3_YunKen.Web/Pages/B3YunKen/Overlays/VerificationPage_Ext.cs b/BWP.B3_YunKen.Web/Pages/B3YunKen/Overlays/VerificationPage_Ext.cs
new file mode 100644
index 0000000..c218e2b
--- /dev/null
+++ b/BWP.B3_YunKen.Web/Pages/B3YunKen/Overlays/VerificationPage_Ext.cs
@@ -0,0 +1,21 @@
+using BWP.Web.Pages.B3Sale.Bills.Verification_;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BWP.Web.Pages.B3YunKen.Overlays
+{
+ class VerificationPage_Ext: VerificationPage
+ {
+
+ protected override string BaseLogUrl
+ {
+
+ get
+ {
+ return "~/B3YunKen/Dialogs/SelectBillDialog.aspx";
+ }
+ }
+ }
+}
diff --git a/BWP.B3_YunKen.Web/PluginClass.cs b/BWP.B3_YunKen.Web/PluginClass.cs
index a3847df..1362e36 100644
--- a/BWP.B3_YunKen.Web/PluginClass.cs
+++ b/BWP.B3_YunKen.Web/PluginClass.cs
@@ -14,6 +14,7 @@ using BWP.Web.Pages.B3Sale.Bills.CustomerApply_;
using BWP.Web.Pages.B3Butchery.Dialogs;
using BWP.B3Frameworks.Attributes;
using BWP.B3Sale.BO;
+using BWP.Web.Pages.B3Sale.Bills.Verification_;
namespace BWP.B3_YunKen.Web
{
@@ -47,6 +48,7 @@ namespace BWP.B3_YunKen.Web
WpfPageFactory.RegisterPageOverlay(typeof(CustomerApplyEdit).FullName, typeof(CustomerApplyEdit_Ext).FullName);
WpfPageFactory.RegisterPageOverlay(typeof(SelectProductNoticeDialog).FullName, typeof(SelectProductNoticeDialog_Ext).FullName);
WpfPageFactory.RegisterPageOverlay(typeof(CustomerApplyList).FullName, typeof(CustomerApplyList_Ext).FullName);
+ WpfPageFactory.RegisterPageOverlay(typeof(VerificationPage).FullName, typeof(VerificationPage_Ext).FullName);
WeChatDataTemplateNameAttribute.SetCustomName(typeof(Order), "耘垦销售订单");
WeChatDataTemplateNameAttribute.SetCustomName(typeof(SaleOutStore), "耘垦销售出库单");
WeChatDataTemplateNameAttribute.SetCustomName(typeof(SaleForecast), "耘垦销售预报");