Browse Source

读取方式调整

master
yibo 7 years ago
parent
commit
272e779025
3 changed files with 41 additions and 59 deletions
  1. +4
    -1
      B3SheepButcherManage.Web/Pages/B3SheepButcherManage/Bills/WeightBill_/WeightBillEdit.cs
  2. +35
    -53
      B3SheepButcherManage/BL/Bill/ButcherBL/ButcherBL.cs
  3. +2
    -5
      B3SheepButcherManage/BL/Bill/WeightBillBL/WeightBillBL.cs

+ 4
- 1
B3SheepButcherManage.Web/Pages/B3SheepButcherManage/Bills/WeightBill_/WeightBillEdit.cs View File

@ -276,7 +276,10 @@ __DFContainer.setValue('Supplier_Card_ID','');
{ {
e.Control.Style["width"] = "160px"; e.Control.Style["width"] = "160px";
}; };
_abnormalGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Price"));
_abnormalGrid.Columns.EAdd(new DFEditGridColumn<DFTextBox>("Price")).InitEditControl += (sender, e) =>
{
e.Control.Style["width"] = "160px";
};
_abnormalGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Abnormal_Money")); _abnormalGrid.Columns.Add(new DFEditGridColumn<DFValueLabel>("Abnormal_Money"));
_abnormalGrid.PreferWidthGridSet = new Dictionary<string, Unit> { { "序号", Unit.Pixel(80) }, { "奖罚项目", Unit.Percentage(20) }, { "头数", Unit.Percentage(20) }, { "单价", Unit.Percentage(20) }, { "金额", Unit.Percentage(20) } }; _abnormalGrid.PreferWidthGridSet = new Dictionary<string, Unit> { { "序号", Unit.Pixel(80) }, { "奖罚项目", Unit.Percentage(20) }, { "头数", Unit.Percentage(20) }, { "单价", Unit.Percentage(20) }, { "金额", Unit.Percentage(20) } };
var section3 = mPageLayoutManager.AddSection("detailColumns2", "明细"); var section3 = mPageLayoutManager.AddSection("detailColumns2", "明细");


+ 35
- 53
B3SheepButcherManage/BL/Bill/ButcherBL/ButcherBL.cs View File

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


+ 2
- 5
B3SheepButcherManage/BL/Bill/WeightBillBL/WeightBillBL.cs View File

@ -38,6 +38,8 @@ namespace BWP.B3SheepButcherManage.BL
dmo.BuyNum = dmo.WeighRecords.Sum(x => (x.Number)); dmo.BuyNum = dmo.WeighRecords.Sum(x => (x.Number));
} }
SetAbnormal_Money(dmo); 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); dmo.AbnormalMoney = dmo.WeighAbnormalRecording.Sum(x => (x.Abnormal_Money ?? 0).Value);
base.beforeSave(dmo); base.beforeSave(dmo);
} }
@ -72,11 +74,6 @@ namespace BWP.B3SheepButcherManage.BL
detail.Price = TypeMarshal.AsNumber(runner.Global["单价"]); detail.Price = TypeMarshal.AsNumber(runner.Global["单价"]);
} }
} }
else
{
detail.Price = null;
}
detail.Abnormal_Money = detail.Price * detail.Number;
} }
} }


Loading…
Cancel
Save