// //////////////////////////////////////////////////////////////////////// // STEP1 - NEW BATCH - METHODS // private void StepNewBatchIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Please provide information for the new batch"; // Load MrBatchVerification model = new MrBatchVerification(mrBatchVerificationTDS); model.LoadAll(Int32.Parse(hdfCompanyId.Value)); // Store tables Session["mrBatchVerification"] = mrBatchVerificationTDS.BatchValidation; Session["mrBatchVerificationTDS"] = mrBatchVerificationTDS; }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP2 - SUMMARY // // //////////////////////////////////////////////////////////////////////// // STEP2 - SUMMARY - METHODS // private void StepSummaryIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Summary"; // Initialize summary MrBatchVerification mrBatchVerification = new MrBatchVerification(mrBatchVerificationTDS); tbxSummary.Text = mrBatchVerification.GetSummary(); }
private void GrdBatchAdd() { if (ValidateBatchFooter()) { Page.Validate("dataFooter"); if (Page.IsValid) { string description = ((TextBox)grdNewBatch.FooterRow.FindControl("tbxBatchDescriptionFooter")).Text.Trim(); DateTime date = (DateTime)((RadDatePicker)grdNewBatch.FooterRow.FindControl("tkrdpDateFooter")).SelectedDate; int companyId = Int32.Parse(hdfCompanyId.Value); bool inDatabase = false; bool deleted = false; MrBatchVerification model = new MrBatchVerification(mrBatchVerificationTDS); model.Insert(description, date, deleted, companyId, inDatabase); Session.Remove("mrBatchVerificationDummy"); Session["mrBatchVerificationTDS"] = mrBatchVerificationTDS; Session["mrBatchVerification"] = mrBatchVerificationTDS.BatchValidation; grdNewBatch.DataBind(); grdNewBatch.PageIndex = grdNewBatch.PageCount - 1; } } }
private void Save() { // save to database DB.Open(); DB.BeginTransaction(); try { MrBatchVerification model = new MrBatchVerification(mrBatchVerificationTDS); model.Save(Int32.Parse(hdfCompanyId.Value)); DB.CommitTransaction(); } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_ADMIN"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if (((string)Request.QueryString["source_page"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in mr_batch_add.aspx"); } // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); hdfUpdate.Value = "no"; Session.Remove("mrBatchVerification"); Session.Remove("mrBatchVerificationDummy"); // Load information mrBatchVerificationTDS = new MrBatchVerificationTDS(); int companyId = Int32.Parse(hdfCompanyId.Value); MrBatchVerification mrBatchVerificationForLastRow = new MrBatchVerification(); mrBatchVerificationForLastRow.LoadLastBatch(companyId); if (mrBatchVerificationForLastRow.Table.Rows.Count > 0) { MrBatchVerificationGateway mrBatchVerificationGatewayForLastRow = new MrBatchVerificationGateway(mrBatchVerificationForLastRow.Data); WorkManholeRehabilitationBatchGateway workManholeRehabilitationBatchGateway = new WorkManholeRehabilitationBatchGateway(); hdfBatchId.Value = workManholeRehabilitationBatchGateway.GetLastId(companyId).ToString(); int batchId = Int32.Parse(hdfBatchId.Value); DateTime date = mrBatchVerificationGatewayForLastRow.GetDate(batchId); hdfBatchDate.Value = date.Month.ToString() + "/" + date.Day.ToString() + "/" + date.Year.ToString(); hdfBatchDescription.Value = mrBatchVerificationGatewayForLastRow.GetDescription(batchId); } // ... Store datasets Session["mrBatchVerificationTDS"] = mrBatchVerificationTDS; Session["mrBatchVerification"] = mrBatchVerificationTDS.BatchValidation; // StepIn wizardBatch.ActiveStepIndex = 0; StepNewBatchIn(); } else { // Restore datasets mrBatchVerificationTDS = (MrBatchVerificationTDS)Session["mrBatchVerificationTDS"]; // Store Session["mrBatchVerification"] = mrBatchVerificationTDS.BatchValidation; } }
protected void grdNewBatch_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("dataEdit"); if (Page.IsValid) { int batchId = (int)e.Keys["BatchID"]; int companyId = Int32.Parse(hdfCompanyId.Value); DateTime date = (DateTime)((RadDatePicker)grdNewBatch.Rows[e.RowIndex].Cells[1].FindControl("tkrdpDateEdit")).SelectedDate; string description = ((TextBox)grdNewBatch.Rows[e.RowIndex].Cells[2].FindControl("tbxBatchDescriptionEdit")).Text.Trim(); MrBatchVerification model = new MrBatchVerification(mrBatchVerificationTDS); model.Update(batchId, description, date); // Store dataset Session["mrBatchVerificationTDS"] = mrBatchVerificationTDS; Session["flatSectionJlCommentDetails"] = mrBatchVerificationTDS.BatchValidation; } else { e.Cancel = true; } }
protected void grdNewBatch_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Catalysts Gridview, if the gridview is edition mode if (grdNewBatch.EditIndex >= 0) { grdNewBatch.UpdateRow(grdNewBatch.EditIndex, true); } //Delete catalysts int batchId = (int)e.Keys["BatchID"]; int companyId = Int32.Parse(hdfCompanyId.Value); // Delete catalysts MrBatchVerification model = new MrBatchVerification(mrBatchVerificationTDS); model.Delete(batchId, companyId); // Store dataset Session["mrBatchVerificationTDS"] = mrBatchVerificationTDS; grdNewBatch.DataBind(); }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP3 - SUMMARY // // //////////////////////////////////////////////////////////////////////// // STEP2 - SUMMARY - METHODS // private void StepSummaryIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Summary"; // Initialize summary string summary = "Selected batch: \n\n"; if (rbtnUseLastBatch.Checked) { DateTime date = DateTime.Parse(hdfBatchDate.Value); summary = summary + "Date: " + date.Month.ToString() + "/" + date.Day.ToString() + "/" + date.Year.ToString() +"\n"; summary = summary + "Description: " + hdfBatchDescription.Value + "\n\n"; } else { if (rbtnUseNewBatch.Checked) { MrBatchVerification mrBatchVerification = new MrBatchVerification(mrBatchVerificationTDS); summary = mrBatchVerification.GetSummary(); } } tbxSummary.Text = summary; }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP1 - BEGIN // // //////////////////////////////////////////////////////////////////////// // STEP - BEGIN - AUXILIAR EVENTS // protected void StartBatch_OnCheckedChanged(object sender, EventArgs e) { if (rbtnUseLastBatch.Checked) { int companyId = Int32.Parse(hdfCompanyId.Value); MrBatchVerification mrBatchVerificationForLastRow = new MrBatchVerification(mrBatchVerificationTDS); mrBatchVerificationForLastRow.LoadLastBatch(companyId); if (mrBatchVerificationForLastRow.Table.Rows.Count > 0) { MrBatchVerificationGateway mrBatchVerificationGatewayForLastRow = new MrBatchVerificationGateway(mrBatchVerificationForLastRow.Data); WorkManholeRehabilitationBatchGateway workManholeRehabilitationBatchGateway = new WorkManholeRehabilitationBatchGateway(); hdfBatchId.Value = workManholeRehabilitationBatchGateway.GetLastId(companyId).ToString(); int batchId = Int32.Parse(hdfBatchId.Value); DateTime date = mrBatchVerificationGatewayForLastRow.GetDate(batchId); hdfBatchDate.Value = date.Month.ToString() + "/" + date.Day.ToString() + "/" + date.Year.ToString(); hdfBatchDescription.Value = mrBatchVerificationGatewayForLastRow.GetDescription(batchId); // Show messages at wizard lblBatchIdWarning.Visible = false; lblBatchLast.Visible = true; lblBatchLast.Text = "Last Batch used: " + hdfBatchDate.Value + " " + hdfBatchDescription.Value; } else { lblBatchIdWarning.Visible = true; lblBatchLast.Visible = false; } } if (rbtnUseNewBatch.Checked) { lblBatchIdWarning.Visible = false; lblBatchLast.Visible = false; } }