Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Page.IsPostBack == false)
     {
         this.Page.DataBind();
         if (Session["SamplingId"] != null)
         {
             Guid Id = Guid.Empty;
             Id = new Guid(Session["SamplingId"].ToString());
             Session["SamplingId"] = null;
             if (Id != Guid.Empty)
             {
                 SamplingBLL obj = new SamplingBLL();
                 obj    = obj.GetSampleDetail(Id);
                 obj.Id = Id;
                 if (obj != null)
                 {
                     this.lblSampleCode.Text       = obj.SampleCode;
                     this.txtDateCodeGenrated.Text = obj.GeneratedTimeStamp.ToShortDateString();
                     this.txtTimeArrival.Text      = obj.GeneratedTimeStamp.ToShortTimeString();
                     ViewState["SamplingId"]       = Id;
                     CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                     objCDR = objCDR.GetCommodityDepositeDetailById(obj.ReceivigRequestId);
                     if (objCDR != null)
                     {
                         lblArrivalDate.Text = objCDR.DateTimeRecived.ToShortDateString();
                     }
                 }
             }
         }
     }
 }
Example #2
0
        private void LoadDepositeRequest(Guid commDepositeId)
        {
            CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();

            objCDR = objCDR.GetCommodityDepositeDetailById(commDepositeId);
            if (objCDR != null)
            {
                this.lblProductionYear.Text    = objCDR.ProductionYear.ToString();
                this.lblDateRecived.Text       = objCDR.DateTimeRecived.ToString();
                this.lblTrackingNo.Text        = objCDR.TrackingNo;
                this.hfReceivigRequestId.Value = commDepositeId.ToString();
                this.hfWarehouseId.Value       = objCDR.WarehouseId.ToString();
                LoadClient(objCDR.ClientId);
                Guid coffeeId = (Guid)WarehouseApplication.BLL.Utility.GetCommodityId("Coffee");
                if (objCDR.CommodityId == coffeeId)
                {
                    LoadVoucherInformation(commDepositeId);
                    ViewState["hasVoucher"] = true;
                }
                else
                {
                    ViewState["hasVoucher"] = false;
                }
            }
        }
Example #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool isSaved  = false;
            Guid ClientId = Guid.Empty;
            CommodityDepositeRequestBLL objOld = (CommodityDepositeRequestBLL)ViewState["CommDepOld"];

            if (string.IsNullOrEmpty(this.ClientSelector1.ClientGUID.Value.ToString()))
            {
                ClientId = new Guid(this.hfClientId.Value.ToString());
            }
            else
            {
                ClientId = new Guid(this.ClientSelector1.ClientGUID.Value.ToString());
            }
            CommodityDepositeRequestBLL obj = new CommodityDepositeRequestBLL();
            Guid  CommDepId  = new Guid(hfCommodityDepositeId.Value.ToString());
            Guid  CommdityId = new Guid(cboCommodity.SelectedValue.ToString());
            Guid  WoredaId   = new Guid(cboWoreda.SelectedValue.ToString());
            Guid  RepId      = Guid.NewGuid();
            int   Prodyear   = int.Parse(cboProductionYear.SelectedValue.ToString());
            float weight     = 0;

            if (txtWeight.Text != "")
            {
                weight = float.Parse(txtWeight.Text);
            }
            int NoBags = 0;

            if (txtNumberOfBags.Text != "")
            {
                NoBags = int.Parse(this.txtNumberOfBags.Text);
            }
            DateTime dtRecivedDate = Convert.ToDateTime(dtDateTimeRecived.Text + " " + this.txtTimeArrival.Text);
            string   remark        = this.txtRemark.Text;
            int      Status        = int.Parse(this.cboStatus.SelectedValue.ToString());

            int prodYear = int.Parse(cboProductionYear.SelectedValue.ToString());

            try
            {
                isSaved = obj.EditCommodityDepositRequest(ClientId, CommDepId, CommdityId, RepId, Prodyear,
                                                          WoredaId, weight, NoBags, dtRecivedDate, remark, Status, UserBLL.GetCurrentUser(), objOld);
            }
            catch (GRNNotOnUpdateStatus ex)
            {
                this.lblmsg.Text = ex.msg;
                return;
            }
            if (isSaved == true)
            {
                this.lblmsg.Text = "Data Updated Sucessfully";
                LoadData(CommDepId);
            }
            else
            {
                this.lblmsg.Text = "Unable to Updated data.";
            }
        }
