public RMAOutBoundInfo Load(int sysno) { string sql = "select * from rma_outbound (NOLOCK) where sysno = " + sysno; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (!Util.HasMoreRow(ds)) { return(null); } RMAOutBoundInfo oOut = new RMAOutBoundInfo(); map(oOut, ds.Tables[0].Rows[0]); string sql_item = "select registersysno from rma_outbound_item (NOLOCK) where outboundsysno = " + sysno; DataSet ds_item = SqlHelper.ExecuteDataSet(sql_item); foreach (DataRow dr in ds_item.Tables[0].Rows) { oOut.itemHash.Add(Util.TrimIntNull(dr["registerSysNo"]), null); } RMARegisterManager.GetInstance().ConvertRegisterBoundleHash(oOut.itemHash); return(oOut); }
//cancel abandon 还要检查明细中的Register是否加入到其他有效的单据中,所以不提供。 // public void CancelAbandon(int masterSysNo) // { // } public void OutStock(int masterSysNo, int userSysNo) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //必须是初始状态 if (getCurrentStatus(masterSysNo) != (int)AppEnum.RMAOutBoundStatus.Origin) { throw new BizException("status is not origin now, outstock failed"); } Hashtable ht = new Hashtable(5); ht.Add("SysNo", masterSysNo); ht.Add("OutTime", DateTime.Now); ht.Add("OutUserSysNo", userSysNo); ht.Add("Status", (int)AppEnum.RMAOutBoundStatus.SendAlready); if (1 != new RMAOutBoundDac().UpdateMaster(ht)) { throw new BizException("expected one-row update failed, update failed "); } string sql = @"select registersysno , ownby , location,rma_register.receivestocksysno,rma_register.productsysno from rma_outbound_item (nolock) inner join rma_register (nolock) on rma_register.sysno = rma_outbound_item.registersysno where rma_outbound_item.outboundsysno=" + masterSysNo; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (Util.HasMoreRow(ds)) { //调用Register的更新 foreach (DataRow dr in ds.Tables[0].Rows) { if (Util.TrimIntNull(dr["ownby"]) == (int)AppEnum.RMAOwnBy.Origin || Util.TrimIntNull(dr["location"]) == (int)AppEnum.RMALocation.Origin) { throw new BizException("非法操作!该产品已经退货入库或者已经原物发还给客户,无法继续送修!"); } Hashtable htRegister = new Hashtable(2); htRegister.Add("SysNo", Util.TrimIntNull(dr["registersysno"])); htRegister.Add("OutBoundStatus", (int)AppEnum.RMAOutBoundStatus.SendAlready); htRegister.Add("Location", (int)AppEnum.RMALocation.Vendor); RMARegisterManager.GetInstance().UpdateRegister(htRegister); InventoryManager.GetInstance().SetOutStockQty(Util.TrimIntNull(dr["receivestocksysno"]), Util.TrimIntNull(dr["productsysno"]), 1); } } scope.Complete(); } }
public void DeleteItem(ShiftInfo masterInfo, int itemProductSysNo) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //必须是初始 if (getCurrentStatus(masterInfo.SysNo) != (int)AppEnum.ShiftStatus.Origin) { throw new BizException("status is not origin now, delete item failed"); } //获取数量差值 ShiftItemInfo oldItemInfo = masterInfo.itemHash[itemProductSysNo] as ShiftItemInfo; int deltQty = -1 * oldItemInfo.ShiftQty; //更新item if (1 != new ShiftDac().DeleteItem(oldItemInfo.SysNo)) { throw new BizException("expected one-row update failed, delete item qty failed"); } //更新库存 InventoryManager.GetInstance().SetAvailableQty(masterInfo.StockSysNoA, itemProductSysNo, deltQty); //更新 masterInfo masterInfo.itemHash.Remove(itemProductSysNo); //更新RMA移库信息信息 Hashtable ht = new Hashtable(); ht.Add("ShiftSysNo", masterInfo.SysNo); ht.Add("RevertProductSysNo", itemProductSysNo); DataSet ds = GetRMARegisterByShiftSysNo(ht); if (Util.HasMoreRow(ds)) { RMARegisterManager.GetInstance().DeleteRegisterShift(ds); } scope.Complete(); } }
public void Create(RMAOutBoundInfo oParam) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { oParam.SysNo = SequenceDac.GetInstance().Create("RMA_OutBound_Sequence"); oParam.OutBoundID = getOutBoundID(oParam.SysNo); new RMAOutBoundDac().InsertMaster(oParam); int OutBoundInvoiceQty = 0; foreach (int registerSysNo in oParam.itemHash.Keys) { object item = oParam.itemHash[registerSysNo]; this.InsertItem(oParam.SysNo, registerSysNo); Hashtable htRegister = new Hashtable(); htRegister.Add("SysNo", registerSysNo); htRegister.Add("OutBoundWithInvoice", Util.TrimIntNull(item.ToString())); RMARegisterManager.GetInstance().UpdateRegister(htRegister); if (Util.TrimIntNull(item.ToString()) == (int)AppEnum.OutBoundWithInvoice.SendWithInvoice) { OutBoundInvoiceQty = OutBoundInvoiceQty + 1; } else { OutBoundInvoiceQty = OutBoundInvoiceQty + 0; } } Hashtable htOutBound = new Hashtable(); htOutBound.Add("SysNo", oParam.SysNo); htOutBound.Add("OutBoundInvoiceQty", OutBoundInvoiceQty); RMAOutBoundManager.GetInstance().UpdateMaster(htOutBound); scope.Complete(); } }