public Boolean GrabarBD(ro_Empleado_X_Horario_Info info, ref string msg)
        {
            try {
                using (EntitiesRoles db = new EntitiesRoles()){
                    ro_empleado_x_horario item = new ro_empleado_x_horario();

                    item.IdEmpresa        = info.IdEmpresa;
                    item.IdEmpleado       = info.IdEmpleado;
                    item.IdHorario        = info.IdHorario;
                    item.EsPredeterminado = info.EsPredeterminado;
                    item.FechaIngresa     = info.FechaIngresa;
                    item.UsuarioIngresa   = info.UsuarioIngresa;

                    db.ro_empleado_x_horario.Add(item);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.InnerException.ToString());
            }
        }
        public Boolean GetExiste(ro_Empleado_X_Horario_Info info, ref string msg)
        {
            try
            {
                Boolean valorRetornar = false;
                using (EntitiesRoles db = new EntitiesRoles())
                {
                    int cont = (from a in db.ro_empleado_x_horario
                                where a.IdEmpresa == info.IdEmpresa && a.IdEmpleado == info.IdEmpleado && a.IdHorario == info.IdHorario
                                select a).Count();

                    if (cont > 0)
                    {
                        valorRetornar = true;
                    }
                    else
                    {
                        valorRetornar = false;
                    }
                }
                return(valorRetornar);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.InnerException.ToString());
            }
        }
        public ro_Empleado_X_Horario_Info Get_Info_Empleado_X_Horario_Preterminado(int IdEmpresa, decimal IdEmpleado)
        {
            try
            {
                ro_Empleado_X_Horario_Info info = new ro_Empleado_X_Horario_Info();

                EntitiesRoles db = new EntitiesRoles();

                var datos = from a in db.ro_empleado_x_horario
                            where a.IdEmpresa == IdEmpresa &&
                            a.IdEmpleado == IdEmpleado &&
                            a.EsPredeterminado == true
                            select a;

                foreach (var item in datos)
                {
                    info.IdEmpresa        = item.IdEmpresa;
                    info.IdEmpleado       = item.IdEmpleado;
                    info.IdHorario        = item.IdHorario;
                    info.EsPredeterminado = item.EsPredeterminado;
                    info.FechaIngresa     = item.FechaIngresa;
                    info.UsuarioIngresa   = item.UsuarioIngresa;
                }
                return(info);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.InnerException.ToString());
            }
        }
Beispiel #4
0
 public Boolean GrabarBD(ro_Empleado_X_Horario_Info info, ref string msg)
 {
     try
     {
         if (oData.GetExiste(info, ref msg))
         {  //MODIFICA
             return(oData.ModificarBD(info, ref msg));
         }
         else
         {
             //NUEVO
             info.UsuarioIngresa = param.IdUsuario;
             info.FechaIngresa   = param.Fecha_Transac;
             return(oData.GrabarBD(info, ref msg));
         }
     }
     catch (Exception ex)
     {
         Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
         throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GrabarBD", ex.Message), ex)
               {
                   EntityType = typeof(ro_Empleado_X_Horario_Bus)
               };
     }
 }