Example #4
0
        public static List <CommodityDepositeRequestBLL> SearchCommodityDeposite(string TrackingNo, string VoucherNo, Nullable <Guid> Clientid, Nullable <Guid> CommodityId, Nullable <DateTime> from, Nullable <DateTime> to)
        {
            List <CommodityDepositeRequestBLL> list = new List <CommodityDepositeRequestBLL>();
            string        strSql = SearchHelper(TrackingNo, VoucherNo, Clientid, CommodityId, from, to);
            DataSet       dsCommodityDepositeRequest = null;
            SqlConnection conn = Connection.getConnection();

            try
            {
                dsCommodityDepositeRequest = SqlHelper.ExecuteDataset(conn, CommandType.Text, strSql);
                if (dsCommodityDepositeRequest.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; dsCommodityDepositeRequest.Tables[0].Rows.Count > i; i++)
                    {
                        DataRow row;
                        row = dsCommodityDepositeRequest.Tables[0].Rows[i];
                        CommodityDepositeRequestBLL obj = new CommodityDepositeRequestBLL();
                        if (row["Id"] != null)
                        {
                            obj.Id = new Guid(row["Id"].ToString());
                        }
                        obj.TrackingNo = row["TransactionId"].ToString();
                        if (row["ClientId"] != null)
                        {
                            obj.ClientId = new Guid(row["ClientId"].ToString());
                        }
                        if (row["VoucherNo"] != null)
                        {
                            obj.VoucherNo = row["VoucherNo"].ToString();
                        }
                        if (row["CommodityId"] != null)
                        {
                            obj.CommodityId = new Guid(row["CommodityId"].ToString());
                        }
                        if (row["DateTimeRecived"] != null)
                        {
                            obj.DateTimeRecived = Convert.ToDateTime(row["DateTimeRecived"].ToString());
                        }

                        list.Add(obj);
                    }
                    return(list);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
Example #5
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            List <CommodityDepositeRequestBLL> list = new List <CommodityDepositeRequestBLL>();
            CommodityDepositeRequestBLL        obj  = new CommodityDepositeRequestBLL();
            string          strTrackingNo           = this.txtTrackingNumber.Text;
            string          strVoucherNo            = this.txtVoucherNo.Text;
            Nullable <Guid> ClientId = null;

            if (this.ClientSelector1.ClientGUID.Value.ToString() != "")
            {
                ClientId = new Guid(this.ClientSelector1.ClientGUID.Value.ToString());
            }
            Nullable <Guid> CommodityId = null;

            if (this.cboCommodity.SelectedValue != "")
            {
                CommodityId = new Guid(this.cboCommodity.SelectedValue);
            }
            Nullable <DateTime> from = null;

            if (this.dtFrom.Text != "")
            {
                from = Convert.ToDateTime(this.dtFrom.Text);
            }
            Nullable <DateTime> to = null;

            if (this.dtTo.Text != "")
            {
                to = Convert.ToDateTime(this.dtTo.Text);
            }
            //Check at least one search parameter is provided.
            if (strTrackingNo == "" && strVoucherNo == "" && ClientId == null && CommodityId == null && from == null && to == null)
            {
                this.lblMsg.Text = "Please provide at least one search Criteria";
                return;
            }

            list = obj.SearchCommodityDeposite(strTrackingNo, strVoucherNo, ClientId, CommodityId, from, to);
            ViewState["list"] = list;


            if (list != null)
            {
                this.lblMsg.Text = "";
                this.gvDepositeRequetsList.DataSource = list;
                this.gvDepositeRequetsList.DataBind();
                if (list.Count == 0)
                {
                    lblMsg.Text = "No record found";
                }
            }
            else
            {
                lblMsg.Text = "No record found";
            }
        }
Example #6
0
        private void LoadDepositeRequest(Guid commDepositeId)
        {
            CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();

            objCDR = objCDR.GetCommodityDepositeDetailById(commDepositeId);
            if (objCDR != null)
            {
                //this.lblProductionYear.Text = objCDR.ProductionYear.ToString();
                this.lblDateRecived.Text       = objCDR.DateTimeRecived.ToString();
                this.lblTrackingNo.Text        = objCDR.TrackingNo;
                this.hfReceivigRequestId.Value = commDepositeId.ToString();
                this.hfWarehouseId.Value       = objCDR.WarehouseId.ToString();
                LoadClient(objCDR.ClientId);
            }
        }
Example #7
0
        private void LoadCommodity()
        {
            Guid GradingId = Guid.Empty;

            try
            {
                GradingId = new Guid(this.cboGradingCode.SelectedValue.ToString());
            }
            catch
            {
                this.lblMsg.Text = "Please Select Grading Code.";
                return;
            }
            if (GradingId == Guid.Empty)
            {
                this.lblMsg.Text = "Please Select Grading Code.";
                return;
            }
            GradingBLL objGrading = new GradingBLL();

            objGrading = objGrading.GetById(GradingId);
            Guid CommodityReciveingRequestId = Guid.Empty;

            if (objGrading != null)
            {
                CommodityReciveingRequestId = objGrading.CommodityRecivingId;
            }
            else
            {
                this.lblMsg.Text = "An error has occured please Try again.";
                return;
            }
            if (CommodityReciveingRequestId != Guid.Empty)
            {
                CommodityDepositeRequestBLL objCommDepReq = new CommodityDepositeRequestBLL();
                objCommDepReq = objCommDepReq.GetCommodityDepositeDetailById(CommodityReciveingRequestId);
                if (objCommDepReq != null)
                {
                    if (objCommDepReq.CommodityId != null)
                    {
                        this.cboCommodity_CascadingDropDown.ContextKey    = objCommDepReq.CommodityId.ToString();
                        this.cboCommodity_CascadingDropDown.SelectedValue = objCommDepReq.CommodityId.ToString();
                        this.cboCommodity.SelectedValue = objCommDepReq.CommodityId.ToString();
                        LoadGradingFactors(objCommDepReq.CommodityId);
                    }
                }
            }
        }
Example #8
0
        public static int UpdateCommodityDepositeRequest(CommodityDepositeRequestBLL objCommDepoReq, SqlTransaction tran)
        {
            int    AffectedRows;
            string strSql = "spEditCommodityDepositeRequest";

            SqlParameter[] arPar = new SqlParameter[12];

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

            arPar[1]       = new SqlParameter("@Commodity", SqlDbType.UniqueIdentifier);
            arPar[1].Value = objCommDepoReq.CommodityId;

            arPar[2]       = new SqlParameter("@RepresentativeId", SqlDbType.UniqueIdentifier);
            arPar[2].Value = objCommDepoReq.RepresentativeId;

            arPar[3]       = new SqlParameter("@ProductionYear", SqlDbType.Int);
            arPar[3].Value = objCommDepoReq.ProductionYear;

            arPar[4]       = new SqlParameter("@Woreda", SqlDbType.UniqueIdentifier);
            arPar[4].Value = objCommDepoReq.WoredaId;

            arPar[5]       = new SqlParameter("@Weight", SqlDbType.Float);
            arPar[5].Value = objCommDepoReq.Weight;

            arPar[6]       = new SqlParameter("@NumberofBags", SqlDbType.Int);
            arPar[6].Value = objCommDepoReq.NumberofBags;

            arPar[7]       = new SqlParameter("@DateTimeRecived", SqlDbType.DateTime);
            arPar[7].Value = objCommDepoReq.DateTimeRecived;

            arPar[8]       = new SqlParameter("@Remark", SqlDbType.Text);
            arPar[8].Value = objCommDepoReq.Remark;

            arPar[9]       = new SqlParameter("@Status", SqlDbType.Int);
            arPar[9].Value = objCommDepoReq.Status;

            arPar[10]       = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier);
            arPar[10].Value = objCommDepoReq.LastModifiedBy;

            arPar[11]       = new SqlParameter("@ClientId", SqlDbType.UniqueIdentifier);
            arPar[11].Value = objCommDepoReq.ClientId;

            AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar);
            return(AffectedRows);
        }
