// //////////////////////////////////////////////////////////////////////// // 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; } }
/// <summary> /// SaveMHRehabWork /// </summary> /// <param name="projectId">projectId</param> /// <param name="mh_assetId">mh_assetId</param> /// <param name="companyId">companyId</param> private void SaveMHRehabWork(int projectId, int mh_assetId, int companyId) { MrBatchVerificationGateway mrBatchVerificationForLastBatch = new MrBatchVerificationGateway(); mrBatchVerificationForLastBatch.LoadLastBatch(companyId); int? batchId = null; if (mrBatchVerificationForLastBatch.Table.Rows.Count > 0) { WorkManholeRehabilitationBatchGateway workManholeRehabilitationBatchGateway = new WorkManholeRehabilitationBatchGateway(); batchId = workManholeRehabilitationBatchGateway.GetLastId(companyId); } WorkManholeRehabilitation workManholeRehabilitation = new WorkManholeRehabilitation(null); workManholeRehabilitation.InsertDirectEmptyWorks(projectId, mh_assetId, null, null, batchId, false, companyId); }
/// <summary> /// Update /// </summary> /// <param name="workId">workId</param> /// <param name="preppedDate">preppedDate</param> /// <param name="sprayedDate">sprayedDate</param> /// <param name="batchId">batchId</param> /// <param name="date">date</param> /// <param name="companyId">companyId</param> public void Update(int workId, DateTime? preppedDate, DateTime? sprayedDate, int? batchId, DateTime date, int companyId) { WorkManholeRehabilitationGateway workManholeRehabilitationGatewayForReview = new WorkManholeRehabilitationGateway(); workManholeRehabilitationGatewayForReview.LoadByWorkId(workId, companyId); if (workManholeRehabilitationGatewayForReview.Table.Rows.Count > 0) { // Update work ManholeRehabilitationTDS.WorkDetailsRow row = GetRow(workId); if (preppedDate.HasValue) row.PreppedDate = (DateTime)preppedDate; else row.SetPreppedDateNull(); if (sprayedDate.HasValue) row.SprayedDate = (DateTime)sprayedDate; else row.SetSprayedDateNull(); row.Date = date; row.BatchID = (int)batchId; } else { // ... Insert work ManholeRehabilitationTDS.WorkDetailsRow lfsManholeRehabilitationRow = ((ManholeRehabilitationTDS.WorkDetailsDataTable)Table).NewWorkDetailsRow(); workId = GetNewId(); lfsManholeRehabilitationRow.WorkID = workId; if (preppedDate.HasValue) lfsManholeRehabilitationRow.PreppedDate = (DateTime)preppedDate; else lfsManholeRehabilitationRow.SetPreppedDateNull(); if (sprayedDate.HasValue) lfsManholeRehabilitationRow.SprayedDate = (DateTime)sprayedDate; else lfsManholeRehabilitationRow.SetSprayedDateNull(); lfsManholeRehabilitationRow.BatchID = 0; MrBatchVerificationGateway mrBatchVerificationGateway = new MrBatchVerificationGateway(); mrBatchVerificationGateway.LoadAll(companyId); if (mrBatchVerificationGateway.Table.Rows.Count > 0) { WorkManholeRehabilitationBatchGateway workManholeRehabilitationBatchGateway = new WorkManholeRehabilitationBatchGateway(); lfsManholeRehabilitationRow.BatchID = workManholeRehabilitationBatchGateway.GetLastId(companyId); } else { lfsManholeRehabilitationRow.SetBatchIDNull(); } lfsManholeRehabilitationRow.Date = (DateTime)date; lfsManholeRehabilitationRow.Deleted = false; lfsManholeRehabilitationRow.COMPANY_ID = companyId; ((ManholeRehabilitationTDS.WorkDetailsDataTable)Table).AddWorkDetailsRow(lfsManholeRehabilitationRow); } }
private void LoadWorkData(int workId, int assetId) { int companyId = Int32.Parse(hdfCompanyId.Value); if (workId != 0) { ManholeRehabilitationWorkDetailsGateway manholeRehabilitationWorkDetailsGateway = new ManholeRehabilitationWorkDetailsGateway(manholeRehabilitationTDS); if (manholeRehabilitationWorkDetailsGateway.Table.Rows.Count > 0) { if (manholeRehabilitationWorkDetailsGateway.GetPreppedDate(workId).HasValue) { DateTime preppedDate = (DateTime)manholeRehabilitationWorkDetailsGateway.GetPreppedDate(workId); tkrdpRehabilitationPreppedDate.SelectedDate = DateTime.Parse(preppedDate.Month.ToString() + "/" + preppedDate.Day.ToString() + "/" + preppedDate.Year.ToString()); } if (manholeRehabilitationWorkDetailsGateway.GetSprayedDate(workId).HasValue) { DateTime sprayedDate = (DateTime)manholeRehabilitationWorkDetailsGateway.GetSprayedDate(workId); tkrdpRehabilitationSprayedDate.SelectedDate = DateTime.Parse(sprayedDate.Month.ToString() + "/" + sprayedDate.Day.ToString() + "/" + sprayedDate.Year.ToString()); } if (manholeRehabilitationWorkDetailsGateway.GetDate(workId).HasValue) { //Load saved batch int batchId = (manholeRehabilitationWorkDetailsGateway.GetBatchID(workId)); ddlRehabilitationBatchDate.SelectedValue = batchId.ToString(); hdfExistBatchId.Value = "True"; hdfBatchId.Value = batchId.ToString(); } else { ddlRehabilitationBatchDate.SelectedValue = "0"; hdfExistBatchId.Value = "False"; } // Show Comments tbxCommentsDataComments.Text = manholeRehabilitationWorkDetailsGateway.GetComments(workId); // ... ... Store datasets Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS; } } // Load last batch MrBatchVerificationGateway mrBatchVerificationGateway = new MrBatchVerificationGateway(); mrBatchVerificationGateway.LoadAll(companyId); if (mrBatchVerificationGateway.Table.Rows.Count > 0) { WorkManholeRehabilitationBatchGateway workManholeRehabilitationBatchGateway = new WorkManholeRehabilitationBatchGateway(); hdfBatchId.Value = workManholeRehabilitationBatchGateway.GetLastId(companyId).ToString(); int batchId = Int32.Parse(hdfBatchId.Value); mrBatchVerificationGateway.LoadByBatchId(batchId, companyId); DateTime batchDate = mrBatchVerificationGateway.GetDate(batchId); tbxLastRehabilitationBatchDate.Text = batchDate.Month.ToString() + "/" + batchDate.Day.ToString() + "/" + batchDate.Year.ToString(); lblBatchDateRequired.Visible = false; // ... ... Store datasets Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS; } else { lblBatchDateRequired.Visible = true; } }
protected void tkrdpRehabilitationSprayedDate_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e) { if (hdfExistBatchId.Value == "False") { if (tkrdpRehabilitationSprayedDate.SelectedDate.HasValue) { int companyId = Int32.Parse(hdfCompanyId.Value); MrBatchVerificationGateway mrBatchVerificationForLastBatch = new MrBatchVerificationGateway(); mrBatchVerificationForLastBatch.LoadLastBatch(companyId); if (mrBatchVerificationForLastBatch.Table.Rows.Count > 0) { WorkManholeRehabilitationBatchGateway workManholeRehabilitationBatchGateway = new WorkManholeRehabilitationBatchGateway(); ddlRehabilitationBatchDate.SelectedValue = workManholeRehabilitationBatchGateway.GetLastId(companyId).ToString(); } } else { ddlRehabilitationBatchDate.SelectedValue = "0"; } } }
protected void ddlRehabilitationBatchDate_SelectedIndexChanged(object sender, EventArgs e) { // Get last batch id int companyId = Int32.Parse(hdfCompanyId.Value); int lastBatchId = 0; MrBatchVerificationGateway mrBatchVerificationForLastBatch = new MrBatchVerificationGateway(); mrBatchVerificationForLastBatch.LoadLastBatch(companyId); if (mrBatchVerificationForLastBatch.Table.Rows.Count > 0) { WorkManholeRehabilitationBatchGateway workManholeRehabilitationBatchGateway = new WorkManholeRehabilitationBatchGateway(); lastBatchId = workManholeRehabilitationBatchGateway.GetLastId(companyId); } lblNotLastBatch.Visible = false; if (ddlRehabilitationBatchDate.SelectedValue != lastBatchId.ToString()) { lblNotLastBatch.Visible = true; } }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // 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; } }
private void LoadWorkData(int workId, int assetId) { int companyId = Int32.Parse(hdfCompanyId.Value); if (workId != 0) { ManholeRehabilitationWorkDetailsGateway manholeRehabilitationWorkDetailsGateway = new ManholeRehabilitationWorkDetailsGateway(manholeRehabilitationTDS); if (manholeRehabilitationWorkDetailsGateway.Table.Rows.Count > 0) { tbxRehabilitationPreppedDate.Text = ""; if (manholeRehabilitationWorkDetailsGateway.GetPreppedDate(workId).HasValue) { DateTime preppedDate = (DateTime)manholeRehabilitationWorkDetailsGateway.GetPreppedDate(workId); tbxRehabilitationPreppedDate.Text = preppedDate.Month.ToString() + "/" + preppedDate.Day.ToString() + "/" + preppedDate.Year.ToString(); } tbxRehabilitationSprayedDate.Text = ""; if (manholeRehabilitationWorkDetailsGateway.GetSprayedDate(workId).HasValue) { DateTime sprayedDate = (DateTime)manholeRehabilitationWorkDetailsGateway.GetSprayedDate(workId); tbxRehabilitationSprayedDate.Text = sprayedDate.Month.ToString() + "/" + sprayedDate.Day.ToString() + "/" + sprayedDate.Year.ToString(); } tbxRehabilitationBatchDate.Text = ""; if (manholeRehabilitationWorkDetailsGateway.GetDate(workId).HasValue) { try { DateTime batchDate = (DateTime)manholeRehabilitationWorkDetailsGateway.GetDate(workId); tbxRehabilitationBatchDate.Text = batchDate.Month.ToString() + "/" + batchDate.Day.ToString() + "/" + batchDate.Year.ToString(); hdfBatchId.Value = manholeRehabilitationWorkDetailsGateway.GetBatchID(workId).ToString(); } catch { } } // Show Comments tbxCommentsDataComments.Text = manholeRehabilitationWorkDetailsGateway.GetComments(workId); // ... ... Store datasets Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS; } } else { // Load last batch MrBatchVerificationGateway mrBatchVerificationGateway = new MrBatchVerificationGateway(); mrBatchVerificationGateway.LoadAll(companyId); if (mrBatchVerificationGateway.Table.Rows.Count > 0) { WorkManholeRehabilitationBatchGateway workManholeRehabilitationBatchGateway = new WorkManholeRehabilitationBatchGateway(); hdfBatchId.Value = workManholeRehabilitationBatchGateway.GetLastId(companyId).ToString(); int batchId = Int32.Parse(hdfBatchId.Value); mrBatchVerificationGateway.LoadByBatchId(batchId, companyId); DateTime batchDate = mrBatchVerificationGateway.GetDate(batchId); tbxRehabilitationBatchDate.Text = batchDate.Month.ToString() + "/" + batchDate.Day.ToString() + "/" + batchDate.Year.ToString(); // ... ... Store datasets Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS; } } }