From 272e779025e1ac5cabeb77184991a080e7c3dd19 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Mon, 15 Oct 2018 15:45:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=96=B9=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bills/WeightBill_/WeightBillEdit.cs | 5 +- .../BL/Bill/ButcherBL/ButcherBL.cs | 88 ++++++++----------- .../BL/Bill/WeightBillBL/WeightBillBL.cs | 7 +- 3 files changed, 41 insertions(+), 59 deletions(-) diff --git a/B3SheepButcherManage.Web/Pages/B3SheepButcherManage/Bills/WeightBill_/WeightBillEdit.cs b/B3SheepButcherManage.Web/Pages/B3SheepButcherManage/Bills/WeightBill_/WeightBillEdit.cs index 9939166..0c0cce7 100644 --- a/B3SheepButcherManage.Web/Pages/B3SheepButcherManage/Bills/WeightBill_/WeightBillEdit.cs +++ b/B3SheepButcherManage.Web/Pages/B3SheepButcherManage/Bills/WeightBill_/WeightBillEdit.cs @@ -276,7 +276,10 @@ __DFContainer.setValue('Supplier_Card_ID',''); { e.Control.Style["width"] = "160px"; }; - _abnormalGrid.Columns.Add(new DFEditGridColumn("Price")); + _abnormalGrid.Columns.EAdd(new DFEditGridColumn("Price")).InitEditControl += (sender, e) => + { + e.Control.Style["width"] = "160px"; + }; _abnormalGrid.Columns.Add(new DFEditGridColumn("Abnormal_Money")); _abnormalGrid.PreferWidthGridSet = new Dictionary { { "序号", Unit.Pixel(80) }, { "奖罚项目", Unit.Percentage(20) }, { "头数", Unit.Percentage(20) }, { "单价", Unit.Percentage(20) }, { "金额", Unit.Percentage(20) } }; var section3 = mPageLayoutManager.AddSection("detailColumns2", "明细"); diff --git a/B3SheepButcherManage/BL/Bill/ButcherBL/ButcherBL.cs b/B3SheepButcherManage/BL/Bill/ButcherBL/ButcherBL.cs index 96c2a57..8aaed24 100644 --- a/B3SheepButcherManage/BL/Bill/ButcherBL/ButcherBL.cs +++ b/B3SheepButcherManage/BL/Bill/ButcherBL/ButcherBL.cs @@ -77,17 +77,17 @@ namespace BWP.B3SheepButcherManage.BL if (startID > endID) throw new Exception("开始ID不能比结束ID大"); - //判断删除的明细后面有无已经录入了重量的明细 - var dom = new DQueryDom(new JoinAlias(typeof(Butcher_Detail))); - dom.Where.Conditions.Add(DQCondition.EQ("Butcher_ID", butcherID)); - dom.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("Sequence", startID)); - dom.Where.Conditions.Add(DQCondition.LessThanOrEqual("Sequence", endID)); - dom.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("Weight"))); - dom.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("PhaseCode"))); - dom.Range = SelectRange.Top(1); - dom.Columns.Add(DQSelectColumn.Field("ID")); - if (Session.ExecuteScalar(dom) != null) - throw new Exception("你要删除的屠宰单明细后已经有重量录入"); + ////判断删除的明细后面有无已经录入了重量的明细 + //var dom = new DQueryDom(new JoinAlias(typeof(Butcher_Detail))); + //dom.Where.Conditions.Add(DQCondition.EQ("Butcher_ID", butcherID)); + //dom.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("Sequence", startID)); + //dom.Where.Conditions.Add(DQCondition.LessThanOrEqual("Sequence", endID)); + //dom.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("Weight"))); + //dom.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("PhaseCode"))); + //dom.Range = SelectRange.Top(1); + //dom.Columns.Add(DQSelectColumn.Field("ID")); + //if (Session.ExecuteScalar(dom) != null) + // throw new Exception("你要删除的屠宰单明细后已经有重量录入"); var needUpdateIds = GetNeedUpdateWeightDetailIDs(butcherID, startID, endID); //删除屠宰单明细 @@ -356,19 +356,19 @@ namespace BWP.B3SheepButcherManage.BL { throw new ApplicationException("未设置 屠宰单 数据库连接字符串!"); } - ReadFromWeight(beginTime, endTime, list, connectionString); + ReadFromWeightTable(beginTime, endTime, list, connectionString); return list; } - private void ReadFromWeight(DateTime beginTime, DateTime? endTime, ICollection list, string connectionString) + private static void ReadFromWeightTable(DateTime beginTime, DateTime? endTime, ICollection list, string connectionString) { - var selectSql = "select * from [Weight] where [DataTime]>='" + beginTime + "'"; + var selectSql = "select * from WeightTable where [DateTime]>='" + beginTime + "'"; if (endTime.HasValue) { - selectSql += " and [DataTime]<='" + endTime.Value + "'"; + selectSql += " and [DateTime]<='" + endTime.Value + "'"; } - selectSql += " Order by DataTime"; + selectSql += " Order by DateTime"; using (var sqlUtil = new SqlUtil(connectionString)) { using (var reader = sqlUtil.ExecuteReader(selectSql)) @@ -380,20 +380,26 @@ namespace BWP.B3SheepButcherManage.BL { weigh.ID = Convert.ToInt64(reader["ID"]); // ID } - if (!(reader["DataTime"] is DBNull)) + if (!(reader["DateTime"] is DBNull)) { - weigh.DateTime = Convert.ToDateTime(reader["DataTime"]); // 日期 + weigh.DateTime = Convert.ToDateTime(reader["DateTime"]); // 日期 } - if (!(reader["Level_Code"] is DBNull)) + if (!(reader["Livestock_ID"] is DBNull)) { - weigh.Level_Code = Convert.ToInt32(reader["Level_Code"]); // 快捷编码 + weigh.Livestock_ID = Convert.ToInt64(reader["Livestock_ID"]); // 级别号 + } + if (!(reader["Livestock_Name"] is DBNull)) + { + weigh.Livestock_Name = (reader["Livestock_Name"]).ToString(); // 级别 } - if (!(reader["Weight"] is DBNull)) { weigh.Weight = Convert.ToDecimal(reader["Weight"]); // 重量 } - + if (!(reader["Remark"] is DBNull)) + { + weigh.Remark = reader["Remark"].ToString(); // 备注 + } if (!(reader["SubWeight"] is DBNull)) { weigh.SubWeight = Convert.ToDecimal(reader["SubWeight"]); // 扣重 @@ -402,41 +408,14 @@ namespace BWP.B3SheepButcherManage.BL { weigh.Sequence = Convert.ToInt64(reader["Sequence"]); // 顺序号 } - + if (!(reader["PhaseCode"] is DBNull)) + { + weigh.PhaseCode = reader["PhaseCode"].ToString(); // 阶段号 + } list.Add(weigh); } } } - var dic = new Dictionary>(); - foreach (var table in list) - { - if (table.Level_Code == null) - continue; - if (dic.ContainsKey(table.Level_Code.Value)) - { - table.Livestock_ID = dic[table.Level_Code.Value].Item1; - table.Livestock_Name = dic[table.Level_Code.Value].Item2; - } - else - { - var tuple = GetGoods(table.Level_Code.Value); - if (tuple == null) - continue; - table.Livestock_ID = tuple.Item1; - table.Livestock_Name = tuple.Item2; - dic.Add(table.Level_Code.Value, tuple); - } - } - } - - Tuple GetGoods(int code) - { - var dom = new DQueryDom(new JoinAlias(typeof(Livestock))); - dom.Columns.Add(DQSelectColumn.Field("ID")); - dom.Columns.Add(DQSelectColumn.Field("Name")); - dom.Where.Conditions.Add(DQCondition.EQ("Shortcut", code.ToString())); - dom.Where.Conditions.Add(DQCondition.EQ("Stopped", false)); - return dom.EExecuteScalar(Session); } } @@ -457,6 +436,9 @@ namespace BWP.B3SheepButcherManage.BL [LogicName("重量")] public decimal? Weight { get; set; } + [LogicName("备注")] + public string Remark { get; set; } + [LogicName("扣重")] public decimal? SubWeight { get; set; } diff --git a/B3SheepButcherManage/BL/Bill/WeightBillBL/WeightBillBL.cs b/B3SheepButcherManage/BL/Bill/WeightBillBL/WeightBillBL.cs index bdb3eed..38469eb 100644 --- a/B3SheepButcherManage/BL/Bill/WeightBillBL/WeightBillBL.cs +++ b/B3SheepButcherManage/BL/Bill/WeightBillBL/WeightBillBL.cs @@ -38,6 +38,8 @@ namespace BWP.B3SheepButcherManage.BL dmo.BuyNum = dmo.WeighRecords.Sum(x => (x.Number)); } SetAbnormal_Money(dmo); + foreach (var detail in dmo.WeighAbnormalRecording) + detail.Abnormal_Money = detail.Number * detail.Price; dmo.AbnormalMoney = dmo.WeighAbnormalRecording.Sum(x => (x.Abnormal_Money ?? 0).Value); base.beforeSave(dmo); } @@ -72,11 +74,6 @@ namespace BWP.B3SheepButcherManage.BL detail.Price = TypeMarshal.AsNumber(runner.Global["单价"]); } } - else - { - detail.Price = null; - } - detail.Abnormal_Money = detail.Price * detail.Number; } }