Example #9
0
        private void CoffeeCodingReport_ReportStart(object sender, EventArgs e)
        {
            Guid       CommodityDepositeId = Guid.Empty;
            Guid       WoredaId            = Guid.Empty;
            GradingBLL objCode             = new GradingBLL();

            if (HttpContext.Current.Session["CodeReport"] != null)
            {
                objCode = (GradingBLL)HttpContext.Current.Session["CodeReport"];
            }
            else
            {
                throw new Exception("Session expired.");
            }
            if (objCode != null)
            {
                this.txtDateCoded.Text = objCode.DateCoded.ToString("dd MMM-yyyy");
                this.txtCode.Text      = objCode.GradingCode.ToString();
                CommodityDepositeId    = objCode.CommodityRecivingId;
            }
            if (CommodityDepositeId != Guid.Empty)
            {
                CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                objCDR = objCDR.GetCommodityDepositeDetailById(CommodityDepositeId);
                if (objCDR != null)
                {
                    WoredaId = objCDR.WoredaId;
                    WoredaBLL objWoreda = new WoredaBLL();
                    objWoreda = objWoreda.GetWoredabyId(WoredaId);
                    if (objWoreda != null)
                    {
                        this.txtOrigin.Text = objWoreda.WoredaName;
                    }
                }
            }
            this.txtDateGenerated.Text = DateTime.Now.ToString("dd MMM-yyyy");


            conn = Connection.getConnection();
            GradingByBLL objGradersReader = new GradingByBLL();

            reader = objGradersReader.GetGradersByGradingIdDataReader(objCode.Id, conn);
        }