Beispiel #5
0
        public List <ro_horario_planificacion_Grid_Info> Get_List_horario_planificacion_Grid(DateTime FechaIni, DateTime FechaFin, List <ro_horario_planificacion_Grid_Info> ListadoEmpleados)
        {
            List <ro_horario_planificacion_Grid_Info> Listtempo = new List <ro_horario_planificacion_Grid_Info>();

            List <ro_horario_planificacion_Grid_Info> resultado = new List <ro_horario_planificacion_Grid_Info>();

            try
            {
                int dias = 0;
                var x    = FechaFin - FechaIni;
                dias = x.Days;
                EntitiesRoles oEnt = new EntitiesRoles();

//                RolesParam = busParam.ConsultaParametrosRoles(ListadoEmpleados[0].IdEmpresa).First(var => var.IdEmpresa == ListadoEmpleados[0].IdEmpresa);
                RolesParam = busParam.Get_List_Parametros(ListadoEmpleados[0].IdEmpresa).FirstOrDefault();

                List <VwRo_Planificaion_Horarios_x_Empleado_Info> listHorariosxEmple = new List <VwRo_Planificaion_Horarios_x_Empleado_Info>();
                //List<VwRo_Planificaion_Horarios_x_Empleado_Info> listHorariosxEmple_ItemEmpleado = new List<VwRo_Planificaion_Horarios_x_Empleado_Info>();


                IQueryable <VwRo_Planificaion_Horarios_x_Empleado_Info> Consulta =
                    from C in oEnt.vwRo_Planificacion_Horarios_x_Empleado
                    where
                    C.fecha <= FechaFin &&
                    C.fecha >= FechaIni &&
                    C.Estado == "A"
                    select new VwRo_Planificaion_Horarios_x_Empleado_Info
                {
                    Descripcion         = C.Descripcion
                    , Estado            = C.Estado
                    , fecha             = C.fecha
                    , IdEmpleado        = C.IdEmpleado
                    , IdEmpresa         = C.IdEmpresa
                    , IdRegistro        = C.IdPlanificacion
                    , IdSucursal        = C.IdSucursal
                    , IdHorario         = C.IdHorario
                    , Inicial_del_Dia   = C.Inicial_del_Dia
                    , NombreCortoFecha  = C.NombreCortoFecha
                    , pe_nombreCompleto = C.pe_nombreCompleto
                    , Su_Descripcion    = C.Su_Descripcion
                    , ca_descripcion    = C.ca_descripcion
                    , Departamento      = C.Departamento
                    , IdCalendario      = C.IdCalendario
                };

                listHorariosxEmple = Consulta.ToList();


                foreach (var empl in ListadoEmpleados)
                {
                    ro_horario_planificacion_Grid_Info Info = new ro_horario_planificacion_Grid_Info();
                    Info.IdEmpleado     = empl.IdEmpleado;
                    Info.IdEmpresa      = empl.IdEmpresa;
                    Info.NomCompleto    = empl.NomCompleto;
                    Info.ca_descripcion = empl.ca_descripcion;
                    Info.Departamento   = empl.Departamento;
                    Info.Sucursal       = empl.Sucursal;
                    Info.IdCalendario   = empl.IdCalendario;


                    List <VwRo_Planificaion_Horarios_x_Empleado_Info> listHorariosxEmple_ItemEmpleado =
                        listHorariosxEmple.FindAll(C => C.IdEmpleado == empl.IdEmpleado);

                    var turnosdobles = from C in listHorariosxEmple_ItemEmpleado
                                       group C by new { C.fecha }
                    into grupo
                        select new { grupo.Key };

                    foreach (var item in turnosdobles)
                    {
                        ro_horario_planificacion_Grid_Info.turnos turn = new ro_horario_planificacion_Grid_Info.turnos(); int sec = 0;
                        foreach (var item2 in listHorariosxEmple_ItemEmpleado)
                        {
                            if (item2.fecha == item.Key.fecha)
                            {
                                turn.fecha      = item2.fecha;
                                turn.turno[sec] = Convert.ToInt32(item2.IdHorario);
                                turn.count      = ++sec;
                            }
                        }
                        empl.Listado.Add(turn);
                    }
                    try
                    {
                        if (listHorariosxEmple_ItemEmpleado.Count > 0)
                        {
                            for (int i = 0; i < dias + 1; i++)
                            {
                                DateTime dia;
                                dia = FechaIni.AddDays(i);


                                foreach (var reg in listHorariosxEmple_ItemEmpleado)
                                {
                                    if (reg.fecha == dia)
                                    {
                                        Info                = new ro_horario_planificacion_Grid_Info();
                                        Info.IdEmpleado     = empl.IdEmpleado;
                                        Info.IdEmpresa      = empl.IdEmpresa;
                                        Info.NomCompleto    = empl.NomCompleto;
                                        Info.Sucursal       = empl.Sucursal;
                                        Info.ca_descripcion = empl.ca_descripcion;
                                        Info.Departamento   = empl.Departamento;
                                        Info.IdCalendario   = empl.IdCalendario;

                                        Info.IdHorarioDia[i] = Convert.ToInt32(reg.IdHorario);

                                        {
                                            ro_horario_planificacion_Grid_Info tempo = new ro_horario_planificacion_Grid_Info();
                                            try
                                            {
                                                tempo = resultado.First(var => var.IdEmpleado == empl.IdEmpleado && var.IdHorarioDia[i] == 0);
                                                if (tempo != null)
                                                {
                                                    resultado.Remove(tempo);
                                                    Info = tempo;
                                                    Info.IdHorarioDia[i] = Convert.ToInt32(reg.IdHorario);
                                                    Info = Get_Info_horario_planificacion_Grid(Info.IdHorarioDia, Info);
                                                    resultado.Add(Info);
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                string arreglo = ToString();
                                                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                                                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                                                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                                                mensaje = ex.InnerException + " " + ex.Message;
                                                Info    = Get_Info_horario_planificacion_Grid(Info.IdHorarioDia, Info);
                                                resultado.Add(Info);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < dias + 1; i++)
                            {
                                Info.IdHorarioDia[i] = 0;
                            }
                            Info = Get_Info_horario_planificacion_Grid(Info.IdHorarioDia, Info);
                            resultado.Add(Info);
                        }
                    }
                    catch (Exception ex)
                    {
                        string arreglo = ToString();
                        tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                        tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                        oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                        mensaje = ex.InnerException + " " + ex.Message;
                    }
                }

                ro_Empleado_X_Horario_Data oRo_Empleado_X_Horario_Data = new Roles.ro_Empleado_X_Horario_Data();


                foreach (var item in resultado)
                {
                    var reg = Getarray(item.IdHorarioDia, item);

                    for (int i = 0; i < 32; i++)
                    {
                        if (reg.IdHorarioDia[i] == 0)
                        {
                            reg.IdHorarioDia[i] = 1;
                        }
                    }

                    reg = Get_Info_horario_planificacion_Grid(reg.IdHorarioDia, reg);

                    ro_Empleado_X_Horario_Info info = new ro_Empleado_X_Horario_Info();
                    info          = oRo_Empleado_X_Horario_Data.Get_Info_Empleado_X_Horario_Preterminado(item.IdEmpresa, item.IdEmpleado);
                    reg.IdHorario = info.IdHorario;

                    Listtempo.Add(reg);
                }
                return(Listtempo);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.InnerException.ToString());
            }
        }