Example #1
0
        /// <summary>
        /// Populate information inserted at previous stages like cdr and Grading stages
        /// and display it as a table inside gridview. It uses on stored procedure to populate data
        /// </summary>
        private void LoadDisplayInfo(string GradingCode)
        {
            try
            {
                GRN_BL obj = new BLL.GRN_BL();

                DataTable dt = obj.GetDisplayInfoByGradingCode(GradingCode);
                grdDisplayInfo.DataSource = dt;
                grdDisplayInfo.DataBind();
                //If coffee then change lable to Kg. Else change label to Qtl.
                if (dt.Rows[0]["CommodityId"].ToString() == "71604275-df23-4449-9dae-36501b14cc3b")
                {
                    lblUnit1.Text = "Kg.";
                    lblUnit2.Text = "Kg.";
                }
                else
                {
                    lblUnit1.Text = "Qtl.";
                    lblUnit2.Text = "Qtl.";
                }
                GRNStatusNew status;
                GRNStatusNew.TryParse((dt.Rows[0]["status"].ToString()), out status);

                if (status == GRNStatusNew.New || status == GRNStatusNew.NotCreated)
                {
                    btnSave.Enabled = true;
                }
                else
                {
                    btnSave.Enabled = false;
                    btnSave.ToolTip = "Can't Update GRN because it is at " + status.ToString() + " Stage";
                }
                ViewState["WarehouseId"]    = dt.Rows[0]["WarehouseId"].ToString();
                ViewState["ProductionYear"] = dt.Rows[0]["Pro_Year"].ToString();

                Session["ArrivalId_GRN"]        = new Guid(dt.Rows[0]["ArrivalId"].ToString());
                Session["GradeId_GRN"]          = new Guid(dt.Rows[0]["GradeId"].ToString());
                Session["CommodityGradeId_GRN"] = new Guid(dt.Rows[0]["CommodityGradeId"].ToString());
                Session["ShedId_GRN"]           = new Guid(dt.Rows[0]["ShedId"].ToString());
                Session["LICID_GRN"]            = new Guid(dt.Rows[0]["LICID"].ToString());

                hdnTare.Value = dt.Rows[0]["Tare"].ToString();
                ViewState["CommodityGradeId"] = dt.Rows[0]["CommodityGradeId"].ToString();
                ViewState["TrackingNumber"]   = dt.Rows[0]["TrackingNumber"].ToString();
                ViewState["GRNID"]            = dt.Rows[0]["GRNID"].ToString();

                BagTypeId = new Guid(dt.Rows[0]["BagTypeId"].ToString());
                txtClientAcceptanceDate.Text  = DateTime.Parse(dt.Rows[0]["ClientAcceptanceDate"].ToString()).ToString("g");
                hdnClientAcceptanceDate.Value = DateTime.Parse(dt.Rows[0]["ClientAcceptanceDate"].ToString()).ToShortDateString();
                string TrackingNumber = ViewState["TrackingNumber"].ToString();
                PopulateSameGradingGrid(TrackingNumber);
            }
            catch
            {
                Messages.SetMessage("Failed to load existing information!");
            }
        }