Example #10
0
        protected void btnGenerateSampleTicket_Click(object sender, EventArgs e)
        {
            //

            Nullable <Guid> Id;
            Guid            WarehouseId        = UserBLL.GetCurrentWarehouse();
            Guid            Moistureid         = Guid.Empty;
            bool            isMoisture         = false;
            string          TransactionId      = String.Empty;
            Nullable <Guid> RecievingRequestId = null;

            try
            {
                if (this.chkReSampling.Checked == false)
                {
                    RecievingRequestId = SamplingBLL.GetRandomSample(WarehouseId);
                    isMoisture         = false;
                }
                else
                {
                    try
                    {
                        RecievingRequestId = SamplingBLL.GetRandomReSampling(WarehouseId, out Moistureid, out TransactionId);
                    }
                    catch (Exception ex)
                    {
                        this.lblMsg.Text = ex.Message;
                    }
                    isMoisture = true;
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
                return;
            }
            if (RecievingRequestId == null)
            {
                this.lblMsg.Text = "There are no records Pending Sampling";
                return;
            }

            Nullable <int> SerialNo  = null;
            SamplingBLL    objSample = new SamplingBLL();

            SerialNo = objSample.GetSerialNo(WarehouseId);
            if (SerialNo == null)
            {
                throw new Exception("Inavlid Serial No. exception");
            }
            // Create sampling obect

            SamplingBLL objSampling = new SamplingBLL();

            objSampling.ReceivigRequestId = (Guid)RecievingRequestId;
            objSampling.SamplingStatusId  = SamplingStatus.Active;
            objSampling.SerialNo          = SamplingBLL.GetSerial(WarehouseId);
            objSampling.WarehouseId       = WarehouseId;

            CommodityDepositeRequestBLL objCommDep = new CommodityDepositeRequestBLL();

            objCommDep = objCommDep.GetCommodityDepositeDetailById((Guid)RecievingRequestId);
            if (objCommDep != null)
            {
                if (string.IsNullOrEmpty(objCommDep.TrackingNo) == true)
                {
                    this.lblMsg.Text = "Can not get Tracking Number.Please try again.";
                    return;
                }
                else
                {
                    if (isMoisture == false)
                    {
                        objSampling.TrackingNo = objCommDep.TrackingNo;
                    }
                    else
                    {
                        objSampling.TrackingNo = TransactionId;
                    }
                }
            }
            else
            {
                throw new Exception("Unable to get Arrival Information CommDepId=" + RecievingRequestId.ToString());
            }

            //Create Sampler
            SamplerBLL objSampler = new SamplerBLL();

            try
            {
                objSampler.SamplerId = new Guid(this.cboSampler.SelectedValue.ToString());
            }
            catch
            {
                this.lblMsg.Text = "Please select Sampler";
                return;
            }

            objSampler.Status = SamplerStatus.Active;



            Id = objSampling.InsertSample(objSampling, objSampler, isMoisture);

            if (Id != null)
            {
                objSampling.Id = (Guid)Id;
                string tran = "";
                tran = SamplingBLL.GetTransactionNumber((Guid)RecievingRequestId);
                Session["Sampler"] = objSampler;
                Session["Sample"]  = objSampling;



                ScriptManager.RegisterStartupScript(this,
                                                    this.GetType(),
                                                    "ShowReport",
                                                    "<script type=\"text/javascript\">" +
                                                    string.Format("javascript:window.open(\"ReportSampleTicket.aspx?id={0}\", \"_blank\",\"height=400px,width=600px,top=0,left=0,resizable=yes,scrollbars=yes\");", Id.ToString()) +
                                                    "</script>",
                                                    false);
            }
            else
            {
                this.lblMsg.Text = "Data can not be saved.Please try again if the error persists contact the administrator.";
            }
        }
Example #11
0
        private void LoadData()
        {
            string str = "";
            Guid   Id;

            if (Session["GRID"] != null)
            {
                str = Session["GRID"].ToString();
            }
            if (str == "")
            {
                this.lblMsg.Text = "Unable to load data please try again.";
                return;
            }
            try
            {
                Id = new Guid(str);
                this.hfId.Value = Id.ToString();
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to Update Data.", ex);
            }
            GradingResultBLL obj = new GradingResultBLL();

            obj = obj.GetGradingResultById(Id);

            if (obj != null)
            {
                this.cboGradingRecivedStatus.SelectedValue = ((int)obj.Status).ToString();
            }
            lblGradingReceivedDate.Text = obj.GradeRecivedTimeStamp.ToShortDateString();
            cmpSampGen.ValueToCompare   = obj.GradeRecivedTimeStamp.ToShortDateString();
            if (obj.GradingCode != null)
            {
                this.lblGradeCode.Text = obj.GradingCode;
            }
            this.lblClient.Text = "";
            string cg = "";
            CommodityDepositeRequestBLL obCD = new CommodityDepositeRequestBLL();

            obCD = obCD.GetCommodityDepositeDetailById(obj.CommodityDepositRequestId);
            ClientBLL objClient = new ClientBLL();

            objClient = ClientBLL.GetClinet(obCD.ClientId);
            if (objClient != null)
            {
                this.lblClient.Text = objClient.ClientName;
            }
            else
            {
                this.lblMsg.Text = "Unable to load client Data.";
            }

            cg = CommodityGradeBLL.GetCommodityGradeNameById(obj.CommodityGradeId);
            this.lblCommodityGrade.Text = cg;
            if (((int)obj.Status == 3 || (int)obj.Status == 4) && obj.ClientAcceptanceTimeStamp != null)
            {
                this.cboAcceptanceStatus.SelectedValue = ((int)obj.Status).ToString();

                DateTime dtCA = DateTime.Now;
                if (obj.ClientAcceptanceTimeStamp == null)
                {
                    this.cboAcceptanceStatus.SelectedIndex = -1;
                }

                dtCA = (DateTime)obj.ClientAcceptanceTimeStamp;
                this.txtDateOfAcceptance.Text = dtCA.Date.ToShortDateString();
                this.txtTimeodAcceptance.Text = dtCA.ToLongTimeString();
                this.cboGradingRecivedStatus.SelectedValue = ((int)obj.GradingResult).ToString();
            }
        }
Example #12
0
        protected void btnComplete_Click(object sender, EventArgs e)
        {
            this.lblMessage.Text = "";
            Nullable <Guid> Id            = null;
            string          TransactionNo = "";

            TransactionNo = Request.QueryString["TranNo"];
            if (string.IsNullOrEmpty(TransactionNo))
            {
                return;
            }

            if (Session["CommodityRequestId"] == null)
            {
                CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();
                objCDR = objCDR.GetCommodityDepositeDetailByTrackingNo(TransactionNo);
                Id     = objCDR.Id;
                Session["CommodityRequestId"] = Id.ToString();
            }
            else
            {
                Id = new Guid(Session["CommodityRequestId"].ToString());
            }
            // if the Step is in Driver Info.
            //if (WFTransaction.GetMessage(TransactionNo) == "AddDriverInformation")
            //{
            //    WFTransaction.WorkFlowManager(TransactionNo);
            //}
            //Check if Driver Information is Added.
            List <DriverInformationBLL> listDriverInfo = null;
            DriverInformationBLL        objDriverInfo  = new DriverInformationBLL();

            if (Session["CommodityRequestId"] != null)
            {
                Guid CdrId = new Guid(Session["CommodityRequestId"].ToString());
                listDriverInfo = objDriverInfo.GetActiveDriverInformationByReceivigRequestId(CdrId);
                if (listDriverInfo == null)
                {
                    this.btnComplete.Enabled = false;
                }
                else
                {
                    if (listDriverInfo.Count <= 0)
                    {
                        this.btnComplete.Enabled = false;
                    }
                    else
                    {
                        if (Id != null)
                        {
                            ECXWF.CMessage msg = (ECXWF.CMessage)HttpContext.Current.Session["msg"];
                            if (msg != null)
                            {
                                if (msg.Name == "AddDriverInformation")
                                {
                                    WFTransaction.WorkFlowManager(TransactionNo);
                                    Response.Redirect("ListInbox.aspx");
                                }
                            }
                        }
                    }
                }
            }
        }
Example #13
0
        protected void btnGenerateCode_Click(object sender, EventArgs e)
        {
            bool isSaved = false;

            this.lblMsg.Text = "";
            string WarehouseNo;

            try
            {
                WarehouseNo = UserBLL.GetCurrentWarehouseCode();
            }
            catch
            {
                this.lblMsg.Text = "No warehouse code,please try agian.";
                return;
            }
            if (string.IsNullOrEmpty(WarehouseNo) == true)
            {
                this.lblMsg.Text = "No warehouse code,please try agian.";
                return;
            }
            if (string.IsNullOrEmpty(this.cboSampleCode.SelectedItem.Text) == true)
            {
                this.lblMsg.Text = "Please if the sample code exists";
                return;
            }

            string[] IdCollection = new string[3];
            IdCollection = this.cboSampleCode.SelectedValue.Split('/');
            Guid SamplingResultId  = Guid.Empty;
            Guid ReceivigRequestId = Guid.Empty;

            try
            {
                SamplingResultId  = new Guid(IdCollection[0].ToString());
                ReceivigRequestId = new Guid(IdCollection[1].ToString());
            }
            catch
            {
                this.lblMsg.Text = "Please if the sample code exists";
                return;
            }
            string     TrackingNo = IdCollection[2].ToString();
            DateTime   DateCoded  = DateTime.Parse(this.txtDateCodeGenrated.Text + " " + txtTimeArrival.Text);
            GradingBLL objGrading = new GradingBLL();

            if (SamplingResultId != Guid.Empty)
            {
                objGrading.SamplingResultId = SamplingResultId;
            }
            else
            {
                this.lblMsg.Text = "Please if the sample code exists";
                return;
            }
            if (ReceivigRequestId != Guid.Empty)
            {
                objGrading.CommodityRecivingId = ReceivigRequestId;
            }
            else
            {
                this.lblMsg.Text = "Please if the sample code exists";
                return;
            }
            objGrading.Status     = GradingStatus.Coded;
            objGrading.TrackingNo = TrackingNo;
            objGrading.CreatedBy  = UserBLL.GetCurrentUser();
            objGrading.DateCoded  = DateCoded;
            List <GradingByBLL> list = new List <GradingByBLL>();

            list = (List <GradingByBLL>)Session["Graders"];
            if (list == null)
            {
                this.lblMsg.Text = "Please provide graders.";
                return;
            }
            if (list.Count <= 0)
            {
                this.lblMsg.Text = "Please provide graders.";
                return;
            }
            if (isSingleSupervisorGrader(list) == false)
            {
                return;
            }
            Guid CommodityId = Guid.Empty;
            CommodityDepositeRequestBLL objCDR = new CommodityDepositeRequestBLL();

            objCDR = objCDR.GetCommodityDepositeDetailById(ReceivigRequestId);
            if (GradingByBLL.IsNumberofGraderAcceptable(list.Count, objCDR.CommodityId) == false)
            {
                this.lblMsg.Text = "The number of graders selected is less than the minimum required.";
                return;
            }

            if (list == null || list.Count <= 0)
            {
                this.lblMsg.Text = "Please add graders before generating code.";
                return;
            }
            if (this.hfTrackingNo.Value == "" || this.hfTrackingNo.Value == null)
            {
                this.lblMsg.Text = "An error has occured.";
                return;
            }
            isSaved = objGrading.Add(WarehouseNo, this.hfTrackingNo.Value.ToString(), list);
            if (isSaved == true)
            {
                // TODO Update a GridView dataBind and print the Coding Ticket.
                this.lblMsg.Text = "Data Added Successfully.";
                CommodityDepositeRequestBLL obj = new CommodityDepositeRequestBLL();
                Session["Graders"]       = null;
                this.gvGrader.DataSource = null;
                this.gvGrader.DataBind();
                this.pnlGradingDetail.Visible = false;
                this.btnGenerateCode.Visible  = false;
                LoadCode(objGrading.SamplingResultId);
            }
            else
            {
                this.lblMsg.Text = "Data can not be saved. Please check the data entered and try again.If the error persists, conatact the IT support.";
            }
        }
Example #14
0
        /// <summary>
        /// InsertCommodityDepositeRequest
        /// </summary>
        /// <param name="objCommDepoReq"></param>
        /// <returns>affected No</returns>
        public Guid  InsertCommodityDepositeRequest(CommodityDepositeRequestBLL objCommDepoReq, SqlTransaction tran)
        {
            string strSql = "spInsertCommodityDepositeRequest";

            SqlParameter[] arPar = new SqlParameter[14];

            arPar[0]       = new SqlParameter("@TransactionId", SqlDbType.NVarChar, 50);
            arPar[0].Value = objCommDepoReq.TransactionId;

            arPar[1]       = new SqlParameter("@ClientId", SqlDbType.UniqueIdentifier);
            arPar[1].Value = objCommDepoReq.ClientId;

            arPar[2]       = new SqlParameter("@CommodityId", SqlDbType.UniqueIdentifier);
            arPar[2].Value = objCommDepoReq.CommodityId;;

            arPar[3]       = new SqlParameter("@WarehouseId", SqlDbType.UniqueIdentifier);
            arPar[3].Value = objCommDepoReq.WarehouseId;

            arPar[4]       = new SqlParameter("@RepresentativeId", SqlDbType.UniqueIdentifier);
            arPar[4].Value = objCommDepoReq.RepresentativeId;

            arPar[5] = new SqlParameter("@WoredaId", SqlDbType.UniqueIdentifier);
            if (objCommDepoReq.WoredaId != Guid.Empty)
            {
                arPar[5].Value = objCommDepoReq.WoredaId;
            }
            else
            {
                arPar[5].Value = null;
            }

            arPar[6] = new SqlParameter("@productionYear", SqlDbType.Int);
            if (objCommDepoReq.ProductionYear != 0)
            {
                arPar[6].Value = objCommDepoReq.ProductionYear;
            }
            else
            {
                arPar[6].Value = null;
            }

            arPar[7]       = new SqlParameter("@Status", SqlDbType.Int);
            arPar[7].Value = objCommDepoReq.Status;

            arPar[8]       = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier);
            arPar[8].Value = objCommDepoReq.CreatedBy;



            arPar[9]       = new SqlParameter("@Remark", SqlDbType.Text);
            arPar[9].Value = objCommDepoReq.Remark;

            arPar[10]       = new SqlParameter("@Weight", SqlDbType.Decimal);
            arPar[10].Value = objCommDepoReq.Weight;

            arPar[11]       = new SqlParameter("@NumberofBags", SqlDbType.Int);
            arPar[11].Value = objCommDepoReq.NumberofBags;

            arPar[12]       = new SqlParameter("@DateTimeRecived", SqlDbType.DateTime);
            arPar[12].Value = objCommDepoReq.DateTimeRecived;
            int AffectedRows;

            arPar[13]           = new SqlParameter("@CommodityDepositRequestId", SqlDbType.UniqueIdentifier);
            arPar[13].Direction = ParameterDirection.Output;
            try
            {
                AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar);
            }
            catch (Exception ex)
            {
                throw new Exception("Can not update the database.", ex);
            }
            Guid CommodityDepositRequestId = new Guid();

            CommodityDepositRequestId = (Guid)arPar[13].Value;
            return(CommodityDepositRequestId);
        }
