private void gridView_planificacion_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
 {
     if (e.Column.Name == "Col_imagen")
     {
         try
         {
             DialogResult dialogResult = MessageBox.Show("¿Esta seguro de querer eliminar el registro?", param.Nombre_sistema, MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 ro_planificacion_x_ruta_x_empleado_det_Info info = (ro_planificacion_x_ruta_x_empleado_det_Info)gridView_planificacion.GetFocusedRow();
                 if (info != null)
                 {
                     if (bus_planificacion_detalle.EliminarDB(info))
                     {
                         gridView_planificacion.DeleteSelectedRows();
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Log_Error_bus.Log_Error(ex.ToString());
             MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 public bool EliminarDB(ro_planificacion_x_ruta_x_empleado_det_Info info)
 {
     try
     {
         return(data.EliminarDB(info));
     }
     catch (Exception ex)
     {
         mensaje = ex.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(), "", mensaje, "", "", "", "", "", DateTime.Now);
         oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
         throw new Exception(mensaje);
     }
 }
        public bool EliminarDB(ro_planificacion_x_ruta_x_empleado_det_Info info)
        {
            try
            {
                using (EntityRoles_FJ db = new EntityRoles_FJ())
                {
                    db.Database.ExecuteSqlCommand("delete Fj_servindustrias.ro_planificacion_x_ruta_x_empleado_det where IdEmpresa='" + info.IdEmpresa + "' and IdNomina_Tipo='" + info.IdNomina_Tipo + "' and IdEmpleado='" + info.IdEmpleado + "' and IdPeriodo='" + info.IdPeriodo + "' and IdNomina_Tipo_Liq='" + info.IdNomina_Tipo_Liq + "' ");

                    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);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref MensajeError);
                MensajeError = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }
        private Boolean Agregar_fila_copiada(string data)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(data))
                {
                    return(false);
                }
                string[] rowData = data.Split(new char[] { '\r', '\x09' });

                ro_fectividad_Entrega_x_Periodo_Empleado_Info newRow = new ro_fectividad_Entrega_x_Periodo_Empleado_Info();
                if (rowData.Count() >= 3) //return false;
                {
                    string cedula  = Convert.ToString(rowData[0]);
                    string Nombres = Convert.ToString(rowData[1]);
                    string Fuerza  = Convert.ToString(rowData[2]);
                    string Zona    = Convert.ToString(rowData[3]);
                    string Disco   = Convert.ToString(rowData[4]);
                    string Placa   = Convert.ToString(rowData[5]);
                    string Ruta    = Convert.ToString(rowData[6]);

                    ro_fectividad_Entrega_x_Periodo_Empleado_Info emp = new ro_fectividad_Entrega_x_Periodo_Empleado_Info();
                    if (!string.IsNullOrWhiteSpace(cedula.ToString()))
                    {
                        if (fx_Verificar_Reg_Repetidos(emp, false, 0))
                        {
                            bool si_existe_cedula = false;
                            foreach (var item in listaempleado)
                            {
                                ro_planificacion_x_ruta_x_empleado_det_Info info = new ro_planificacion_x_ruta_x_empleado_det_Info();

                                if (item.InfoPersona.pe_cedulaRuc == cedula)
                                {
                                    si_existe_cedula = true;
                                    info.IdEmpresa   = param.IdEmpresa;
                                    info.IdEmpleado  = item.IdEmpleado;

                                    // FUERZA
                                    List <ro_fuerza_Info> fuerzatmp = new List <ro_fuerza_Info>();
                                    fuerzatmp = lista_fuerza.Where(v => v.fu_descripcion == Fuerza).ToList();
                                    if (fuerzatmp.Count() > 0)
                                    {
                                        info.IdFuerza = fuerzatmp.FirstOrDefault().IdFuerza;
                                    }



                                    // ZONA
                                    List <ro_zona_Info> zonatmp = new List <ro_zona_Info>();
                                    zonatmp = lista_zona.Where(v => v.zo_descripcion == Zona).ToList();
                                    if (zonatmp.Count() > 0)
                                    {
                                        info.IdZona = zonatmp.FirstOrDefault().IdZona;
                                    }



                                    // DISO
                                    List <ro_disco_Info> discotmp = new List <ro_disco_Info>();
                                    discotmp = lista_disco.Where(v => v.Disco == Disco).ToList();
                                    if (discotmp.Count() > 0)
                                    {
                                        info.IdDisco = discotmp.FirstOrDefault().IdDisco;
                                    }



                                    // PLACA
                                    List <ro_placa_Info> placatmp = new List <ro_placa_Info>();
                                    placatmp = lista_placa.Where(v => v.Placa == Placa).ToList();
                                    if (placatmp.Count() > 0)
                                    {
                                        info.IdPlaca = placatmp.FirstOrDefault().IdPlaca;
                                    }



                                    // RUTA
                                    List <ro_ruta_Info> rutatmp = new List <ro_ruta_Info>();
                                    rutatmp = lista_ruta.Where(v => v.ru_descripcion == Ruta).ToList();
                                    if (rutatmp.Count() > 0)
                                    {
                                        info.IdRuta = rutatmp.FirstOrDefault().IdRuta;
                                    }



                                    lista_planificada.Add(info);
                                }
                            }

                            if (!si_existe_cedula)
                            {
                                ro_planificacion_x_ruta_x_empleado_det_Info info = new ro_planificacion_x_ruta_x_empleado_det_Info();
                                info.pe_nombreCompleto = Nombres;
                                info.cedula            = cedula;
                                lista_planificada_error.Add(info);
                                gridControl_error.DataSource = lista_planificada_error;
                            }

                            return(true);
                        }
                    }
                    else
                    {
                        MessageBox.Show("No hay las columnas necesarias para insertar al registros");
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log_Error_bus.Log_Error(ex.ToString());
                return(false);
            }
        }
        public List <ro_planificacion_x_ruta_x_empleado_det_Info> lista_planificacion(int IdEmpresa, int idnomina_tipo, int IdPeriodo)
        {
            try
            {
                List <ro_planificacion_x_ruta_x_empleado_det_Info> lista = new List <ro_planificacion_x_ruta_x_empleado_det_Info>();


                using (EntityRoles_FJ Context = new EntityRoles_FJ())
                {
                    var contact = from q in Context.vwro_planificacion_x_ruta_entrega_x_empleado
                                  where q.IdEmpresa == IdEmpresa &&
                                  q.IdTipoNomina == idnomina_tipo &&
                                  q.IdPeriodo == IdPeriodo
                                  select q;

                    foreach (var item in contact)
                    {
                        ro_planificacion_x_ruta_x_empleado_det_Info Info = new ro_planificacion_x_ruta_x_empleado_det_Info();
                        Info.IdEmpresa     = Convert.ToInt32(item.IdEmpresa);
                        Info.IdNomina_Tipo = Convert.ToInt32(item.IdTipoNomina);
                        Info.IdEmpleado    = Convert.ToInt32(item.IdEmpleado);
                        if (item.IdPeriodo != null)
                        {
                            Info.IdPeriodo = Convert.ToInt32(item.IdPeriodo);
                        }
                        if (item.IdFuerza != null)
                        {
                            Info.IdFuerza = Convert.ToInt32(item.IdFuerza);
                        }
                        if (item.IdZona != null)
                        {
                            Info.IdZona = Convert.ToInt32(item.IdZona);
                        }
                        if (item.IdPlaca != null)
                        {
                            Info.IdPlaca = Convert.ToInt32(item.IdPlaca);
                        }
                        if (item.IdDisco != null)
                        {
                            Info.IdDisco = Convert.ToInt32(item.IdDisco);
                        }
                        if (item.IdRuta != null)
                        {
                            Info.IdRuta = Convert.ToInt32(item.IdRuta);
                        }
                        Info.pe_nombreCompleto = item.pe_nombreCompleto;
                        Info.de_descripcion    = item.de_descripcion;
                        Info.ca_descripcion    = item.ca_descripcion;


                        Info.icono_eliminar = true;
                        lista.Add(Info);
                    }
                }
                return(lista);
            }
            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 MensajeError);
                MensajeError = ex.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }