public bool CancelPlan(string userID, double plan) { bool ret = true; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { PlanProduceDAL produceDAL = new PlanProduceDAL(); PlanPurchaseDAL purchaseDAL = new PlanPurchaseDAL(); PlanReceiveDAL receiveDAL = new PlanReceiveDAL(); PlanReceiveItemDAL receiveItemDAL = new PlanReceiveItemDAL(); PlanRemainDAL remainDAL = new PlanRemainDAL(); PlanSaleDAL saleDAL = new PlanSaleDAL(); PlanUseDAL useDAL = new PlanUseDAL(); DALObj.OnDB = false; DALObj.GetDataByLOID(plan, obj.zTrans); if (DALObj.STATUS == Constz.Requisition.Status.Approved.Code) { DALObj.STATUS = Constz.Requisition.Status.Void.Code; DALObj.ACTIVE = Constz.ActiveStatus.InActive; ret = DALObj.UpdateCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(DALObj.ErrorMessage); produceDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, obj.zTrans); purchaseDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, obj.zTrans); receiveDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, obj.zTrans); receiveItemDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, obj.zTrans); remainDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, obj.zTrans); saleDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, obj.zTrans); useDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, obj.zTrans); } obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
private void CommitPlan(string userID, double plan, OracleTransaction trans) { bool ret = true; DALObj.OnDB = false; if (!PlanInvDAL.HaveProductNotReceive(plan, trans)) { DALObj.GetDataByLOID(plan, trans); PlanProduceDAL produceDAL = new PlanProduceDAL(); PlanPurchaseDAL purchaseDAL = new PlanPurchaseDAL(); PlanReceiveDAL receiveDAL = new PlanReceiveDAL(); PlanReceiveItemDAL receiveItemDAL = new PlanReceiveItemDAL(); PlanRemainDAL remainDAL = new PlanRemainDAL(); PlanSaleDAL saleDAL = new PlanSaleDAL(); PlanUseDAL useDAL = new PlanUseDAL(); if (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code) { DALObj.STATUS = Constz.Requisition.Status.Approved.Code; DALObj.ACTIVE = Constz.ActiveStatus.Active; DALObj.CONFIRMDATE = DateTime.Today; ret = DALObj.UpdateCurrentData(userID, trans); if (!ret) throw new ApplicationException(DALObj.ErrorMessage); ret = produceDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, trans); if (!ret) throw new ApplicationException(produceDAL.ErrorMessage); ret = purchaseDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, trans); if (!ret) throw new ApplicationException(purchaseDAL.ErrorMessage); ret = receiveDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, trans); if (!ret) throw new ApplicationException(receiveDAL.ErrorMessage); ret = receiveItemDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, trans); if (!ret) throw new ApplicationException(receiveItemDAL.ErrorMessage); ret = remainDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, trans); if (!ret) throw new ApplicationException(remainDAL.ErrorMessage); ret = saleDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, trans); if (!ret) throw new ApplicationException(saleDAL.ErrorMessage); ret = useDAL.UpdateStatusByPlan(plan, DALObj.STATUS, userID, trans); if (!ret) throw new ApplicationException(useDAL.ErrorMessage); } } else throw new ApplicationException("äÁèÊÒÁÒö͹ØÁѵÔÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ÁÕÊÔ¹¤éÒºÒ§ÃÒ¡ÒÃÂѧäÁèä´éÊÑ觫×éÍ/ÊÑ觼ÅÔµ"); }