private void UpdateDatabase() { int companyId = Int32.Parse(hdfCompanyId.Value); LibraryFilesGateway libraryFilesGateway = new LibraryFilesGateway(libraryTDSForServices); libraryFilesGateway.Update(); DB.Open(); DB.BeginTransaction(); try { ServiceInformationServiceNoteGateway serviceInformationServiceNoteGateway = new ServiceInformationServiceNoteGateway(serviceInformationTDS); ServiceInformationServiceNote serviceInformationServiceNote = new ServiceInformationServiceNote(serviceInformationTDS); foreach (ServiceInformationTDS.NoteInformationRow rowNotes in (ServiceInformationTDS.NoteInformationDataTable)serviceInformationServiceNoteGateway.Table) { if (!rowNotes.IsLIBRARY_FILES_IDNull()) { if (rowNotes.LIBRARY_FILES_ID == 0 && rowNotes.FILENAME != "") { libraryFilesGateway.LoadByFileName(rowNotes.FILENAME, companyId); int newLibraryFilesId = libraryFilesGateway.GetlibraryFilesId(rowNotes.FILENAME); rowNotes.LIBRARY_FILES_ID = newLibraryFilesId; } } } // Save costs information ServiceInformationServiceCost serviceInformationServiceCost = new ServiceInformationServiceCost(serviceInformationTDS); serviceInformationServiceCost.Save(companyId); // Save notes information serviceInformationServiceNote.Save(companyId); // Save service information ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS); serviceInformationBasicInformation.Save(companyId); DB.CommitTransaction(); // Store datasets libraryTDSForServices.AcceptChanges(); serviceInformationTDS.AcceptChanges(); Session["serviceInformationTDS"] = serviceInformationTDS; Session["libraryTDSForServices"] = libraryTDSForServices; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
private void UpdateDatabase() { int companyId = Int32.Parse(hdfCompanyId.Value); DB.Open(); DB.BeginTransaction(); try { ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS); serviceInformationBasicInformation.Save(companyId); string subject = ""; string title = ""; // Send Mails switch ((string)Request.QueryString["state"]) { case "Assigned": // ... If there is an assignation send mail to Assigned Personal if (rbtnPnlAssignToTeamMember.Checked) { SendMailTeamMember(); } // ... Send mail to fleet manager subject = "New service request has been registered."; title = "The following service request has been assigned."; SendMailFleetManager (subject, title); break; case "Accepted": subject = "A service request has been accepted."; title = "The following service request has been accepted."; SendMailFleetManagerAcceptRejectCompleted(subject, title); break; case "Rejected": subject = "A service request has been rejected."; title = "The following service request has been rejected."; SendMailFleetManagerAcceptRejectCompleted(subject, title); break; case "CompleteWork": subject = "A service request has been completed."; title = "The following service request has been completed."; SendMailFleetManagerAcceptRejectCompleted(subject, title); break; } DB.CommitTransaction(); // Store datasets serviceInformationTDS.AcceptChanges(); Session["serviceInformationTDS"] = serviceInformationTDS; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }