using System; using System.Collections.Generic; using System.Text; using System.Data; using Stone.Entity; using Stone.DataService.Biz.BizPublic; using Gm_WMS.DataAccess.DataService; using Stone.DataService.Biz.Info; namespace Stone.DataService.Biz.Bill { public class F_BillVerify { public F_BillVerify() { } public DataSet BillNew(Command cmd) { string BillNo = cmd.Pars[0]; string UserName = cmd.Pars[1]; if (BillNo.Trim() == "") throw new Exception("排序单号不能为空!"); Entity_t_VerifyBill t_VerifyBill = new Entity_t_VerifyBill(); Entity_t_JIS_Seq5000 t_JIS_Seq5000 = new Entity_t_JIS_Seq5000(); DataSet dsPackingList = t_JIS_Seq5000.GetData("*", "[PackingListNumber]='" + BillNo + "'", "[SequenceNumber] desc"); if (dsPackingList.Tables[0].Rows.Count == 0) throw new Exception("排序单号 " + BillNo + " 不存在!"); DataSet dsData = t_VerifyBill.GetData("[BillNo]='" + BillNo + "'"); if (dsData.Tables[0].Rows.Count == 0) { for (int i = 0; i < dsPackingList.Tables[0].Rows.Count; i++) { DataRow drData = dsData.Tables[0].NewRow(); drData["ID"] = 0; drData["Sn"] = i+1; drData["BillNo"] = BillNo; drData["OrderNumber"] = dsPackingList.Tables[0].Rows[i]["OrderNumber"].ToString(); drData["BarCode"] = ""; drData["State"] = ""; drData["UserName"] = UserName; drData["SequenceNumber"] = dsPackingList.Tables[0].Rows[i]["SequenceNumber"].ToString(); dsData.Tables[0].Rows.Add(drData); } } else { for (int i = 0; i < dsData.Tables[0].Rows.Count; i++) { dsData.Tables[0].Rows[i]["UserName"] = UserName; } } return dsData; } public void BillSubmit(DataSet dsData) { if (dsData.Tables[0].Rows.Count == 0) throw new Exception("提交的数据不能为空!"); string BillNo = dsData.Tables[0].Rows[0]["BillNo"].ToString(); if (new Entity_t_VerifyBill().GetData("[BillNo]='" + BillNo + "'").Tables[0].Rows.Count > 0) throw new Exception(BillNo + " 已经提交过了"); LocalDBService db = null; try { db = new LocalDBService(); db.BeginTrans(); Entity_t_VerifyBill t_VerifyBill = new Entity_t_VerifyBill(db); foreach (DataRow drData in dsData.Tables[0].Rows) { DataRow drNew = t_VerifyBill.Table.NewRow(); drNew["BillNo"] = drData["BillNo"].ToString(); drNew["Sn"] = drData["Sn"].ToString(); drNew["OrderNumber"] = drData["OrderNumber"].ToString(); drNew["BarCode"] = drData["BarCode"].ToString(); drNew["State"] = drData["State"].ToString(); drNew["UserName"] = drData["UserName"].ToString(); drNew["SequenceNumber"] = drData["SequenceNumber"].ToString(); t_VerifyBill.Add(drNew); } db.Commit(); } catch (Exception ex) { if (db != null) db.Rollback(); throw ex; } finally { if (db != null) db.EndTrans(); } } } }