public void SendBill(string oriBillNo, string sysDate, string userID, string status) { using (PersistentManager pm = new PersistentManager()) { try { BillDao billDao = new BillDao(); ProductStateDao stateDao = new ProductStateDao(); pm.BeginTransaction(); string billNo = billDao.FindNewBillNo("P", sysDate); billDao.UpdateMasterState(oriBillNo, "5", "SENDER", userID, "SENDDATE", sysDate); billDao.SendMaster(billNo, sysDate, oriBillNo, userID, status); DataTable detailTable = stateDao.Find(oriBillNo); billDao.InsertDetail(billNo, detailTable); if (status == "1")//���ⵥ { billDao.InsertDetail("T" + billNo, detailTable); stateDao.Send("T" + billNo, oriBillNo); } //DataTable cigaretteTable = stateDao.FindCigarette(oriBillNo); //stateDao.UpdateCigarette(oriBillNo, cigaretteTable); stateDao.UpdateBarcode2(oriBillNo); stateDao.Send(billNo, oriBillNo); pm.Commit(); } catch (Exception e) { pm.Rollback(); throw new Exception(e.Message); } } }
public string GenBillFromTask(string billNo, string billType, string userID, string sysDate) { string newNo = null; using (PersistentManager pm = new PersistentManager()) { BillDao billDao = new BillDao(); ProductStateDao stateDao = new ProductStateDao(); try { pm.BeginTransaction(); DataTable stateTable = stateDao.FindBillDetail(billNo); DataTable masterTable = billDao.FindMaster(billNo); if (masterTable.Rows.Count != 0) { DataRow masterRow = masterTable.Rows[0]; string target = ""; if (billType == "002")//���ɵĵ���Ϊ���ⵥ target = "3"; newNo = billDao.FindNewBillNo("P", sysDate); billDao.InsertMaster(newNo, sysDate, billType, masterRow["SCHEDULENO"].ToString(), masterRow["BILLNO"].ToString(), masterRow["WAREHOUSECODE"].ToString(), target, "0", "1", userID); int itemNo = 1; foreach (DataRow stateRow in stateTable.Rows) { if (stateRow["REALQUANTITY"].ToString().Trim().Length != 0) { stateRow["REALQUANTITY"] = 0; stateDao.Insert(newNo, billType, itemNo++, stateRow); } } if (itemNo == 1) throw new Exception("û���̰��ѳ��⣬����Ҫ�����˿ⵥ"); DataTable detailTable = stateDao.Find(newNo); billDao.InsertDetail(newNo, detailTable); } pm.Commit(); } catch (Exception e) { pm.Rollback(); throw new Exception(e.Message); } } return newNo; }