Esempio n. 1
0
        public Boolean GetExiste(ro_historico_vacaciones_x_empleado_Info info, ref string msg)
        {
            try
            {
                Boolean valorRetornar = false;
                using (EntitiesRoles db = new EntitiesRoles())
                {
                    int cont = (from a in db.ro_historico_vacaciones_x_empleado
                                where a.IdEmpresa == info.IdEmpresa && a.IdEmpleado == info.IdEmpleado &&
                                a.IdHis_Vacaciones == info.IdHis_Vacaciones &&
                                a.Secuencia == info.Secuencia
                                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 Boolean GrabarBD(ro_historico_vacaciones_x_empleado_Info info, ref int id, ref string msg)
        {
            try
            {
                Boolean valorRetornar = false;

                //MODIFICAR
                if (oRo_historico_vacaciones_x_empleado_Data.GetExiste(info, ref msg))
                {
                    valorRetornar = oRo_historico_vacaciones_x_empleado_Data.ModificarBD(info, ref msg);
                    id            = info.IdHis_Vacaciones;
                }
                else  //GRABAR
                {
                    valorRetornar = oRo_historico_vacaciones_x_empleado_Data.GrabarBD(info, ref id, ref msg);
                }

                return(valorRetornar);
            }
            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_historico_vacaciones_x_empleado_Bus)
                      };
            }
        }
        public List <ro_historico_vacaciones_x_empleado_Info> CalculoDiasTrabajosDetalle(int IdEmpresa, DateTime FI, DateTime FF, Decimal IdEmpleado)
        {
            List <ro_historico_vacaciones_x_empleado_Info> lst = new List <ro_historico_vacaciones_x_empleado_Info>();

            try
            {
                using (EntitiesRoles base_ = new EntitiesRoles())
                {
                    var Calculo = from q in base_.spRo_Calculo_Dias_Trabajados_detalle(IdEmpresa, FI, FF, IdEmpleado, IdEmpleado)
                                  select q;
                    foreach (var item in Calculo)
                    {
                        ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                        info.DiasTomados  = Convert.ToInt32(item.Dias_a_disfrutar);
                        info.FechaInicio  = Convert.ToDateTime(item.fecha_desde);
                        info.FechaFin     = Convert.ToDateTime(item.fecha_Hasta);
                        info.Observacion  = item.observacion;
                        info.FechaRetorno = Convert.ToDateTime(item.fecha_retorno);
                        lst.Add(info);
                    }

                    return(lst);
                }
            }
            catch (Exception ex)
            {
                string array = 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(), "", array, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
Esempio n. 4
0
 public Boolean GrabarBD(ro_historico_vacaciones_x_empleado_Info info)
 {
     try
     {
         using (Entities_rrhh contex = new Entities_rrhh())
         {
             ro_historico_vacaciones_x_empleado data = new ro_historico_vacaciones_x_empleado();
             data.IdEmpresa        = info.IdEmpresa;
             data.IdEmpleado       = info.IdEmpleado;
             data.IdVacacion       = info.IdVacacion;
             data.IdPeriodo_Inicio = info.IdPeriodo_Inicio;
             data.IdPeriodo_Fin    = info.IdPeriodo_Fin;
             data.FechaIni         = info.FechaIni;
             data.FechaFin         = info.FechaFin;
             data.DiasGanado       = info.DiasGanado;
             data.DiasTomados      = info.DiasTomados;
             contex.ro_historico_vacaciones_x_empleado.Add(data);
             contex.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 5
0
        public Boolean GetExiste(ro_historico_vacaciones_x_empleado_Info info, ref string msg)
        {
            try
            {
                Boolean valorRetornar = false;
                using (Entities_rrhh contex = new Entities_rrhh())
                {
                    int cont = (from a in contex.ro_historico_vacaciones_x_empleado
                                where a.IdEmpresa == info.IdEmpresa && a.IdEmpleado == info.IdEmpleado &&
                                a.IdPeriodo_Inicio == info.IdPeriodo_Inicio &&
                                a.IdPeriodo_Fin == info.IdPeriodo_Fin
                                select a).Count();

                    if (cont > 0)
                    {
                        valorRetornar = true;
                    }
                    else
                    {
                        valorRetornar = false;
                    }
                }
                return(valorRetornar);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 6
0
        public Boolean ModificarBD(ro_historico_vacaciones_x_empleado_Info info, ref string msg)
        {
            try
            {
                using (EntitiesRoles db = new EntitiesRoles())
                {
                    var data = db.ro_historico_vacaciones_x_empleado.First(a => a.IdEmpresa == info.IdEmpresa && a.IdEmpleado == info.IdEmpleado &&
                                                                           a.IdHis_Vacaciones == info.IdHis_Vacaciones && a.Secuencia == info.Secuencia);
                    data.FechaIni    = info.FechaInicio;
                    data.FechaFin    = info.FechaFin;
                    data.DiasGanado  = info.DiasGanados;
                    data.DiasTomados = info.DiasTomados;

                    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());
            }
        }
Esempio n. 7
0
 public Boolean GrabarBD(ro_historico_vacaciones_x_empleado_Info info, ref int id, ref string msg)
 {
     try
     {
         using (EntitiesRoles db = new EntitiesRoles())
         {
             ro_historico_vacaciones_x_empleado data = new ro_historico_vacaciones_x_empleado();
             data.IdEmpresa   = info.IdEmpresa;
             data.IdEmpleado  = info.IdEmpleado;
             data.IdVacacion  = id = getId(info.IdEmpresa, info.IdEmpleado);
             data.FechaIni    = info.FechaInicio;
             data.FechaFin    = info.FechaFin;
             data.DiasGanado  = info.DiasGanados;
             data.DiasTomados = info.DiasTomados;
             db.ro_historico_vacaciones_x_empleado.Add(data);
             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 ModificarBD(ro_historico_vacaciones_x_empleado_Info info)
 {
     try
     {
         return(odata.ModificarBD(info));
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 9
0
 public void Consultar(ro_Empleado_Info empinfoVaca, ro_historico_vacaciones_x_empleado_Info histoInfo)
 {
     try
     {
         Datasource = new BindingList <ro_historico_vacaciones_x_empleado_Info>(busSolicitudVaca.CalculoDiasTrabajosDetalle(param.IdEmpresa, histoInfo.FechaInicio, histoInfo.FechaFin, empinfoVaca.IdEmpleado));
         gridControlConsultaH.DataSource = Datasource;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         Log_Error_bus.Log_Error(ex.ToString());
     }
 }
Esempio n. 10
0
        public ActionResult Modificar(ro_Solicitud_Vacaciones_x_empleado_Info info)
        {
            try
            {
                bus_solicitud = new ro_Solicitud_Vacaciones_x_empleado_Bus();
                if (ModelState.IsValid)
                {
                    string mensaje = "";
                    ro_historico_vacaciones_x_empleado_Info info_historico = null;
                    lst_vacaciones          = ro_historico_vacaciones_x_empleado_Info_list.get_list();
                    info_historico          = lst_vacaciones.Where(v => v.IdVacacion == info.IdVacacion).FirstOrDefault();
                    info.Dias_a_disfrutar   = Convert.ToInt32((info.Fecha_Hasta - info.Fecha_Desde).TotalDays) + 1;
                    info.Dias_q_Corresponde = info_historico.DiasGanado;
                    info.Dias_pendiente     = info_historico.DiasGanado - info.Dias_a_disfrutar;
                    info.Anio_Desde         = info_historico.FechaIni.Date;
                    info.Anio_Hasta         = info_historico.FechaFin.Date;
                    info.IdVacacion         = info_historico.IdVacacion;
                    info.Fecha_Desde        = info.Fecha_Desde.Date;
                    info.Fecha_Hasta        = info.Fecha_Hasta.Date;
                    mensaje             = bus_solicitud.validar(info);
                    info.lst_vacaciones = lst_vacaciones;

                    if (mensaje != "")
                    {
                        ViewBag.mensaje = mensaje;
                        cargar_combo();
                        return(View(info));
                    }

                    info.IdEmpresa = GetIdEmpresa();

                    if (!bus_solicitud.modificarDB(info))
                    {
                        cargar_combo();
                        return(View(info));
                    }
                    else
                    {
                        return(RedirectToAction("Modificar", new { IdEmpleado = info.IdEmpleado, IdSolicitud = info.IdSolicitud, Exito = true }));
                    }
                }
                else
                {
                    return(View(info));
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
 public ActionResult Nuevo(ro_Solicitud_Vacaciones_x_empleado_Info info)
 {
     try
     {
         bus_solicitud = new ro_Solicitud_Vacaciones_x_empleado_Bus();
         if (ModelState.IsValid)
         {
             string mensaje = "";
             ro_historico_vacaciones_x_empleado_Info info_historico = null;
             lst_vacaciones          = Session["lst_vacaciones"] as List <ro_historico_vacaciones_x_empleado_Info>;
             info_historico          = lst_vacaciones.Where(v => v.IdVacacion == info.IdVacacion).FirstOrDefault();
             info.Dias_a_disfrutar   = Convert.ToInt32((info.Fecha_Hasta.AddDays(1) - info.Fecha_Desde).TotalDays);
             info.Dias_q_Corresponde = info_historico.DiasGanado;
             info.Dias_pendiente     = info_historico.DiasGanado - info.Dias_a_disfrutar;
             info.Anio_Desde         = info_historico.FechaIni.Date;
             info.Anio_Hasta         = info_historico.FechaFin.Date;
             info.IdVacacion         = info_historico.IdVacacion;
             info.Fecha_Desde        = info.Fecha_Desde.Date;
             info.Fecha_Hasta        = info.Fecha_Hasta.Date;
             mensaje = bus_solicitud.validar(info);
             if (mensaje != "")
             {
                 ViewBag.mensaje = mensaje;
                 cargar_combo();
                 return(View(info));
             }
             info.IdEmpresa = GetIdEmpresa();
             if (!bus_solicitud.guardarDB(info))
             {
                 cargar_combo();
                 return(View(info));
             }
             else
             {
                 info_historico.DiasTomados = info.Dias_a_disfrutar;
             }
             bus_vacaciones = new ro_historico_vacaciones_x_empleado_Bus();
             bus_vacaciones.ModificarBD(info_historico);
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(info));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 private void gridViewHistorico_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     try
     {
         histoinfo = new ro_historico_vacaciones_x_empleado_Info();
         histoinfo = (ro_historico_vacaciones_x_empleado_Info)gridViewHistorico.GetFocusedRow();
     }
     catch (Exception ex)
     {
         string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
         MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
     }
 }
Esempio n. 13
0
        public ActionResult Nuevo(ro_Solicitud_Vacaciones_x_empleado_Info info)
        {
            try
            {
                bus_solicitud = new ro_Solicitud_Vacaciones_x_empleado_Bus();

                string mensaje = "";
                ro_historico_vacaciones_x_empleado_Info info_historico = null;
                lst_vacaciones          = ro_historico_vacaciones_x_empleado_Info_list.get_list();
                info_historico          = lst_vacaciones.FirstOrDefault();
                info.Dias_a_disfrutar   = Convert.ToInt32((info.Fecha_Hasta.AddDays(1) - info.Fecha_Desde).TotalDays);
                info.Dias_q_Corresponde = info.Dias_a_disfrutar;
                info.Dias_pendiente     = 0;
                info.Anio_Desde         = info_historico.FechaIni.Date;
                info.Anio_Hasta         = info_historico.FechaFin.Date;
                info.Fecha_Desde        = info.Fecha_Desde.Date;
                info.Fecha_Hasta        = info.Fecha_Hasta.Date;
                mensaje             = bus_solicitud.validar(info);
                info.lst_vacaciones = lst_vacaciones;
                if (mensaje != "")
                {
                    ViewBag.mensaje = mensaje;
                    cargar_combo();
                    return(View(info));
                }

                info.IdEmpresa = GetIdEmpresa();

                if (!bus_solicitud.guardarDB(info))
                {
                    cargar_combo();
                    return(View(info));
                }
                else
                {
                    info_historico.DiasTomados = info.Dias_a_disfrutar;
                }

                bus_vacaciones = new ro_historico_vacaciones_x_empleado_Bus();
                bus_vacaciones.ModificarBD(info_historico);

                return(RedirectToAction("Modificar", new { IdEmpleado = info.IdEmpleado, IdSolicitud = info.IdSolicitud, Exito = true }));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 14
0
        public List <ro_historico_vacaciones_x_empleado_Info> ConsultarHistoricoVaca(Decimal IdEmpleado, int IdEmpresa)
        {
            List <ro_historico_vacaciones_x_empleado_Info> lst = new List <ro_historico_vacaciones_x_empleado_Info>();

            try
            {
                using (EntitiesRoles rol = new EntitiesRoles())
                {
                    var consultar = from q in rol.ro_historico_vacaciones_x_empleado
                                    where q.IdEmpleado == IdEmpleado &&
                                    q.IdEmpresa == IdEmpresa
                                    orderby q.FechaIni ascending
                                    select q;
                    foreach (var item in consultar)
                    {
                        ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                        info.IdEmpresa        = item.IdEmpresa;
                        info.IdEmpleado       = item.IdEmpleado;
                        info.IdHis_Vacaciones = item.IdHis_Vacaciones;
                        info.Secuencia        = item.Secuencia;
                        info.FechaInicio      = Convert.ToDateTime(item.FechaIni);
                        info.FechaFin         = Convert.ToDateTime(item.FechaFin);
                        info.DiasGanados      = Convert.ToInt32(item.DiasGanado);
                        info.DiasTomados      = Convert.ToInt32(item.DiasTomados);
                        info.DiasPendientes   = Convert.ToInt32(item.DiasGanado - item.DiasTomados);
                        info.check            = (info.DiasTomados > 0) ? true : false;

                        lst.Add(info);
                    }
                }


                //lst = (from a in lst
                //            orderby a.FechaInicio ascending
                //            select a).ToList();

                return(lst);
            }
            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());
            }
        }
Esempio n. 15
0
 public Boolean ModificarBD(ro_historico_vacaciones_x_empleado_Info info)
 {
     try
     {
         using (Entities_rrhh contex = new Entities_rrhh())
         {
             var data = contex.ro_historico_vacaciones_x_empleado.First(a => a.IdEmpresa == info.IdEmpresa &&
                                                                        a.IdEmpleado == info.IdEmpleado &&
                                                                        a.IdPeriodo_Inicio == info.IdPeriodo_Inicio &&
                                                                        a.IdPeriodo_Fin == info.IdPeriodo_Fin);
             data.DiasGanado = info.DiasGanado;
             contex.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 16
0
        public List <ro_historico_vacaciones_x_empleado_Info> get_list_periodo_con_saldo(int IdEmpresa, decimal IdEmpleado)
        {
            List <ro_historico_vacaciones_x_empleado_Info> lst = new List <ro_historico_vacaciones_x_empleado_Info>();

            try
            {
                using (Entities_rrhh contex = new Entities_rrhh())
                {
                    var consultar = from q in contex.ro_historico_vacaciones_x_empleado
                                    where q.IdEmpleado == IdEmpleado &&
                                    q.IdEmpresa == IdEmpresa &&
                                    q.DiasTomados >= q.DiasTomados
                                    orderby q.FechaIni ascending
                                    select q;
                    foreach (var item in consultar)
                    {
                        ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                        info.IdEmpresa        = item.IdEmpresa;
                        info.IdEmpleado       = item.IdEmpleado;
                        info.IdVacacion       = item.IdVacacion;
                        info.IdPeriodo_Inicio = item.IdPeriodo_Inicio;
                        info.IdPeriodo_Fin    = item.IdPeriodo_Fin;
                        info.FechaIni         = item.FechaIni;
                        info.FechaFin         = item.FechaFin;
                        info.DiasGanado       = item.DiasGanado;
                        info.DiasTomados      = item.DiasTomados;
                        lst.Add(info);
                    }
                }

                return(lst);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public Boolean GenerarVacacionesPorEmpleado(ro_Empleado_Info oRo_Empleado_Info, ref string msg)
        {
            try
            {
                List <ro_historico_vacaciones_x_empleado_Info> listadoOriginal = new List <ro_historico_vacaciones_x_empleado_Info>();
                List <ro_historico_vacaciones_x_empleado_Info> listadoTmp      = new List <ro_historico_vacaciones_x_empleado_Info>();

                Boolean  valorRetornar = false;
                DateTime fechaActual   = param.Fecha_Transac;
                DateTime fechaIngreso  = Convert.ToDateTime(oRo_Empleado_Info.em_fechaIngaRol);
                DateTime fechaNueva    = new DateTime();


                double dias  = 0;
                int    meses = 0;
                int    anio  = 0;
                if (oRo_Empleado_Info.em_status == "EST_PLQ")
                {
                    dias  = CalcularDiasDeDiferencia(fechaIngreso, Convert.ToDateTime(oRo_Empleado_Info.em_fechaSalida));
                    meses = CalcularMesesDeDiferencia(fechaIngreso, Convert.ToDateTime(oRo_Empleado_Info.em_fechaSalida));
                    anio  = CalcularAniosDeDiferencia(fechaIngreso, Convert.ToDateTime(oRo_Empleado_Info.em_fechaSalida));
                }
                else
                {
                    dias  = CalcularDiasDeDiferencia(fechaIngreso, fechaActual);
                    meses = CalcularMesesDeDiferencia(fechaIngreso, fechaActual);
                    anio  = CalcularAniosDeDiferencia(fechaIngreso, fechaActual);
                }
                int minAnio        = 5;
                int maxDiasGanados = 15;
                int minDiasGanados = 15;

                int diasGanados     = 0;
                int contDiasGanados = 0;



                int idSecuencia = 0;

                //MODIFICA
                if (ExisteHistoricoVaca(oRo_Empleado_Info.IdEmpleado, oRo_Empleado_Info.IdEmpresa))
                {
                    listadoOriginal = ConsultarHistoricoVaca(oRo_Empleado_Info.IdEmpleado, oRo_Empleado_Info.IdEmpresa);

                    //CREAR ARREGLO PREVIO DE FECHAS DE VACACIONES

                    fechaNueva = fechaIngreso;
                    //RECORRE LA CANTIDAD DE AÑOS QUE TIENE DE SERVICIO
                    for (int i = 0; i < anio; i++)
                    {
                        ro_historico_vacaciones_x_empleado_Info tmp = new ro_historico_vacaciones_x_empleado_Info();

                        diasGanados        = minDiasGanados;
                        tmp.IdEmpresa      = oRo_Empleado_Info.IdEmpresa;
                        tmp.IdEmpleado     = oRo_Empleado_Info.IdEmpleado;
                        tmp.FechaInicio    = fechaNueva.AddYears(i);
                        tmp.FechaFin       = tmp.FechaInicio.AddYears(1).AddDays(-1);
                        tmp.DiasGanados    = diasGanados;
                        tmp.DiasPendientes = diasGanados;
                        tmp.DiasTomados    = 0;

                        //listadoTmp.Add(tmp);
                        int indice = -1;
                        indice = listadoOriginal.FindIndex(v => v.FechaInicio.ToShortDateString() == tmp.FechaInicio.ToShortDateString());

                        if (indice < 0)//OBJETO ENCONTRADO
                        {
                            valorRetornar = oRo_historico_vacaciones_x_empleado_Data.GrabarBD(tmp, ref idSecuencia, ref msg);
                        }
                    }
                }
                else
                {//GRABAR NUEVO
                    //VALIDA SI TIENE MAS DE 1 AÑO
                    if (dias > 360)
                    {
                        fechaNueva = fechaIngreso;

                        //RECORRE LA CANTIDAD DE AÑOS QUE TIENE DE SERVICIO
                        for (int i = 0; i < anio; i++)
                        {
                            if (i < minAnio)//VALIDA LOS 5 AÑOS BASE
                            {
                                diasGanados     = minDiasGanados;
                                contDiasGanados = 0;
                            }
                            else
                            {
                                if (i >= minAnio && contDiasGanados < maxDiasGanados)//VALIDA QUE SOLO ACUMULE 30 DIAS DE VACACIONES A PARTIR DEL 5 AÑO
                                {
                                    contDiasGanados++;
                                    diasGanados = minDiasGanados + contDiasGanados;
                                }
                                else
                                {
                                    diasGanados = 30;//DE AQUI EN ADELANTE TENDREA SOLO 30 DIAS
                                }
                            }

                            ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                            info.IdEmpresa      = oRo_Empleado_Info.IdEmpresa;
                            info.IdEmpleado     = oRo_Empleado_Info.IdEmpleado;
                            info.FechaInicio    = fechaNueva.AddYears(i);
                            info.FechaFin       = info.FechaInicio.AddYears(1).AddDays(-1);
                            info.DiasGanados    = diasGanados;
                            info.DiasPendientes = diasGanados;
                            info.DiasTomados    = 0;

                            valorRetornar = oRo_historico_vacaciones_x_empleado_Data.GrabarBD(info, ref idSecuencia, ref msg);
                        }
                    }
                    else
                    {
                        ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                        info.IdEmpresa      = oRo_Empleado_Info.IdEmpresa;
                        info.IdEmpleado     = oRo_Empleado_Info.IdEmpleado;
                        info.FechaInicio    = Convert.ToDateTime(oRo_Empleado_Info.em_fecha_ingreso);
                        info.FechaFin       = Convert.ToDateTime(oRo_Empleado_Info.em_fechaSalida);
                        info.DiasGanados    = Convert.ToInt32(dias);
                        info.DiasPendientes = Convert.ToInt32(dias);
                        info.Secuencia      = 1;
                        valorRetornar       = oRo_historico_vacaciones_x_empleado_Data.GrabarBD(info, ref idSecuencia, ref msg);
                    }
                }


                return(valorRetornar);
            }
            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("", "GenerarVacacionesPorEmpleado", ex.Message), ex)
                      {
                          EntityType = typeof(ro_historico_vacaciones_x_empleado_Bus)
                      };
            }
        }
        public List <ro_historico_vacaciones_x_empleado_Info> calcular_vacaciones(int IdEmpresa, decimal IdEmpleado)
        {
            try
            {
                odata = new ro_historico_vacaciones_x_empleado_Data();
                string msg        = "";
                int    IdVacacion = 1;
                info_empleado = bus_empleado.get_info(IdEmpresa, IdEmpleado);
                List <ro_historico_vacaciones_x_empleado_Info> lst_vacaciones = new List <ro_historico_vacaciones_x_empleado_Info>();
                List <ro_historico_vacaciones_x_empleado_Info> listadoTmp     = new List <ro_historico_vacaciones_x_empleado_Info>();
                #region empleados gozan quince dias

                if (!info_empleado.GozaMasDeQuinceDiasVaciones)
                {
                    DateTime fechaActual  = DateTime.Now;
                    DateTime fechaIngreso = Convert.ToDateTime(info_empleado.em_fechaIngaRol);
                    DateTime fechaNueva   = new DateTime();
                    double   dias         = 0;
                    int      meses        = 0;
                    int      anio         = 0;
                    if (info_empleado.em_status == "EST_PLQ")
                    {
                        dias  = CalcularDiasDeDiferencia(fechaIngreso, Convert.ToDateTime(info_empleado.em_fechaSalida));
                        meses = CalcularMesesDeDiferencia(fechaIngreso, Convert.ToDateTime(info_empleado.em_fechaSalida));
                        anio  = CalcularAniosDeDiferencia(fechaIngreso, Convert.ToDateTime(info_empleado.em_fechaSalida));
                    }
                    else
                    {
                        dias  = CalcularDiasDeDiferencia(fechaIngreso, fechaActual);
                        meses = CalcularMesesDeDiferencia(fechaIngreso, fechaActual);
                        anio  = CalcularAniosDeDiferencia(fechaIngreso, fechaActual);
                    }
                    int minAnio         = 5;
                    int maxDiasGanados  = 15;
                    int minDiasGanados  = 15;
                    int diasGanados     = 0;
                    int contDiasGanados = 0;
                    //VALIDA SI TIENE MAS DE 1 AÑO
                    if (dias > 360)
                    {
                        fechaNueva = fechaIngreso;
                        //RECORRE LA CANTIDAD DE AÑOS QUE TIENE DE SERVICIO
                        for (int i = 0; i < anio; i++)
                        {
                            IdVacacion++;
                            if (i < minAnio)//VALIDA LOS 5 AÑOS BASE
                            {
                                diasGanados     = minDiasGanados;
                                contDiasGanados = 0;
                            }
                            else
                            {
                                if (i >= minAnio && contDiasGanados < maxDiasGanados)//VALIDA QUE SOLO ACUMULE 30 DIAS DE VACACIONES A PARTIR DEL 5 AÑO
                                {
                                    contDiasGanados++;
                                    diasGanados = minDiasGanados + contDiasGanados;
                                }
                                else
                                {
                                    diasGanados = 30;//DE AQUI EN ADELANTE TENDREA SOLO 30 DIAS
                                }
                            }
                            ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                            info.IdEmpresa        = info_empleado.IdEmpresa;
                            info.IdEmpleado       = info_empleado.IdEmpleado;
                            info.FechaIni         = fechaNueva.AddYears(i);
                            info.FechaFin         = info.FechaIni.AddYears(1).AddDays(-1);
                            info.DiasGanado       = diasGanados;
                            info.DiasPendientes   = diasGanados;
                            info.DiasTomados      = 0;
                            info.Descripcion      = info.FechaIni.Date.ToString().Substring(0, 10) + " " + info.FechaFin.Date.ToString().Substring(0, 10) + " " + info.DiasGanado.ToString();
                            info.IdVacacion       = IdVacacion;
                            info.IdPeriodo_Inicio = Convert.ToInt32(info.FechaIni.ToString("ddMMyyyy"));
                            info.IdPeriodo_Fin    = Convert.ToInt32(info.FechaFin.ToString("ddMMyyyy"));

                            lst_vacaciones.Add(info);
                        }
                    }
                    else
                    {
                        ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                        info.IdEmpresa        = info_empleado.IdEmpresa;
                        info.IdEmpleado       = info_empleado.IdEmpleado;
                        info.FechaIni         = Convert.ToDateTime(info_empleado.em_fechaIngaRol);
                        info.FechaFin         = Convert.ToDateTime(Convert.ToDateTime(info_empleado.em_fechaIngaRol).AddYears(1).AddDays(-1));
                        info.DiasGanado       = Convert.ToInt32(dias * 15) / 360;
                        info.DiasPendientes   = Convert.ToInt32(dias * 15) / 360;
                        info.Descripcion      = info.FechaIni.Date.ToString() + " " + info.FechaFin.Date.ToString() + " " + info.DiasGanado.ToString();
                        info.IdVacacion       = IdVacacion + 1;
                        info.IdPeriodo_Inicio = Convert.ToInt32(info.FechaIni.ToString("ddMMyyyy"));
                        info.IdPeriodo_Fin    = Convert.ToInt32(info.FechaFin.ToString("ddMMyyyy"));
                        lst_vacaciones.Add(info);
                    }

                    foreach (var item in lst_vacaciones)
                    {
                        if (!odata.GetExiste(item, ref msg))
                        {
                            odata.GrabarBD(item);
                        }
                        else
                        {
                            odata.ModificarBD(item);
                        }
                        item.FechaFin = item.FechaFin.Date;
                        item.FechaIni = item.FechaIni.Date;
                    }
                }
                else
                {
                    DateTime fechaActual  = DateTime.Now;
                    DateTime fechaIngreso = Convert.ToDateTime(info_empleado.em_fechaIngaRol);
                    DateTime fechaNueva   = new DateTime();
                    double   dias         = 0;
                    int      meses        = 0;
                    int      anio         = 0;
                    if (info_empleado.em_status == "EST_PLQ")
                    {
                        dias  = CalcularDiasDeDiferencia(fechaIngreso, Convert.ToDateTime(info_empleado.em_fechaSalida));
                        meses = CalcularMesesDeDiferencia(fechaIngreso, Convert.ToDateTime(info_empleado.em_fechaSalida));
                        anio  = CalcularAniosDeDiferencia(fechaIngreso, Convert.ToDateTime(info_empleado.em_fechaSalida));
                    }
                    else
                    {
                        dias  = CalcularDiasDeDiferencia(fechaIngreso, fechaActual);
                        meses = CalcularMesesDeDiferencia(fechaIngreso, fechaActual);
                        anio  = CalcularAniosDeDiferencia(fechaIngreso, fechaActual);
                    }
                    int minAnio         = 5;
                    int maxDiasGanados  = Convert.ToInt32(info_empleado.DiasVacaciones);
                    int minDiasGanados  = Convert.ToInt32(info_empleado.DiasVacaciones);
                    int diasGanados     = 0;
                    int contDiasGanados = 0;
                    //VALIDA SI TIENE MAS DE 1 AÑO
                    if (dias > 180)
                    {
                        fechaNueva = fechaIngreso;
                        //RECORRE LA CANTIDAD DE AÑOS QUE TIENE DE SERVICIO
                        for (int i = 0; i < anio; i++)
                        {
                            IdVacacion++;
                            if (i < minAnio)//VALIDA LOS 5 AÑOS BASE
                            {
                                diasGanados     = minDiasGanados;
                                contDiasGanados = 0;
                            }
                            else
                            {
                                if (i >= minAnio && contDiasGanados < maxDiasGanados)//VALIDA QUE SOLO ACUMULE 30 DIAS DE VACACIONES A PARTIR DEL 5 AÑO
                                {
                                    contDiasGanados++;
                                    diasGanados = minDiasGanados + contDiasGanados;
                                }
                                else
                                {
                                    diasGanados = 30;//DE AQUI EN ADELANTE TENDREA SOLO 30 DIAS
                                }
                            }
                            ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                            info.IdEmpresa        = info_empleado.IdEmpresa;
                            info.IdEmpleado       = info_empleado.IdEmpleado;
                            info.FechaIni         = fechaNueva.AddYears(i);
                            info.FechaFin         = info.FechaIni.AddYears(1).AddDays(-1);
                            info.DiasGanado       = diasGanados;
                            info.DiasPendientes   = diasGanados;
                            info.DiasTomados      = 0;
                            info.Descripcion      = info.FechaIni.Date.ToString().Substring(0, 10) + " " + info.FechaFin.Date.ToString().Substring(0, 10) + " " + info.DiasGanado.ToString();
                            info.IdVacacion       = IdVacacion;
                            info.IdPeriodo_Inicio = Convert.ToInt32(info.FechaIni.ToString("ddMMyyyy"));
                            info.IdPeriodo_Fin    = Convert.ToInt32(info.FechaFin.ToString("ddMMyyyy"));

                            lst_vacaciones.Add(info);
                        }
                    }
                    else
                    {
                        ro_historico_vacaciones_x_empleado_Info info = new ro_historico_vacaciones_x_empleado_Info();
                        info.IdEmpresa        = info_empleado.IdEmpresa;
                        info.IdEmpleado       = info_empleado.IdEmpleado;
                        info.FechaIni         = Convert.ToDateTime(info_empleado.em_fechaIngaRol);
                        info.FechaFin         = Convert.ToDateTime(Convert.ToDateTime(info_empleado.em_fechaIngaRol).AddYears(1).AddDays(-1));
                        info.DiasGanado       = Convert.ToInt32(dias * info_empleado.DiasVacaciones) / 360;
                        info.DiasPendientes   = Convert.ToInt32(dias * info_empleado.DiasVacaciones) / 360;
                        info.Descripcion      = info.FechaIni.Date.ToString() + " " + info.FechaFin.Date.ToString() + " " + info.DiasGanado.ToString();
                        info.IdVacacion       = IdVacacion + 1;
                        info.IdPeriodo_Inicio = Convert.ToInt32(info.FechaIni.ToString("ddMMyyyy"));
                        info.IdPeriodo_Fin    = Convert.ToInt32(info.FechaFin.ToString("ddMMyyyy"));
                        lst_vacaciones.Add(info);
                    }

                    foreach (var item in lst_vacaciones)
                    {
                        if (!odata.GetExiste(item, ref msg))
                        {
                            odata.GrabarBD(item);
                        }
                        else
                        {
                            odata.ModificarBD(item);
                        }
                        item.FechaFin = item.FechaFin.Date;
                        item.FechaIni = item.FechaIni.Date;
                    }
                }
                #endregion

                return(lst_vacaciones);
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void gridViewHistorico_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                historico = new ro_historico_vacaciones_x_empleado_Info();
                historico = (ro_historico_vacaciones_x_empleado_Info)gridViewHistorico.GetFocusedRow();
                List <ro_historico_vacaciones_x_empleado_Info> LST = new List <ro_historico_vacaciones_x_empleado_Info>();
                if (historico.DiasTomados > historico.DiasGanados)
                {
                    MessageBox.Show("Los dias Tomados no pueden pasarse de los Dias Ganados", "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (HistoricoVacacionesBus.ExisteHistoricoVaca(IdEmpleado, param.IdEmpresa) == true)
                    {
                        bHistorico = new BindingList <ro_historico_vacaciones_x_empleado_Info>();
                        List <ro_historico_vacaciones_x_empleado_Info> lst = new List <ro_historico_vacaciones_x_empleado_Info>(HistoricoVacacionesBus.ConsultarHistoricoVaca(IdEmpleado, param.IdEmpresa));
                        foreach (var item in lst)
                        {
                            item.Ico = (Bitmap)imageList1.Images[0];
                            bHistorico.Add(item);
                        }
                        //gridControlHistorico.RefreshDataSource();
                        gridControlHistorico.DataSource = bHistorico;
                        //RoHistoricoVacaInfoLst = new List<ro_historico_vacaciones_x_empleado_Info>(bHistorico);
                    }
                    else
                    {
                        foreach (var item in bHistorico)
                        {
                            if (item.IdHis_Vacaciones == historico.IdHis_Vacaciones)
                            {
                                item.DiasTomados    = 0;
                                item.check          = false;
                                item.DiasPendientes = item.DiasGanados;
                            }
                            LST.Add(item);
                        }
                        gridControlHistorico.RefreshDataSource();
                        //Valores Totales
                        valortotalDiasPEndientes = Convert.ToInt32(colDiasPendientes.SummaryText);

                        valortotalDiasTomados = 0;
                        foreach (var item in bHistorico)
                        {
                            valortotalDiasTomados = valortotalDiasTomados + item.DiasTomados;
                        }

                        SumatotalDiasGanados = 0;
                        foreach (var item in bHistorico)
                        {
                            SumatotalDiasGanados = SumatotalDiasGanados + item.DiasGanados;
                        }
                        event_gridViewHistorico_CellValueChanged(SumarDiasTomados());
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
                MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
            }
        }
        //DEREK 11/10/2014//mod DEREK 13/10/2014//mod DEREK 16/01/2014
        void HistoricoDeVacaciones(DateTime FI, decimal IdEmpleado)
        {
            try
            {
                bHistorico = new BindingList <ro_historico_vacaciones_x_empleado_Info>();
                lHistorico = new List <ro_historico_vacaciones_x_empleado_Info>();
                //DateTime fechaIngreso = new DateTime(2011, 01, 13);
                if (FI.Date == Convert.ToDateTime("01/01/0001"))
                {
                    MessageBox.Show("El Empleado no tiene Fecha de ingreso, vaya al mantenimiento de empleado y agreguele una Fecha nueva.", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                DateTime fechaIngreso = FI;
                int      anio         = fechaIngreso.Year;

                //DateTime fechaIngreso1 = fechaIngreso.AddDays(-1);
                //fechaIngreso1 = fechaIngreso1.AddYears(1);
                DateTime fechaIngreso1 = fechaIngreso;
                DateTime fechaIngreso2;
                //int a = 0;
                //mayor6 = DateTime.Now.Year - fechaIngreso.Year;
                //int cm = DateTime.Now.Month - fechaIngreso.Month;
                TimeSpan cm = DateTime.Now.Date - fechaIngreso.Date;

                double CA = 0;
                mayor6 = 0;
                double meses = (cm.Days / 31) / 12;

                double x = meses - (Math.Abs(meses));

                if (x > 0)
                {
                    CA = Math.Abs(meses) + 1;
                }
                else
                {
                    CA = meses;
                }

                //while (anio <= DateTime.Now.Year)
                //{
                //historico = new Ro_Historico_Vacaciones_Info();
                int contador = 0;
                for (int i = 0; i <= CA; i++)
                {
                    historico     = new ro_historico_vacaciones_x_empleado_Info();
                    fechaIngreso2 = fechaIngreso1;
                    fechaIngreso1 = fechaIngreso1.AddDays(-1);
                    fechaIngreso1 = fechaIngreso1.AddYears(1);
                    mayor6++;
                    //a++;
                    //if (a == 1)
                    if (i == 0)
                    {
                        historico.Tipo           = "Ingreso";
                        historico.IdEmpresa      = param.IdEmpresa;
                        historico.IdEmpleado     = IdEmpleado;
                        historico.FechaInicio    = fechaIngreso2;
                        historico.FechaFin       = fechaIngreso1;
                        historico.DiasGanados    = calculoDiasGanados(historico.FechaInicio, historico.FechaFin);
                        historico.DiasTomados    = busSolicitudVaca.CalculoDiasTrabajos(param.IdEmpresa, historico.FechaInicio, historico.FechaFin, IdEmpleado);
                        historico.DiasPendientes = (historico.DiasTomados == 0) ? historico.DiasGanados : (historico.DiasGanados - historico.DiasTomados);
                    }
                    else
                    {
                        //if (fechaIngreso2.Year == DateTime.Now.Year)
                        if (i == CA)
                        {
                            historico.Tipo           = "Hoy";
                            historico.IdEmpresa      = param.IdEmpresa;
                            historico.IdEmpleado     = IdEmpleado;
                            historico.FechaInicio    = fechaIngreso2;
                            historico.FechaFin       = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                            historico.DiasGanados    = Math.Abs(calculoDiasGanados(historico.FechaInicio, historico.FechaFin));
                            historico.DiasTomados    = busSolicitudVaca.CalculoDiasTrabajos(param.IdEmpresa, historico.FechaInicio, historico.FechaFin, IdEmpleado);
                            historico.DiasPendientes = (historico.DiasTomados == 0) ? Math.Abs(historico.DiasGanados) : (Math.Abs(historico.DiasGanados) - historico.DiasTomados);
                        }
                        else
                        {
                            //if (fechaIngreso2.Year < DateTime.Now.Year)
                            if (i < CA)
                            {
                                historico.Tipo           = "Historico";
                                historico.IdEmpresa      = param.IdEmpresa;
                                historico.IdEmpleado     = IdEmpleado;
                                historico.FechaInicio    = fechaIngreso2;
                                historico.FechaFin       = fechaIngreso1;
                                historico.DiasGanados    = calculoDiasGanados(historico.FechaInicio, historico.FechaFin);
                                historico.DiasTomados    = busSolicitudVaca.CalculoDiasTrabajos(param.IdEmpresa, historico.FechaInicio, historico.FechaFin, IdEmpleado);
                                historico.DiasPendientes = (historico.DiasTomados == 0) ? historico.DiasGanados : (historico.DiasGanados - historico.DiasTomados);
                            }
                        }
                    }
                    contador++;
                    historico.Secuencia        = contador;
                    historico.IdHis_Vacaciones = contador;
                    historico.check            = false;
                    historico.Ico = (Bitmap)imageList1.Images[0];
                    lHistorico.Add(historico);
                    fechaIngreso1 = fechaIngreso1.AddDays(1);
                    anio          = fechaIngreso1.Year;
                }

                bHistorico = new BindingList <ro_historico_vacaciones_x_empleado_Info>(lHistorico);
                gridControlHistorico.DataSource = bHistorico;
            }
            catch (Exception ex)
            {
                string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
                MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
            }
        }
        private void gridViewHistorico_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                historico = new ro_historico_vacaciones_x_empleado_Info();
                historico = (ro_historico_vacaciones_x_empleado_Info)gridViewHistorico.GetFocusedRow();


                List <ro_historico_vacaciones_x_empleado_Info> LST = new List <ro_historico_vacaciones_x_empleado_Info>();

                if (e.Column == colcheck && Convert.ToBoolean(e.Value) == false)
                {
                    foreach (var item in bHistorico)
                    {
                        if (item.IdHis_Vacaciones == historico.IdHis_Vacaciones)
                        {
                            item.DiasGanados    = historico.DiasGanados;
                            item.DiasTomados    = 0;
                            item.DiasPendientes = historico.DiasGanados - historico.DiasTomados;
                            item.check          = false;
                        }
                        LST.Add(item);
                    }
                }

                if (e.Column == colcheck && Convert.ToBoolean(e.Value) == true)
                {
                    foreach (var item in bHistorico)
                    {
                        if (item.IdHis_Vacaciones == historico.IdHis_Vacaciones)
                        {
                            item.DiasGanados = historico.DiasGanados;
                            //item.DiasTomados = (historico.DiasGanados>15)?(historico.DiasGanados):15;
                            item.DiasTomados    = historico.DiasGanados;
                            item.DiasPendientes = historico.DiasGanados - historico.DiasTomados;
                            item.check          = true;
                        }
                        LST.Add(item);
                    }
                }
                string Diastomados = (Convert.ToString(e.Value) == "") ? "0" : Convert.ToString(e.Value);
                if (e.Column == colDiasTomados)
                {
                    foreach (var item in bHistorico)
                    {
                        if (item.IdHis_Vacaciones == historico.IdHis_Vacaciones)
                        {
                            item.DiasGanados = historico.DiasGanados;
                            //item.DiasTomados = (historico.DiasGanados>15)?(historico.DiasGanados):15;
                            item.DiasTomados    = (Diastomados == "") ? 0 : Convert.ToInt32(Diastomados);
                            item.DiasPendientes = historico.DiasGanados - historico.DiasTomados;
                            item.check          = true;
                        }
                        LST.Add(item);
                    }
                }
                //bHistorico = new BindingList<Ro_Historico_Vacaciones_Info>();
                //bHistorico = new BindingList<Ro_Historico_Vacaciones_Info>(LST);
                gridControlHistorico.RefreshDataSource();

                //Valores Totales
                valortotalDiasPEndientes = Convert.ToInt32(colDiasPendientes.SummaryText);

                valortotalDiasTomados = 0;
                foreach (var item in LST)
                {
                    valortotalDiasTomados = valortotalDiasTomados + item.DiasTomados;
                }

                SumatotalDiasGanados = 0;
                foreach (var item in LST)
                {
                    SumatotalDiasGanados = SumatotalDiasGanados + item.DiasGanados;
                }
                //valortotalDiasTomados = Convert.ToInt32(colDiasTomados.SummaryText);
                //Usando delegados
                event_gridViewHistorico_CellValueChanging(SumarDiasTomados());
            }
            catch (Exception ex)
            {
                string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
                MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
            }
        }