Example #2
0
        /// <summary>
        /// Populates existing information for update purpose, if it is text box then it fills the value
        /// if it is dropdown list then it chooses from one of the alternatives supplied by FillControls() method
        /// </summary>
        private void PopulateExistingData()
        {
            //if (theArrival.IsNew) return;
            GRNStatusNew GRNStatus;

            GRNStatusNew.TryParse(theArrival.GRNStatus.ToString(), out GRNStatus);
            if (GRNStatus == GRNStatusNew.New || GRNStatus == GRNStatusNew.NotCreated)
            {
                btnSave.Enabled = true;
            }
            else
            {
                btnSave.Enabled = false;
                btnSave.ToolTip = "Can't Update Arrival because this step is at " + GRNStatus.ToString() + " Stage";
            }
            if (theArrival.WarehouseID != WarehouseBLL.CurrentWarehouse.WarehouseId)
            {
                Response.Redirect("ErrorPage.aspx");
            }
            try
            {
                lblClient.Text             = theArrival.ClientName;
                lblWarehouse.Text          = WarehouseBLL.CurrentWarehouse.WarehouseName;
                isNonTruck.Checked         = theArrival.IsNonTruck;
                cboCommodity.SelectedValue = theArrival.CommodityID.ToString();
                //chkIsSourceDetermined.Checked = theArrival.IsLocationKnown;
                if (!theArrival.IsLocationKnown)
                {
                    cboRegion.SelectedValue = Guid.Empty.ToString();
                }
                else
                {
                    LookupValue lv = SimpleLookup.Lookup(LookupTypeEnum.Woredas).GetDictionary()[theArrival.WoredaID];
                    cboRegion.SelectedValue = lv.RegionID.ToString();
                    cboRegion_SelectedIndexChanged(this, EventArgs.Empty);
                    cboZone.SelectedValue = lv.ZoneID.ToString();
                    cboZone_SelectedIndexChanged(this, EventArgs.Empty);
                    cboWoreda.SelectedValue = theArrival.WoredaID.ToString();
                    txtSpecificArea.Text    = theArrival.SpecificArea;
                }
                cboProductionYear.SelectedValue = theArrival.ProductionYear.ToString();
                txtProcessingCenter.Text        = theArrival.ProcessingCenter;
                txtNumberOfBags.Text            = theArrival.NumberofBags.ToString() == "0" ? "" : theArrival.NumberofBags.ToString();
                txtWeight.Text = theArrival.VoucherWeight.ToString() == "0" ? "" : theArrival.VoucherWeight.ToString();

                if ("1/1/1901" == theArrival.DateTimeReceived.ToShortDateString() || theArrival.DateTimeReceived.ToShortDateString() == "1/1/0001")
                {
                    txtArrivalDate.Text = "";
                    txtTimeArrival.Text = "";
                }
                else
                {
                    txtArrivalDate.Text = theArrival.DateTimeReceived.ToShortDateString();
                    txtTimeArrival.Text = theArrival.DateTimeReceived.ToShortTimeString();
                }
                txtRemark.Text = theArrival.Remark;
                if (!theArrival.IsNonTruck)
                {
                    chkIsTruckInCompound.Checked = theArrival.IsTruckInCompound;
                    txtDriverName.Text           = theArrival.DriverName;
                    txtLicenseNo.Text            = theArrival.LicenseNumber;
                    txtPlaceIssued.Text          = theArrival.LicenseIssuedPlace;
                    txtPlateNo.Text         = theArrival.TruckPlateNumber;
                    txtTrailerPlateNo.Text  = theArrival.TrailerPlateNumber;
                    txtNoPlomps.Text        = theArrival.VoucherNumberOfPlomps.ToString() == "0" ? "" : theArrival.VoucherNumberOfPlomps.ToString();
                    txtTrailerNoPlomps.Text = theArrival.VoucherNumberOfPlompsTrailer.ToString() == "0" ? "" : theArrival.VoucherNumberOfPlompsTrailer.ToString();
                }
                txtVoucherNo.Text   = theArrival.VoucherNumber;
                hdnHasVoucher.Value = theArrival.HasVoucher.ToString();
                //chkIsBiProduct.Checked = theArrival.IsBiProduct;
                if (Guid.Empty == theArrival.VoucherCommodityTypeID || string.IsNullOrEmpty(theArrival.VoucherCommodityTypeID.ToString()))
                {
                    cboCommodityType.SelectedIndex = 0;
                    cboCommodityType.Enabled       = false;
                }
                else
                {
                    cboCommodityType.SelectedValue = theArrival.VoucherCommodityTypeID.ToString();
                }
            }
            catch (Exception ex)
            {
                //lblMessage.Text = "Failed to populate existing data!";

                Messages.SetMessage("Existing data cannot be retrieved.  Please try again.", WarehouseApplication.Messages.MessageType.Error);
            }
        }