示例#1
0
        private static List <CommodityDepositeRequestBLL> MergeWithCommodity(List <CommodityDepositeRequestBLL> myList)
        {
            List <CommodityDepositeRequestBLL> CDList = new List <CommodityDepositeRequestBLL>();
            List <CommodityGradeBLL>           CList  = new List <CommodityGradeBLL>();

            CList = CommodityGradeBLL.GetAllCommodity();
            var q = from CD in myList
                    join c in CList on CD.CommodityId equals c.CommodityId
                    select new { CD.Id, CD.TrackingNo, CD.VoucherNo, CD.ClientId, CD.ClientName, CD.CommodityId, CD.DateTimeRecived, c.Commodity };

            foreach (var i in q)
            {
                CommodityDepositeRequestBLL obj = new CommodityDepositeRequestBLL();
                obj.Id              = i.Id;
                obj.TrackingNo      = i.TrackingNo;
                obj.VoucherNo       = i.VoucherNo;
                obj.ClientName      = i.ClientName;
                obj.ClientId        = i.ClientId;
                obj.CommodityId     = i.CommodityId;
                obj.DateTimeRecived = i.DateTimeRecived;
                obj.CommodityName   = i.Commodity;
                CDList.Add(obj);
            }
            return(CDList);
        }
示例#2
0
        public CommodityDepositeRequestBLL GetCommodityDepositeDetailByTrackingNo(string TrackingNo)
        {
            CommodityDepositRequest objCommDepReq = new CommodityDepositRequest();
            DataSet dsResult = new DataSet();

            dsResult = objCommDepReq.getCommodityDepositRequestByTrackingNo(TrackingNo);
            if (dsResult.Tables[0].Rows.Count > 0)
            {
                CommodityDepositeRequestBLL obj = new CommodityDepositeRequestBLL();
                obj.Id       = new Guid(dsResult.Tables[0].Rows[0]["Id"].ToString());
                obj.ClientId = new Guid(dsResult.Tables[0].Rows[0]["ClientId"].ToString());
                if (dsResult.Tables[0].Rows[0]["ProductionYear"] != DBNull.Value)
                {
                    obj.ProductionYear = Convert.ToInt32(dsResult.Tables[0].Rows[0]["ProductionYear"].ToString());
                }
                obj.DateTimeRecived = Convert.ToDateTime(dsResult.Tables[0].Rows[0]["DateTimeRecived"].ToString());
                obj.TrackingNo      = dsResult.Tables[0].Rows[0]["TransactionId"].ToString();
                obj.WarehouseId     = new Guid(dsResult.Tables[0].Rows[0]["WarehouseId"].ToString());
                obj.CommodityId     = new Guid(dsResult.Tables[0].Rows[0]["CommodityId"].ToString());

                return(obj);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        private static List <CommodityDepositeRequestBLL> MergeWithClient(List <CommodityDepositeRequestBLL> myList)
        {
            //Get Client list.
            List <CommodityDepositeRequestBLL> CDList = new List <CommodityDepositeRequestBLL>();
            List <ClientBLL> ClientList = new List <ClientBLL>();

            ClientList = ClientBLL.GetAllClient();


            List <CommodityGradeBLL> CommGradeList = new List <CommodityGradeBLL>();

            CommGradeList = getAllCommodities();


            if (ClientList == null)
            {
                //throw new ClientInformationException("Can not get Clinet Information");
            }
            else
            {
                var q = from CD in myList
                        join client in ClientList on CD.ClientId equals client.ClientUniqueIdentifier
                        select new { CD.Id, CD.TrackingNo, CD.VoucherNo, client.ClientName, CD.CommodityId, CD.DateTimeRecived };

                foreach (var i in q)
                {
                    CommodityDepositeRequestBLL obj = new CommodityDepositeRequestBLL();
                    obj.Id              = i.Id;
                    obj.TrackingNo      = i.TrackingNo;
                    obj.VoucherNo       = i.VoucherNo;
                    obj.ClientName      = i.ClientName;
                    obj.CommodityId     = i.CommodityId;
                    obj.DateTimeRecived = i.DateTimeRecived;
                    CDList.Add(obj);
                }


                return(CDList);
            }
            return(null);
        }
示例#4
0
        /// <summary>
        /// Declare and Initialize SQL Scalars for CommodityDepositRequest, DriverInformation and VoucherInformation
        /// Fields so that it would be sent to DAL to execute the procedure
        /// </summary>
        /// <param name="comodityObj"></param>
        /// <param name="objDriver"></param>
        /// <param name="objVoucher"></param>
        /// <returns>
        /// sql parameter array
        /// </returns>
        private SqlParameter[] ParamList(CommodityDepositeRequestBLL objCommodityDepositRequest, DriverInformationBLL objDriver, VoucherInformationBLL objVoucher)
        {
            SqlParameter[] arPar = new SqlParameter[29];
            //use arPar [] to hold all 3 tables parameter to insert
            //COMMODITY-DEPOSIT-REQUEST PARAMETERSS
            arPar[0]       = new SqlParameter("@TransactionId", SqlDbType.NVarChar, 50);
            arPar[0].Value = objCommodityDepositRequest.TransactionId;
            arPar[1]       = new SqlParameter("@ClientId", SqlDbType.UniqueIdentifier);
            arPar[1].Value = objCommodityDepositRequest.ClientId;
            arPar[2]       = new SqlParameter("@CommodityId", SqlDbType.UniqueIdentifier);
            arPar[2].Value = objCommodityDepositRequest.CommodityId;;
            arPar[3]       = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier);
            arPar[3].Value = objCommodityDepositRequest.WarehouseId;
            arPar[4]       = new SqlParameter("@RepresentativeId", SqlDbType.UniqueIdentifier);
            arPar[4].Value = objCommodityDepositRequest.RepresentativeId;
            arPar[5]       = new SqlParameter("@WoredaId", SqlDbType.UniqueIdentifier);
            if (objCommodityDepositRequest.WoredaId != Guid.Empty)
            {
                arPar[5].Value = objCommodityDepositRequest.WoredaId;
            }
            else
            {
                arPar[5].Value = null;
            }

            arPar[6] = new SqlParameter("@productionYear", SqlDbType.Int);
            if (objCommodityDepositRequest.ProductionYear != 0)
            {
                arPar[6].Value = objCommodityDepositRequest.ProductionYear;
            }
            else
            {
                arPar[6].Value = null;
            }
            arPar[7]        = new SqlParameter("@StatusC", SqlDbType.Int);
            arPar[7].Value  = objCommodityDepositRequest.Status;
            arPar[8]        = new SqlParameter("@CreatedByC", SqlDbType.UniqueIdentifier);
            arPar[8].Value  = objCommodityDepositRequest.CreatedBy;
            arPar[9]        = new SqlParameter("@Remark", SqlDbType.Text);
            arPar[9].Value  = objCommodityDepositRequest.Remark;
            arPar[10]       = new SqlParameter("@Weight", SqlDbType.Decimal);
            arPar[10].Value = objCommodityDepositRequest.Weight;
            arPar[11]       = new SqlParameter("@NumberofBags", SqlDbType.Int);
            arPar[11].Value = objCommodityDepositRequest.NumberofBags;
            arPar[12]       = new SqlParameter("@DateTimeRecived", SqlDbType.DateTime);
            arPar[12].Value = objCommodityDepositRequest.DateTimeRecived;

            arPar[13]       = new SqlParameter("@CommodityDepositRequestId", SqlDbType.UniqueIdentifier);
            arPar[13].Value = this.Id;

            //DRIVER PARAMETERS
            //arPar[14] = new SqlParameter("@ReceivigRequestId", SqlDbType.UniqueIdentifier);
            //arPar[14].Value = objDriver.ReceivigRequestId;
            arPar[14]       = new SqlParameter("@DriverName", SqlDbType.NVarChar, 50);
            arPar[14].Value = objDriver.DriverName;
            arPar[15]       = new SqlParameter("@LicenseNumber", SqlDbType.NVarChar, 50);
            arPar[15].Value = objDriver.LicenseNumber;
            arPar[16]       = new SqlParameter("@LicenseIssuedPlace", SqlDbType.NVarChar, 50);
            arPar[16].Value = objDriver.LicenseIssuedPlace;
            arPar[17]       = new SqlParameter("@PlateNumber", SqlDbType.NVarChar, 50);
            arPar[17].Value = objDriver.PlateNumber;
            arPar[18]       = new SqlParameter("TrailerPlateNumber", SqlDbType.NVarChar, 50);
            arPar[18].Value = objDriver.TrailerPlateNumber;
            //arPar[20] = new SqlParameter("@CreatedByD", SqlDbType.UniqueIdentifier);
            //arPar[20].Value = objDriver.CreatedBy;
            arPar[19]       = new SqlParameter("@StatusD", SqlDbType.Int);
            arPar[19].Value = 1;
            //arPar[22] = new SqlParameter("@DriverInformationId", SqlDbType.UniqueIdentifier);
            //arPar[22].Direction = ParameterDirection.Output;

            //VOUCHER PARAMETERS
            //arPar[23] = new SqlParameter("@DepositRequestId", SqlDbType.UniqueIdentifier);
            //arPar[23].Value = objVoucher.DepositRequestId;
            arPar[20]       = new SqlParameter("@VoucherNo", SqlDbType.NVarChar, 50);
            arPar[20].Value = objVoucher.VoucherNo;
            arPar[21]       = new SqlParameter("@CoffeeTypeId", SqlDbType.UniqueIdentifier);
            arPar[21].Value = objVoucher.CoffeeTypeId;
            arPar[22]       = new SqlParameter("@SpecificArea", SqlDbType.NVarChar);
            arPar[22].Value = objVoucher.SpecificArea;
            //arPar[27] = new SqlParameter("@NumberOfBagsV", SqlDbType.Int);
            //arPar[27].Value = objVoucher.NumberofBags;
            arPar[23]       = new SqlParameter("@NumberOfPlomps", SqlDbType.Int);
            arPar[23].Value = objVoucher.NumberOfPlomps;
            arPar[24]       = new SqlParameter("@NumberOfPlompsTrailer", SqlDbType.Int);
            arPar[24].Value = objVoucher.NumberOfPlompsTrailer;
            arPar[25]       = new SqlParameter("@CertificateNo", SqlDbType.NVarChar, 50);
            arPar[25].Value = "";// objVoucher.CertificateNo;
            //arPar[31] = new SqlParameter("@CreatedByV", SqlDbType.UniqueIdentifier);
            //arPar[31].Value = objVoucher.CreatedBy;
            arPar[26]       = new SqlParameter("@CreatedDate", SqlDbType.DateTime);
            arPar[26].Value = DateTime.Now;
            arPar[27]       = new SqlParameter("@StatusV", SqlDbType.Int);
            arPar[27].Value = objVoucher.Status;
            //????????
            arPar[28]           = new SqlParameter("@VoucherId", SqlDbType.UniqueIdentifier);
            arPar[28].Direction = ParameterDirection.Output;
            return(arPar);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
0
        public static void LoadVariables(string msg, string TrackingNo)
        {
            TrackingNo = TrackingNo.Trim();
            if (msg.Trim() == WFStepsName.AddDriverInformation.ToString())
            {
                CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                objCDR = objCDR.GetCommodityDepositeDetailByTrackingNo(TrackingNo);
                if (objCDR != null)
                {
                    HttpContext.Current.Session["CommodityRequestId"] = objCDR.Id;
                }
                else
                {
                    throw new Exception("Can't load page variables,please try again.");
                }
            }
            else if (msg.Trim() == WFStepsName.AddVoucherInfo.ToString())
            {
                CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                objCDR = objCDR.GetCommodityDepositeDetailByTrackingNo(TrackingNo);
                if (objCDR != null)
                {
                    HttpContext.Current.Session["CommodityRequestId"] = objCDR.Id;
                }
                else
                {
                    throw new Exception("Can't load page variables,please try again.");
                }
            }
            else if (msg.Trim() == WFStepsName.AddDriverInformation.ToString())
            {
                CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                objCDR = objCDR.GetCommodityDepositeDetailByTrackingNo(TrackingNo);
                if (objCDR != null)
                {
                    HttpContext.Current.Session["CommodityRequestId"] = objCDR.Id;
                }
                else
                {
                    throw new Exception("Can't load page variables,please try again.");
                }
            }
            else if (msg.Trim() == WFStepsName.AddVoucherInfo.ToString())
            {
                CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                objCDR = objCDR.GetCommodityDepositeDetailByTrackingNo(TrackingNo);
                if (objCDR != null)
                {
                    HttpContext.Current.Session["CommodityRequestId"] = objCDR.Id;
                }
                else
                {
                    throw new Exception("Can't load page variables,please try again.");
                }
            }
            else if (msg.Trim() == WFStepsName.GetSampleTicket.ToString())
            {
            }
            else if (msg.Trim() == WFStepsName.AddSamplingResult.ToString())
            {
                List <SamplingBLL> list = new List <SamplingBLL>();
                SamplingBLL        obj  = new SamplingBLL();
                list = obj.GetSamplesPenndingResultByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        obj = list[0];
                        HttpContext.Current.Session["SamplingReasultAddId"] = obj.Id;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.AddSampleCoding.ToString())
            {
                //SamplingResultBLL obj = new SamplingResultBLL();
                //obj = obj.GetSamplesResultsPendingCodingByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                //if (obj != null)
                //{
                //    if (string.IsNullOrEmpty(obj.TrackingNo) != true)
                //    {

                //        HttpContext.Current.Session["GenerateCodeSampleId"] = obj.Id;
                //    }
                //    else
                //    {
                //        throw new Exception("Unable to get Record");
                //    }

                //}
                SamplingResultBLL objGrading = new SamplingResultBLL();

                objGrading = objGrading.GetSamplesResultsPendingCodingByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (objGrading != null)
                {
                    if (string.IsNullOrEmpty(objGrading.TrackingNo) != true)
                    {
                        HttpContext.Current.Session["GradingCodeId"] = objGrading.SamplingResultCode;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.GenerateGradingCode.ToString())
            {
                SamplingResultBLL objGrading = new SamplingResultBLL();

                objGrading = objGrading.GetSamplesResultsPendingCodingByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (objGrading != null)
                {
                    if (string.IsNullOrEmpty(objGrading.TrackingNo) != true)
                    {
                        HttpContext.Current.Session["GradingCodeId"]         = objGrading.SamplingResultCode;
                        HttpContext.Current.Session["GradingCodeTrackingNo"] = TrackingNo.ToString();
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.CodeSampRec.ToString())
            {
                GradingBLL        objGrading = new GradingBLL();
                List <GradingBLL> list       = new List <GradingBLL>();
                list = objGrading.GetGradingsPendingCodeReceivingByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        objGrading = list[0];
                        HttpContext.Current.Session["CodeSampleRecivedGradingId"] = objGrading.Id;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.AddGradingResult.ToString())
            {
                GradingBLL        objGrading = new GradingBLL();
                List <GradingBLL> list       = new List <GradingBLL>();
                list = objGrading.GetGradingsPendingResultByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        objGrading = list[0];
                        HttpContext.Current.Session["GradingRecivedGradingId"] = objGrading.Id;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.GradingResultCA.ToString())
            {
                GradingResultBLL objGrading = new GradingResultBLL();
                objGrading = objGrading.GetGradingResultByTrackingNo(TrackingNo);
                if (objGrading != null)
                {
                    if (objGrading.ID != null)
                    {
                        HttpContext.Current.Session["GRID"] = objGrading.ID;
                    }
                }
            }

            else if (msg.Trim() == WFStepsName.PreWeighTruck.ToString())
            {
                GradingResultBLL        objGrading = new GradingResultBLL();
                List <GradingResultBLL> list       = new List <GradingResultBLL>();
                list = objGrading.GetAcceptedresultsPendingUnloadingByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        objGrading = list[0];
                        HttpContext.Current.Session["AddUnLoadingId"]            = objGrading.ID;
                        HttpContext.Current.Session["AddUnLoadingIdGradingCode"] = objGrading.GradingCode;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.AddUnloadingInfo.ToString())
            {
                GradingResultBLL        objGrading = new GradingResultBLL();
                List <GradingResultBLL> list       = new List <GradingResultBLL>();
                list = objGrading.GetAcceptedresultsPendingUnloadingByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        objGrading = list[0];
                        HttpContext.Current.Session["AddUnLoadingId"]            = objGrading.ID;
                        HttpContext.Current.Session["AddUnLoadingIdGradingCode"] = objGrading.GradingCode;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.PostWeighTruck.ToString())
            {
                GradingResultBLL        objGrading = new GradingResultBLL();
                List <GradingResultBLL> list       = new List <GradingResultBLL>();
                list = objGrading.GetAcceptedresultsPendingScalingByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        objGrading = list[0];
                        HttpContext.Current.Session["AddScalingGradingCode"] = objGrading.GradingCode;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.AddScalingInfo.ToString())
            {
                GradingResultBLL        objGrading = new GradingResultBLL();
                List <GradingResultBLL> list       = new List <GradingResultBLL>();
                list = objGrading.GetAcceptedresultsPendingScalingByTrackingNo(UserBLL.GetCurrentWarehouse(), TrackingNo);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        objGrading = list[0];
                        HttpContext.Current.Session["AddScalingGradingCode"] = objGrading.GradingCode;
                    }
                }
            }
            // ADD GRN
            else if (msg.Trim() == WFStepsName.AddGRN.ToString())
            {
                GradingResultBLL objGrading = new GradingResultBLL();
                objGrading = objGrading.GetGradingResultByTrackingNo(TrackingNo);
                if (objGrading != null)
                {
                    if (objGrading.ID != null)
                    {
                        HttpContext.Current.Session["GRNID"] = TrackingNo; // objGrading.ID;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.GRNAcceptance.ToString())
            {
                GRNBLL objGRN = new GRNBLL();
                objGRN = objGRN.GetbyByTrackingNo(TrackingNo);
                if (objGRN != null)
                {
                    if (objGRN.Id != null)
                    {
                        HttpContext.Current.Session["GRNID"] = objGRN.Id;
                    }
                    else
                    {
                        throw new Exception("Invalid GRN Id");
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.ClientAcceptance.ToString())
            {
                RequestforEditGRNBLL objGRN = new RequestforEditGRNBLL();
                objGRN = objGRN.GetByTrackingNo(TrackingNo);
                if (objGRN != null)
                {
                    if (objGRN.Id != null)
                    {
                        HttpContext.Current.Session["GRNID"] = objGRN.GRNId;
                    }
                    else
                    {
                        throw new Exception("Invalid GRN Id");
                    }
                }
            }
            //Update GRN
            else if (msg.Trim() == WFStepsName.UpdateGRNNo.ToString())
            {
                GRNBLL objGRN = new GRNBLL();
                objGRN = objGRN.GetbyByTrackingNo(TrackingNo);
                if (objGRN != null)
                {
                    if (objGRN.GRN_Number != null)
                    {
                        HttpContext.Current.Session["GRNIDUpdateGRNNo"]      = objGRN.Id;
                        HttpContext.Current.Session["TrackingNoUpdateGRNNo"] = TrackingNo;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.EditGRN.ToString())
            {
                GRNBLL objGRN = new GRNBLL();
                objGRN = objGRN.GetbyByTrackingNo(TrackingNo);
                if (objGRN != null)
                {
                    if (objGRN.GRN_Number != null)
                    {
                        HttpContext.Current.Session["GRNID"]         = objGRN.Id;
                        HttpContext.Current.Session["GRNTrackingNo"] = TrackingNo;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.WarehouseManagerAppr.ToString())
            {
                RequestforEditGRNBLL objGRN = new RequestforEditGRNBLL();
                objGRN = objGRN.GetByTrackingNo(TrackingNo);
                if (objGRN != null)
                {
                    if (objGRN.Id != null)
                    {
                        HttpContext.Current.Session["GRNID"]         = objGRN.GRNId;
                        HttpContext.Current.Session["GRNTrackingNo"] = TrackingNo;
                    }
                    else
                    {
                        throw new Exception("Invalid GRN Id");
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.EditGradeDispute.ToString())
            {
                GradingDisputeBLL objGradeDispute = new GradingDisputeBLL();
                objGradeDispute = objGradeDispute.GetByTransactionNo(TrackingNo);
                if (objGradeDispute != null)
                {
                    if (objGradeDispute.Id != null)
                    {
                        HttpContext.Current.Session["EditGradeDisputeId"] = objGradeDispute.Id;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.ApproveReSampling.ToString())
            {
                ReSamplingBLL objReSampling = new ReSamplingBLL();
                objReSampling = objReSampling.GetByTrackingNo(TrackingNo);
                if (objReSampling != null)
                {
                    if (objReSampling.Id != null)
                    {
                        HttpContext.Current.Session["ResamplingEdit"] = objReSampling.Id;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.WHAppGRNEdit.ToString())
            {
                RequestforEditGRNBLL obj = new RequestforEditGRNBLL();
                obj = obj.GetByTrackingNo(TrackingNo);
                if (obj != null)
                {
                    if (obj.Id != null)
                    {
                        HttpContext.Current.Session["GRNEditRequestId"] = obj.Id;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.OpenGRNForEdit.ToString())
            {
                RequestforEditGRNBLL obj = new RequestforEditGRNBLL();
                obj = obj.GetByTrackingNo(TrackingNo);
                if (obj != null)
                {
                    if (obj.Id != null)
                    {
                        HttpContext.Current.Session["OpenGRNEditId"] = obj.Id;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.EditWHR.ToString().Trim())
            {
                RequestforEditGRNBLL obj = new RequestforEditGRNBLL();
                obj = obj.GetByTrackingNo(TrackingNo);
                if (obj != null)
                {
                    if (obj.GRNId != null)
                    {
                        HttpContext.Current.Session["ReCreateGRNID"]         = obj.GRNId;
                        HttpContext.Current.Session["ReCreateGRNTrackingNo"] = TrackingNo;
                    }
                }
            }
            else if (msg.Trim() == "ApproveCancelationRequest".ToString().Trim() || (msg.Trim() == "CancelGRN"))
            {
                RequestforApprovedGRNCancelationBLL obj = new RequestforApprovedGRNCancelationBLL();
                obj = obj.GetByTrackingNo(TrackingNo);
                if (obj != null)
                {
                    if (obj.GRNId != null)
                    {
                        HttpContext.Current.Session["CancelGRNTrackingNo"] = TrackingNo;
                        HttpContext.Current.Session["GRNID"] = obj.GRNId;
                    }
                }
            }
            else if (msg.Trim() == WFStepsName.EditGradingResult.ToString().Trim())
            {
                GradingResultBLL objGradingResult = new GradingResultBLL();
                HttpContext.Current.Session["GRID"] = null;
                objGradingResult = objGradingResult.GetGradingResultByTrackingNo(TrackingNo.Trim());
                if (objGradingResult != null)
                {
                    HttpContext.Current.Session["GRID"] = objGradingResult.ID.ToString();
                }
                else
                {
                    objGradingResult = new GradingResultBLL();
                    objGradingResult = objGradingResult.GetGradingResultByTrackingNoForGradeDispute(TrackingNo.Trim());
                    if (objGradingResult != null)
                    {
                        HttpContext.Current.Session["GRID"] = objGradingResult.ID.ToString();
                    }
                }
            }
            else if (msg.Trim() == "UpdateClientNo")
            {
                //NoClient
                CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                objCDR = objCDR.GetCommodityDepositeDetailByTrackingNo(TrackingNo);
                if (objCDR != null)
                {
                    HttpContext.Current.Session["CommodityRequestId"] = objCDR.Id;
                }
                else
                {
                    throw new Exception("Can't load page variables,please try again.");
                }
            }
        }