Exemple #1
0
        public bool EditCommodityDepositRequest(Guid ClientId, Guid commodityDepositRequestId, Guid commodityId, Guid representativeId,
                                                int productionYear, Guid woreda, float weight, int numberofBags, DateTime dateTimeRecived, string remark,
                                                int status, Guid lastModifiedBy, CommodityDepositeRequestBLL OldObject
                                                )
        {
            int isSaved = 0;


            #region Validations


            //if (CommodityDepositRequestId == null)
            //{
            //    throw new Exception("Invalid Commodity Deposit Request Id");
            //}
            //if (commodityId == null )
            //{
            //    throw new Exception("Invalid Commodity Id");
            //}
            //if (representativeId == null)
            //{
            //    throw new Exception("Invalid Representative Id");
            //}
            //if (woreda == null)
            //{
            //    throw new Exception("Invalid Woreda");
            //}
            //if (dateTimeRecived == null)
            //{
            //    throw new Exception("Invalid Date Time Recived");
            //}

            //if (remark == null || remark == "")
            //{
            //    throw new Exception("Invalid Remark");
            //}

            //if (status == null || status == "")
            //{
            //    throw new Exception("Invalid status");
            //}
            //if (lastModifiedBy == null )
            //{
            //    throw new Exception("Invalid last Modified by");
            //}
            #endregion

            // has GRN on Rdit mood
            bool canBeEdited = false;
            canBeEdited = CommodityDepositeRequestBLL.isGRNEditable(commodityDepositRequestId);
            if (canBeEdited == false)
            {
                throw new GRNNotOnUpdateStatus("A GRN has already been created for this Deposit request, please request GRN the manger to edit this GRN.");
            }

            CommodityDepositeRequestBLL objEdit = new CommodityDepositeRequestBLL();
            //NoClient
            objEdit = objEdit.GetCommodityDepositeDetailById(commodityDepositRequestId);
            string trNo = objEdit.TrackingNo;

            objEdit.Id               = commodityDepositRequestId;
            objEdit.CommodityId      = commodityId;
            objEdit.RepresentativeId = representativeId;
            objEdit.ProductionYear   = productionYear;
            objEdit.WoredaId         = woreda;
            objEdit.Weight           = weight;
            objEdit.NumberofBags     = numberofBags;
            objEdit.DateTimeRecived  = dateTimeRecived;
            objEdit.Remark           = remark;
            objEdit.Status           = status;
            objEdit.LastModifiedBy   = lastModifiedBy;
            objEdit.ClientId         = ClientId;

            bool           returnstatus = false;
            int            atStatus     = 0;
            SqlTransaction tran;
            SqlConnection  conn = Connection.getConnection();
            tran = conn.BeginTransaction();
            try
            {
                isSaved = CommodityDepositRequest.UpdateCommodityDepositeRequest(objEdit, tran);
                if (isSaved == 0)
                {
                    returnstatus = false;
                }
                else
                {
                    //NoClient
                    if (WFTransaction.GetMessage(trNo) == "UpdateClientNo")
                    {
                        if (objEdit.ClientId != Guid.Empty)
                        {
                            WFTransaction.UnlockTask(trNo);
                            WarehouseApplication.ECXWF.CMessage msg = WFTransaction.Request(trNo);
                            WFTransaction.WorkFlowManager(trNo, msg);
                        }
                    }

                    AuditTrailBLL objAT = new AuditTrailBLL();
                    atStatus = objAT.saveAuditTrail(OldObject, objEdit, WFStepsName.ArrivalUpdate.ToString(), UserBLL.GetCurrentUser(), "Update Arrival");
                    if (atStatus == 1)
                    {
                        returnstatus = true;
                        tran.Commit();
                    }
                }
            }
            catch
            {
                tran.Rollback();
            }
            finally
            {
                tran.Dispose();
                conn.Close();
            }
            return(returnstatus);
        }
Exemple #2
0
        //oct-18-2011
        //update empty voucher entry error
        public bool Save(Guid DepositRequestId, string VoucherNo, Guid CoffeeTypeId,
                         string SpecificArea, int NumberofBags, int NumberOfPlomps, int NumberOfPlompsTrailer, string CertificateNo, Guid CreatedBy,
                         int Status, string TrackingNo)
        {
            SqlTransaction tran;
            bool           isSaved = false;

            //get Tracking No.
            CommodityDepositeRequestBLL oC = new CommodityDepositeRequestBLL();

            oC         = oC.GetCommodityDepositeDetailById(DepositRequestId);
            TrackingNo = oC.TrackingNo;

            VoucherInformationBLL obj = new VoucherInformationBLL();

            obj.DepositRequestId      = DepositRequestId;
            obj.VoucherNo             = VoucherNo;
            obj.CoffeeTypeId          = CoffeeTypeId;
            obj.SpecificArea          = SpecificArea;
            obj.NumberofBags          = NumberofBags;
            obj.NumberOfPlomps        = NumberOfPlomps;
            obj.NumberOfPlompsTrailer = NumberOfPlompsTrailer;
            obj.CertificateNo         = CertificateNo;
            obj.CreatedBy             = CreatedBy;
            obj.Status = Status;
            Voucher       objSave = new Voucher();
            SqlConnection conn    = Connection.getConnection();

            tran = conn.BeginTransaction();
            AuditTrailBLL objAt   = new AuditTrailBLL();
            int           AtSaved = -1;

            try
            {
                Guid VoucherId = Guid.Empty;
                VoucherId = objSave.InsertVoucherInformation(obj, tran);
                if (VoucherId == Guid.Empty)
                {
                    isSaved = false;
                }
                else
                {
                    obj.Id = VoucherId;
                    if (objAt.saveAuditTrail(obj, WFStepsName.NewVoucherInfo.ToString(), UserBLL.GetCurrentUser(), "Insert Voucher") == 1)
                    {
                        AtSaved = 1;
                        string msgFromWF = "";
                        msgFromWF = WFTransaction.GetMessage(TrackingNo);
                        if (msgFromWF == "AddVoucherInfo")
                        {
                            WFTransaction.WorkFlowManager(TrackingNo);
                            WFTransaction.UnlockTask(TrackingNo);
                            HttpContext.Current.Session["msg"] = null;
                        }
                        tran.Commit();
                        isSaved = true;
                    }
                    else
                    {
                        tran.Rollback();
                        isSaved = false;
                    }
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                if (AtSaved == 1)
                {
                    objAt.RoleBack();
                }
                throw ex;
            }
            finally
            {
                conn.Close();
                tran.Dispose();
            }
            return(isSaved);
        }