修改
This commit is contained in:
@@ -221,27 +221,62 @@ namespace U8AppMain
|
||||
|
||||
private void 领料单ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var a = new Voucher.VoucherDAL(connStr);
|
||||
a.Add(new Voucher.Vouch()
|
||||
{
|
||||
DDate=DateTime.Today,
|
||||
CRdCode="201",
|
||||
CDepCode="5401",
|
||||
CPersonCode="wx014",
|
||||
CMaker="朱杰",
|
||||
Vt_id="30718",
|
||||
IswfControlled=0,
|
||||
Vouchs=new List<Voucher.Vouchs>() {
|
||||
new Voucher.Vouchs(){
|
||||
CInvCode="107001",
|
||||
Iquantity=20,
|
||||
CwhCode="2",
|
||||
|
||||
|
||||
}
|
||||
|
||||
//单据号 日期 部门编码 业务员 制单人 存货编码 数量
|
||||
if (this.dataTable == null || this.dataTable.Rows.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var bomLookup = new Dictionary<string, Voucher.Vouch>();
|
||||
try
|
||||
{
|
||||
foreach (DataRow row in this.dataTable.Rows)
|
||||
{
|
||||
var Vouch = new Voucher.Vouch();
|
||||
var Vouchs = new Voucher.Vouchs();
|
||||
Vouch.CCode = row["单据号"].ToString();
|
||||
Vouch.DDate = DateTime.Parse(row["日期"].ToString());
|
||||
Vouch.CDepCode = row["部门编码"].ToString();
|
||||
Vouch.CPersonCode = row["业务员"].ToString();
|
||||
Vouch.CMaker = row["制单人"].ToString();
|
||||
Vouch.CRdCode = "201";
|
||||
|
||||
Vouch.Vt_id = "30718";
|
||||
Vouch.IswfControlled = 0;
|
||||
var strKey = Vouch.CCode;
|
||||
if (bomLookup.ContainsKey(strKey))
|
||||
{
|
||||
Vouch = bomLookup[strKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
bomLookup.Add(strKey, Vouch);
|
||||
}
|
||||
Vouchs.CInvCode = row["存货编码"].ToString();
|
||||
Vouchs.Iquantity = int.Parse(row["数量"].ToString());
|
||||
Vouch.Vouchs.Add(Vouchs);
|
||||
}
|
||||
});;
|
||||
foreach (var item in bomLookup.Values)
|
||||
{
|
||||
var a = new Voucher.VoucherDAL(connStr);
|
||||
if (a.Add(item))
|
||||
{
|
||||
this.richTextBox1.SelectionColor = Color.Green;
|
||||
this.richTextBox1.AppendText($"{item.CCode} {item.cDefine12} 保存成功\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.richTextBox1.SelectionColor = Color.Red;
|
||||
this.richTextBox1.AppendText($"{item.CCode} 保存出错\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
this.richTextBox1.SelectionColor = Color.Red;
|
||||
this.richTextBox1.AppendText($"{err.Message}读取数据出错\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user