private void Save() { FlatSectionJl flatSectionJl = new FlatSectionJl(flatSectionJlTDS); DataView dataViewFlatSectionJl = new DataView(flatSectionJlTDS.FlatSectionJl); dataViewFlatSectionJl.RowFilter = "(Selected = 1) AND (Deleted = 0)"; string summary = ""; bool existsDataModificated = false; string fieldToUpdate = ddlFieldToUpdate.SelectedValue; foreach (DataRowView row in dataViewFlatSectionJl) { if (IsValidLateralToUpdate(fieldToUpdate, row)) { int workId = Int32.Parse(row["WorkID"].ToString()); // Date fields if ((fieldToUpdate == "VideoInspection") || (fieldToUpdate == "PipeLocated") || (fieldToUpdate == "ServicesLocated") || (fieldToUpdate == "CoInstalled") || (fieldToUpdate == "BackfilledConcrete") || (fieldToUpdate == "BackfilledSoil") || (fieldToUpdate == "Grouted") || (fieldToUpdate == "Cored") || (fieldToUpdate == "Prepped") || (fieldToUpdate == "PreVideo") || (fieldToUpdate == "Measured") || (fieldToUpdate == "NoticeDelivered") || (fieldToUpdate == "InProcess") || (fieldToUpdate == "InStock") || (fieldToUpdate == "Delivered") || (fieldToUpdate == "LinerInstalled") || (fieldToUpdate == "FinalVideo") || (fieldToUpdate == "CoCutDown") || (fieldToUpdate == "FinalRestoration") || (fieldToUpdate == "DigRequiredPriorToLiningCompleted") || (fieldToUpdate == "DigRequiredAfterLiningCompleted") || (fieldToUpdate == "HoldClientIssueResolved") || (fieldToUpdate == "HoldLFSIssueResolved") || (fieldToUpdate == "LateralRequiresRoboticPrepCompleted") ) { // ... Update row flatSectionJl.UpdateDateField(workId, fieldToUpdate, tkrdpValue.SelectedDate); existsDataModificated = true; } else { // String fields if (fieldToUpdate == "CoPitLocation") { // ... Update row flatSectionJl.UpdateStringField(workId, fieldToUpdate, ddlCoPitLocationValue.SelectedValue); existsDataModificated = true; } // String fields if (fieldToUpdate == "PrepType") { // ... Update row flatSectionJl.UpdateStringField(workId, fieldToUpdate, ddlPrepType.SelectedValue); existsDataModificated = true; } // String fields if (fieldToUpdate == "LinerType") { // ... Update row flatSectionJl.UpdateStringField(workId, fieldToUpdate, ddlLinerType.SelectedValue); existsDataModificated = true; } // String fields if (fieldToUpdate == "ContractYear") { // ... Update row flatSectionJl.UpdateStringField(workId, fieldToUpdate, tbxValue.Text); existsDataModificated = true; } // Boolean fields if ((fieldToUpdate == "CoRequired") || (fieldToUpdate == "OutOfScope") || (fieldToUpdate == "DigRequiredPriorToLining") || (fieldToUpdate == "DigRequiredAfterLining") || (fieldToUpdate == "HoldClientIssue") || (fieldToUpdate == "HoldLFSIssue") || (fieldToUpdate == "LateralRequiresRoboticPrep")) { // ... Update row flatSectionJl.UpdateBooleanField(workId, fieldToUpdate, cbxValue.Checked); existsDataModificated = true; } // Special field - Comment if (fieldToUpdate == "Comment") { // ... Update row AddComments(workId, tbxComments.Text); ViewState["UpdateComments"] = true; existsDataModificated = true; } } } else { string[] flowOderId = row["LateralDescription"].ToString().Split('-'); if (summary.Trim().Length == 0) { string reason = ""; switch (fieldToUpdate) { case "DigRequiredPriorToLining": reason = "Dig Required Prior To Lining Completed has value."; break; case "DigRequiredPriorToLiningCompleted": reason = "Dig Required Prior To Lining is not checked."; break; case "DigRequiredAfterLining": reason = "Dig Required After Lining Completed has value."; break; case "DigRequiredAfterLiningCompleted": reason = "Dig Required After Lining is not checked."; break; case "HoldClientIssue": reason = "Hold - Client Issue Resolved has value."; break; case "HoldClientIssueResolved": reason = "Hold - Client Issue is not checked."; break; case "HoldLFSIssue": reason = "Hold - LFS Issue Resolved has value."; break; case "HoldLFSIssueResolved": reason = "Hold - LFS Issue is not checked."; break; case "LateralRequiresRoboticPrep": reason = "Requires Robotic Prep Completed has value."; break; case "LateralRequiresRoboticPrepCompleted": reason = "Requires Robotic Prep is not checked."; break; } summary = "The following laterals were not updated because " + reason + "\n\n"; summary = summary + "\t - " + flowOderId[1] + "-JL-" + flowOderId[2] + "\n"; } else { summary = summary + "\t - " + flowOderId[1] + "-JL-" + flowOderId[2] + "\n"; } } } if (summary.Trim().Length == 0) { summary = "All the laterals were updated\n\n"; } tbxSummary.Text = summary; // Store datasets Session["flatSectionJlTDS"] = flatSectionJlTDS; if (existsDataModificated) { // Update database UpdateDatabase(); } }