Exemple #1
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());
            }
        }
Exemple #2
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);
        }
Exemple #3
0
        //oct-18-2011
        //update empty voucher entry error
        public bool Save(Guid DepositRequestId, string VoucherNo, Guid CoffeeTypeId,
                         string SpecificArea, int NumberofBags, int NumberOfPlomps, int NumberOfPlompsTrailer, string CertificateNo, Guid CreatedBy,
                         int Status, string TrackingNo)
        {
            SqlTransaction tran;
            bool           isSaved = false;

            //get Tracking No.
            CommodityDepositeRequestBLL oC = new CommodityDepositeRequestBLL();

            oC         = oC.GetCommodityDepositeDetailById(DepositRequestId);
            TrackingNo = oC.TrackingNo;

            VoucherInformationBLL obj = new VoucherInformationBLL();

            obj.DepositRequestId      = DepositRequestId;
            obj.VoucherNo             = VoucherNo;
            obj.CoffeeTypeId          = CoffeeTypeId;
            obj.SpecificArea          = SpecificArea;
            obj.NumberofBags          = NumberofBags;
            obj.NumberOfPlomps        = NumberOfPlomps;
            obj.NumberOfPlompsTrailer = NumberOfPlompsTrailer;
            obj.CertificateNo         = CertificateNo;
            obj.CreatedBy             = CreatedBy;
            obj.Status = Status;
            Voucher       objSave = new Voucher();
            SqlConnection conn    = Connection.getConnection();

            tran = conn.BeginTransaction();
            AuditTrailBLL objAt   = new AuditTrailBLL();
            int           AtSaved = -1;

            try
            {
                Guid VoucherId = Guid.Empty;
                VoucherId = objSave.InsertVoucherInformation(obj, tran);
                if (VoucherId == Guid.Empty)
                {
                    isSaved = false;
                }
                else
                {
                    obj.Id = VoucherId;
                    if (objAt.saveAuditTrail(obj, WFStepsName.NewVoucherInfo.ToString(), UserBLL.GetCurrentUser(), "Insert Voucher") == 1)
                    {
                        AtSaved = 1;
                        string msgFromWF = "";
                        msgFromWF = WFTransaction.GetMessage(TrackingNo);
                        if (msgFromWF == "AddVoucherInfo")
                        {
                            WFTransaction.WorkFlowManager(TrackingNo);
                            WFTransaction.UnlockTask(TrackingNo);
                            HttpContext.Current.Session["msg"] = null;
                        }
                        tran.Commit();
                        isSaved = true;
                    }
                    else
                    {
                        tran.Rollback();
                        isSaved = false;
                    }
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                if (AtSaved == 1)
                {
                    objAt.RoleBack();
                }
                throw ex;
            }
            finally
            {
                conn.Close();
                tran.Dispose();
            }
            return(isSaved);
        }
Exemple #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());
     }
 }
Exemple #5
0
        public bool Update(Guid Id, Guid RecReqId, string VoucherNo, Guid CoffeeTypeId,
                           string SpecificArea, int NumberofBags, int NumberOfPlomps, int NumberOfPlompsTrailer, string CertificateNo, Guid LastModifiedBy,
                           int Status)
        {
            if (isGRNEditable(RecReqId) == 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;
            VoucherInformationBLL objEdit = new VoucherInformationBLL();

            objEdit = objEdit.GetVoucherInformationById(Id);
            VoucherInformationBLL obj = new VoucherInformationBLL();

            obj.Id                    = Id;
            obj.VoucherNo             = VoucherNo;
            obj.CoffeeTypeId          = CoffeeTypeId;
            obj.SpecificArea          = SpecificArea;
            obj.NumberofBags          = NumberofBags;
            obj.NumberOfPlomps        = NumberOfPlomps;
            obj.NumberOfPlompsTrailer = NumberOfPlompsTrailer;
            obj.CertificateNo         = CertificateNo;
            obj.LastModifiedBy        = LastModifiedBy;
            obj.Status                = Status;
            obj.DepositRequestId      = RecReqId;
            conn = Connection.getConnection();
            tran = conn.BeginTransaction();
            Voucher objUpdate = new Voucher();
            int     atStatus  = -1;

            try
            {
                isSaved = objUpdate.UpdateVoucherInformation(obj, tran);
                if (isSaved == true)
                {
                    AuditTrailBLL objAt   = new AuditTrailBLL();
                    string        AppMode = WFStepsName.EditVoucherInfo.ToString();
                    atStatus = objAt.saveAuditTrail(objEdit, obj, AppMode, UserBLL.GetCurrentUser(), "UpdateVoucher");
                    if (atStatus == 1)
                    {
                        tran.Commit();
                    }
                    else
                    {
                        tran.Rollback();
                    }
                }
                else
                {
                    tran.Rollback();
                    tran.Dispose();
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                tran.Dispose();
                conn.Close();
            }
            return(isSaved);
        }