예제 #1
0
        public bool UpdateEach(Guid Id, string Value)
        {
            //get the old
            SqlTransaction tran;
            SqlConnection  conn = Connection.getConnection();

            bool isSaved = false;
            GradingResultDetailBLL objOld = GradingResultDetailDAL.GetGradingResultDetailById(Id);
            GradingResultDetailBLL objNew = objOld;

            objNew.RecivedValue = Value;
            tran = conn.BeginTransaction();
            try
            {
                isSaved = GradingResultDetailDAL.UpdateGradingResultDetailEach(Id, Value, tran);
                AuditTrailBLL objAt = new AuditTrailBLL();
                int           x     = objAt.saveAuditTrail(objOld, objNew, Utility.GetApplicationName(), UserBLL.GetCurrentUser(), "Update Grading factorValue");
                if (x == 1 && isSaved == true)
                {
                    tran.Commit();
                }
                else if (isSaved == true && x == -1)
                {
                    tran.Rollback();
                    isSaved = false;
                    objAt.RoleBack();
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                tran.Dispose();
                conn.Close();
            }
            return(isSaved);
        }
예제 #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);
        }
예제 #3
0
        public Nullable <Guid> Add(List <GradingResultDetailBLL> list, string TrackingNo)
        {
            bool isSaved = false;

            if (this.IsSupervisor == true)
            {
                int count = 1;
                count = GradingResultDAL.GetNumberofSupervisorResults(this.GradingId);
                if (count > 0)
                {
                    throw new Exception("Multiple Supervisor Grading result exception.");
                }
            }
            Nullable <Guid> Id = null;

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

            this.WarehouseId      = UserBLL.GetCurrentWarehouse();
            this.ID               = Guid.NewGuid();
            this.CreatedBy        = UserBLL.GetCurrentUser();
            this.CreatedTimestamp = DateTime.Now;
            try
            {
                Id = (Guid)GradingResultDAL.InsertGradingResult(this, tran);

                if (Id != null)
                {
                    // add audit trail

                    int           At    = -1;
                    AuditTrailBLL objAt = new AuditTrailBLL();

                    At = objAt.saveAuditTrail(this, WFStepsName.AddGradingResult.ToString(), UserBLL.GetCurrentUser(), "Add Grading result");
                    if (At == 1)
                    {
                        GradingResultDetailBLL objDetail = new GradingResultDetailBLL();
                        isSaved = objDetail.Add(list, tran, Id);
                        if (isSaved == true)
                        {
                            isSaved = true;
                        }
                        else
                        {
                            if (At == 1)
                            {
                                objAt.RoleBack();
                                isSaved = false;
                            }
                        }
                        if (isSaved == true)
                        {
                            GradingBLL objGrading = new GradingBLL();
                            objGrading = objGrading.GetById(this.GradingId);
                            if (objGrading == null)
                            {
                                throw new Exception("Invalid Code.Please try again");
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(objGrading.TrackingNo) == true)
                                {
                                    throw new Exception("Invalid Code.Please try again");
                                }
                            }
                            if (this.Status == GradingResultStatus.MoistureFailed || this.Status == GradingResultStatus.GeneralRequiementfail)
                            {
                                // Client Should Be Informed of the Grading Result.
                                // WFTransaction.Close(objGrading.TrackingNo);
                                WFTransaction.WorkFlowManager(objGrading.TrackingNo);
                            }
                            else
                            {
                                WFTransaction.WorkFlowManager(objGrading.TrackingNo);
                            }
                            HttpContext.Current.Session["AddGradingRecivedTranNo"] = objGrading.TrackingNo;
                        }
                    }
                    else
                    {
                        isSaved = false;
                    }
                }

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