diff --git a/BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj b/BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj index 1d93fdf..4788927 100644 --- a/BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj +++ b/BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj @@ -34,6 +34,14 @@ AllRules.ruleset + + False + ..\..\..\tsref\release\B3Butchery.dll + + + False + ..\..\..\tsref\release\B3Butchery.Web.dll + @@ -79,6 +87,9 @@ ASPXCodeBehind + + ASPXCodeBehind + ASPXCodeBehind @@ -91,6 +102,7 @@ ASPXCodeBehind + diff --git a/BWP.B3_YunKen.Web/Pages/B3YunKen/Overlays/ProductNoticeEdit_Ext.cs b/BWP.B3_YunKen.Web/Pages/B3YunKen/Overlays/ProductNoticeEdit_Ext.cs new file mode 100644 index 0000000..0c72768 --- /dev/null +++ b/BWP.B3_YunKen.Web/Pages/B3YunKen/Overlays/ProductNoticeEdit_Ext.cs @@ -0,0 +1,27 @@ +using BWP.B3Butchery.BO; +using BWP.B3UnitedInfos; +using BWP.Web.Pages.B3Butchery.Bills.ProductNotice_; +using Forks.EnterpriseServices.DataForm; +using System.Linq; +using TSingSoft.WebControls2; +using TSingSoft.WebPluginFramework; + +namespace BWP.Web.Pages.B3YunKen.Overlays +{ + public class ProductNoticeEdit_Ext: ProductNoticeEdit + { + protected override void AddYunKenGridColumns(DFEditGrid _detailGrid) + { + _detailGrid.Columns.Add(new DFEditGridColumn("OrderByID")); + if (GlobalFlags.get(B3UnitedInfosConsts.GlobalFlags.库存支持品牌项)) + { + _detailGrid.Columns.Add(new DFEditGridColumn("BrandItem_ID")); + } + _detailGrid.Columns.Add(new DFEditGridColumn("Detail_Customer_ID")); + } + protected override DFCollectionEditor AddYunKenGridOrderByID() + { + return new DFCollectionEditor(() => Dmo.Details.OrderBy(x => x.OrderByID).ToList()); + } + } +} diff --git a/BWP.B3_YunKen.Web/Pages/MainToSecondConvertRowManger.cs b/BWP.B3_YunKen.Web/Pages/MainToSecondConvertRowManger.cs new file mode 100644 index 0000000..428dd66 --- /dev/null +++ b/BWP.B3_YunKen.Web/Pages/MainToSecondConvertRowManger.cs @@ -0,0 +1,531 @@ +using BWP.B3Sale.BL; +using Forks.EnterpriseServices.BusinessInterfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TSingSoft.WebControls2; + +namespace BWP.Web.Pages +{ + public class MainToSecondConvertRowManger + { + readonly DFEditGridColumn _unitNumInput; + readonly DFEditGridColumn _mainNumberInput; + readonly DFEditGridColumn _secondNumberInput; + readonly DFEditGridColumn _priceInput; + readonly DFEditGridColumn _willOutStoreSecondNumberInput; + readonly DFEditGridColumn _willOutStoreUnitNumInput; + readonly DFEditGridColumn _invoicedUnitNumInput; + readonly DFEditGridColumn _invoicedMoneyInput; + readonly DFEditGridColumn _moneyInput; + readonly DFEditGridColumn NetPriceInput; + readonly DFEditGridColumn PriceCostInput; + + readonly string _unitNumField; + readonly string _mainNumberField; + readonly string _secondNumberField; + readonly string _moneyField; + readonly string _rebateField; + readonly string _rebateMoneyField; + readonly string _willOutStoreUnitNumField; + readonly string _willOutStoreSecondNumberField; + readonly string _invoicedUnitNumField; + readonly string _invoicedMoneyField; + readonly string _discountMoneyfield; + bool _hasPrice; + bool _hasMoney; + bool _hasRebate; + bool _hasRebateMoney; + bool _hasDiscountMoney; + bool _hasUnitNum; + public MainToSecondConvertRowManger(DFGridBase grid) + : this(grid, "UnitNum", "Number", "SecondNumber", "Money", "Rebate", "RebateMoney", "WillOutStoreUnitNum", "WillOutStoreSecondNumber", "InvoicedUnitNum", "InvoicedMoney", "DiscountMoney") + { + + } + + public MainToSecondConvertRowManger(DFGridBase grid, string unitNumfield, string mainfield, string secondfield, string moneyfield, string rebatefield, string rebateMoneyfield, string willOutStoreUnitNumfield, string willOutStoreSecondNumberfield, string invoicedUnitNumfield, string invoicedMoneyfield, string discountMoneyfield) + { + _unitNumField = unitNumfield; + _mainNumberField = mainfield; + _secondNumberField = secondfield; + _moneyField = moneyfield; + _rebateField = rebatefield; + _rebateMoneyField = rebateMoneyfield; + _willOutStoreUnitNumField = willOutStoreUnitNumfield; + _willOutStoreSecondNumberField = willOutStoreSecondNumberfield; + _discountMoneyfield = discountMoneyfield; + _invoicedUnitNumField = invoicedUnitNumfield; + _invoicedMoneyField = invoicedMoneyfield; + _discountMoneyfield = discountMoneyfield; + _hasMoney = _hasPrice = _hasRebate = _hasRebateMoney = _hasDiscountMoney = false; + foreach (DFGridColumn column in grid.Columns) + { + if (column is DFEditGridColumn) + { + var c = (DFEditGridColumn)column; + if (c.Name == unitNumfield) + { + _unitNumInput = c; + _hasUnitNum = true; + } + else if (c.Name == mainfield) + _mainNumberInput = c; + else if (c.Name == secondfield) + _secondNumberInput = c; + else if (c.Name == "Price") + { + _priceInput = c; + _hasPrice = true; + } + else if (c.Name == moneyfield) + { + _moneyInput = c; + _hasMoney = true; + } + else if (c.Name == "NetPrice") + NetPriceInput = c; + else if (c.Name == "PriceCost") + PriceCostInput = c; + else if (c.Name == willOutStoreUnitNumfield) + _willOutStoreUnitNumInput = c; + else if (c.Name == willOutStoreSecondNumberfield) + _willOutStoreSecondNumberInput = c; + else if (c.Name == invoicedUnitNumfield) + _invoicedUnitNumInput = c; + else if (c.Name == invoicedMoneyfield) + _invoicedMoneyInput = c; + } + else if (column is DFEditGridColumn) + { + var c1 = (DFEditGridColumn)column; + if (c1.Name == _moneyField) + { + _hasMoney = true; + } + else if (c1.Name == "Price") + { + _hasPrice = true; + } + else if (c1.Name == _rebateField) + { + _hasRebate = true; + } + else if (c1.Name == _rebateMoneyField) + { + _hasRebateMoney = true; + } + else if (c1.Name == _discountMoneyfield) + { + _hasDiscountMoney = true; + } + else if (c1.Name == _unitNumField) + { + _hasUnitNum = true; + } + } + } + SetClientScript(); + } + + string SetMainNumber + { + get + { + return string.Format("dfContainer.setValue('{0}', (dfContainer.getValue('{1}')*{2}/{3}).toFixed(6));", _mainNumberField, _secondNumberField, MainUnitRatio, SecondUnitRatio); + } + } + + string SetSecondNumber + { + get + { + return string.Format("dfContainer.setValue('{0}', (dfContainer.getValue('{1}')*{2}/{3}).toFixed(6));", _secondNumberField, _mainNumberField, SecondUnitRatio, MainUnitRatio); + } + } + + string SetMoney + { + get + { + return string.Format("dfContainer.setValue('{0}', (dfContainer.getValue('Price')*dfContainer.getValue('{1}')).toFixed(2));", _moneyField, _unitNumField); + } + } + + string SetRebateMoney + { + get + { + return string.Format("dfContainer.setValue('RebateMoney', (dfContainer.getValue('Money')*dfContainer.getValue('Rebate')/100).toFixed(2));"); + } + } + + string SetDiscountMoney + { + get + { + return string.Format("dfContainer.setValue('DiscountMoney', dfContainer.getValue('Money')-dfContainer.getValue('RebateMoney'));"); + } + } + + + private const string ConvertDirection = "dfContainer.getValue('Goods_UnitConvertDirection')"; + private const string MainUnitRatio = "dfContainer.getValue('Goods_MainUnitRatio')"; + private const string SecondUnitRatio = "dfContainer.getValue('Goods_SecondUnitRatio')"; + private const string LeftRatio = "dfContainer.getValue('LeftRatio')"; + private const string RightRatio = "dfContainer.getValue('RightRatio')"; + + private void SetClientScript() + { + SetUnitNumChanged(); + SetMainNumberChanged(); + SetSecondNumberChanged(); + SetPriceChanged(); + SetWillOutStoreUnitNumChanged(); + SetWillOutStoreSecondNumberChanged(); + SetinvoicedUnitNumChanged(); + SetinvoicedMoneyChanged(); + SetMoneyChanged(); + SetNetPriceChanged(); + SetPriceCostChanged(); + } + + private void SetinvoicedUnitNumChanged() + { + if (_invoicedUnitNumInput == null || _invoicedMoneyInput == null) + return; + if (_hasPrice && _hasRebate) + { + _invoicedUnitNumInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) + { + e.Control.Attributes["onchange"] = + "if(dfContainer.getValue('Price')!=0){dfContainer.setValue('InvoicedMoney', (dfContainer.getValue('InvoicedUnitNum')*dfContainer.getValue('Price')*dfContainer.getValue('Rebate')/100).toFixed(2));}"; + }; + } + } + + private void SetMoneyChanged() + { + if (_moneyInput == null) + return; + if (_hasPrice && _hasUnitNum) + { + + var str = @" var number = dfContainer.getValue('" + _unitNumField + @"'); + if(number==''|| number=='0'){ + number = 1; + dfContainer.setValue('" + _unitNumField + @"','1' ) + }; + dfContainer.setValue('Price', (dfContainer.getValue('" + _moneyField + "')/ number).toFixed(6));"; + _moneyInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) { + e.Control.Attributes["onchange"] = str; + }; + } + } + + private void SetinvoicedMoneyChanged() + { + if (_invoicedUnitNumInput == null && _invoicedMoneyInput == null) + return; + if (_hasPrice) + { + _invoicedMoneyInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) + { + e.Control.Attributes["onchange"] = string.Format("dfContainer.setValue('{0}', (dfContainer.getValue('{1}')*100/dfContainer.getValue('Rebate')/dfContainer.getValue('Price')).toFixed(2));", _invoicedUnitNumField, _invoicedMoneyField); + }; + } + } + + string SetWillOutStoreSecondNumberByUnitNum + { + get + { + return string.Format("var number = dfContainer.getValue('{0}')/{1}*{2}; dfContainer.setValue('{3}', (number /{4}*{5}).toFixed(6));", _willOutStoreUnitNumField, LeftRatio, RightRatio, _willOutStoreSecondNumberField, MainUnitRatio, SecondUnitRatio); + } + } + + private void SetWillOutStoreUnitNumChanged() + { + if (_willOutStoreUnitNumInput == null) + return; + + var builder = new StringBuilder(); + + if (_willOutStoreSecondNumberInput != null) + { + builder.Append(@"if({convertDirection}=='双向转换'||{convertDirection}=='由主至辅'){if({unitRatioLeft} > 0 && {unitRatioRight}>0 && {ratioRight}>0 && {ratioLeft}>0){SetWillOutStoreSecondNumberByUnitNum}}" + .Replace("{convertDirection}", ConvertDirection) + .Replace("{ratioLeft}", MainUnitRatio) + .Replace("{ratioRight}", SecondUnitRatio) + .Replace("{unitRatioLeft}", LeftRatio) + .Replace("{unitRatioRight}", RightRatio) + .Replace("{SetWillOutStoreSecondNumberByUnitNum}", SetWillOutStoreSecondNumberByUnitNum) + ); + } + + _willOutStoreUnitNumInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) + { + e.Control.Attributes["onchange"] = builder.ToString(); + }; + } + + string SetWillOutStoreUnitNumBySecondNumber + { + get + { + return string.Format("var number = dfContainer.getValue('{0}')*{1}/{2};dfContainer.setValue('{3}', (number/{4}*{5}).toFixed(2));", _willOutStoreSecondNumberField, MainUnitRatio, SecondUnitRatio, _willOutStoreUnitNumField, RightRatio, LeftRatio); + } + } + + private void SetWillOutStoreSecondNumberChanged() + { + if (_willOutStoreSecondNumberInput == null) + return; + + var builder = new StringBuilder(); + if (_willOutStoreUnitNumInput != null) + { + builder.Append(@"if({convertDirection}=='双向转换'||{convertDirection}=='由辅至主'){ if({ratioRight}>0 && {ratioLeft}>0 && {unitRatioLeft} > 0 && {unitRatioRight}>0) + {SetWillOutStoreUnitNumBySecondNumber}}" + .Replace("{convertDirection}", ConvertDirection) + .Replace("{ratioRight}", SecondUnitRatio) + .Replace("{ratioLeft}", MainUnitRatio) + .Replace("{unitRatioLeft}", LeftRatio) + .Replace("{unitRatioRight}", RightRatio) + .Replace("{SetWillOutStoreUnitNumBySecondNumber}", SetWillOutStoreUnitNumBySecondNumber)); + } + + _willOutStoreSecondNumberInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) + { + e.Control.Attributes["onchange"] = builder.ToString(); + }; + } + + string SetNumberByUnitNum + { + get + { + return string.Format("dfContainer.setValue('{0}', (dfContainer.getValue('{1}')/{2}*{3}).toFixed(6));", _mainNumberField, _unitNumField, LeftRatio, RightRatio); + } + } + + string SetSecondNumberByUnitNum + { + get + { + return string.Format("var number = dfContainer.getValue('{0}')/{1}*{2}; dfContainer.setValue('{3}', (number /{4}*{5}).toFixed(6));", _unitNumField, LeftRatio, RightRatio, _secondNumberField, MainUnitRatio, SecondUnitRatio); + } + } + + private void SetUnitNumChanged() + { + if (_unitNumInput == null) + return; + + var builder = new StringBuilder(); + + if (_mainNumberInput != null) + { + builder.Append(@"if({unitRatioLeft} > 0 && {unitRatioRight}>0){ +{SetNumberByUnitNum}}".Replace("{unitRatioLeft}", LeftRatio) + .Replace("{unitRatioRight}", RightRatio) + .Replace("{SetNumberByUnitNum}", SetNumberByUnitNum) +); + } + + if (_secondNumberInput != null) + { + builder.Append(@"if({convertDirection}=='双向转换'||{convertDirection}=='由主至辅'){if({unitRatioLeft} > 0 && {unitRatioRight}>0 && {ratioRight}>0 && {ratioLeft}>0){{SetSecondNumberByUnitNum}}}" + .Replace("{convertDirection}", ConvertDirection) + .Replace("{ratioLeft}", MainUnitRatio) + .Replace("{ratioRight}", SecondUnitRatio) + .Replace("{unitRatioLeft}", LeftRatio) + .Replace("{unitRatioRight}", RightRatio) + .Replace("{SetSecondNumberByUnitNum}", SetSecondNumberByUnitNum) + ); + } + + if (_hasPrice && _hasMoney) + { + builder.Append(SetMoney); + if (_hasRebate && _hasRebateMoney) + { + builder.Append(SetRebateMoney); + } + if (_hasRebate && _hasDiscountMoney) + { + builder.Append(SetDiscountMoney); + } + } + + _unitNumInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) + { + e.Control.Attributes["onchange"] = builder.ToString(); + }; + } + + private void SetSecondNumberChanged() + { + if (_secondNumberInput == null) + return; + + var builder = new StringBuilder(); + if (_mainNumberInput != null) + { + builder.Append(@"if({convertDirection}=='双向转换'||{convertDirection}=='由辅至主'){ if({ratioRight}>0 && {ratioLeft}>0) + {setMainNumber}}" + .Replace("{convertDirection}", ConvertDirection) + .Replace("{ratioRight}", SecondUnitRatio) + .Replace("{ratioLeft}", MainUnitRatio) + .Replace("{setMainNumber}", SetMainNumber)); + } + if (_unitNumInput != null) + { + builder.Append(@"if({convertDirection}=='双向转换'||{convertDirection}=='由辅至主'){ if({ratioRight}>0 && {ratioLeft}>0 && {unitRatioLeft} > 0 && {unitRatioRight}>0) + {{setUnitNum}}}" + .Replace("{convertDirection}", ConvertDirection) + .Replace("{ratioRight}", SecondUnitRatio) + .Replace("{ratioLeft}", MainUnitRatio) + .Replace("{unitRatioLeft}", LeftRatio) + .Replace("{unitRatioRight}", RightRatio) + .Replace("{setUnitNum}", SetUnitNumBySecondNumber)); + } + if (_hasPrice && _hasMoney) + { + builder.Append(SetMoney); + if (_hasRebate && _hasRebateMoney) + { + builder.Append(SetRebateMoney); + } + if (_hasRebate && _hasDiscountMoney) + { + builder.Append(SetDiscountMoney); + } + } + _secondNumberInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) { + e.Control.Attributes["onchange"] = builder.ToString(); + }; + } + + string SetUnitNumBySecondNumber + { + get + { + return string.Format("var number = dfContainer.getValue('{0}')*{1}/{2};dfContainer.setValue('{3}', (number/{4}*{5}).toFixed(2));", _secondNumberField, MainUnitRatio, SecondUnitRatio, _unitNumField, RightRatio, LeftRatio); + } + } + + string SetUnitNumByNumber + { + get + { + return string.Format("dfContainer.setValue('{0}', (dfContainer.getValue('{1}')/{2}*{3}).toFixed(2));", _unitNumField, _mainNumberField, RightRatio, LeftRatio); + } + } + + private void SetMainNumberChanged() + { + if (_mainNumberInput == null) + return; + + var builder = new StringBuilder(); + + if (_secondNumberInput != null) + { + builder.Append(@"if({convertDirection}=='双向转换'||{convertDirection}=='由主至辅'){ if({ratioLeft}>0 && {ratioRight}>0){setSecondNumber}}" + .Replace("{convertDirection}", ConvertDirection) + .Replace("{ratioLeft}", MainUnitRatio) + .Replace("{ratioRight}", SecondUnitRatio) + .Replace("{setSecondNumber}", SetSecondNumber) + ); + } + if (_unitNumInput != null) + { + builder.Append(@"if({convertDirection}=='双向转换'||{convertDirection}=='由主至辅'){if({unitRatioLeft} > 0 && {unitRatioRight}>0){setUnitNum}}" + .Replace("{convertDirection}", ConvertDirection) + .Replace("{unitRatioLeft}", MainUnitRatio) + .Replace("{unitRatioRight}", SecondUnitRatio) + .Replace("{setUnitNum}", SetUnitNumByNumber) + ); + } + if (_hasPrice && _hasMoney) + { + builder.Append(SetMoney); + if (_hasRebate && _hasRebateMoney) + { + builder.Append(SetRebateMoney); + } + if (_hasRebate && _hasDiscountMoney) + { + builder.Append(SetDiscountMoney); + } + } + _mainNumberInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) { + e.Control.Attributes["onchange"] = builder.ToString(); + }; + } + + ISaleForecastBL bl = BIFactory.Create(); + private void SetPriceChanged() + { + if (_priceInput == null) + return; + + var builder = new StringBuilder(); + + if (_hasMoney && _unitNumInput != null) + { + builder.Append(SetMoney); + if (_hasRebate && _hasRebateMoney) + { + builder.Append(SetRebateMoney); + } + if (_hasRebate && _hasDiscountMoney) + { + builder.Append(SetDiscountMoney); + } + } + string SetPriceCost = "dfContainer.setValue('PriceCost',(dfContainer.getValue('Price')*1.00-dfContainer.getValue('NetPrice')*1.00));"; + if (NetPriceInput != null && PriceCostInput != null && !bl.LockCostPrice) + builder.Append(SetPriceCost); + _priceInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) { + e.Control.Attributes["onchange"] = builder.ToString(); + }; + } + + private void SetNetPriceChanged() + { + if (_priceInput == null) + return; + if (PriceCostInput == null) + return; + string SetPriceByNetPrice = "dfContainer.setValue('Price',(dfContainer.getValue('NetPrice')*1.00+dfContainer.getValue('PriceCost')*1.00));"; + if (NetPriceInput != null) + { + NetPriceInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) + { + e.Control.Attributes["onchange"] = SetPriceByNetPrice; + }; + } + } + + private void SetPriceCostChanged() + { + if (_priceInput == null) + return; + if (NetPriceInput == null) + return; + string SetPriceByNetPrice = "dfContainer.setValue('Price',(dfContainer.getValue('NetPrice')*1.00+dfContainer.getValue('PriceCost')*1.00));"; + + if (PriceCostInput != null) + { + PriceCostInput.InitEditControl += delegate (object sender, InitEditControlEventArgs e) + { + e.Control.Attributes["onchange"] = SetPriceByNetPrice; + }; + } + + } + } +} diff --git a/BWP.B3_YunKen.Web/PluginClass.cs b/BWP.B3_YunKen.Web/PluginClass.cs index 78559e2..30313b3 100644 --- a/BWP.B3_YunKen.Web/PluginClass.cs +++ b/BWP.B3_YunKen.Web/PluginClass.cs @@ -6,6 +6,7 @@ using BWP.Web.Pages.B3Sale.Bills.Order_; using BWP.Web.Pages.B3YunKen.Overlays; using BWP.Web.Pages.B3Sale.Bills.SaleOutStore_; using BWP.Web.Pages.B3Sale.Bills.SaleForecast_; +using BWP.Web.Pages.B3Butchery.Bills.ProductNotice_; namespace BWP.B3_YunKen.Web { @@ -22,6 +23,7 @@ namespace BWP.B3_YunKen.Web WpfPageFactory.RegisterPageOverlay(typeof(OrderEdit).FullName, typeof(OrderEdit_Ext).FullName); WpfPageFactory.RegisterPageOverlay(typeof(SaleOutStoreEdit).FullName, typeof(SaleOutStoreEdit_Ext).FullName); WpfPageFactory.RegisterPageOverlay(typeof(SaleForecastEdit).FullName, typeof(SaleForecastEdit_Ext).FullName); + WpfPageFactory.RegisterPageOverlay(typeof(ProductNoticeEdit).FullName, typeof(ProductNoticeEdit_Ext).FullName); } public void OnUnitInit()