Browse Source

包装物设置增加保存价格功能

master
xueyingcheng 7 years ago
parent
commit
e4c9f11f12
3 changed files with 212 additions and 49 deletions
  1. +176
    -49
      BWP.B3_YunKen.Web/Pages/B3YunKen/Bill/GoodsPackageSet.cs
  2. +35
    -0
      BWP.B3_YunKen/BO/Bill/Goods_PackagePrice.cs
  3. +1
    -0
      BWP.B3_YunKen/BWP.B3_YunKen.csproj

+ 176
- 49
BWP.B3_YunKen.Web/Pages/B3YunKen/Bill/GoodsPackageSet.cs View File

@ -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<SavePriceTemp> savePriceList = new List<SavePriceTemp>();
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_PackagePrice> Goods_PackagePriceList = new List<Goods_PackagePrice>();
#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()


+ 35
- 0
BWP.B3_YunKen/BO/Bill/Goods_PackagePrice.cs View File

@ -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; }
}
}

+ 1
- 0
BWP.B3_YunKen/BWP.B3_YunKen.csproj View File

@ -74,6 +74,7 @@
<Compile Include="BLActions\OrderFreightData.cs" />
<Compile Include="BL\Bill\Goods_PackageBL.cs" />
<Compile Include="BO\Bill\Goods_Package.cs" />
<Compile Include="BO\Bill\Goods_PackagePrice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rpcs\DriverRpc.cs" />
<Compile Include="TimerTask\NullifyCustomerTask.cs" />


Loading…
Cancel
Save