Esempio n. 1
0
        public bool ClientAcceptance(Guid Id, int Status, GradingResultStatus GradeRecivedStatatus, Nullable <DateTime> ClientAccpetedTimeStamp, out string strQueueNo)
        {
            DateTime         dt;
            GradingResultBLL objUpdate = new GradingResultBLL();

            objUpdate.ID     = Id;
            objUpdate.Status = (GradingResultStatus)Status;
            try
            {
                dt = (DateTime)ClientAccpetedTimeStamp;
            }
            catch
            {
                throw new Exception("Invalid Client Acceptance Date.");
            }
            objUpdate.ClientAcceptanceTimeStamp = ClientAccpetedTimeStamp;
            // Get Queue No.
            DateTime currDate         = DateTime.Today;
            Guid     WarehouseId      = UserBLL.GetCurrentWarehouse();
            string   Code             = currDate.Day.ToString() + currDate.Year.ToString().Substring(2, 2);
            int?     QueueNo          = null;
            int?     PreWeightQueueNo = null;

            try
            {
                GradingResultDAL.GetQueueNumber(Code, WarehouseId, currDate, out QueueNo, out PreWeightQueueNo);
                if (QueueNo == null || PreWeightQueueNo == null)
                {
                    throw new Exception("Can not get queue number");
                }
            }
            catch
            {
                new Exception("Can not get queue number.");
            }
            objUpdate.QueueDate        = currDate;
            objUpdate.QueueNo          = (int)QueueNo;
            strQueueNo                 = PreWeightQueueNo.ToString();
            objUpdate.PreWeightQueueNo = (int)PreWeightQueueNo;



            bool           isSaved = false;
            SqlTransaction tran;
            SqlConnection  conn = Connection.getConnection();

            tran = conn.BeginTransaction();
            GradingResultBLL objGradingResult = new GradingResultBLL();

            objGradingResult = objGradingResult.GetGradingResultById(Id, tran);
            AuditTrailBLL objAt = new AuditTrailBLL();
            int           At    = -1;

            try
            {
                isSaved = GradingResultDAL.ClientAcceptanceGradingResult(objUpdate, tran);
                if (objAt.saveAuditTrail(objGradingResult, objUpdate, WFStepsName.ClientAcceptance.ToString(), UserBLL.GetCurrentUser(), "Grading Result Client Respose") == 1)
                {
                    isSaved = true;
                    At      = 1;
                }

                string TranNo;
                TranNo = objGradingResult.TrackingNo;
                if (string.IsNullOrEmpty(TranNo) == true)
                {
                    tran.Rollback();
                    if (At == 1)
                    {
                        objAt.RoleBack();
                    }
                    isSaved = false;
                }
                else
                {
                    if ((int)GradingResultStatus.ClientAccepted == Status && (GradeRecivedStatatus == GradingResultStatus.New || GradeRecivedStatatus == GradingResultStatus.Approved))
                    {
                        WFTransaction.WorkFlowManager(TranNo);
                        HttpContext.Current.Session["CATranNo"] = TranNo;
                    }
                    else
                    {
                        WFTransaction.Close(TranNo);
                        //Create a new Grading Dispute task or General reqiurment fail.
                    }
                }
                if (isSaved == true)
                {
                    tran.Commit();
                    return(true);
                }
                else
                {
                    tran.Rollback();
                    objAt.RoleBack();
                    HttpContext.Current.Session["CATranNo"] = null;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                if (At == 1)
                {
                    objAt.RoleBack();
                }
                throw ex;
            }
            finally
            {
                tran.Dispose();
                conn.Close();
            }
        }
Esempio n. 2
0
        public bool UpdateGradingResult(List <GradingResultDetailBLL> list, Nullable <Guid> Id, string TrackingNo)
        {
            bool isSaved = false;


            SqlConnection  conn = Connection.getConnection();
            SqlTransaction tran = conn.BeginTransaction();

            this.WarehouseId = UserBLL.GetCurrentWarehouse();


            if (Id != null)
            {
                try
                {
                    this.ID = (Guid)Id;
                    if (GradingResultDAL.InactivateGradingResultDetails(this.ID, tran) == true)
                    {
                        int           at     = -1;
                        AuditTrailBLL objAt  = new AuditTrailBLL();
                        string        strNew = "(Grading Result Id -" + this.ID.ToString() + "),(LastModifiedby-" + UserBLL.GetCurrentUser().ToString() + "),(LastModifiedTimeStamp-" + DateTime.Now.ToString() + ")";
                        at = objAt.saveAuditTrailStringFormat("Grading Factor Details Cancelled", strNew, WFStepsName.EditGradingResultDet.ToString(), UserBLL.GetCurrentUser(), "Cancel Grading Result Detail");
                        if (at == -1)
                        {
                            tran.Rollback();
                            isSaved = false;
                        }
                        else
                        {
                            GradingResultBLL objGR = new GradingResultBLL();
                            objGR = objGR.GetGradingResultById(this.ID);
                            if (GradingResultDAL.UpdateGradingResult(this, tran) == true)
                            {
                                AuditTrailBLL objAtGR = new AuditTrailBLL();
                                at = objAtGR.saveAuditTrail(objGR, this, WFStepsName.EditGradingResult.ToString(), UserBLL.GetCurrentUser(), "Updating Grading Result");
                                if (at == -1)
                                {
                                    tran.Rollback();
                                    isSaved = false;
                                    return(isSaved);
                                }
                                GradingResultDetailBLL objDetail = new GradingResultDetailBLL();
                                isSaved = objDetail.Add(list, tran, Id);
                                if (isSaved == true)
                                {
                                    //Request
                                    ECXWF.CMessage msg = WFTransaction.Request(TrackingNo);
                                    if (msg != null)
                                    {
                                        if (msg.Name == "EditGradingResult")
                                        {
                                            WFTransaction.WorkFlowManager(TrackingNo, msg);
                                        }
                                    }
                                }


                                if (isSaved == false)
                                {
                                    tran.Rollback();
                                    isSaved = false;
                                }
                                else
                                {
                                    tran.Commit();
                                    isSaved = true;
                                }
                            }
                            else
                            {
                                tran.Rollback();
                                isSaved = false;
                            }
                        }
                    }
                    else
                    {
                        tran.Rollback();
                        isSaved = false;
                    }
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Dispose();
                    conn.Close();
                }
            }

            return(isSaved);
        }