Example #1
0
        private static List <TransactionDetail> getDislayName(string[] TranArr, string FlowName, string StepName)
        {
            string str = "";
            List <TransactionDetail> list;

            for (int i = 0; i < TranArr.Count(); i++)
            {
                if (i < TranArr.Count() - 1)
                {
                    str += "'" + TranArr[i].ToString() + "' ,";
                }
                else
                {
                    str += "'" + TranArr[i].ToString() + "'";
                }
            }
            list = new List <TransactionDetail>();
            if (StepName == WFStepName.AddSamplingResult.ToString())
            {
                SamplingBLL objSampling = new SamplingBLL();
                if (FlowName.Trim().ToUpper() == "WRCM".ToUpper())
                {
                    TranArr = objSampling.GetMixedSamplingCodeBylistTrackingNo(str);
                }
                else
                {
                    TranArr = objSampling.GetSamplingCodeBylistTrackingNo(str);
                }
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.GenerateGradingCode.ToString())
            {
                SamplingResultBLL objSampling = new SamplingResultBLL();
                TranArr = objSampling.GetSamplingResultCodeBylistTrackingNo(str);
                if (TranArr != null)
                {
                    if (TranArr != null)
                    {
                        for (int x = 0; x < TranArr.Count(); x++)
                        {
                            string[] temp = TranArr[x].Split('*');
                            list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                        }
                    }
                }
                // regrading
                GradingDisputeBLL objGradeDispute = new GradingDisputeBLL();
                TranArr = objGradeDispute.GetReGradingRequestbyTrackingNo(str);
                if (TranArr != null)
                {
                    if (TranArr != null)
                    {
                        for (int x = 0; x < TranArr.Count(); x++)
                        {
                            string[] temp = TranArr[x].Split('*');
                            list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                        }
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.AddGradingResult.ToString())
            {
                GradingBLL objSampling = new GradingBLL();
                TranArr = objSampling.GetGradingResultCodeBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.GradingResultCA.ToString())
            {
                GradingBLL objSampling = new GradingBLL();
                TranArr = objSampling.GetGradingResultCodeBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }


                return(list);
            }
            else if (StepName == WFStepName.PreWeighTruck.ToString() || StepName == WFStepName.AddUnloadingInfo.ToString())
            {
                GradingResultBLL obj = new GradingResultBLL();
                TranArr = obj.GetGradingResultResultCodeBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.PostWeighTruck.ToString() || StepName == WFStepName.AddScalingInfo.ToString())
            {
                //TODO _ check hwewe
                //post Weight que No.
                GradingResultBLL obj = new GradingResultBLL();
                TranArr = obj.GetGradingResultResultCodeBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.AddGRN.ToString())
            {
                GRNBLL obj = new GRNBLL();
                TranArr = obj.GetGradingResultResultCodeBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.GRNAcceptance.ToString() && FlowName == "WHEditAppGRN")
            {
                GRNBLL obj = new GRNBLL();
                TranArr = obj.GetGRNNoBylistEditTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.GRNAcceptance.ToString() && FlowName != "WHEditAppGRN")
            {
                GRNBLL obj = new GRNBLL();
                TranArr = obj.GetGRNNoBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            //Update GRN
            else if (StepName == WFStepName.UpdateGRNNo.ToString())
            {
                GRNBLL obj = new GRNBLL();
                TranArr = obj.GetGRNNoBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.WarehouseManagerAppr.ToString() && FlowName == "WHEditAppGRN")
            {
                GRNBLL obj = new GRNBLL();
                TranArr = obj.GetGRNNoBylistEditTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepName.EditGRN.ToString() || StepName == WFStepName.WarehouseManagerAppr.ToString())
            {
                GRNBLL obj = new GRNBLL();
                TranArr = obj.GetGRNNoBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else if (StepName == WFStepsName.EditGradingResult.ToString())
            {
                string            strTr;
                GradingDisputeBLL objGrDisp = new GradingDisputeBLL();
                TranArr = objGrDisp.GetReGradingRequestbyTrackingNo(str);

                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }

                return(list);
            }
            else if (StepName.ToUpper().Trim() == "CodeSampRec".ToUpper().Trim())
            {
                GradingBLL objSampling = new GradingBLL();
                TranArr = objSampling.GetGradingResultCodeBylistTrackingNo(str);
                if (TranArr != null)
                {
                    for (int x = 0; x < TranArr.Count(); x++)
                    {
                        string[] temp = TranArr[x].Split('*');
                        list.Add(new TransactionDetail(temp[0].Trim(), temp[1].Trim()));
                    }
                }
                return(list);
            }
            else
            {
                for (int x = 0; x < TranArr.Count(); x++)
                {
                    list.Add(new TransactionDetail(TranArr[x].Trim(), TranArr[x].Trim()));
                }
                return(list);
            }
        }
Example #2
0
        public Nullable <Guid> InsertSample(SamplingBLL objSampling, SamplerBLL objSampler, bool isMoisture)
        {
            bool issaved = false;

            SqlConnection   conn              = null;
            SqlTransaction  trans             = null;
            int             at                = -1;
            Nullable <Guid> DepositeRequestId = null;

            try
            {
                conn  = Connection.getConnection();
                trans = conn.BeginTransaction();
                //using (TransactionScope scope = new TransactionScope())
                //{
                DepositeRequestId = new Guid(SamplingDAL.InsertSample(objSampling, trans).ToString());
                if (DepositeRequestId == null)
                {
                    trans.Rollback();
                    return(null);
                    //throw new Exception("Invalid Sample Id.");
                }
                objSampling.Id = (Guid)DepositeRequestId;
                AuditTrailBLL objAt = new AuditTrailBLL();
                at = objAt.saveAuditTrail(objSampling, WFStepsName.AddSampleCoding.ToString(), UserBLL.GetCurrentUser(), "Get Sample Ticket");
                if (at == 1)
                {
                    at = -1;
                    objSampler.SampleingTicketId = (Guid)DepositeRequestId;
                    objSampler.Id = Guid.NewGuid();
                    issaved       = SamplerDAL.InsertSampler(objSampler, trans);
                    if (issaved == true)
                    {
                        HttpContext.Current.Session["msg"] = null;
                        WFTransaction.UnlockTask(objSampling.TrackingNo);
                        ECXWF.CMessage mess = WFTransaction.Request(objSampling.TrackingNo);
                        HttpContext.Current.Session["msg"] = mess;
                        if (mess.Name.Trim() == "GetSampleTicket".Trim())
                        {
                            WFTransaction.WorkFlowManager(objSampling.TrackingNo);
                            trans.Commit();
                        }
                        else
                        {
                            objAt.RoleBack();
                            trans.Rollback();
                            DepositeRequestId = null;
                        }
                    }
                    else
                    {
                        objAt.RoleBack();
                        trans.Rollback();
                        DepositeRequestId = null;
                    }
                }
                else
                {
                    trans.Rollback();
                    DepositeRequestId = null;
                    throw new Exception("Unable to log Audit Trail");
                }
                //    scope.Complete();
                // }
            }
            catch (Exception ex)
            {
                trans.Rollback();
                DepositeRequestId = null;
                throw ex;
            }
            finally
            {
                trans.Dispose();
                conn.Close();
            }
            return(DepositeRequestId);
        }
Example #3
0
        public Boolean Add(List <SamplingResultBLL> list, Guid SamplingId)
        {
            if (list == null)
            {
                throw new Exception("No sampling Result to save.");
            }
            SamplingBLL objSampling = new SamplingBLL();

            objSampling = objSampling.GetSampleDetail(SamplingId);

            if (objSampling == null)
            {
                throw new Exception("Invalid Tracking No.Plase Tray Again.");
            }
            if (String.IsNullOrEmpty(objSampling.TrackingNo) == true)
            {
                throw new Exception("Invalid Tracking No.Plase Tray Again.");
            }
            string OldTrackingNo = String.Empty;
            int    count         = 0;

            count = list.Count;
            bool           isSaved = false;
            SqlTransaction tran    = null;
            SqlConnection  conn    = null;

            List <string> tranlist = new List <string>();

            try
            {
                conn = Connection.getConnection();
                tran = conn.BeginTransaction();
                foreach (SamplingResultBLL i in list)
                {
                    if (count == 1)
                    {
                        i.Id                     = Guid.NewGuid();
                        i.TrackingNo             = objSampling.TrackingNo;
                        i.ResultReceivedDateTime = this.ResultReceivedDateTime;
                        i.IsPlompOk              = this.IsPlompOk;
                        if (this.IsPlompOk == true)
                        {
                            i.Status = SamplingResultStatus.Approved;
                        }
                        else
                        {
                            i.Status = SamplingResultStatus.New;
                        }
                        isSaved = SamplingResultDAL.InsertSamplingResult(i, tran);
                        int at = -1;
                        if (isSaved == true)
                        {
                            AuditTrailBLL objAt = new AuditTrailBLL();
                            at = objAt.saveAuditTrail(i, WFStepsName.AddSamplingResult.ToString(), UserBLL.GetCurrentUser(), "Add Sampling Result");
                            if (at == 1)
                            {
                                if (i.Status == SamplingResultStatus.Approved)
                                {
                                    WFTransaction.WorkFlowManager(objSampling.TrackingNo);
                                }
                            }
                            else
                            {
                                tran.Rollback();
                                isSaved = false;
                            }
                        }
                    }
                    else if (count > 1)
                    {
                        //Close previous Tracking No.
                        OldTrackingNo = objSampling.TrackingNo;
                        Guid TransactionTypeId = Guid.Empty;
                        i.ResultReceivedDateTime = this.ResultReceivedDateTime;
                        try
                        {
                            TransactionTypeId = TransactionTypeProvider.GetTransactionTypeId("RegularCoffeeMixed");
                        }
                        catch (InvalidTransactionType ex)
                        {
                            throw new Exception("Can Not open Mixed Transaction Type please Contact the Administrator.", ex);
                        }
                        string tranNo = WFTransaction.GetTransaction(TransactionTypeId, tran);
                        if (string.IsNullOrEmpty(tranNo) == true)
                        {
                            throw new Exception("Can Not get Transaction Number please Contact the Administrator.");
                        }
                        else
                        {
                            i.Id                     = Guid.NewGuid();
                            i.TrackingNo             = tranNo;
                            i.IsPlompOk              = this.IsPlompOk;
                            i.ResultReceivedDateTime = this.ResultReceivedDateTime;
                            tranlist.Add(tranNo);
                            isSaved = SamplingResultDAL.InsertSamplingResult(i, tran);
                            int at = -1;
                            if (i.IsPlompOk == true)
                            {
                                i.Status = SamplingResultStatus.Approved;
                            }
                            else
                            {
                                i.Status = SamplingResultStatus.New;
                            }
                            if (i.Status == SamplingResultStatus.Approved)
                            {
                                //Move One Step
                                ECXWF.CMessage mess = null;
                                mess = WFTransaction.Request(tranNo);
                                if (mess == null)
                                {
                                    throw new Exception("Can Not get Message for the Tracking No.");
                                }
                                else
                                {
                                    if (WFStepName.AddSamplingResult.ToString().Trim().ToUpper() == mess.Name.Trim().ToUpper())
                                    {
                                        WFTransaction.WorkFlowManager(tranNo, mess);
                                    }
                                    else
                                    {
                                        throw new Exception("Can Not get Message for the Tracking No.");
                                    }
                                }
                            }
                            AuditTrailBLL objAt = new AuditTrailBLL();
                            at = objAt.saveAuditTrail(i, WFStepsName.AddSamplingResult.ToString(), UserBLL.GetCurrentUser(), "Add Sampling Result");
                            if (at == -1)
                            {
                                isSaved = false;
                                break;
                            }
                            if (isSaved == false)
                            {
                                break;
                            }
                        }
                    }
                }
                if (string.IsNullOrEmpty(OldTrackingNo) != true)
                {
                    if ((isSaved == true) && (list.Count > 0))
                    {
                        WFTransaction.Close(OldTrackingNo);
                    }
                }
                if (isSaved == true)
                {
                    tran.Commit();
                    return(true);
                }
                else
                {
                    tran.Rollback();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                RemoveTransaction(tranlist);
                tran.Rollback();
                throw ex;
            }
            finally
            {
                if (tran != null)
                {
                    tran.Dispose();
                }
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
Example #4
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.");
                }
            }
        }