Example #15
0
        private void LoadData(Guid Id)
        {
            //get The Id from the qs

            //Get the Commodity  deposite Request form.
            CommodityDepositeRequestBLL objEdit       = new CommodityDepositeRequestBLL();
            CommodityDepositRequest     objCommDepReq = new CommodityDepositRequest();
            DataSet dsResult = new DataSet();

            objEdit.Id = Id;
            dsResult   = objCommDepReq.getCommodityDepositRequestById(Id);
            Guid ClientGuid = new Guid(dsResult.Tables[0].Rows[0]["ClientId"].ToString());

            objEdit.ClientId          = ClientGuid;
            this.hfClientId.Value     = ClientGuid.ToString();
            this.txtNumberOfBags.Text = dsResult.Tables[0].Rows[0]["NumberofBags"].ToString();
            objEdit.NumberofBags      = int.Parse((dsResult.Tables[0].Rows[0]["NumberofBags"].ToString()));
            float weight = float.Parse(dsResult.Tables[0].Rows[0]["Weight"].ToString());

            if (weight == 0)
            {
                this.txtWeight.Text = "";
            }
            else
            {
                this.txtWeight.Text = dsResult.Tables[0].Rows[0]["Weight"].ToString();
            }
            objEdit.Weight                      = float.Parse(dsResult.Tables[0].Rows[0]["Weight"].ToString());
            this.txtRemark.Text                 = dsResult.Tables[0].Rows[0]["Remark"].ToString();
            objEdit.Remark                      = this.txtRemark.Text;
            this.dtDateTimeRecived.Text         = Convert.ToDateTime(dsResult.Tables[0].Rows[0]["DateTimeRecived"]).ToShortDateString();
            this.txtTimeArrival.Text            = Convert.ToDateTime(dsResult.Tables[0].Rows[0]["DateTimeRecived"]).ToLongTimeString();
            objEdit.DateTimeRecived             = Convert.ToDateTime((dsResult.Tables[0].Rows[0]["DateTimeRecived"]).ToString());
            this.cboReprsentative.SelectedValue = dsResult.Tables[0].Rows[0]["RepresentativeId"].ToString();
            objEdit.RepresentativeId            = Guid.Empty;
            if (dsResult.Tables[0].Rows[0]["WoredaId"] != DBNull.Value)
            {
                this.cboWoreda.SelectedValue = dsResult.Tables[0].Rows[0]["WoredaId"].ToString();
                objEdit.WoredaId             = new Guid(dsResult.Tables[0].Rows[0]["WoredaId"].ToString());
            }
            this.cboStatus.SelectedValue = dsResult.Tables[0].Rows[0]["Status"].ToString();
            objEdit.Status = int.Parse(dsResult.Tables[0].Rows[0]["Status"].ToString());
            //if (Convert.ToInt32((this.cboStatus.SelectedValue)) == 0 )
            //{
            //    //this.btnEdit.Enabled = false;
            //}
            // Display the Client Id from this
            // Id = dsResult.Tables[0].Rows[0]["ClientId"].ToString();

            ECXLookUp.ECXLookup objLookUp = new WarehouseApplication.ECXLookUp.ECXLookup();
            //Populate Drop down from server cboCommodity
            this.cboCommodity.AppendDataBoundItems = true;
            ECXLookUp.CCommodity[] objCommodity = objLookUp.GetActiveCommodities(WarehouseApplicationConfiguration.GetWorkingLanguage());
            this.cboCommodity.DataSource     = objCommodity;
            this.cboCommodity.DataTextField  = "Name";
            this.cboCommodity.DataValueField = "UniqueIdentifier";
            this.cboCommodity.DataBind();
            this.cboCommodity.SelectedValue = dsResult.Tables[0].Rows[0]["CommodityId"].ToString();
            objEdit.CommodityId             = new Guid(dsResult.Tables[0].Rows[0]["CommodityId"].ToString());
            //Populate Region
            //ECXLookUp.CRegion[] objRegion = objLookUp.GetActiveRegions(WarehouseApplicationConfiguration.GetWorkingLanguage());
            //this.cboRegion.DataSource = objRegion;
            //this.cboRegion.DataTextField = "Name";
            //this.cboRegion.DataValueField = "UniqueIdentifier";
            //this.cboRegion.DataBind();


            string SelectedWoreda = "";

            SelectedWoreda = dsResult.Tables[0].Rows[0]["WoredaId"].ToString();


            if (SelectedWoreda != "")
            {
                ECXLookUp.CWoreda objWoreda     = objLookUp.GetWoreda(WarehouseApplicationConfiguration.GetWorkingLanguage(), new Guid(SelectedWoreda));
                Guid            SelectedZone    = new Guid(objWoreda.ZoneUniqueIdentifier.ToString());
                ECXLookUp.CZone objZoneSelected = objLookUp.GetZone(WarehouseApplicationConfiguration.GetWorkingLanguage(), SelectedZone);
                Guid            SelectedRegion  = new Guid(objZoneSelected.RegionUniqueIdentifier.ToString());
                this.cboRegion_CascadingDropDown.SelectedValue = SelectedRegion.ToString();
                this.cboZone_CascadingDropDown.SelectedValue   = SelectedZone.ToString();
                this.cboWoreda_CascadingDropDown.SelectedValue = SelectedWoreda;
            }



            // Bind Clinet
            ClientBLL objClient = new ClientBLL();

            objClient = ClientBLL.GetClinet(ClientGuid);

            if (objClient != null)
            {
                this.txtClient.Text    = objClient.ClientName + " - " + objClient.ClientId;
                this.txtClient.Enabled = false;
            }


            //Populate the Production Year
            // set because we will not have Production year no latter than 2007
            string strSelectedYear = dsResult.Tables[0].Rows[0]["ProductionYear"].ToString();
            int    currYear        = int.Parse(ConfigurationSettings.AppSettings["CurrentEthiopianYear"]);

            this.cboProductionYear.Items.Add(new ListItem("Please Select Production Year.", ""));
            this.cboProductionYear.AppendDataBoundItems = true;
            if (strSelectedYear != "")
            {
                if (int.Parse(strSelectedYear) < currYear - 2)
                {
                    this.cboProductionYear.Items.Add(new ListItem(strSelectedYear, strSelectedYear));
                }
            }
            for (int i = currYear - 2; i <= currYear; i++)
            {
                this.cboProductionYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
            this.cboProductionYear.SelectedValue = dsResult.Tables[0].Rows[0]["ProductionYear"].ToString();
            if (dsResult.Tables[0].Rows[0]["ProductionYear"] != DBNull.Value)
            {
                objEdit.ProductionYear = int.Parse(dsResult.Tables[0].Rows[0]["ProductionYear"].ToString());
            }
            ViewState["CommDepOld"] = objEdit;
        }
Example #16
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.lblMessage.Text = "";

            if (this.btnSave.Text == "Save")
            {
                string TransactionNo     = "";
                Guid   TransactionTypeId = Guid.Empty;
                Guid   CommodityGuid     = Guid.Empty;

                Guid            ClientId, CommodityId, WarehouseId, CreatedBY;
                Guid            RepId, WoredaId;
                DateTime        DateTimeRecived;
                float           Weight;
                int             Year, NumberOfBags;
                string          Remark, TransactionId;
                int             Status; // Status - 1= new
                Nullable <Guid> Id;
                //NoClient
                ClientId = new Guid(this.ClientSelector1.ClientGUID.Value.ToString());
                try
                {
                    ClientId = new Guid(this.ClientSelector1.ClientGUID.Value.ToString());
                }
                catch
                {
                    this.lblMessage.Text = "Please Select Client";
                    return;
                }

                //NoClient
                //Check if ClientId is Empty.
                if (ClientId != Guid.Empty)
                {
                    if (!(string.IsNullOrEmpty(this.cboCommodity.SelectedValue)))
                    {
                        CommodityGuid = new Guid(this.cboCommodity.SelectedValue);
                        try
                        {
                            TransactionTypeId = TransactionTypeProvider.GetTransactionTypeId(CommodityGuid);
                        }
                        catch (InvalidTransactionType ex)
                        {
                            this.lblMessage.Text = ex.msg;
                            return;
                        }
                    }
                    else
                    {
                        TransactionTypeId = TransactionTypeProvider.GetTransactionTypeId("RegularGrainTypeId");
                    }
                }
                else
                {
                    TransactionTypeId = TransactionTypeProvider.GetTransactionTypeId(Guid.Empty);
                }



                Status = 1;// Approved Status



                try
                {
                    CommodityId = new Guid(this.cboCommodity.SelectedValue.ToString());
                }
                catch
                {
                    this.lblMessage.Text = "Please Select Commodity";
                    return;
                }


                try
                {
                    WarehouseId = new Guid(this.cboWarehouse.SelectedValue.ToString());// Should be Non selectable.
                }
                catch
                {
                    this.lblMessage.Text = "Please Select Warehouse";
                    return;
                }

                try
                {
                    WoredaId = new Guid(this.cboWoreda.SelectedValue.ToString());
                }
                catch
                {
                    WoredaId = Guid.Empty;
                }

                try
                {
                    Year = Convert.ToInt32(this.cboProductionYear.SelectedValue.ToString());
                }
                catch
                {
                    Year = 0;
                }
                Remark = this.txtRemark.Text;


                float.TryParse(this.txtWeight.Text, out Weight);

                int.TryParse(this.txtNumberOfBags.Text, out NumberOfBags);


                try
                {
                    DateTimeRecived = Convert.ToDateTime(this.txtArrivalDate.Text + " " + this.txtTimeArrival.Text);
                }
                catch
                {
                    this.lblMessage.Text = "Please enter the correct date time format.";
                    return;
                }

                // get from Workflow
                TransactionId = TransactionNo;//WFTransaction.GetTransaction();
                CreatedBY     = UserBLL.GetCurrentUser();
                //TO DO Remove this.
                RepId = new Guid();
                CommodityDepositeRequestBLL objSave = new CommodityDepositeRequestBLL();
                objSave.ClientId         = ClientId;
                objSave.CommodityId      = CommodityId;
                objSave.WarehouseId      = WarehouseId;
                objSave.RepresentativeId = RepId;
                objSave.WoredaId         = WoredaId;
                objSave.ProductionYear   = Year;
                objSave.NumberofBags     = NumberOfBags;
                objSave.DateTimeRecived  = DateTimeRecived;
                objSave.Weight           = Weight;
                objSave.Remark           = Remark;
                objSave.Status           = Status;
                objSave.CreatedBy        = CreatedBY;

                Id = objSave.AddCommodityDepositRequest(TransactionTypeId);

                if (Id != null)
                {
                    Session["CommodityRequestId"] = Id.ToString();
                    this.btnSave.CausesValidation = false;
                    this.lblMessage.Text          = "Data Added Sucessfully.";
                    this.btnSave.Text             = "Next";
                    //StringBuilder sb = new StringBuilder();
                    //sb.Append("<script>");
                    //sb.Append("window.open('ReportTrackingNumber.aspx");
                    //sb.Append("', '', '');");
                    //sb.Append("location.href='ListInbox.aspx';");
                    //sb.Append("</scri");
                    //sb.Append("pt>");
                    ////Page.ClientScript.RegisterStartupScript(GetType(), "js", sb.ToString());
                    //ScriptManager.RegisterStartupScript(this, typeof(Page), "win", sb.ToString(), false);
                    //return;
                    ////Response.Redirect("~/PageSwicther.aspx?TranNo=" + TransactionNo);

                    ScriptManager.RegisterStartupScript(this,
                                                        this.GetType(),
                                                        "ShowReport",
                                                        "<script type=\"text/javascript\">" +
                                                        string.Format("javascript:window.open(\"ReportTrackingNumber.aspx?id={0}\", \"_blank\",\"height=400px,width=600px,top=0,left=0,resizable=yes,scrollbars=yes\");", Guid.NewGuid()) +
                                                        "</script>",
                                                        false);
                }
                else
                {
                    this.lblMessage.Text = "Error Saving Request!";
                }
            }
            else
            {
                string trackingNo = Session["TransactionNo"].ToString();
                Session["TransactionNo"] = null;
                Response.Redirect("ListInbox.aspx");
            }
        }