Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        public bool DeletePlan(ArrayList arr)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                PlanProduceDAL produceDAL = new PlanProduceDAL();
                PlanPurchaseDAL purchaseDAL = new PlanPurchaseDAL();
                PlanReceiveDAL receiveDAL = new PlanReceiveDAL();
                PlanRemainDAL remainDAL = new PlanRemainDAL();
                PlanSaleDAL saleDAL = new PlanSaleDAL();
                PlanUseDAL useDAL = new PlanUseDAL();
                PlanReceiveItemDAL receiveItemDAL = new PlanReceiveItemDAL();

                for (int i = 0; i < arr.Count; ++i)
                {
                    DALObj.OnDB = false;
                    double plan = Convert.ToDouble(arr[i]);
                    if (DALObj.GetDataByLOID(plan, obj.zTrans))
                    {
                        if (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code)
                        {
                            produceDAL.DeleteDataByPlan(DALObj.LOID, obj.zTrans);
                            purchaseDAL.DeleteDataByPlan(DALObj.LOID, obj.zTrans);
                            receiveDAL.DeleteDataByPlan(DALObj.LOID, obj.zTrans);
                            receiveItemDAL.DeleteDataByPlan(DALObj.LOID, obj.zTrans);
                            remainDAL.DeleteDataByPlan(DALObj.LOID, obj.zTrans);
                            saleDAL.DeleteDataByPlan(DALObj.LOID, obj.zTrans);
                            useDAL.DeleteDataByPlan(DALObj.LOID, obj.zTrans);

                            ret = DALObj.DeleteCurrentData(obj.zTrans);
                            if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                        }

                    }
                }
                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Esempio n. 3
0
        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("äÁèÊÒÁÒö͹ØÁѵÔÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ÁÕÊÔ¹¤éÒºÒ§ÃÒ¡ÒÃÂѧäÁèä´éÊÑ觫×éÍ/ÊÑ觼ÅÔµ");
        }