Esempio n. 1
0
        /// <summary>
        /// Validates whether the Data fields are in proper format
        /// </summary>
        /// <param name="objDriverInfoBll"></param>
        /// <returns>True when all check are okay</returns>
        public bool isValidForSave(DriverInformationBLL objDriverInfoBll)
        {
            if (objDriverInfoBll.ReceivigRequestId == null)
            {
                return(false);
            }
            //if (objDriverInfoBll.DriverName == "" || objDriverInfoBll.DriverName.Length > 50 )
            //{

            //    return false;
            //}
            //if (objDriverInfoBll.LicenseNumber == "" || objDriverInfoBll.LicenseNumber.Length > 50)
            //{

            //    return false;
            //}
            //if (objDriverInfoBll.LicenseIssuedPlace == "" || objDriverInfoBll.LicenseIssuedPlace.Length > 50)
            //{

            //    return false;
            //}
            //if (objDriverInfoBll.PlateNumber == "" || objDriverInfoBll.PlateNumber.Length > 50)
            //{

            //    return false;
            //}


            //if (objDriverInfoBll.CreatedBy  == null)
            //{
            //    throw new Exception("Invalid Created By");

            //}
            return(true);
        }
Esempio n. 2
0
        public bool EditDriverInformation(DriverInformationBLL objEdit)
        {
            //check if it has a GRN not in Edit mood.

            if (isGRNEditable(this.ReceivigRequestId) == false)
            {
                throw new GRNNotOnUpdateStatus(" This Information can't up updated because the GRN is not on Edit status");
            }


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

            tran = Conn.BeginTransaction();
            int AtStatus = -1;

            try
            {
                DriverInformation objDriverInfoDAL = new DriverInformation();
                isSaved = objDriverInfoDAL.UpdateDriverInformation(this, tran);
                if (isSaved == true)
                {
                    string        AppMode = WFStepsName.EditDriverInfo.ToString();
                    AuditTrailBLL objAt   = new AuditTrailBLL();
                    AtStatus = objAt.saveAuditTrail(this, objEdit, AppMode, UserBLL.GetCurrentUser(), "DriverInformationUpdate");
                    if (AtStatus == 1 || AtStatus == 0)
                    {
                        tran.Commit();
                    }
                    else
                    {
                        tran.Rollback();
                    }
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                ErrorLogger.Log(ex);
                return(false);
            }
            if (AtStatus == 1 || AtStatus == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Checks if the Object can be Updated, in that all required Data are in a correct format
        /// </summary>
        /// <param name="objDriverInfoBll"></param>
        /// <returns>True if all checks are passed otherwise false</returns>
        public bool isValidForEdit(DriverInformationBLL objDriverInfoBll)
        {
            bool isValid = false;

            isValid = this.isValidForSave(objDriverInfoBll);
            if (isValid == true)
            {
                if (objDriverInfoBll.LastModifiedBy == null)
                {
                    return(false);
                }
                else
                {
                    isValid = true;
                }
            }
            return(isValid);
        }
Esempio n. 4
0
 /// <summary>
 /// A function that collects values of CDR, Driver and Voucher information and Save it using
 /// DataAccessPoint Class from DAL through Stored Procedure called "ExecuteProcedure"
 /// </summary>
 /// <param name="TransactionTypeId"></param>
 /// <param name="objDriver"></param>
 /// <param name="objVoucher"></param>
 /// <returns>
 /// Id with type Guid to form. Id is PK for CDR and FK for Driver and Voucher Information
 /// </returns>
 public Guid AddArrival(Guid TransactionTypeId, DriverInformationBLL objDriver, VoucherInformationBLL objVoucher)
 {
     try
     {
         this.Id = Guid.NewGuid();
         string TransactionNo = WFTransaction.GetTransaction(TransactionTypeId);
         this.TransactionId = TransactionNo;
         DataAccessPoint objDAL = new DataAccessPoint();
         objDAL.ExcuteProcedure("spInsertArrival", ParamList(this, objDriver, objVoucher));
         return(Id);
         //1st argument is the procedure name
         //2nd arguemnt is a method found in this class that returns all tables parameter list
         //SaveByText found at DAL and it executes the procedure
     }
     catch (Exception ex)
     {
         throw new Exception("Failed to save arrival information! " + ex.Message.ToString());
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Collectes all existing values of selected information and assign to scalar variables
        /// And Update old values using DataAccessPoint class from DAL through stored Procedure
        /// called "ExecuteProcedure"
        /// </summary>
        /// <param name="objDriver"></param>
        /// <param name="objVoucher"></param>
        public void UpdateArrival(DriverInformationBLL objDriver, VoucherInformationBLL objVoucher)
        {
            SqlParameter[] paramList = new SqlParameter[23];
            //COMMODITY DEPOSIT REQUEST PARAMETERS
            paramList[0] = this.param("@CommodityDepositRequestId", SqlDbType.UniqueIdentifier, this.Id);
            paramList[1] = this.param("@ClientId", SqlDbType.UniqueIdentifier, this.ClientId);
            paramList[2] = this.param("@CommodityId", SqlDbType.UniqueIdentifier, this.CommodityId);
            paramList[3] = this.param("@WoredaId", SqlDbType.UniqueIdentifier, this.WoredaId);
            paramList[4] = this.param("@ProductionYear", SqlDbType.Int, this.ProductionYear);
            paramList[5] = this.param("@Weight", SqlDbType.Float, this.Weight);
            paramList[6] = this.param("@DateTimeRecived", SqlDbType.DateTime, this.DateTimeRecived);
            paramList[7] = this.param("@StatusC", SqlDbType.Int, this.Status);
            paramList[8] = this.param("@RemarkC", SqlDbType.Text, this.Remark);
            paramList[9] = this.param("@LastModifiedBy", SqlDbType.UniqueIdentifier, this.LastModifiedBy);
            //DRIVER INFORMATION PARAMETERS
            paramList[10] = this.param("@DriverName", SqlDbType.NVarChar, objDriver.DriverName, 50);
            paramList[11] = this.param("@LicenseNumber", SqlDbType.NVarChar, objDriver.LicenseNumber, 50);
            paramList[12] = this.param("@PlateNumber", SqlDbType.NVarChar, objDriver.PlateNumber, 50);
            paramList[13] = this.param("@LicenseIssuedPlace", SqlDbType.NVarChar, objDriver.LicenseIssuedPlace, 50);
            paramList[14] = this.param("@TrailerPlateNumber", SqlDbType.NVarChar, objDriver.TrailerPlateNumber, 50);
            paramList[15] = this.param("@RemarkD", SqlDbType.Text, objDriver.Remark);
            paramList[16] = this.param("@StatusD", SqlDbType.Int, objDriver.Status);//????????????????
            //VOUCHER INFORMATION PARAMETERS
            paramList[17] = this.param("@VoucherNo", SqlDbType.NVarChar, objVoucher.VoucherNo, 50);
            paramList[18] = this.param("@CoffeeTypeId", SqlDbType.UniqueIdentifier, objVoucher.CoffeeTypeId);
            paramList[19] = this.param("@SpecificArea", SqlDbType.NVarChar, objVoucher.SpecificArea);
            paramList[20] = this.param("@NumberOfBags", SqlDbType.Int, objVoucher.NumberofBags);
            paramList[21] = this.param("@NumberOfPlomps", SqlDbType.Int, objVoucher.NumberOfPlomps);
            paramList[22] = this.param("@NumberOfPlompsTrailer", SqlDbType.Int, objVoucher.NumberOfPlompsTrailer);
            DataAccessPoint dal = new DataAccessPoint();

            try
            {
                dal.ExcuteProcedure("spUpdateArrival", paramList);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to update arrival! " + ex.Message.ToString());
            }
        }
Esempio n. 6
0
        public DriverInformationBLL GetById(Guid Id)
        {
            DriverInformationBLL obj = new DriverInformationBLL();
            DataSet dsDriver         = DriverInformation.GetDriverInformationById(Id);

            if (dsDriver != null)
            {
                if (dsDriver.Tables[0].Rows.Count == 1)
                {
                    obj.Id = new Guid(dsDriver.Tables[0].Rows[0]["Id"].ToString());
                    obj.ReceivigRequestId  = new Guid(dsDriver.Tables[0].Rows[0]["ReceivingRequestId"].ToString());
                    obj.DriverName         = dsDriver.Tables[0].Rows[0]["DriverName"].ToString();
                    obj.LicenseNumber      = dsDriver.Tables[0].Rows[0]["LicenseNumber"].ToString();
                    obj.LicenseIssuedPlace = dsDriver.Tables[0].Rows[0]["LicenseIssuedPlace"].ToString();
                    obj.PlateNumber        = dsDriver.Tables[0].Rows[0]["PlateNumber"].ToString();
                    obj.TrailerPlateNumber = dsDriver.Tables[0].Rows[0]["TrailerPlateNumber"].ToString();
                    obj.Status             = Convert.ToInt32(dsDriver.Tables[0].Rows[0]["Status"].ToString());
                    obj.Remark             = dsDriver.Tables[0].Rows[0]["Remark"].ToString();
                    return(obj);
                }
            }
            return(null);
        }
Esempio n. 7
0
        /// <summary>
        /// Declare and Initialize SQL Scalars for CommodityDepositRequest, DriverInformation and VoucherInformation
        /// Fields so that it would be sent to DAL to execute the procedure
        /// </summary>
        /// <param name="comodityObj"></param>
        /// <param name="objDriver"></param>
        /// <param name="objVoucher"></param>
        /// <returns>
        /// sql parameter array
        /// </returns>
        private SqlParameter[] ParamList(CommodityDepositeRequestBLL objCommodityDepositRequest, DriverInformationBLL objDriver, VoucherInformationBLL objVoucher)
        {
            SqlParameter[] arPar = new SqlParameter[29];
            //use arPar [] to hold all 3 tables parameter to insert
            //COMMODITY-DEPOSIT-REQUEST PARAMETERSS
            arPar[0]       = new SqlParameter("@TransactionId", SqlDbType.NVarChar, 50);
            arPar[0].Value = objCommodityDepositRequest.TransactionId;
            arPar[1]       = new SqlParameter("@ClientId", SqlDbType.UniqueIdentifier);
            arPar[1].Value = objCommodityDepositRequest.ClientId;
            arPar[2]       = new SqlParameter("@CommodityId", SqlDbType.UniqueIdentifier);
            arPar[2].Value = objCommodityDepositRequest.CommodityId;;
            arPar[3]       = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier);
            arPar[3].Value = objCommodityDepositRequest.WarehouseId;
            arPar[4]       = new SqlParameter("@RepresentativeId", SqlDbType.UniqueIdentifier);
            arPar[4].Value = objCommodityDepositRequest.RepresentativeId;
            arPar[5]       = new SqlParameter("@WoredaId", SqlDbType.UniqueIdentifier);
            if (objCommodityDepositRequest.WoredaId != Guid.Empty)
            {
                arPar[5].Value = objCommodityDepositRequest.WoredaId;
            }
            else
            {
                arPar[5].Value = null;
            }

            arPar[6] = new SqlParameter("@productionYear", SqlDbType.Int);
            if (objCommodityDepositRequest.ProductionYear != 0)
            {
                arPar[6].Value = objCommodityDepositRequest.ProductionYear;
            }
            else
            {
                arPar[6].Value = null;
            }
            arPar[7]        = new SqlParameter("@StatusC", SqlDbType.Int);
            arPar[7].Value  = objCommodityDepositRequest.Status;
            arPar[8]        = new SqlParameter("@CreatedByC", SqlDbType.UniqueIdentifier);
            arPar[8].Value  = objCommodityDepositRequest.CreatedBy;
            arPar[9]        = new SqlParameter("@Remark", SqlDbType.Text);
            arPar[9].Value  = objCommodityDepositRequest.Remark;
            arPar[10]       = new SqlParameter("@Weight", SqlDbType.Decimal);
            arPar[10].Value = objCommodityDepositRequest.Weight;
            arPar[11]       = new SqlParameter("@NumberofBags", SqlDbType.Int);
            arPar[11].Value = objCommodityDepositRequest.NumberofBags;
            arPar[12]       = new SqlParameter("@DateTimeRecived", SqlDbType.DateTime);
            arPar[12].Value = objCommodityDepositRequest.DateTimeRecived;

            arPar[13]       = new SqlParameter("@CommodityDepositRequestId", SqlDbType.UniqueIdentifier);
            arPar[13].Value = this.Id;

            //DRIVER PARAMETERS
            //arPar[14] = new SqlParameter("@ReceivigRequestId", SqlDbType.UniqueIdentifier);
            //arPar[14].Value = objDriver.ReceivigRequestId;
            arPar[14]       = new SqlParameter("@DriverName", SqlDbType.NVarChar, 50);
            arPar[14].Value = objDriver.DriverName;
            arPar[15]       = new SqlParameter("@LicenseNumber", SqlDbType.NVarChar, 50);
            arPar[15].Value = objDriver.LicenseNumber;
            arPar[16]       = new SqlParameter("@LicenseIssuedPlace", SqlDbType.NVarChar, 50);
            arPar[16].Value = objDriver.LicenseIssuedPlace;
            arPar[17]       = new SqlParameter("@PlateNumber", SqlDbType.NVarChar, 50);
            arPar[17].Value = objDriver.PlateNumber;
            arPar[18]       = new SqlParameter("TrailerPlateNumber", SqlDbType.NVarChar, 50);
            arPar[18].Value = objDriver.TrailerPlateNumber;
            //arPar[20] = new SqlParameter("@CreatedByD", SqlDbType.UniqueIdentifier);
            //arPar[20].Value = objDriver.CreatedBy;
            arPar[19]       = new SqlParameter("@StatusD", SqlDbType.Int);
            arPar[19].Value = 1;
            //arPar[22] = new SqlParameter("@DriverInformationId", SqlDbType.UniqueIdentifier);
            //arPar[22].Direction = ParameterDirection.Output;

            //VOUCHER PARAMETERS
            //arPar[23] = new SqlParameter("@DepositRequestId", SqlDbType.UniqueIdentifier);
            //arPar[23].Value = objVoucher.DepositRequestId;
            arPar[20]       = new SqlParameter("@VoucherNo", SqlDbType.NVarChar, 50);
            arPar[20].Value = objVoucher.VoucherNo;
            arPar[21]       = new SqlParameter("@CoffeeTypeId", SqlDbType.UniqueIdentifier);
            arPar[21].Value = objVoucher.CoffeeTypeId;
            arPar[22]       = new SqlParameter("@SpecificArea", SqlDbType.NVarChar);
            arPar[22].Value = objVoucher.SpecificArea;
            //arPar[27] = new SqlParameter("@NumberOfBagsV", SqlDbType.Int);
            //arPar[27].Value = objVoucher.NumberofBags;
            arPar[23]       = new SqlParameter("@NumberOfPlomps", SqlDbType.Int);
            arPar[23].Value = objVoucher.NumberOfPlomps;
            arPar[24]       = new SqlParameter("@NumberOfPlompsTrailer", SqlDbType.Int);
            arPar[24].Value = objVoucher.NumberOfPlompsTrailer;
            arPar[25]       = new SqlParameter("@CertificateNo", SqlDbType.NVarChar, 50);
            arPar[25].Value = "";// objVoucher.CertificateNo;
            //arPar[31] = new SqlParameter("@CreatedByV", SqlDbType.UniqueIdentifier);
            //arPar[31].Value = objVoucher.CreatedBy;
            arPar[26]       = new SqlParameter("@CreatedDate", SqlDbType.DateTime);
            arPar[26].Value = DateTime.Now;
            arPar[27]       = new SqlParameter("@StatusV", SqlDbType.Int);
            arPar[27].Value = objVoucher.Status;
            //????????
            arPar[28]           = new SqlParameter("@VoucherId", SqlDbType.UniqueIdentifier);
            arPar[28].Direction = ParameterDirection.Output;
            return(arPar);
        }
Esempio n. 8
0
        public bool SaveDriverInformation()
        {
            bool                 isValid, isDuplicate = false;
            bool                 isSaved          = false;
            AuditTrailBLL        objAt            = new AuditTrailBLL();
            DriverInformationBLL objDriverInfoBLL = new DriverInformationBLL(this.ReceivigRequestId, this.DriverName,
                                                                             this.LicenseNumber, this.LicenseIssuedPlace, this.PlateNumber, this.TrailerPlateNumber, this.Status, this.Remark, this.CreatedBy);

            //TODO : Check status is not cancelled
            //isDuplicate = this.isDuplicate(this.ReceivigRequestId, this.LicenseIssuedPlace, this.LicenseIssuedPlace);
            //if (isDuplicate == true)
            //{
            //throw new DuplicateDriverInformationException("This driver information has already been added");
            //}
            isValid = this.isValidForSave(objDriverInfoBLL);
            if (isValid == true)
            {
                SqlTransaction tran;
                SqlConnection  conn = Connection.getConnection();
                tran = conn.BeginTransaction();
                try
                {
                    DriverInformation objDriverInfoDAL = new DriverInformation();
                    Guid DriverInformationId           = Guid.Empty;

                    DriverInformationId = objDriverInfoDAL.InsertDriverInformation(objDriverInfoBLL, tran);
                    if (DriverInformationId == Guid.Empty)
                    {
                        tran.Rollback();
                        isSaved = false;
                    }
                    else
                    {
                        objDriverInfoBLL.Id = DriverInformationId;

                        if (objAt.saveAuditTrail(objDriverInfoBLL, WFStepsName.AddDriverInformation.ToString(), UserBLL.GetCurrentUser(), "Add New Driver Information") == -1)
                        {
                            tran.Rollback();
                            isSaved = false;
                        }
                        else
                        {
                            tran.Commit();
                            isSaved = true;
                        }
                    }
                    conn.Close();
                }
                catch (Exception e)
                {
                    tran.Rollback();
                    objAt.RoleBack();
                    throw e;
                }
                finally
                {
                    tran.Dispose();
                    conn.Close();
                }
            }
            else
            {
                return(false);
            }
            return(isSaved);
        }
Esempio n. 9
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;
            }
        }
Esempio n. 10
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;
            }
        }