コード例 #1
0
 public GradingResultBLL(GradingResultBLL source)
 {
     this._id                    = source._id;
     this._gradingId             = source._gradingId;
     this._commodityGradeId      = source._commodityGradeId;
     this._status                = source._status;
     this._remark                = source._remark;
     this._gradeRecivedTimestamp = source._gradeRecivedTimestamp;
     this._isSupervisor          = source._isSupervisor;
     this.CreatedBy              = source.CreatedBy;
     this.CreatedTimestamp       = source.CreatedTimestamp;
     this.LastModifiedBy         = source.LastModifiedBy;
     this.LastModifiedTimestamp  = source.LastModifiedTimestamp;
 }
コード例 #2
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();
            }
        }