private void LoadLICByShed(Guid ShedId) { if (cboShed.SelectedIndex == 0) { return; } for (int i = cboInventoryController.Items.Count - 1; i > 0; i--) { cboInventoryController.Items.RemoveAt(i); } GRN_BL objGRN_BL = new BLL.GRN_BL(); DataTable dt; dt = objGRN_BL.GetInventoryControllersByShed(ShedId); cboInventoryController.DataSource = dt; cboInventoryController.DataValueField = "Id"; cboInventoryController.DataTextField = "Name"; cboInventoryController.DataBind(); if (cboShed.SelectedValue.ToString() == Session["ShedId_GRN"].ToString()) { if (ViewState["CommandName"].ToString() == "Insert") { cboInventoryController.SelectedValue = Session["LICID_GRN"].ToString(); } } }
private void PopulateSameGradingGrid(string TrackingNo) { GRN_BL obj2 = new BLL.GRN_BL(); DataTable dt2 = obj2.GetGradingsWithSameResults(TrackingNo); grdSameGradingResults.DataSource = dt2; grdSameGradingResults.DataBind(); }
/// <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!"); } }
protected void btnSave_Click(object sender, EventArgs e) { GRN_BL objGrnSetter = new BLL.GRN_BL(); string GradesToBeClosedQuery = "UPDATE tblworkflow SET UpdatedBy = '" + UserBLL.GetCurrentUser() + "', UpdateTimeStamp = '" + DateTime.Now + "' WHERE TrackingNo IN("; string closingGradesTrackingNumbers = ""; int counter = 0; try { InitializeInstance(objGrnSetter); if (objGrnSetter == null) { throw new Exception("Initialization has not been successfull!"); } string GradingIdsWithSameGradeResult = ""; foreach (GridViewRow grdRow in grdSameGradingResults.Rows) { CheckBox chkItem = (CheckBox)grdRow.FindControl("chkChoice"); if (chkItem.Checked == true) { GradingIdsWithSameGradeResult += grdSameGradingResults.DataKeys[grdRow.RowIndex].Values["GradeId"].ToString() + ","; if (chkItem.Enabled == true) { counter++; if (counter > 1) { closingGradesTrackingNumbers += "," + "'" + grdSameGradingResults.DataKeys[grdRow.RowIndex].Values["TrackingNumber"].ToString() + "'"; } else { closingGradesTrackingNumbers += "'" + grdSameGradingResults.DataKeys[grdRow.RowIndex].Values["TrackingNumber"].ToString() + "'"; } } } } objGrnSetter.GradingIdsWithSameGradeResult = GradingIdsWithSameGradeResult; GradesToBeClosedQuery += closingGradesTrackingNumbers + ") AND (UpdatedBy IS NULL AND UpdateTimeStamp IS NULL)"; if (!string.IsNullOrEmpty(closingGradesTrackingNumbers)) { objGrnSetter.GradesToBeClosedQuery = GradesToBeClosedQuery; } else { objGrnSetter.GradesToBeClosedQuery = ""; } objGrnSetter.SaveGRN(); string TrackingNumber = ViewState["TrackingNumber"].ToString(); PopulateSameGradingGrid(TrackingNumber); Messages.SetMessage("Record added successfully.", WarehouseApplication.Messages.MessageType.Success); btnPrintGrn.Enabled = true; btnNext.Enabled = true; } catch (Exception ex) { Messages.SetMessage("Failed to insert data!" + ex.Message.ToString(), WarehouseApplication.Messages.MessageType.Error); //lblmsg.Text = "Failed to insert data! " + ex.Message.ToString(); } }
/// <summary> /// this function filled dropdowns with possible alternatives each time the page is loaded /// </summary> private void LoadControls() { GRN_BL objGRN_BL = new BLL.GRN_BL(); DataTable dt; //string a = Session["WarehouseId"].ToString(); //string b = Session["ProductionYear"].ToString(); //Guid x = new Guid(Session["WarehouseId"].ToString()); //int y = int.Parse(Session["ProductionYear"].ToString()); //Load Sheds if (ViewState["CommodityGradeId"] == null) { //zaid return; } Guid commodityGradeID = new Guid(ViewState["CommodityGradeId"].ToString()); dt = objGRN_BL.GetAllAvailableSheds(new Guid(ViewState["WarehouseId"].ToString()), commodityGradeID, int.Parse(ViewState["ProductionYear"].ToString())); cboShed.DataSource = dt; cboShed.DataValueField = "Id"; cboShed.DataTextField = "Number"; cboShed.DataBind(); cboShed.SelectedValue = Session["ShedId_GRN"].ToString(); if (ViewState["CommandName"].ToString() == "Insert") { cboShed.SelectedValue = Session["ShedId_GRN"].ToString(); } //load stack on page lode time LoadStacksByShadeId(new Guid(Session["ShedId_GRN"].ToString())); if (cboShed.SelectedIndex != 0) { LoadLICByShed(new Guid(cboShed.SelectedValue.ToString())); } //Load Weighers dt = objGRN_BL.GetAllWeighers(new Guid(ViewState["WarehouseId"].ToString())); cboWeigher.DataSource = dt; cboWeigher.DataValueField = "Id"; cboWeigher.DataTextField = "Name"; cboWeigher.DataBind(); //Load WB Service Provider dt = objGRN_BL.GetAllWBServiceProviders(new Guid(ViewState["WarehouseId"].ToString())); cboWBServiceProvider.DataSource = dt; cboWBServiceProvider.DataValueField = "Id"; cboWBServiceProvider.DataTextField = "ServiceProviderName"; cboWBServiceProvider.DataBind(); //Load Labourer Group dt = objGRN_BL.GetAllLabourerGroup(); cboLabourerGroup.DataSource = dt; cboLabourerGroup.DataValueField = "Id"; cboLabourerGroup.DataTextField = "GroupName"; cboLabourerGroup.DataBind(); //Load Trucks dt = objGRN_BL.GetAllTrucks(); cboTruckType.DataSource = dt; cboTruckType.DataValueField = "Id"; cboTruckType.DataTextField = "Name"; cboTruckType.DataBind(); }