/// <summary> /// Save all to database (direct) /// </summary> /// <param name="companyId">companyId</param> public void Save(int employeeId, int companyId) { // Delete previous types EmployeeTypeHistory employeeTypeHistoryForDelete = new EmployeeTypeHistory(null); employeeTypeHistoryForDelete.DeleteAllDirect(employeeId, companyId); // Insert new types EmployeeInformationTDS typeHistoryInformationChanges = (EmployeeInformationTDS)Data.GetChanges(); if (typeHistoryInformationChanges.TypeHistoryInformation.Rows.Count > 0) { EmployeeInformationTypeHistoryInformationGateway employeeInformationTypeHistoryInformationGateway = new EmployeeInformationTypeHistoryInformationGateway(typeHistoryInformationChanges); foreach (EmployeeInformationTDS.TypeHistoryInformationRow row in (EmployeeInformationTDS.TypeHistoryInformationDataTable)typeHistoryInformationChanges.TypeHistoryInformation) { // Insert new typeHistorys if ((!row.Deleted) && (!row.InDatabase)) { EmployeeTypeHistory employeeTypeHistory = new EmployeeTypeHistory(null); employeeTypeHistory.InsertDirect(row.EmployeeID, row.RefID, row.Date, row.Type, row.Deleted, row.COMPANY_ID); } // Deleted typeHistorys if ((row.Deleted) && (row.InDatabase)) { EmployeeTypeHistory employeeTypeHistory = new EmployeeTypeHistory(null); employeeTypeHistory.DeleteDirect(row.EmployeeID, row.RefID, row.COMPANY_ID); } } } }
private void UpdateDatabase() { // Get ids int currentEmployeeId = Int32.Parse(hdfCurrentEmployeeId.Value); int companyId = Int32.Parse(hdfCompanyId.Value); // Delete DB.Open(); DB.BeginTransaction(); try { EmployeeTypeHistory employeeTypeHistory = new EmployeeTypeHistory(employeeInformationTDS); employeeTypeHistory.DeleteAllDirect(currentEmployeeId, companyId); Employee employee = new Employee(employeeTDS); employee.DeleteDirect(currentEmployeeId); DB.CommitTransaction(); } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }