From e4c9f11f121a7d9eee22eff810634639d3975209 Mon Sep 17 00:00:00 2001 From: xueyingcheng Date: Tue, 6 Feb 2018 18:36:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=85=E8=A3=85=E7=89=A9=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=9D=E5=AD=98=E4=BB=B7=E6=A0=BC=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/B3YunKen/Bill/GoodsPackageSet.cs | 225 ++++++++++++++---- BWP.B3_YunKen/BO/Bill/Goods_PackagePrice.cs | 35 +++ BWP.B3_YunKen/BWP.B3_YunKen.csproj | 1 + 3 files changed, 212 insertions(+), 49 deletions(-) create mode 100644 BWP.B3_YunKen/BO/Bill/Goods_PackagePrice.cs diff --git a/BWP.B3_YunKen.Web/Pages/B3YunKen/Bill/GoodsPackageSet.cs b/BWP.B3_YunKen.Web/Pages/B3YunKen/Bill/GoodsPackageSet.cs index a5f3738..c4b540e 100644 --- a/BWP.B3_YunKen.Web/Pages/B3YunKen/Bill/GoodsPackageSet.cs +++ b/BWP.B3_YunKen.Web/Pages/B3YunKen/Bill/GoodsPackageSet.cs @@ -79,6 +79,8 @@ namespace BWP.Web.Pages.B3YunKen.Bill hPanel.Add(new LiteralControl("  ")); hPanel.Add(new TSButton("未配产品", delegate { GridDataBind(); })); + hPanel.Add(new TSButton("保存价格", delegate { SavePrice(); })); + _grid = vPanel.Add(new DFBrowseGrid(new DFDataTableEditor()), new VLayoutOption(HorizontalAlign.Center)); _grid.Width = Unit.Percentage(50); _grid.Add(new DFBrowseGridAutoColumn("Goods_ID")); @@ -194,6 +196,131 @@ namespace BWP.Web.Pages.B3YunKen.Bill } + + private void SavePrice(bool configured = false) + { + + var dom=GetDQueryDom(true); + + List savePriceList = new List(); + using (var context = new TransactionContext()) + { + using (var reader = context.Session.ExecuteReader(dom)) + { + while (reader.Read()) + { + var d = new SavePriceTemp(); + d.Goods_ID = (long)reader[0]; + d.AccountingUnit_Name = (string)reader[3]; + d.WrappageKindID1 = (string)reader[4]; + d.WrappageKindID2 = (string)reader[5]; + d.WrappageKindID3 = (string)reader[6]; + d.WrappageKindID4 = (string)reader[7]; + d.SmallPackNum = reader[8] == null ? 0 : Convert.ToInt32(reader[8]); + savePriceList.Add(d); + } + } + } + + List Goods_PackagePriceList = new List(); + #region + foreach (var savePrice in savePriceList) + { + decimal priceSum = 0; + decimal price1 = 0, price2 = 0, price3 = 0, price4 = 0; + if (!string.IsNullOrEmpty(savePrice.WrappageKindID1)) + { + price1 = GetWrappageUnitPrice(savePrice.AccountingUnit_Name, savePrice.WrappageKindID1) ?? 0; + if (price1 == 0) + { + price1 = GetWrappagePrice(savePrice.AccountingUnit_Name, savePrice.WrappageKindID1) ?? 0; + } + } + + if (!string.IsNullOrEmpty(savePrice.WrappageKindID2)) + { + price2 = GetWrappageUnitPrice(savePrice.AccountingUnit_Name, savePrice.WrappageKindID2) ?? 0; + if (price2 == 0) + { + price2 = GetWrappagePrice(savePrice.AccountingUnit_Name, savePrice.WrappageKindID2) ?? 0; + } + } + + if (!string.IsNullOrEmpty(savePrice.WrappageKindID3)) + { + price3 = GetWrappageUnitPrice(savePrice.AccountingUnit_Name, savePrice.WrappageKindID3) ?? 0; + if (price3 == 0) + { + price3 = GetWrappagePrice(savePrice.AccountingUnit_Name, savePrice.WrappageKindID3) ?? 0; + } + } + + if (!string.IsNullOrEmpty(savePrice.WrappageKindID4)) + { + price4 = GetWrappageUnitPrice(savePrice.AccountingUnit_Name, savePrice.WrappageKindID4) ?? 0; + if (price4 == 0) + { + price4 = GetWrappagePrice(savePrice.AccountingUnit_Name, savePrice.WrappageKindID4) ?? 0; + } + + price4 = price4 * savePrice.SmallPackNum; + } + + priceSum = price1 + price2 + price3 +price4; + + Goods_PackagePrice gp = new Goods_PackagePrice + { Goods_ID = savePrice.Goods_ID, Price = priceSum, AccountingUnit_Name = savePrice.AccountingUnit_Name, User_ID = DomainContext.Current.DomainUser.User_ID }; + + Goods_PackagePriceList.Add(gp); + + } + #endregion + + + + using (var context = new TransactionContext()) + { + string sql = "delete from B3_YunKen_Goods_PackagePrice where User_ID=" + DomainContext.Current.DomainUser.User_ID; + context.Session.ExecuteSqlNonQuery(sql); + context.Session.Commit(); + } + + using (var context = new TransactionContext()) + { + var session = context.Session; + + foreach (var gp in Goods_PackagePriceList) + { + session.Insert(gp); + } + session.Commit(); + } + + + + } + + + + class SavePriceTemp + { + public long Goods_ID { get; set; } + + public string AccountingUnit_Name { get; set; } + + public string WrappageKindID1 { get; set; } + public string WrappageKindID2 { get; set; } + public string WrappageKindID3 { get; set; } + public string WrappageKindID4 { get; set; } + + public int SmallPackNum { get; set; } + //public string SmallPackNum { get; set; } + + } + + + + private void GridDataBind(bool configured = false) { if (configured) @@ -222,59 +349,59 @@ namespace BWP.Web.Pages.B3YunKen.Bill private DQueryDom GetDQueryDom(bool configured = false) { - var goods = new JoinAlias(typeof(Goods)); - var temp = new JoinAlias(typeof(TempPackage)); - var temp2 = new JoinAlias(typeof(TempPackage2)); - var dom = new DQueryDom(goods); - OrganizationUtil.RegisterOrganizationQueryTable(dom); - dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goods, "ID"), "Goods_ID")); - dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goods, "Name"), "产品")); - if (configured) + var goods = new JoinAlias(typeof(Goods)); + var temp = new JoinAlias(typeof(TempPackage)); + var temp2 = new JoinAlias(typeof(TempPackage2)); + var dom = new DQueryDom(goods); + OrganizationUtil.RegisterOrganizationQueryTable(dom); + dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goods, "ID"), "Goods_ID")); + dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(goods, "Name"), "产品")); + if (configured) + { + var strings = new string[] { "Goods_ID", "AccountingUnit_Name", "Count" }.ToList(); + for (var index = 0; index < WrappageKindList.Count; index++) { - var strings = new string[] { "Goods_ID", "AccountingUnit_Name", "Count" }.ToList(); - for (var index = 0; index < WrappageKindList.Count; index++) - { - if (index + 1 > MaxCol) - break; - strings.Add("ID" + (index + 1)); - } - strings.Add("SmallPackNum"); - dom.RegisterQueryTable(typeof(TempPackage2), strings, GetTempDom2()); - dom.From.AddJoin(JoinType.Right, new DQDmoSource(temp2), DQCondition.EQ(temp2, "Goods_ID", goods, "ID")); - dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(temp2, "Count"), "已配数量")); - dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(temp2, "AccountingUnit_Name"), "会计单位")); - - int i = 1; - foreach (var tuple in WrappageKindList) - { - if (i > MaxCol) - break; - var package = new JoinAlias("p" + i, typeof(Wrappage)); - dom.From.AddJoin(JoinType.Left, new DQDmoSource(package), DQCondition.EQ(package, "ID", temp2, "ID" + i)); - dom.Columns.Add( - DQSelectColumn.Create(DQExpression.Field(package, "Name"), tuple.Item2)); - i++; - } - dom.OrderBy.Expressions.Add(DQOrderByExpression.Create(goods, "Name")); - dom.OrderBy.Expressions.Add(DQOrderByExpression.Create(temp2, "AccountingUnit_Name")); - - dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(temp2, "SmallPackNum"), "内包装物数量")); + if (index + 1 > MaxCol) + break; + strings.Add("ID" + (index + 1)); } - else - { - dom.RegisterQueryTable(typeof(TempPackage), new[] { "Goods_ID" }, GetTempDom()); - dom.From.AddJoin(JoinType.Left, new DQDmoSource(temp), DQCondition.EQ(temp, "Goods_ID", goods, "ID")); - dom.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field(temp, "Goods_ID"))); - } - if (!string.IsNullOrEmpty(_goodsDfc.Value)) + strings.Add("SmallPackNum"); + dom.RegisterQueryTable(typeof(TempPackage2), strings, GetTempDom2()); + dom.From.AddJoin(JoinType.Right, new DQDmoSource(temp2), DQCondition.EQ(temp2, "Goods_ID", goods, "ID")); + dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(temp2, "Count"), "已配数量")); + dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(temp2, "AccountingUnit_Name"), "会计单位")); + + int i = 1; + foreach (var tuple in WrappageKindList) { - dom.Where.Conditions.Add(DQCondition.EQ("ID", _goodsDfc.Value)); + if (i > MaxCol) + break; + var package = new JoinAlias("p" + i, typeof(Wrappage)); + dom.From.AddJoin(JoinType.Left, new DQDmoSource(package), DQCondition.EQ(package, "ID", temp2, "ID" + i)); + dom.Columns.Add( + DQSelectColumn.Create(DQExpression.Field(package, "Name"), tuple.Item2)); + i++; } - - dom.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field(goods, "ID"))); - //不显示停用存货 - dom.Where.Conditions.Add(DQCondition.InEQ(DQExpression.Field(goods, "Stopped"), DQExpression.Value(1))); - return dom; + dom.OrderBy.Expressions.Add(DQOrderByExpression.Create(goods, "Name")); + dom.OrderBy.Expressions.Add(DQOrderByExpression.Create(temp2, "AccountingUnit_Name")); + + dom.Columns.Add(DQSelectColumn.Create(DQExpression.Field(temp2, "SmallPackNum"), "内包装物数量")); + } + else + { + dom.RegisterQueryTable(typeof(TempPackage), new[] { "Goods_ID" }, GetTempDom()); + dom.From.AddJoin(JoinType.Left, new DQDmoSource(temp), DQCondition.EQ(temp, "Goods_ID", goods, "ID")); + dom.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field(temp, "Goods_ID"))); + } + if (!string.IsNullOrEmpty(_goodsDfc.Value)) + { + dom.Where.Conditions.Add(DQCondition.EQ("ID", _goodsDfc.Value)); + } + + dom.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field(goods, "ID"))); + //不显示停用存货 + dom.Where.Conditions.Add(DQCondition.InEQ(DQExpression.Field(goods, "Stopped"), DQExpression.Value(1))); + return dom; } private DQueryDom GetTempDom() diff --git a/BWP.B3_YunKen/BO/Bill/Goods_PackagePrice.cs b/BWP.B3_YunKen/BO/Bill/Goods_PackagePrice.cs new file mode 100644 index 0000000..a7c095e --- /dev/null +++ b/BWP.B3_YunKen/BO/Bill/Goods_PackagePrice.cs @@ -0,0 +1,35 @@ +using BWP.B3Frameworks.BO; +using BWP.B3Frameworks.BO.MoneyTemplate; +using Forks.EnterpriseServices; +using Forks.EnterpriseServices.DataForm; +using Forks.Utils; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BWP.B3_YunKen.BO +{ + + [Serializable, DFClass] + [LogicName("包装物价格")] + public class Goods_PackagePrice : Base + { + + public long? Goods_ID { get; set; } + + + [LogicName("包装物价格")] + public decimal? Price { get; set; } + + + [LogicName("会计单位")] + public string AccountingUnit_Name { get; set; } + + + [LogicName("用户ID")] + public long? User_ID { get; set; } + + + } +} diff --git a/BWP.B3_YunKen/BWP.B3_YunKen.csproj b/BWP.B3_YunKen/BWP.B3_YunKen.csproj index 5aeae1f..9673f82 100644 --- a/BWP.B3_YunKen/BWP.B3_YunKen.csproj +++ b/BWP.B3_YunKen/BWP.B3_YunKen.csproj @@ -74,6 +74,7 @@ +