/// <summary> /// /// </summary> /// <param name="employee"></param> /// <param name="operation"></param> /// <returns></returns> public MessageDTO SaveEmployee(EmployeeDTO employee, string operation) { DataTable dataTable = new DataTable(); IUniversalConnector connector = new UniversalConnectorImpl(ServerEnumType.SqlServer, connectionString); MessageDTO message = new MessageDTO(); try { connector.BeginTransaction(); //Todos los registros object[] parameters = new object[] { employee.EmployeeId, employee.Company.CompanyId, employee.Department.DepartmentId, employee.ContractType.ContractTypeId, employee.Charge.ChargeId, employee.Schedule.ScheduleId, employee.User.UserId, employee.IdentificationType.IdentificationTypeId, employee.Sex.SexId, employee.SectorId, employee.IdentificationNumber, employee.EmployeeName, employee.EmployeeLastName, employee.ScheduleType, employee.EmployeeFingerPrint, employee.EmployeeCardNumber, employee.EmployeeBirthDate, employee.EmployeeSalary, employee.EmployeeEntryDate, employee.EmployeeModificationDate, employee.EmployeeValidityStartDate, employee.EmployeeValidityEndDate, employee.EmployeeTruancy, employee.EmployeeUsedCard, employee.EmployeeStreetAddress, employee.EmployeeStatus, operation }; //connector.ExecuteNonQuery(CommandType.StoredProcedure, "SaveEmployee", parameters); dataTable = connector.ExecuteDataTable(CommandType.StoredProcedure, "SaveEmployee", parameters); foreach (DataRow row in dataTable.Rows) { message.ErrorCode = row["ERROR_NUMBER"].ToString(); message.ErrorMessage = row["ERROR_DESCRIPTION"].ToString(); } if (message.ErrorCode == "0") { connector.Commit(); } else { connector.RollBack(); } } catch (Exception exception) { message.ErrorCode = "-1"; message.ErrorMessage = exception.ToString(); connector.RollBack(); } finally { connector.Dispose(); } return(message); }
//string connectionString = ConfigurationManager.ConnectionStrings["ConnectionTA"].ToString(); #endregion #region Schedule /// <summary> /// /// </summary> /// <param name="schedule"></param> /// <param name="operation"></param> /// <returns></returns> public MessageDTO SaveSchedule(ScheduleDTO schedule, string operation) { DataTable dataTable = new DataTable(); IUniversalConnector connector = new UniversalConnectorImpl(ServerEnumType.SqlServer, connectionString); MessageDTO message = new MessageDTO(); try { connector.BeginTransaction(); //Todos los registros object[] parameters = new object[] { schedule.ScheduleId, schedule.Company.CompanyId, schedule.User.UserId, schedule.Workday.WorkdayId, schedule.ScheduleShortName, schedule.ScheduleDescription, schedule.ScheduleStartHour, schedule.ScheduleEndHour, schedule.ScheduleLunchHour, schedule.ScheduleIsNight, schedule.ScheduleAccess, schedule.ScheduleOuterZone, schedule.ScheduleInnerZone, schedule.ScheduleLunchTime, schedule.ScheduleOutputDelay, schedule.ScheduleEntryDelay, schedule.ScheduleStatus, operation }; //connector.ExecuteNonQuery(CommandType.StoredProcedure, "SaveSchedule", parameters); dataTable = connector.ExecuteDataTable(CommandType.StoredProcedure, "SaveSchedule", parameters); foreach (DataRow row in dataTable.Rows) { message.ErrorCode = row["ERROR_NUMBER"].ToString(); message.ErrorMessage = row["ERROR_DESCRIPTION"].ToString(); } if (message.ErrorCode == "0") { connector.Commit(); } else { connector.RollBack(); } } catch (Exception exception) { message.ErrorCode = "-1"; message.ErrorMessage = exception.ToString(); connector.RollBack(); } finally { connector.Dispose(); } return(message); }
//string connectionString = ConfigurationManager.ConnectionStrings["ConnectionTA"].ToString(); #endregion #region Department /// <summary> /// /// </summary> /// <param name="charge"></param> /// <param name="operation"></param> /// <returns></returns> public MessageDTO SaveDepartment(DepartmentDTO department, string operation) { DataTable dataTable = new DataTable(); IUniversalConnector connector = new UniversalConnectorImpl(ServerEnumType.SqlServer, connectionString); MessageDTO message = new MessageDTO(); try { connector.BeginTransaction(); //Todos los registros object[] parameters = new object[] { department.DepartmentId, department.Company.CompanyId, department.SpendingCenter.SpendingCenterId, department.User.UserId, department.DepartmentDescription, department.DepartmentStatus, operation }; //connector.ExecuteNonQuery(CommandType.StoredProcedure, "SaveDepartment", parameters); dataTable = connector.ExecuteDataTable(CommandType.StoredProcedure, "SaveDepartment", parameters); foreach (DataRow row in dataTable.Rows) { message.ErrorCode = row["ERROR_NUMBER"].ToString(); message.ErrorMessage = row["ERROR_DESCRIPTION"].ToString(); } if (message.ErrorCode == "0") { connector.Commit(); } else { connector.RollBack(); } } catch (Exception exception) { message.ErrorCode = "-1"; message.ErrorMessage = exception.ToString(); connector.RollBack(); } finally { connector.Dispose(); } return(message); }