|
|
@ -77,17 +77,17 @@ namespace BWP.B3SheepButcherManage.BL |
|
|
if (startID > endID) |
|
|
if (startID > endID) |
|
|
throw new Exception("开始ID不能比结束ID大"); |
|
|
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); |
|
|
var needUpdateIds = GetNeedUpdateWeightDetailIDs(butcherID, startID, endID); |
|
|
//删除屠宰单明细
|
|
|
//删除屠宰单明细
|
|
|
@ -356,19 +356,19 @@ namespace BWP.B3SheepButcherManage.BL |
|
|
{ |
|
|
{ |
|
|
throw new ApplicationException("未设置 屠宰单 数据库连接字符串!"); |
|
|
throw new ApplicationException("未设置 屠宰单 数据库连接字符串!"); |
|
|
} |
|
|
} |
|
|
ReadFromWeight(beginTime, endTime, list, connectionString); |
|
|
|
|
|
|
|
|
ReadFromWeightTable(beginTime, endTime, list, connectionString); |
|
|
|
|
|
|
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void ReadFromWeight(DateTime beginTime, DateTime? endTime, ICollection<tempWeightTable> list, string connectionString) |
|
|
|
|
|
|
|
|
private static void ReadFromWeightTable(DateTime beginTime, DateTime? endTime, ICollection<tempWeightTable> list, string connectionString) |
|
|
{ |
|
|
{ |
|
|
var selectSql = "select * from [Weight] where [DataTime]>='" + beginTime + "'"; |
|
|
|
|
|
|
|
|
var selectSql = "select * from WeightTable where [DateTime]>='" + beginTime + "'"; |
|
|
if (endTime.HasValue) |
|
|
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 sqlUtil = new SqlUtil(connectionString)) |
|
|
{ |
|
|
{ |
|
|
using (var reader = sqlUtil.ExecuteReader(selectSql)) |
|
|
using (var reader = sqlUtil.ExecuteReader(selectSql)) |
|
|
@ -380,20 +380,26 @@ namespace BWP.B3SheepButcherManage.BL |
|
|
{ |
|
|
{ |
|
|
weigh.ID = Convert.ToInt64(reader["ID"]); // ID
|
|
|
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)) |
|
|
if (!(reader["Weight"] is DBNull)) |
|
|
{ |
|
|
{ |
|
|
weigh.Weight = Convert.ToDecimal(reader["Weight"]); // 重量
|
|
|
weigh.Weight = Convert.ToDecimal(reader["Weight"]); // 重量
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!(reader["Remark"] is DBNull)) |
|
|
|
|
|
{ |
|
|
|
|
|
weigh.Remark = reader["Remark"].ToString(); // 备注
|
|
|
|
|
|
} |
|
|
if (!(reader["SubWeight"] is DBNull)) |
|
|
if (!(reader["SubWeight"] is DBNull)) |
|
|
{ |
|
|
{ |
|
|
weigh.SubWeight = Convert.ToDecimal(reader["SubWeight"]); // 扣重
|
|
|
weigh.SubWeight = Convert.ToDecimal(reader["SubWeight"]); // 扣重
|
|
|
@ -402,41 +408,14 @@ namespace BWP.B3SheepButcherManage.BL |
|
|
{ |
|
|
{ |
|
|
weigh.Sequence = Convert.ToInt64(reader["Sequence"]); // 顺序号
|
|
|
weigh.Sequence = Convert.ToInt64(reader["Sequence"]); // 顺序号
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!(reader["PhaseCode"] is DBNull)) |
|
|
|
|
|
{ |
|
|
|
|
|
weigh.PhaseCode = reader["PhaseCode"].ToString(); // 阶段号
|
|
|
|
|
|
} |
|
|
list.Add(weigh); |
|
|
list.Add(weigh); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
var dic = new Dictionary<int, Tuple<long, string>>(); |
|
|
|
|
|
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<long, string> 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<long, string>(Session); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -457,6 +436,9 @@ namespace BWP.B3SheepButcherManage.BL |
|
|
[LogicName("重量")] |
|
|
[LogicName("重量")] |
|
|
public decimal? Weight { get; set; } |
|
|
public decimal? Weight { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
[LogicName("备注")] |
|
|
|
|
|
public string Remark { get; set; } |
|
|
|
|
|
|
|
|
[LogicName("扣重")] |
|
|
[LogicName("扣重")] |
|
|
public decimal? SubWeight { get; set; } |
|
|
public decimal? SubWeight { get; set; } |
|
|
|
|
|
|
|
|
|