public DataTable ReportExtrasHours(DateTime DateStart, DateTime DateEnd, int IdTurn = 0, int IdDepartament = 0, int IdEmployee = 0) { try { DataTable HoursExtras = ReportsDAL.ReportExtras(DateStart, DateEnd, IdTurn, IdDepartament, IdEmployee); TurnBLL TurnBLL = new TurnBLL(); TimeSpan ExtraEntrada; TimeSpan ExtraSalida; TimeSpan RetardoEntrada; TimeSpan SalidaAntes; //return ReportsDAL.ReportExtras(DateStart, DateEnd); HoursExtras.Columns.Add("TiempoExtra", typeof(TimeSpan)); HoursExtras.Columns.Add("Retardos", typeof(TimeSpan)); foreach (DataRow Horas in HoursExtras.Rows) { TimeSpan HoraEntrada = TimeSpan.Parse(Convert.ToDateTime(Horas["ENTRADA"].ToString()).ToString("HH:mm:ss")); TimeSpan HoraSalida = TimeSpan.Parse(Convert.ToDateTime(Horas["SALIDA"].ToString()).ToString("HH:mm:ss")); ExtraEntrada = TimeSpan.Parse("00:00:00"); ExtraSalida = TimeSpan.Parse("00:00:00"); RetardoEntrada = TimeSpan.Parse("00:00:00"); SalidaAntes = TimeSpan.Parse("00:00:00"); if (Horas["TURNO"].ToString() != "HRS EXTRA") { TurnML TurnMLEmployee = TurnBLL.GetTurnForNaMe(Horas["TURNO"].ToString()); TimeSpan HoraInicial = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.StartEntry.ToString()).ToString("HH:mm:ss")); TimeSpan LimiteSalida = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.LimitDeparture.ToString()).ToString("HH:mm:ss")); TimeSpan LimiteEntrada = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.LimitEntry.ToString()).ToString("HH:mm:ss")); TimeSpan Salida = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.Departuretime.ToString()).ToString("HH:mm:ss")); if (HoraEntrada < HoraInicial) { ExtraEntrada = HoraInicial.Subtract(HoraEntrada); } if (HoraSalida > LimiteSalida) { ExtraSalida = HoraSalida.Subtract(LimiteSalida); } //RETARDOS if (HoraEntrada > LimiteEntrada) { RetardoEntrada = HoraEntrada.Subtract(LimiteEntrada); } if (HoraSalida < Salida && HoraSalida > HoraEntrada) { SalidaAntes = Salida.Subtract(HoraSalida); } else { RetardoEntrada = TimeSpan.Parse("00:00:00"); } Horas["TiempoExtra"] = SumToTime(ExtraEntrada, ExtraSalida); Horas["Retardos"] = SumToTime(RetardoEntrada, SalidaAntes); } else { Horas["TiempoExtra"] = HoraSalida.Subtract(HoraEntrada); Horas["Retardos"] = "00:00:00"; } } return(HoursExtras); } catch (Exception ex) { throw new Exception(String.Format("ReportExtrasHours: {0}", ex.Message)); } }
//--------------- NUEVA MIGRACION public void ListRecord(DateTime Start, DateTime End) { try { DataTable ListRecord = MigrationHistoryDAL.ListRecord(Start, End); TimeOutCheckBLL TimeOutCheckBLL = new TimeOutCheckBLL(); TurnBLL TurnBLL = new TurnBLL(); DataTable TimeOutCheckDT = TimeOutCheckBLL.TimeOutCheck("checkin"); DataTable TimeOutCheckMax = TimeOutCheckBLL.TimeOutCheck("maxihours"); //String TotalAddHours; //= new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0,0, 0); TimeSpan TotalAddHours; TimeSpan MaxAddHours; int idGetUser = 0; if (TimeOutCheckMax.Rows.Count > 0) { MaxAddHours = TimeSpan.Parse(TimeOutCheckMax.Rows[0]["timeCheck"].ToString()); } else { MaxAddHours = TimeSpan.Parse("00:00:00"); } //bool SinHoras = false; if (TimeOutCheckDT.Rows.Count > 0) { //TotalAddHours = TimeOutCheckDT.Rows[0]["timeCheck"].ToString(); TotalAddHours = TimeSpan.Parse(TimeOutCheckDT.Rows[0]["timeCheck"].ToString()); //SinHoras = true; } else { TotalAddHours = TimeSpan.Parse("00:00:00"); } if (ListRecord.Rows.Count > 0) { String NameTurn = String.Empty; CheckInHoursML CheckInHours = new CheckInHoursML(); foreach (DataRow Record in ListRecord.Rows) { idGetUser = MigrationHistoryDAL.getUserDialing(Record["idUser"].ToString()); //Verificar si es MARCACION VALIDA if (MigrationHistoryDAL.ValidRecord(Convert.ToDateTime(Record["dateTimeRecord"].ToString()), TotalAddHours, idGetUser) && idGetUser != 0) { //VERIFICAR SI NO EXISTE UNA MARCACION CON LOS MISMO PARAMETROS if (MigrationHistoryDAL.IsExistRecord(idGetUser, Convert.ToDateTime(Record["dateTimeRecord"].ToString())) == 0) { TurnML TurnUser = TurnBLL.GetTurnUser(Convert.ToDateTime(Record["dateTimeRecord"].ToString()), idGetUser); String RecordData = MigrationHistoryDAL.RecordOld(idGetUser); if (!String.IsNullOrEmpty(RecordData)) { DateTime RecordOldTime = Convert.ToDateTime(RecordData.ToString()); CheckInHours.IdEmployee = idGetUser; CheckInHours.MachineNumber = 1; CheckInHours.DateTimeRecord = Convert.ToDateTime(Record["dateTimeRecord"].ToString()); CheckInHours.DateOnlyRecord = Convert.ToDateTime(Record["dateOnlyRecord"].ToString()); CheckInHours.TimeOnlyRecord = TimeSpan.Parse(Record["timeOnlyRecord"].ToString()); CheckInHours.IdTurn = (TurnUser != null) ? TurnUser.Id : 0; TimeSpan TotalDiffHours = TotalDiffTime(RecordOldTime, Convert.ToDateTime(Record["dateTimeRecord"].ToString())); if (MaxAddHours > TotalDiffHours) { int Resul = MigrationHistoryDAL.NumRecordsUser(idGetUser) % 2; CheckInHours.TypeCheck = (Resul == 0)?"ENTRADA":"SALIDA"; } else { CheckInHours.TypeCheck = "ENTRADA"; } } else { if (TurnUser != null) { CheckInHours.IdEmployee = idGetUser; CheckInHours.MachineNumber = 1; CheckInHours.DateTimeRecord = Convert.ToDateTime(Record["dateTimeRecord"].ToString()); CheckInHours.DateOnlyRecord = Convert.ToDateTime(Record["dateOnlyRecord"].ToString()); CheckInHours.TimeOnlyRecord = TimeSpan.Parse(Record["timeOnlyRecord"].ToString()); CheckInHours.IdTurn = TurnUser.Id; CheckInHours.TypeCheck = "ENTRADA"; } else { CheckInHours.IdEmployee = idGetUser; CheckInHours.MachineNumber = 1; CheckInHours.DateTimeRecord = Convert.ToDateTime(Record["dateTimeRecord"].ToString()); CheckInHours.DateOnlyRecord = Convert.ToDateTime(Record["dateOnlyRecord"].ToString()); CheckInHours.TimeOnlyRecord = TimeSpan.Parse(Record["timeOnlyRecord"].ToString()); CheckInHours.IdTurn = 0; CheckInHours.TypeCheck = "ENTRADA"; } } CheckInHoursBLL CheckInHoursBLL = new CheckInHoursBLL(); CheckInHoursBLL.Save(CheckInHours); } } } } //return ListRecord; } catch (Exception ex) { throw new Exception(String.Format("{0}.ListRecord: {1}", core, ex)); } }
public DataTable ReportHoursJob(DateTime DateStart, DateTime DateEnd, int IdTurn = 0, int IdDepartament = 0, int IdEmployee = 0) { try { DataTable HoursExtras = ReportsDAL.ReportExtras(DateStart, DateEnd, IdTurn, IdDepartament, IdEmployee); TurnBLL TurnBLL = new TurnBLL(); EmployeeBLL EmployeeBLL = new EmployeeBLL(); TimeSpan ExtraEntrada; TimeSpan ExtraSalida; TimeSpan RetardoEntrada; TimeSpan SalidaAntes; TimeSpan HrsJornadas; TimeSpan HrsExtras; TimeSpan TotalHrsDia; String TotalHrs; HoursExtras.Columns.Add("HORASJORNADA", typeof(TimeSpan)); HoursExtras.Columns.Add("HORASEXTRAS", typeof(TimeSpan)); HoursExtras.Columns.Add("TOTAL_HRS", typeof(TimeSpan)); HoursExtras.Columns.Add("SUELDO_TOTAL", typeof(Decimal)); foreach (DataRow Horas in HoursExtras.Rows) { TimeSpan HoraEntrada = TimeSpan.Parse(Convert.ToDateTime(Horas["ENTRADA"].ToString()).ToString("HH:mm:ss")); TimeSpan HoraSalida = TimeSpan.Parse(Convert.ToDateTime(Horas["SALIDA"].ToString()).ToString("HH:mm:ss")); //int IdEmployee = Int32.Parse(Horas["CVE"].ToString()); ExtraEntrada = TimeSpan.Parse("00:00:00"); ExtraSalida = TimeSpan.Parse("00:00:00"); RetardoEntrada = TimeSpan.Parse("00:00:00"); SalidaAntes = TimeSpan.Parse("00:00:00"); //horasxDias = TimeSpan.Parse("00:00:00"); EmployeeML SalaryEmployeeML = EmployeeBLL.GetColumnsEmployee(Int32.Parse(Horas["CVE"].ToString())); Decimal Salario = Decimal.Parse(SalaryEmployeeML.Salary.ToString()); Decimal horasxDias = Decimal.Parse(SalaryEmployeeML.HoursDay.ToString()); if (Horas["TURNO"].ToString() != "HRS EXTRA") { TurnML TurnMLEmployee = TurnBLL.GetTurnForNaMe(Horas["TURNO"].ToString()); TimeSpan HoraInicial = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.StartEntry.ToString()).ToString("HH:mm:ss")); TimeSpan LimiteSalida = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.LimitDeparture.ToString()).ToString("HH:mm:ss")); TimeSpan LimiteEntrada = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.LimitEntry.ToString()).ToString("HH:mm:ss")); TimeSpan Salida = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.Departuretime.ToString()).ToString("HH:mm:ss")); TimeSpan HorasJornada = TimeSpan.Parse(Convert.ToDateTime(TurnMLEmployee.HoursJornada.ToString()).ToString("HH:mm:ss")); //HORAS EXTRAS if (HoraEntrada < HoraInicial) { ExtraEntrada = HoraInicial.Subtract(HoraEntrada); } if (HoraSalida > LimiteSalida) { ExtraSalida = HoraSalida.Subtract(LimiteSalida); } //HORAS JORNADA NORMAL if (HoraEntrada != TimeSpan.Parse("00:00:00") && HoraSalida != TimeSpan.Parse("00:00:00")) { Horas["HORASJORNADA"] = HorasJornada; HrsJornadas = HorasJornada; } else { Horas["HORASJORNADA"] = TimeSpan.Parse("00:00:00"); HrsJornadas = TimeSpan.Parse("00:00:00"); } Horas["HORASEXTRAS"] = SumToTime(ExtraEntrada, ExtraSalida); HrsExtras = SumToTime(ExtraEntrada, ExtraSalida); } else { Horas["HORASJORNADA"] = TimeSpan.Parse("00:00:00"); Horas["HORASEXTRAS"] = HoraSalida.Subtract(HoraEntrada); HrsJornadas = TimeSpan.Parse("00:00:00"); HrsExtras = HoraSalida.Subtract(HoraEntrada);; } Horas["TOTAL_HRS"] = SumToTime(HrsJornadas, HrsExtras); TotalHrsDia = SumToTime(HrsJornadas, HrsExtras); TotalHrs = Convert.ToDecimal(Convert.ToDecimal(TotalHrsDia.Hours) + (Convert.ToDecimal(TotalHrsDia.Minutes))).ToString("#.00"); if (horasxDias > 0) { Horas["SUELDO_TOTAL"] = (Salario / 15 / horasxDias) * Convert.ToDecimal(TotalHrs); } else { Horas["SUELDO_TOTAL"] = 0; } } return(HoursExtras); } catch (Exception ex) { throw new Exception(String.Format("ReportHoursJob: {0}", ex.Message)); } }