protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { cboSampleStatus.Items.Clear(); cboSampleStatus.DataSource = SamplingModel.GetSamplingStatus(0, ""); cboSampleStatus.DataTextField = "Description"; cboSampleStatus.DataValueField = "ID"; cboSampleStatus.DataBind(); } }
private void SaveSampling(GridView gv) { // this.lblMessage.Visible = false; Messages.ClearMessage(); SamplingModel sampleModel = SetSampling(gv); UpdatePanel4.Update(); if (sampleModel == null) { return; } try { sampleModel.Save(); } catch (Exception ex) { if (ex.Message.ToUpper().Contains("Sample Code".ToUpper())) { string msg = ex.Message.Split('|').First(s => s.ToUpper().Contains("Sample Code".ToUpper())); Messages.SetMessage(msg, Messages.MessageType.Error); return; } else { throw; } } //Repopulate the grid int searchCase = gv.ID == "gvWaitingForSampling" ? 1 : gv.ID == "gvWaitForDriver" ? 2 : 3; populateGrid(searchCase, true); Session["ReportType"] = "SampleTicket"; Session["SampleId"] = sampleModel.ID; ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowReport", "<script type=\"text/javascript\">" + string.Format("javascript:window.open(\"ReportViewer.aspx\", \"_blank\",\"height=1000px,width=1000px,top=0,left=0,resizable=yes,scrollbars=yes\");", Guid.NewGuid()) + "</script>", false); }
void PopulateCombo(Guid?commodityID, Guid?voucherCommodityTypeID) { List <SamplingModel> sampleModels = SamplingModel.GetSamples(UserBLL.GetCurrentWarehouse(), "", "", (int)SamplingBussiness.SamplingStatus.SampleCodeGenerated); //cboSampleCode.DataSource = sampleModels; //cboSampleCode.DataTextField = "SampleCode"; //cboSampleCode.DataValueField = "ID"; //cboSampleCode.DataBind(); //cboSampleCode_SelectedIndexChanged(null, null); drpBagType.Items.Clear(); drpBagType.Items.Add(new ListItem("- - Please Select Bag type - -", "")); drpBagType.DataSource = SamplingModel.GetBagTypes(commodityID, voucherCommodityTypeID); drpBagType.DataTextField = "Description"; drpBagType.DataValueField = "Guid"; drpBagType.DataBind(); }
private void populateGrid() { List <SamplingModelDetail> ls = null; ls = SamplingModel.GetSamplesDetail(UserBLL.GetCurrentWarehouse(), txtTrackNo.Text.Trim(), txtSampleCode.Text.Trim(), int.Parse(cboSampleStatus.SelectedValue)); //if (ls != null && ls.Count > 0) // { this.gvSampleTicketList.DataSource = ls; this.gvSampleTicketList.DataBind(); this.gvSampleTicketList.SelectedIndex = 0; // } if (ls == null || ls.Count <= 0) { Messages.SetMessage("There is no Sampling with the given tracking No.!", WarehouseApplication.Messages.MessageType.Warning); } else { Messages.ClearMessage(); } UpdatePanel1.Update(); }
/// <summary> /// Get all the Arrivals which are Ready for sampling. /// Display them based on their order(CreatedTimeStamp) /// </summary> private void populateGrid(int _case, bool afterSave = false) { Messages.ClearMessage(); List <ArrivalForSampling> ls = null; List <ArrivalForSampling> lsNA = null; List <ArrivalForSampling> lsDM = null; List <ArrivalForSampling> lsMF = null; ls = SamplingModel.GetArrivalsReadyForSampling(UserBLL.GetCurrentWarehouse(), _case, txtTrackingNo.Text.Trim(), txtPreSampleCode.Text.Trim(), txtPreGradingCode.Text.Trim()); lsNA = ls.Where(s => s.SamplingStatusID.Equals(0)).ToList(); lsDM = ls.Where(s => s.SamplingStatusID == (int)SamplingBussiness.SamplingStatus.DriverNotFound).ToList(); lsMF = ls.Where(s => s.SamplingStatusID != (int)SamplingBussiness.SamplingStatus.DriverNotFound && !s.SamplingStatusID.Equals(0)).ToList(); if (_case == 0 || _case == 1) { this.gvWaitingForSampling.DataSource = lsNA; this.gvWaitingForSampling.DataBind(); this.gvWaitingForSampling.SelectedIndex = 0; } if (_case == 0 || _case == 2) { this.gvWaitForDriver.DataSource = lsDM; this.gvWaitForDriver.DataBind(); this.gvWaitForDriver.SelectedIndex = 0; } if (_case == 0 || _case == 3) { this.gvWaitForReSamle.DataSource = lsMF; this.gvWaitForReSamle.DataBind(); this.gvWaitForReSamle.SelectedIndex = 0; } if (gvWaitForDriver.Rows.Count <= 0 && gvWaitForReSamle.Rows.Count <= 0 && gvWaitingForSampling.Rows.Count <= 0 && (ls == null || ls.Count <= 0) && !afterSave) { Messages.SetMessage("No truck available for sampling. Please wait.", WarehouseApplication.Messages.MessageType.Warning); } }
private SamplingModel SetSampling(GridView gv) { SamplingModel samplingModel = new SamplingModel(); if (gv.Rows.Count <= 0) { return(null); } GridViewRow rw = gv.SelectedRow; samplingModel.TrackingNo = ((Label)rw.FindControl("lblTrackingNo")).Text; samplingModel.ID = Guid.NewGuid(); samplingModel.WarehouseID = UserBLL.GetCurrentWarehouse(); samplingModel.ArrivalID = new Guid(((Label)rw.FindControl("lblArrivalId")).Text); Label preGradingStatus = ((Label)rw.FindControl("lblGradingStatusID")); int lastSerialNo = 0; //int.TryParse(SamplingModel.GetLastSerialNoForDate(DateTime.Today.ToShortDateString(), samplingModel.WarehouseID), out lastSerialNo); samplingModel.SerialNo = lastSerialNo + 1; samplingModel.SampleCode = UserBLL.GetCurrentWarehouseCode() + "-" + DateTime.Today.Year.ToString().Substring(2) + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00");// +"-" + samplingModel.SerialNo; samplingModel.SampleCodeGeneratedTimeStamp = DateTime.Now; samplingModel.SamplingStatusID = (int)SamplingBussiness.SamplingStatus.SampleCodeGenerated; if (preGradingStatus != null && preGradingStatus.Text.Trim().Length > 0 && int.Parse(preGradingStatus.Text) == (int)GradingBussiness.GradingResultStatus.SegrigationRequested) { samplingModel.SamplerID = new Guid(((Label)rw.FindControl("lblPreSamplerId")).Text); samplingModel.SamplerName = ((Label)rw.FindControl("lblPreSamplerName")).Text; samplingModel.SamplingInspectorID = new Guid(((Label)rw.FindControl("lblPreSampleInspectorID")).Text); } else { List <string> sampler = SamplingModel.SelectSampler(samplingModel.WarehouseID); if (sampler == null || sampler.Count() <= 0) { Messages.SetMessage("All available Samplers assigned. Please wait.!", WarehouseApplication.Messages.MessageType.Warning); return(null); } samplingModel.SamplerID = new Guid(sampler[0].ToString()); samplingModel.SamplerName = sampler[1]; List <string> samplingInspector = SamplingModel.SelectSampleInspector(samplingModel.WarehouseID, samplingModel.SamplerID); if (samplingInspector == null || samplingInspector.Count() <= 0) { Messages.SetMessage("All available Sampling Inspectors assigned or the available Inspector may also be registed as Sampler. Please wait!", WarehouseApplication.Messages.MessageType.Warning); return(null); } samplingModel.SamplingInspectorID = new Guid(samplingInspector[0].ToString()); } samplingModel.CreatedBy = BLL.UserBLL.CurrentUser.UserId; samplingModel.CreateTimestamp = DateTime.Now; samplingModel.NumberOfBags = null; samplingModel.BagTypeID = null; samplingModel.PlompStatusID = null; samplingModel.SupervisorID = null;//WarehouseBLL.GetById(samplingModel.WarehouseID).SuppervisorId Label templbl = (Label)rw.FindControl("lblGradeId"); if (templbl.Text.Trim() != string.Empty && !templbl.Text.Trim().Contains(Guid.Empty.ToString())) { samplingModel.PreviousGradingResultID = new Guid(templbl.Text); } else { samplingModel.PreviousGradingResultID = null; } templbl = (Label)rw.FindControl("lblSampleId"); if (templbl.Text.Trim() != string.Empty && !templbl.Text.Trim().Contains(Guid.Empty.ToString())) { samplingModel.PreviousSamplingID = new Guid(templbl.Text); } else { samplingModel.PreviousSamplingID = null; } samplingModel.HasChemicalOrPetrol = null; samplingModel.HasLiveInsect = null; samplingModel.HasMoldOrFungus = null; samplingModel.LastModifiedTimestamp = null; return(samplingModel); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SamplingModel sm = new SamplingModel(); if (Session["SamplingsId_Search"] != null && Session["SamplingsId_Search"].ToString().Trim().Length > 0) { sm = SamplingModel.GetSampleById(new Guid(Session["SamplingsId_Search"].ToString())); Session["SamplingsId_Search"] = null; Session.Remove("SamplingsId_Search"); } else if (Request.QueryString["sampleCode"] != null) { sm = SamplingModel.GetSampleBySampleCode(Request.QueryString["sampleCode"]); Session["SamplingsId_Search"] = null; Session.Remove("SamplingsId_Search"); } if (sm != null) { txtResultReceivedDate.Text = DateTime.Now.ToShortDateString(); txtResultReceivedTime.Text = DateTime.Now.ToShortTimeString(); if (sm != null && sm.ID.ToString() != Guid.Empty.ToString()) { ViewState.Add("SelectedSMID", sm.ID); txtSampleCode.Text = sm.SampleCode; txtSamplerName.Text = sm.SamplerName; txtArrivalNoOfBags.Text = sm.ArrivalNumberOfBags.ToString(); txtSampleCodeGeneratedDateStamp.Text = sm.SampleCodeGeneratedTimeStamp.ToShortDateString(); txtSampleCodeGeneratedTimeStamp.Text = sm.SampleCodeGeneratedTimeStamp.ToShortTimeString(); lblCodeGeneratedDate.Text = sm.SampleCodeGeneratedTimeStamp.ToShortDateString() + " " + sm.SampleCodeGeneratedTimeStamp.ToShortTimeString(); if ((Request.QueryString["CommandName"] != null && Request.QueryString["CommandName"].ToUpper() == "Update".ToUpper()) || (sm.IsGraded || sm.IsReSampled)) { txtNumberOfBags.Text = sm.NumberOfBags.ToString(); chkHasChemicalOrPetrol.Checked = sm.HasChemicalOrPetrol != null ? sm.HasChemicalOrPetrol.Value : false; chkHasLiveInsect.Checked = sm.HasLiveInsect != null ? sm.HasLiveInsect.Value : false; chkHasMoldOrFungus.Checked = sm.HasMoldOrFungus != null ? sm.HasMoldOrFungus.Value : false; chkIsPlompOk.Checked = (sm.PlompStatusID == (int)PlompStatus.PlompOK) ? true : false; rbSampleStatus.SelectedValue = sm.SamplingStatusID.ToString(); txtSamplerComments.Text = sm.SamplerComments; if (sm.ResultReceivedDateTime != null) { txtResultReceivedDate.Text = sm.ResultReceivedDateTime.Value.ToShortDateString(); txtResultReceivedTime.Text = sm.ResultReceivedDateTime.Value.ToShortTimeString(); } drpBagType.SelectedValue = sm.BagTypeID.ToString(); if (!chkIsPlompOk.Checked && ((int)SamplingBussiness.SamplingStatus.DriverNotFound) != sm.SamplingStatusID) { reqRemark.Enabled = true; reqRemark.Validate(); } //} if (sm.IsGraded || sm.IsReSampled) { rbSampleStatus.Enabled = txtNumberOfBags.Enabled = txtSamplerComments.Enabled = drpBagType.Enabled = false; chkHasChemicalOrPetrol.Enabled = chkHasLiveInsect.Enabled = chkHasMoldOrFungus.Enabled = chkIsPlompOk.Enabled = false; txtResultReceivedDate.Enabled = txtResultReceivedTime.Enabled = false; btnSaveSampleResult.Enabled = false; btnClear.Enabled = false; btnClear.ToolTip = btnSaveSampleResult.ToolTip = "ReSampled or Graded sample can't be edited!"; } } else { rdSampleStatus_SelectedIndexChanged(null, null); } } } PopulateCombo(sm.CommodityID, sm.VoucherCommodityTypeID); } RangeValidator2.MinimumValue = DateTime.Now.AddYears(-1).ToShortDateString().ToString(System.Globalization.CultureInfo.InvariantCulture); RangeValidator2.MaximumValue = DateTime.Now.ToShortDateString().ToString(System.Globalization.CultureInfo.InvariantCulture); unBlockUI(); }
protected void btnSaveSampleResult_Click(object sender, EventArgs e) { Messages.ClearMessage(); //int no = 0; //if (((int)SamplingBussiness.SamplingStatus.DriverNotFound) != int.Parse(rbSampleStatus.SelectedValue) && // txtArrivalNoOfBags.Text.Trim() != string.Empty && // int.TryParse(txtArrivalNoOfBags.Text, out no) && // no < int.Parse(txtNumberOfBags.Text)) //{ // Messages.SetMessage("Bag count greater than the bag count " + no + " registered on Voucher!", WarehouseApplication.Messages.MessageType.Error); // return; //} if (ViewState["SelectedSMID"] == null) { Messages.SetMessage("The sample ticket dosen't exits. Please try reloading again!", WarehouseApplication.Messages.MessageType.Error); return; } //SamplingModel sm = (SamplingModel)ViewState["SelectedSMID"]; SamplingModel sm = SamplingModel.GetSampleById(new Guid(ViewState["SelectedSMID"].ToString())); if (sm == null) { Messages.SetMessage("The sample ticket dosen't exits. Please try reloading again!", WarehouseApplication.Messages.MessageType.Error); return; } sm.ResultReceivedDateTime = DateTime.Parse(txtResultReceivedDate.Text + " " + txtResultReceivedTime.Text); sm.SamplingStatusID = int.Parse(rbSampleStatus.SelectedValue); if (((int)SamplingBussiness.SamplingStatus.DriverNotFound) != int.Parse(rbSampleStatus.SelectedValue)) { if (!chkIsPlompOk.Checked && txtSamplerComments.Text.Trim().Length <= 0) { Messages.SetMessage("Please enter the remark since the plomp ok is not checked!", WarehouseApplication.Messages.MessageType.Error); return; } int noOfbag = 0; if (!int.TryParse(txtNumberOfBags.Text, out noOfbag)) { Messages.SetMessage("Please enter a valid number of bags!", WarehouseApplication.Messages.MessageType.Error); return; } sm.NumberOfBags = noOfbag; if (drpBagType.SelectedIndex <= 0) { Messages.SetMessage("Please select Bag Type!", WarehouseApplication.Messages.MessageType.Error); return; } sm.BagTypeID = new Guid(drpBagType.SelectedValue); sm.SamplerComments = txtSamplerComments.Text; sm.PlompStatusID = (int)(chkIsPlompOk.Checked ? PlompStatus.PlompOK : PlompStatus.PlompNotOk); // sm.SupervisorApprovalRemark = ""; txtSuppervisorApprovalRemark.Text; //sm.SupervisorApprovalDateTime = DateTime.Parse(txtSupperVisorApprovalDate.Text); sm.HasLiveInsect = chkHasLiveInsect.Checked; sm.HasMoldOrFungus = chkHasMoldOrFungus.Checked; sm.HasChemicalOrPetrol = chkHasChemicalOrPetrol.Checked; reqRemark.Enabled = !chkIsPlompOk.Checked; } sm.LastModifiedBy = BLL.UserBLL.CurrentUser.UserId; sm.LastModifiedTimestamp = DateTime.Now; try { sm.Save(); int no = 0; string msg = ""; if (((int)SamplingBussiness.SamplingStatus.DriverNotFound) != int.Parse(rbSampleStatus.SelectedValue) && txtArrivalNoOfBags.Text.Trim() != string.Empty && int.TryParse(txtArrivalNoOfBags.Text, out no) && no < int.Parse(txtNumberOfBags.Text)) { msg = "Bag count greater than the bag count " + no + " registered on Voucher!"; } //PopulateCombo(sm.CommodityID,sm.VoucherCommodityTypeID); //Clear(true); if (msg == string.Empty) { Messages.SetMessage("Record saved successfully! ", WarehouseApplication.Messages.MessageType.Success); } else { Messages.SetMessage("Record saved successfully! " + msg, WarehouseApplication.Messages.MessageType.Warning); } btnSaveSampleResult.Visible = false; } catch (Exception ex) { Messages.SetMessage(ex.Message, WarehouseApplication.Messages.MessageType.Error); } }