/// GetNewRefId /// </summary> /// <param name="employeeId">employeeId</param> /// <param name="companyId">companyId</param> /// <returns>New ID</returns> public int GetNewRefId(int employeeId, int companyId) { int newRefId = 0; if (Table.Rows.Count == 0) { EmployeeInformationTypeHistoryInformationGateway rr = new EmployeeInformationTypeHistoryInformationGateway(); rr.LoadAllByEmployeeId(employeeId, companyId); foreach (EmployeeInformationTDS.TypeHistoryInformationRow row1 in (EmployeeInformationTDS.TypeHistoryInformationDataTable)rr.Table) { if (newRefId < row1.RefID) { newRefId = row1.RefID; } } } else { foreach (EmployeeInformationTDS.TypeHistoryInformationRow row2 in (EmployeeInformationTDS.TypeHistoryInformationDataTable)Table) { if (newRefId < row2.RefID) { newRefId = row2.RefID; } } } newRefId++; return newRefId; }
/// <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); } } } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// LoadAllByEmployeeId /// </summary> /// <param name="employeeId">employeeId</param> /// <param name="companyId">companyId</param> public void LoadAllByEmployeeId(int employeeId, int companyId) { EmployeeInformationTypeHistoryInformationGateway employeeInformationTypeHistoryInformationGateway = new EmployeeInformationTypeHistoryInformationGateway(Data); employeeInformationTypeHistoryInformationGateway.LoadAllByEmployeeId(employeeId, companyId); }