コード例 #1
0
        public void  GetLatestActiveTruckWeight(string TruckPlateNo, string TrailerPlateNo)
        {
            TruckWeight obj = null;

            obj = TruckWeightDAL.GetLatestActiveTruckWeight(TruckPlateNo, TrailerPlateNo);
            if (obj != null)
            {
                this.Id             = obj.Id;
                this.TruckPlateNo   = obj.TruckPlateNo;
                this.TrailerPlateNo = obj.TrailerPlateNo;
                this.hasTrailer     = obj.hasTrailer;
                this.DateWeighed    = obj.DateWeighed;
                this.Weight         = obj.Weight;
                this.Status         = obj.Status;
            }
        }
コード例 #2
0
        public static TruckWeight GetLatestActiveWeight(string TruckPlateNo, string TrailerPlateNo)
        {
            TruckWeight obj = null;

            //Truck only
            if ((string.IsNullOrEmpty(TruckPlateNo) != true) && (string.IsNullOrEmpty(TrailerPlateNo) == true))
            {
                obj = TruckWeightDAL.GetLatestActiveTruckWeight(TruckPlateNo, TrailerPlateNo);
            }
            //Trailer only
            else if ((string.IsNullOrEmpty(TruckPlateNo) == true) && (string.IsNullOrEmpty(TrailerPlateNo) != true))
            {
                obj = TruckWeightDAL.GetLatestActiveTrailerWeight(TruckPlateNo, TrailerPlateNo);
            }
            else if ((string.IsNullOrEmpty(TruckPlateNo) != true) && (string.IsNullOrEmpty(TrailerPlateNo) != true))
            {
                obj = TruckWeightDAL.GetLatestActivetTruckTrailerWeight(TruckPlateNo, TrailerPlateNo);
            }
            else
            {
                throw new Exception("Truck type is not determinded");
            }
            return(obj);
        }
コード例 #3
0
        public bool AddNew()
        {
            DriverInformationBLL objDriverInfo = new DriverInformationBLL();

            objDriverInfo = objDriverInfo.GetById(this.DriverInformationId);
            TruckWeight objTruckWeight = null;

            if (objDriverInfo == null)
            {
                throw new Exception("Unbale To get Driver Information");
            }

            else
            {
                objTruckWeight                = new TruckWeight();
                objTruckWeight.Id             = Guid.NewGuid();
                objTruckWeight.TruckPlateNo   = objDriverInfo.PlateNumber;
                objTruckWeight.TrailerPlateNo = objDriverInfo.TrailerPlateNumber;
                if ((string.IsNullOrEmpty(objDriverInfo.PlateNumber) == true) && (string.IsNullOrEmpty(objDriverInfo.TrailerPlateNumber) == true))
                {
                    this.TruckWeightId = null;
                }
                else
                {
                    objTruckWeight.DateWeighed = this.DateWeighed;
                    objTruckWeight.Weight      = this.TruckWeight;
                    this.TruckWeightId         = objTruckWeight.Id;
                }
            }

            bool isSaved = false;

            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
            {
                ScalingDAL.GetQueueNumber(Code, WarehouseId, currDate, out QueueNo, out PreWeightQueueNo);
                if (QueueNo == null || PreWeightQueueNo == null)
                {
                    throw new Exception("Invalid Queue.");
                }
                this.Id               = Guid.NewGuid();
                this.QueueDate        = currDate;
                this.QueueNo          = (int)QueueNo;
                this.PreWeightQueueNo = (int)PreWeightQueueNo;
                this.WarehouseId      = WarehouseId;

                SqlParameter[] paramList = new SqlParameter[18];
                string         spName    = "spInsertScaling";
                paramList[0]  = DataAccessPoint.param("@ReceivigRequestId", SqlDbType.UniqueIdentifier, this.ReceivigRequestId);
                paramList[1]  = DataAccessPoint.param("@DriverInformationId", SqlDbType.UniqueIdentifier, this.DriverInformationId);
                paramList[2]  = DataAccessPoint.param("@GradingResultId", SqlDbType.UniqueIdentifier, this.GradingResultId);
                paramList[3]  = DataAccessPoint.param("@ScaleTicketNumber", SqlDbType.NChar, this.ScaleTicketNumber, 50);
                paramList[4]  = DataAccessPoint.param("@DateWeighed", SqlDbType.DateTime, this.DateWeighed);
                paramList[5]  = DataAccessPoint.param("@GrossWeightWithTruck", SqlDbType.Float, this.GrossWeightWithTruck);
                paramList[6]  = DataAccessPoint.param("@TruckWeight", SqlDbType.Float, this.TruckWeight);
                paramList[7]  = DataAccessPoint.param("@GrossWeight", SqlDbType.Float, this.GrossWeight);
                paramList[8]  = DataAccessPoint.param("@Status", SqlDbType.Int, this.Status);
                paramList[9]  = DataAccessPoint.param("@Remark", SqlDbType.Text, this.Remark);
                paramList[10] = DataAccessPoint.param("@CreatedBy", SqlDbType.UniqueIdentifier, UserBLL.GetCurrentUser());
                paramList[11] = DataAccessPoint.param("@WarehouseId", SqlDbType.UniqueIdentifier, this.WarehouseId);
                paramList[12] = DataAccessPoint.param("@PreWeightQueueNo", SqlDbType.Int, this.PreWeightQueueNo);
                paramList[13] = DataAccessPoint.param("@QueueNo", SqlDbType.Int, this.QueueNo);
                paramList[14] = DataAccessPoint.param("@QueueDate", SqlDbType.DateTime, this.QueueDate);
                paramList[15] = DataAccessPoint.param("@WeigherId", SqlDbType.UniqueIdentifier, this.WeigherId);
                paramList[16] = DataAccessPoint.param("@Id", SqlDbType.UniqueIdentifier, this.Id);
                paramList[17] = DataAccessPoint.param("@TruckWeightId", SqlDbType.UniqueIdentifier, this.TruckWeightId);
                DataAccessPoint dal = new DataAccessPoint();

                if (dal.ExcuteProcedure(spName, paramList))
                {
                    isSaved = true;
                }

                //THE FOLLOWING METHOD [SaveNew()] ADDED BY SINISHAW
                if (isSaved == true && this.TruckWeightId != null && objTruckWeight != null && objTruckWeight.SaveNew() != true)
                {
                    isSaved = false;
                }

                int at = -1;
                if (isSaved == true)
                {
                    AuditTrailBLL objAt = new AuditTrailBLL();
                    at = objAt.saveAuditTrail(this, WFStepsName.AddScalingInfo.ToString(), UserBLL.GetCurrentUser(), "Add Scaling");
                }
                if (at == 1 && isSaved == true)
                {
                    WFTransaction.WorkFlowManager(this.TrackingNo);
                }
                else
                {
                    isSaved = false;
                }

                if (isSaved == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        public bool Add()
        {
            //get Driver Info
            DriverInformationBLL objDriverInfo = new DriverInformationBLL();

            objDriverInfo = objDriverInfo.GetById(this.DriverInformationId);
            WarehouseApplication.BLL.TruckWeight objTruckWeight = null;
            if (objDriverInfo == null)
            {
                throw new Exception("Unbale To get Driver Information");
            }
            else
            {
                objTruckWeight = new TruckWeight();

                objTruckWeight.Id = Guid.NewGuid();
                if (string.IsNullOrEmpty(objDriverInfo.PlateNumber) != true)
                {
                    objTruckWeight.TruckPlateNo = objDriverInfo.PlateNumber;
                }
                else
                {
                    objTruckWeight.TruckPlateNo = String.Empty;
                }
                if (string.IsNullOrEmpty(objDriverInfo.TrailerPlateNumber) != true)
                {
                    objTruckWeight.TrailerPlateNo = objDriverInfo.TrailerPlateNumber;
                }
                else
                {
                    objTruckWeight.TrailerPlateNo = String.Empty;
                }
                if ((string.IsNullOrEmpty(objDriverInfo.PlateNumber) == true) && (string.IsNullOrEmpty(objDriverInfo.TrailerPlateNumber) == true))
                {
                    this.TruckWeightId = null;
                }
                else
                {
                    objTruckWeight.DateWeighed = this.DateWeighed;
                    objTruckWeight.Weight      = this.TruckWeight;
                    this.TruckWeightId         = objTruckWeight.Id;
                }
            }


            bool           isSaved          = false;
            SqlTransaction tran             = null;
            SqlConnection  conn             = new SqlConnection();
            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
            {
                ScalingDAL.GetQueueNumber(Code, WarehouseId, currDate, out QueueNo, out PreWeightQueueNo);
                if (QueueNo == null || PreWeightQueueNo == null)
                {
                    throw new Exception("Invalid Queue.");
                }
                this.Id               = Guid.NewGuid();
                this.QueueDate        = currDate;
                this.QueueNo          = (int)QueueNo;
                this.PreWeightQueueNo = (int)PreWeightQueueNo;
                conn             = Connection.getConnection();
                tran             = conn.BeginTransaction();
                this.WarehouseId = WarehouseId;
                isSaved          = ScalingDAL.InsertScalingInformation(this, tran);
                if (isSaved == true)
                {
                    if (this.TruckWeightId != null)
                    {
                        if (objTruckWeight != null)
                        {
                            if (objTruckWeight.Save(tran) != true)
                            {
                                if (isSaved == true)
                                {
                                    isSaved = false;
                                }
                            }
                        }
                    }
                }
                int at = -1;
                if (isSaved == true)
                {
                    AuditTrailBLL objAt = new AuditTrailBLL();
                    at = objAt.saveAuditTrail(this, WFStepsName.AddScalingInfo.ToString(), UserBLL.GetCurrentUser(), "Add Scaling");
                }
                if (at == 1)
                {
                    if (isSaved == true)
                    {
                        WFTransaction.WorkFlowManager(this.TrackingNo);
                    }
                    isSaved = true;
                }
                else
                {
                    isSaved = false;
                }
                if (isSaved == true)
                {
                    tran.Commit();
                    tran.Dispose();
                    conn.Close();
                    return(true);;
                }
                else
                {
                    tran.Rollback();
                    tran.Dispose();
                    conn.Close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                tran.Dispose();
                conn.Close();
                throw ex;
            }
        }