protected void Page_Load(object sender, EventArgs e)
 {
     //Este ID debe coincidir con el Menú registrado en la BD
     int IdPagina = 2;
     if (Negocio.Seguridad.Seguridad.AccesoPagina(IdPagina) == true)
     {
         if (!IsPostBack)
         {
             permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
             if (permisos.R == true)
             {
                 ObtenerParametros();
                 imprimirTitulo();
                 VMs();
                 CaracteristicasC.IdServidor = _IdServidor;
                 AlmacenamientoC.IdServidor = _IdServidor;
                 InterfacesRedC.IdServidor = _IdServidor;
                 SistemasOperativosC.IdServidor = _IdServidor;
                 StorageC.IdServidor = _IdServidor;
                 BitacoraC.IdServidor = _IdServidor;
             }
         }
     }
     else
     {
         Response.Redirect("~/errorAcceso.aspx");
     }
 }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            lblResultado.Text = string.Empty;
            lblResultado.ForeColor = System.Drawing.Color.Red;
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();

            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();

            if (ddlEstatus.SelectedValue != "0")
            {
                Entidades.ConfRed nuevaInterfaz = new Entidades.ConfRed();
                nuevaInterfaz.Servidor.IdServidor = Convert.ToInt32(hdfIdServidor.Value);
                nuevaInterfaz.InterfazRed = txtInterfazRed.Text.Trim();
                nuevaInterfaz.DirMac = txtDirMAC.Text.Trim();
                nuevaInterfaz.DirIP = txtDirIP.Text.Trim();
                nuevaInterfaz.MascaraSubRed = txtMascaraSubRed.Text.Trim();
                if (!string.IsNullOrWhiteSpace(txtGateway.Text.Trim()))
                    nuevaInterfaz.Gateway = txtGateway.Text.Trim();
                if (!string.IsNullOrWhiteSpace(txtDNS.Text.Trim()))
                    nuevaInterfaz.DNS = txtDNS.Text.Trim();
                if (!string.IsNullOrWhiteSpace(txtVlan.Text.Trim()))
                    nuevaInterfaz.VLAN = txtVlan.Text.Trim();
                nuevaInterfaz.Estatus.IdEstatus = Convert.ToInt32(ddlEstatus.SelectedValue);

                //Guardar
                if (hdfEstado.Value == "1" && permisos.C == true)
                {
                    resultado = Negocio.Inventarios.ConfRed.Nuevo(nuevaInterfaz);
                }
                else if (hdfEstado.Value == "2" && permisos.U == true) //actualizar
                {
                    nuevaInterfaz.IdConfRed = Convert.ToInt32(hdfIdConfRed.Value);
                    resultado = Negocio.Inventarios.ConfRed.Actualizar(nuevaInterfaz);
                }
                else
                {
                    lblResultado.Text = "No tienes privilegios para realizar esta acción.";
                }

                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                {
                    lblResultado.Text += error.descripcionCorta + "<br/>";
                });

                lblResultado.ForeColor = System.Drawing.Color.Red;
                if (resultado.resultado == true)
                {
                    lblResultado.ForeColor = System.Drawing.Color.Green;
                    hdfEstado.Value = "0";
                    pnlFormIntRed.Visible = false;
                    gdvInterfacesRed.Visible = true;
                    ObtenerParametros();
                    InterfacesRed();
                }
            }
            else
            {
                lblResultado.Text = "Debe seleccionar un estatus.";
            }
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            lblStatus.Text = string.Empty;
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
            if (hdfEstado.Value == "1" && permisos.C == true)
            {
                resultado = Negocio.Catalogos.Procesador.Nuevo(new Entidades.Procesador()
                {
                    Nombre = txtNombre.Text,
                    NumCores = Convert.ToInt32(txtNumCores.Text),
                    Velocidad = txtVelocidad.Text,
                    Cache = txtCache.Text,
                    TamanoPalabra = !string.IsNullOrWhiteSpace(ddlTamanoPalabra.SelectedValue)? ddlTamanoPalabra.SelectedValue:null
                });
            }
            else if (hdfEstado.Value == "2" && permisos.U == true)
            {
                resultado = Negocio.Catalogos.Procesador.Actualizar(new Entidades.Procesador()
                {
                    IdProcesador = Convert.ToInt32(lblIdProcesador.Value),
                    Nombre = txtNombre.Text,
                    NumCores = Convert.ToInt32(txtNumCores.Text),
                    Velocidad = txtVelocidad.Text,
                    Cache = txtCache.Text,
                    TamanoPalabra = !string.IsNullOrWhiteSpace(ddlTamanoPalabra.SelectedValue) ? ddlTamanoPalabra.SelectedValue : null
                });
            }
            else
            {
                lblStatus.Text = "No tienes privilegios para realizar esta acción.";
            }

            resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
            {
                lblStatus.Text += error.descripcionCorta + "<br/>";
            });

            //lblStatus.ForeColor = System.Drawing.Color.Red;
            lblStatus.Attributes["style"] = "color: #F00;";
            pnlResultado.Attributes["style"] = "background: rgba(252, 55, 55, 0.2);";
            if (resultado.resultado == true)
            {
                //lblStatus.ForeColor = System.Drawing.Color.Green;
                lblStatus.Attributes["style"] = "color: #008000;";
                pnlResultado.Attributes["style"] = "background: rgba(147, 252, 55, 0.22);";
                hdfEstado.Value = "0";
                btnNuevo.Visible = true;
                btnNuevo.Text = "Nuevo";
                pnlProcesadores.Visible = true;
                pnlFormulario.Visible = false;
                llenarGdvProcesadores();
            }
            pnlResultado.Visible = true;
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            lblStatus.Text = string.Empty;
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
            if (hdfEstado.Value == "1" && permisos.C == true)
            //if (hdfEstado.Value == "1")
            {
                resultado = Negocio.Catalogos.Empresa.Nuevo(new Entidades.Empresa()
                {
                    Nombre = txtEmpresa.Text,
                    Telefono = txtTelefono.Text,
                    Direccion = txtDireccion.Text
                });
            }
            else if (hdfEstado.Value == "2" && permisos.U == true)
            //else if (hdfEstado.Value == "2")
            {
                resultado = Negocio.Catalogos.Empresa.Actualizar(new Entidades.Empresa()
                {
                    IdEmpresa = Convert.ToInt32(lblIdNombreEmpresa.Value),
                    Nombre = txtEmpresa.Text,
                    Telefono = txtTelefono.Text,
                    Direccion = txtDireccion.Text
                });
            }
            else
            {
                lblStatus.Text = "No tienes privilegios para realizar esta acción.";
            }

            resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
            {
                lblStatus.Text += error.descripcionCorta + "<br/>";
            });

            //lblStatus.ForeColor = System.Drawing.Color.Red;
            lblStatus.Attributes["style"] = "color: #F00;";
            pnlResultado.Attributes["style"] = "background: rgba(252, 55, 55, 0.2);";
            if (resultado.resultado == true)
            {
                //lblStatus.ForeColor = System.Drawing.Color.Green;
                lblStatus.Attributes["style"] = "color: #008000;";
                pnlResultado.Attributes["style"] = "background: rgba(147, 252, 55, 0.22);";
                hdfEstado.Value = "0";
                btnNuevo.Visible = true;
                btnNuevo.Text = "Nuevo";
                pnlEmpresa.Visible = true;
                pnlFormulario.Visible = false;
                llenarGdvEmpresas();
            }
            pnlResultado.Visible = true;
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            lblResultado.Text = string.Empty;
            //lblResultado.ForeColor = System.Drawing.Color.Red;
            lblResultado.Attributes["style"] = "color: #F00;";
            pnlResultado.Attributes["style"] = "background: rgba(252, 55, 55, 0.2);";
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();

            if (ddlEmpresa.SelectedValue != "0" && ddlModelo.SelectedValue != "0")
            {
                Entidades.Soporte soporte = new Entidades.Soporte();
                soporte.Empresa.IdEmpresa = Convert.ToInt32(ddlEmpresa.SelectedValue);
                soporte.Modelo.IdModelo = Convert.ToInt32(ddlModelo.SelectedValue);
                soporte.FechaInicio = Convert.ToDateTime(txtFechaIni.Text.Trim());
                soporte.FechaFin = Convert.ToDateTime(txtFechaFin.Text.Trim());

                if (hdfEstado.Value == "1" && permisos.C == true)
                {
                    resultado = Negocio.Inventarios.Soporte.Nuevo(soporte);
                }
                else if(hdfEstado.Value == "2" && permisos.U == true)
                {
                    soporte.IdSoporte = Convert.ToInt32(hdfIdSoporte.Value);
                    resultado = Negocio.Inventarios.Soporte.Actualizar(soporte);
                }
                else
                {
                    lblResultado.Text = "No tiene privilegios para realizar esta acción. <br>";
                }

                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                {
                    lblResultado.Text += error.descripcionCorta + "<br>";
                });

                if (resultado.resultado == true)
                {
                    //lblResultado.ForeColor = System.Drawing.Color.Green;
                    lblResultado.Attributes["style"] = "color: #008000;";
                    pnlResultado.Attributes["style"] = "background: rgba(147, 252, 55, 0.22);";
                    pnlForm.Visible = false;
                    pnlSoporte.Visible = true;
                    llenarGdvSoporte();
                }
            }
            else
            {
                lblResultado.Text = "Hay campos que no han sido seleccionados.";
            }
            pnlResultado.Visible = true;
        }
 protected void btnNuevo_Click(object sender, EventArgs e)
 {
     permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
     hdfEstado.Value = "1";
     lblResultado.Text = string.Empty;
     pnlPersonas.Visible = false;
     pnlFormulario.Visible = true;
     pnlResultado.Visible = false;
     btnGuardar.Text = "Guardar";
     btnGuardar.Enabled = permisos.C;
     llenarDdlEstatus();
     limpiar();
 }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            lblResultado.Text = string.Empty;
            lblResultado.ForeColor = System.Drawing.Color.Red;
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            if (ddlTipoStorageForm.SelectedValue != "0" && ddlCapacidad.SelectedValue != "0")
            {
                Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
                ObtenerParametros();

                Entidades.Storage storage = new Entidades.Storage();
                storage.Servidor.IdServidor = _IdServidor;
                storage.TipoStorage.IdTipoStorage = Convert.ToInt32(ddlTipoStorageForm.SelectedValue);
                storage.Estatus = null;
                storage.CapacidadAsignada = txtCapacidad.Text.Trim() + " " + ddlCapacidad.SelectedValue;

                if (hdfEstado.Value == "1" && permisos.C == true)
                {
                    resultado = Negocio.Inventarios.Storage.Nuevo(storage);
                }
                else if (hdfEstado.Value == "2" && permisos.U == true)
                {
                    storage.IdStorage = Convert.ToInt32(hdfStorage.Value);
                    resultado = Negocio.Inventarios.Storage.Actualizar(storage);
                }
                else
                {
                    lblResultado.Text = "No tienes privilegios para realizar esta acción";
                }

                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                {
                    lblResultado.Text += error.descripcionCorta + "<br/>";
                });

                if (resultado.resultado == true)
                {
                    lblResultado.ForeColor = System.Drawing.Color.Green;
                    hdfEstado.Value = "0";
                    pnlForm.Visible = false;
                    pnlStorage.Visible = true;
                    ObtenerParametros();
                    llenarGdvStorage();
                }
            }
            else
            {
                lblResultado.Text = "Revise el formulario, hay campos que no han sido seleccionados.";
            }
        }
 protected void btnNuevo_Click(object sender, EventArgs e)
 {
     permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
     hdfEstado.Value = "1";
     lblStatus.Text = string.Empty;
     btnGuardar.Text = "Guardar";
     btnGuardar.Enabled = permisos.C;
     pnlTipoStorage.Visible = false;
     pnlFormulario.Visible = true;
     pnlResultado.Visible = false;
     lblIdTipoStorage.Value = string.Empty;
     //lblIdSistemaOperativo.Attributes["style"] = "display: none;";
     txtTipoStorage.Text = string.Empty;
 }
 protected void btnNuevo_Click(object sender, EventArgs e)
 {
     permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
     hdfEstado.Value = "1";
     lblStatus.Text = string.Empty;
     btnGuardar.Text = "Guardar";
     btnGuardar.Enabled = permisos.C;
     pnlCatalogo.Visible = false;
     pnlFormulario.Visible = true;
     pnlResultado.Visible = false;
     lblIdConceptoEstatus.Text = string.Empty;
     lblIdConceptoEstatus.Attributes["style"] = "display: none;";
     txtConcepto.Text = string.Empty;
 }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            lblResultado.Text = string.Empty;
            lblResultado.ForeColor = System.Drawing.Color.Red;
            if (ddlTipoAlmacenamiento.SelectedValue != "0" && ddlCapacidad.SelectedValue != "0")
            {
                Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();

                Entidades.Almacenamiento alm = new Entidades.Almacenamiento();
                alm.IdServidor = Convert.ToInt32(hdfIdServidor.Value);
                alm.Unidad = txtUnidad.Text.Trim();
                alm.TipoMemoria.IdTipoMemoria = Convert.ToInt32(ddlTipoAlmacenamiento.SelectedValue);
                alm.Capacidad = txtCapacidad.Text.Trim() + " " + ddlCapacidad.SelectedValue;
                if(hdfEstado.Value == "1" && permisos.C == true)
                {
                    resultado = Negocio.Inventarios.Almacenamiento.Nuevo(alm);
                }
                else if(hdfEstado.Value == "2" && permisos.U == true)
                {
                    alm.IdAlmacenamiento = Convert.ToInt32(hdfIdAlmacenamiento.Value);
                    resultado = Negocio.Inventarios.Almacenamiento.Actualizar(alm);
                }
                else
                {
                    lblResultado.Text = "No tienes privilegios para realizar esta acción.";
                }

                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                {
                    lblResultado.Text += error.descripcionCorta + "<br/>";
                });

                lblResultado.ForeColor = System.Drawing.Color.Red;
                if (resultado.resultado == true)
                {
                    lblResultado.ForeColor = System.Drawing.Color.Green;
                    hdfEstado.Value = "0";
                    pnlForm.Visible = false;
                    pnlAlmacenamiento.Visible = true;
                    ObtenerParametros();
                    llenarGdvAlmacenamiento();
                }
            }
            else
            {
                lblResultado.Text = "Revise el formulario, hay campos que no han sido seleccionados.";
            }
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
            Entidades.Personas persona = new Entidades.Personas();
            persona.Nombre = txtNombre.Text.Trim();
            persona.Puesto = txtPuesto.Text.Trim();
            persona.Extension = txtExtension.Text.Trim();
            persona.Correo = txtCorreo.Text.Trim();
            persona.Estatus.IdEstatus = Convert.ToInt32(ddlEstatus.SelectedValue);
            if (hdfEstado.Value == "1" && permisos.C == true && ddlEstatus.SelectedValue != "0")
            {
                resultado = Negocio.Seguridad.Personas.Nuevo(persona);
            }
            else if (hdfEstado.Value == "2" && permisos.U == true && ddlEstatus.SelectedValue != "0")
            {
                persona.IdPersona = Convert.ToInt32(lblIdPersona.Text);
                resultado = Negocio.Seguridad.Personas.Actualizar(persona);
            }
            else if (ddlEstatus.SelectedValue == "0")
            {
                lblResultado.Text = "Debe tener un Estatus.";
            }
            else
            {
                    lblResultado.Text = "No tienes privilegios para realizar esta acción.";
            }

            resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
            {
                lblResultado.Text += error.descripcionCorta + "<br/>";
            });

            //lblResultado.ForeColor = System.Drawing.Color.Red;
            lblResultado.Attributes["style"] = "color: #F00;";
            pnlResultado.Attributes["style"] = "background: rgba(252, 55, 55, 0.2);";
            if (resultado.resultado == true)
            {
                //lblResultado.ForeColor = System.Drawing.Color.Green;
                lblResultado.Attributes["style"] = "color: #008000;";
                pnlResultado.Attributes["style"] = "background: rgba(147, 252, 55, 0.22);";
                hdfEstado.Value = "0";
                pnlPersonas.Visible = true;
                pnlFormulario.Visible = false;
                btnNuevo.Visible = true;
                llenarGdvPersonas();
            }
            pnlResultado.Visible = true;
        }
 protected void btnNuevo_Click(object sender, EventArgs e)
 {
     permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
     hdfEstado.Value = "1";
     lblStatus.Text = string.Empty;
     btnGuardar.Text = "Guardar";
     btnGuardar.Enabled = permisos.C;
     pnlEmpresa.Visible = false;
     pnlFormulario.Visible = true;
     pnlResultado.Visible = false;
     lblIdNombreEmpresa.Value = string.Empty;
     //lblIdNombreEmpresa.Attributes["style"] = "display: none;";
     txtEmpresa.Text = string.Empty;
     txtTelefono.Text = string.Empty;
     txtDireccion.Text = string.Empty;
 }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            lblResultado.Text = string.Empty;
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            lblResultado.ForeColor = System.Drawing.Color.Red;
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
            if(ddlSO.SelectedValue != "0")
            {
                ObtenerParametros();
                Entidades.SOxServidor so = new Entidades.SOxServidor();
                so.Servidor.IdServidor = _IdServidor;
                so.SO.IdSO = Convert.ToInt32(ddlSO.SelectedValue);
                so.Estatus = null;
                if (hdfEstado.Value == "1" && permisos.C == true)
                {
                    resultado = Negocio.Inventarios.SOxServidor.Nuevo(so);
                }
                else if (hdfEstado.Value == "2" && permisos.U == true)
                {
                    so.IdSOxServidor = Convert.ToInt32(hdfIdSoServidor.Value);
                    resultado = Negocio.Inventarios.SOxServidor.Actualizar(so);
                }
                else
                {
                    lblResultado.Text = "No tiene privilegios para realizar esta acción.";
                }

                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                {
                    lblResultado.Text += error.descripcionCorta + "<br/>";
                });

                if (resultado.resultado == true)
                {
                    lblResultado.ForeColor = System.Drawing.Color.Green;
                    hdfEstado.Value = "0";
                    pnlForm.Visible = false;
                    pnlSO.Visible = true;
                    ObtenerParametros();
                    llenarGdvSO();
                }
            }
            {
                lblResultado.Text = "Seleccione un sistema operativo.";
            }
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();

            List<Entidades.MenuXrol> listMenu = new List<Entidades.MenuXrol>();

            if (hdfEstado.Value == "1" && permisos.C)
            {
                Entidades.RolUsuario nuevoRol = new Entidades.RolUsuario()
                {
                    NombreRol = txtNombre.Text,
                    C = cbxCrear.Checked,
                    R = cbxConsultar.Checked,
                    U = cbxEditar.Checked,
                    D = cbxEliminar.Checked
                };
                foreach (RepeaterItem item in rptMenu.Items)
                {
                    int cont = 0;
                    HiddenField idMenu = (HiddenField)item.FindControl("hdfIdMenu");
                    int IdMenu = Convert.ToInt32(idMenu.Value);
                    CheckBox cbxMenu = (CheckBox)item.FindControl("cbxMenu");
                    CheckBoxList cblSubmenu1 = (CheckBoxList)item.FindControl("cblSubmenu1");
                    foreach (ListItem cbxItem in cblSubmenu1.Items)
                    {
                        if (cbxItem.Selected)
                        {
                            Entidades.MenuXrol m = new Entidades.MenuXrol();
                            m.IdMenu.IdMenu = Convert.ToInt32(cbxItem.Value);
                            listMenu.Add(m);
                            cont++;
                        }
                    }
                    if(cont > 0)
                    {
                        Entidades.MenuXrol m = new Entidades.MenuXrol();
                        m.IdMenu.IdMenu = IdMenu;
                        listMenu.Add(m);
                    }
                    if(cbxMenu.Visible)
                    {
                        if(cbxMenu.Checked)
                        {
                            Entidades.MenuXrol m = new Entidades.MenuXrol();
                            m.IdMenu.IdMenu = Convert.ToInt32(IdMenu);
                            listMenu.Add(m);
                        }
                    }
                }

                resultado = Negocio.Seguridad.RolUsuario.Nuevo(nuevoRol,listMenu);
            }
            else if (hdfEstado.Value == "2" && permisos.U)
            {
                int IdRol = Convert.ToInt32(lblIdRol.Text);
                Entidades.RolUsuario nuevoRol = new Entidades.RolUsuario()
                {
                    IdRol = Convert.ToInt32(lblIdRol.Text),
                    NombreRol = txtNombre.Text,
                    C = cbxCrear.Checked,
                    R = cbxConsultar.Checked,
                    U = cbxEditar.Checked,
                    D = cbxEliminar.Checked
                };

                foreach (RepeaterItem item in rptMenu.Items)
                {
                    int cont = 0;
                    HiddenField idMenu = (HiddenField)item.FindControl("hdfIdMenu");
                    int IdMenu = Convert.ToInt32(idMenu.Value);
                    CheckBox cbxMenu = (CheckBox)item.FindControl("cbxMenu");
                    CheckBoxList cblSubmenu1 = (CheckBoxList)item.FindControl("cblSubmenu1");
                    foreach (ListItem cbxItem in cblSubmenu1.Items)
                    {
                        if (cbxItem.Selected)
                        {
                            Entidades.MenuXrol m = new Entidades.MenuXrol();
                            m.IdMenu.IdMenu = Convert.ToInt32(cbxItem.Value);
                            m.IdRol.IdRol = IdRol;
                            listMenu.Add(m);
                            cont++;
                        }
                    }
                    if (cont > 0)
                    {
                        Entidades.MenuXrol m = new Entidades.MenuXrol();
                        m.IdMenu.IdMenu = IdMenu;
                        m.IdRol.IdRol = IdRol;
                        listMenu.Add(m);
                    }
                    if (cbxMenu.Visible)
                    {
                        if (cbxMenu.Checked)
                        {
                            Entidades.MenuXrol m = new Entidades.MenuXrol();
                            m.IdMenu.IdMenu = Convert.ToInt32(IdMenu);
                            m.IdRol.IdRol = IdRol;
                            listMenu.Add(m);
                        }
                    }
                }

                resultado = Negocio.Seguridad.RolUsuario.Actualizar(nuevoRol, listMenu);
            }
            else
            {
                lblResultado.Text = "No tienes privilegios para realizar esta acción.";
            }

            resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
            {
                lblResultado.Text += error.descripcionCorta + "<br/>";
            });

            //lblResultado.ForeColor = System.Drawing.Color.Red;
            lblResultado.Attributes["style"] = "color: #F00;";
            pnlResultado.Attributes["style"] = "background: rgba(252, 55, 55, 0.2);";
            if (resultado.resultado == true)
            {
                //lblResultado.ForeColor = System.Drawing.Color.Green;
                lblResultado.Attributes["style"] = "color: #008000;";
                pnlResultado.Attributes["style"] = "background: rgba(147, 252, 55, 0.22);";
                hdfEstado.Value = "0";
                btnNuevo.Visible = true;
                btnNuevo.Text = "Nuevo";
                pnlFormRol.Visible = false;
                pnlRoles.Visible = true;
                llenarGdvRoles();
            }
            pnlResultado.Visible = true;
        }
        protected void gdvSO_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            lblResultado.Text = string.Empty;
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            lblResultado.ForeColor = System.Drawing.Color.Red;
            Entidades.SOxServidor so = new Entidades.SOxServidor();
            so.IdSOxServidor = Convert.ToInt32(gdvSO.Rows[e.RowIndex].Cells[1].Text);
            so.Servidor = null;
            so.SO = null;
            so.Estatus = null;
            if(permisos.D)
            {
                Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
                resultado = Negocio.Inventarios.SOxServidor.Eliminar(so);

                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                {
                    lblResultado.Text += error.descripcionCorta + "<br/>";
                });

                if (resultado.resultado == true)
                {
                    lblResultado.ForeColor = System.Drawing.Color.Green;
                    ObtenerParametros();
                    llenarGdvSO();
                }
            }
            else
            {
                lblResultado.Text = "No tienes privilegios para eliminar información";
            }
        }
        private void llenarGdvTiposArreglos()
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();

            gdvTiposArreglos.DataSource = Negocio.Catalogos.TipoArregloDisco.Obtener(new Entidades.TipoArregloDisco());
            gdvTiposArreglos.DataBind();
        }
        protected void gdvAlmacenamiento_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            lblResultado.Text = string.Empty;
            lblResultado.ForeColor = System.Drawing.Color.Red;
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            if(permisos.D)
            {
                Entidades.Almacenamiento alm = new Entidades.Almacenamiento();
                alm.IdAlmacenamiento = Convert.ToInt32(gdvAlmacenamiento.Rows[e.RowIndex].Cells[1].Text);
                alm.TipoMemoria = null;

                Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
                resultado = Negocio.Inventarios.Almacenamiento.Eliminar(alm);

                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                {
                    lblResultado.Text += error.descripcionCorta + "<br/>";
                });

                if (resultado.resultado == true)
                {
                    lblResultado.ForeColor = System.Drawing.Color.Green;
                    ObtenerParametros();
                    llenarGdvAlmacenamiento();
                }
            }
            else
            {
                lblResultado.Text = "No tienes privilegios para eliminar información.";
            }
        }
        protected void gdvTiposArreglos_SelectedIndexChanged(object sender, EventArgs e)
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            hdfEstado.Value = "2";
            lblStatus.Text = string.Empty;
            btnNuevo.Visible = false;
            btnGuardar.Text = "Actualizar";
            btnGuardar.Enabled = permisos.U;
            pnlTipoArreglo.Visible = false;
            pnlFormulario.Visible = true;
            pnlResultado.Visible = false;
            lblIdTipoArreglo.Value = gdvTiposArreglos.SelectedRow.Cells[1].Text;

            txtTipoArreglo.Text = HttpUtility.HtmlDecode(gdvTiposArreglos.SelectedRow.Cells[2].Text);
            txtTipoArregloDesc.Text = HttpUtility.HtmlDecode(gdvTiposArreglos.SelectedRow.Cells[3].Text);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     //Este ID debe coincidir con el Menú registrado en la BD
     int IdPagina = 13;
     if (Negocio.Seguridad.Seguridad.AccesoPagina(IdPagina) == true)
     {
         if (!IsPostBack)
         {
             permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
             if (permisos.R == true)
             {
                 pnlTipoArreglo.Visible = true;
                 pnlFormulario.Visible = false;
                 pnlResultado.Visible = false;
                 llenarGdvTiposArreglos();
             }
             btnNuevo.Enabled = permisos.C;
         }
     }
     else
     {
         Response.Redirect("~/errorAcceso.aspx");
     }
 }
 private void llenarGdvRoles()
 {
     permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
     gdvRoles.DataSource = Negocio.Seguridad.RolUsuario.Obtener(new Entidades.RolUsuario());
     gdvRoles.DataBind();
 }
 protected void gdvNombreEstatus_SelectedIndexChanged(object sender, EventArgs e)
 {
     permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
     hdfEstado.Value = "2";
     lblStatus.Text = string.Empty;
     btnNuevo.Visible = false;
     btnGuardar.Text = "Actualizar";
     btnGuardar.Enabled = permisos.U;
     pnlNombreEstatus.Visible = false;
     pnlFormulario.Visible = true;
     pnlResultado.Visible = false;
     lblIdEstatus.Value = HttpUtility.HtmlDecode(gdvNombreEstatus.SelectedRow.Cells[1].Text);
     llenarDdlEstatusForm();
     //ddlMarcaForm.SelectedItem.Text = ddlMarca.SelectedItem.ToString();
     ddlConceptoEstatusForm.Items.FindByText(ddlConceptoEstatus.SelectedItem.ToString()).Selected = true;
     ddlConceptoEstatusForm.Enabled = false;
     //txtMarca.Text = gdvNombreModelo.SelectedRow.Cells[2].Text;
     txtNombreEstatus.Text = HttpUtility.HtmlDecode(gdvNombreEstatus.SelectedRow.Cells[3].Text);
 }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            lblResultado.Text = string.Empty;
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            Entidades.Usuarios us = new Entidades.Usuarios();
            us.Usuario = txtNombreUsuario.Text.Trim();
            us.IdRol.IdRol = Convert.ToInt32(ddlRol.SelectedValue);
            us.IdPersona.IdPersona = Convert.ToInt32(ddlPersona.SelectedValue);

            //if (ddlPersona.SelectedValue == "0")
            //    us.IdPersona.IdPersona = -1;
            //else
            //    us.IdPersona.IdPersona = Convert.ToInt32(ddlPersona.SelectedValue);

            if (txtPass1.Text.Trim() == txtPass2.Text.Trim())
            {
                if (hdfEstado.Value == "1" && permisos.C == true && ddlRol.SelectedValue != "0" && ddlPersona.SelectedValue != "0")
                {
                    us.Pwd = txtPass1.Text.Trim();
                    resultado = Negocio.Seguridad.Usuarios.Nuevo(us);
                }
                else if (hdfEstado.Value == "2" && permisos.U == true && ddlRol.SelectedValue != "0" && ddlPersona.SelectedValue != "0")
                {
                    us.IdUsuario = Convert.ToInt32(lblIdUsuario.Text);
                    us.Pwd = txtPass1.Text.Trim();
                    resultado = Negocio.Seguridad.Usuarios.Actualizar(us);
                }
                else if(ddlRol.SelectedValue == "0")
                {
                    lblResultado.Text = "Seleccionar un rol.";
                }
                else if (ddlPersona.SelectedValue == "0")
                {
                    lblResultado.Text = "Debe estar ligado a una persona.";
                }
                else
                {

                    lblResultado.Text = "No tienes privilegios para realizar esta acción.";
                }
            }
            else
            {
                txtPass1.Attributes.Add("value", txtPass1.Text);
                txtPass2.Attributes.Add("value", txtPass2.Text);
                lblResultado.Text = "Contraseñas deben coincidir.";
            }
            resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
            {
                lblResultado.Text += error.descripcionCorta + "<br/>";
            });

            //lblResultado.ForeColor = System.Drawing.Color.Red;
            lblResultado.Attributes["style"] = "color: #F00;";
            pnlResultado.Attributes["style"] = "background: rgba(252, 55, 55, 0.2);";
            if (resultado.resultado == true)
            {
                //lblResultado.ForeColor = System.Drawing.Color.Green;
                lblResultado.Attributes["style"] = "color: #008000;";
                pnlResultado.Attributes["style"] = "background: rgba(147, 252, 55, 0.22);";
                hdfEstado.Value = "0";
                lblIdUsuario.Text = string.Empty;
                btnNuevo.Visible = true;
                pnlUsuarios.Visible = true;
                pnlFormulario.Visible = false;
                llenarGdvUsuarios();
            }
            pnlResultado.Visible = true;
        }
        private void llenarGdvMarcas()
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();

            gdvMarcas.DataSource = Negocio.Catalogos.MarcaServidor.obtenerMarcaServidor(new Entidades.MarcaServidor());
            gdvMarcas.DataBind();
        }
 private void llenarGdvUsuarios()
 {
     permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
     gdvUsuarios.DataSource = Negocio.Seguridad.Usuarios.Obtener(new Entidades.Usuarios() { IdPersona = null,  IdRol = null });
     gdvUsuarios.DataBind();
 }
        protected void gdvUsuarios_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblResultado.Text = string.Empty;
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            hdfEstado.Value = "2";
            btnNuevo.Visible = false;
            btnGuardar.Text = "Actualizar";
            btnGuardar.Enabled = permisos.U;
            pnlUsuarios.Visible = false;
            pnlFormulario.Visible = true;
            pnlResultado.Visible = false;
            llenarDdlRoles();
            llenarDdlPersonas();

            lblIdUsuario.Text = gdvUsuarios.SelectedRow.Cells[1].Text;
            List<Entidades.Usuarios> usList = new List<Entidades.Usuarios>();
            usList = Negocio.Seguridad.Usuarios.Obtener(new Entidades.Usuarios()
            {
                IdUsuario = Convert.ToInt32(lblIdUsuario.Text), IdPersona = null, IdRol = null
            });
            Entidades.Usuarios us = usList.First();
            txtNombreUsuario.Text = us.Usuario;
            ddlRol.SelectedValue = us.IdRol.IdRol.ToString();
            if (us.IdPersona != null)
                ddlPersona.SelectedValue = us.IdPersona.IdPersona.ToString();
            txtPass1.Attributes.Add("value", us.Pwd);
            txtPass2.Attributes.Add("value", us.Pwd);
        }
        protected void gdvSoporte_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            lblResultado.Text = string.Empty;
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();

            Entidades.Soporte soporte = new Entidades.Soporte();
            soporte.IdSoporte = Convert.ToInt32(gdvSoporte.Rows[e.RowIndex].Cells[1].Text.Trim());
            soporte.Modelo = null;
            soporte.Empresa = null;

            resultado.resultado = permisos.D;

            if(resultado.resultado == true)
            {
                resultado = Negocio.Inventarios.Soporte.Eliminar(soporte);
            }
            else
            {
                lblResultado.Text = "No tienes privilegios para realizar esta acción.";
            }

            resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
            {
                lblResultado.Text += error.descripcionCorta + "<br/>";
            });
            lblResultado.Attributes["style"] = "color: #F00;";
            pnlResultado.Attributes["style"] = "background: rgba(252, 55, 55, 0.2);";
            if (resultado.resultado == true)
            {
                //lblResultado.ForeColor = System.Drawing.Color.Green;
                lblResultado.Attributes["style"] = "color: #008000;";
                pnlResultado.Attributes["style"] = "background: rgba(147, 252, 55, 0.22);";
                llenarGdvSoporte();
            }
            pnlResultado.Visible = true;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if(!IsPostBack)
     {
         permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
         if (permisos.R == true)
         {
             hdfIdServidor.Value = _IdServidor.ToString();
             llenarGdvSO();
         }
         btnAdd.Enabled = permisos.C;
     }
 }
        private void llenarGdvTiposServidores()
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();

            gdvTiposServidores.DataSource = Negocio.Catalogos.TipoServidor.Obtener(new Entidades.TipoServidor());
            gdvTiposServidores.DataBind();
        }
        private void llenarGdvEstatus()
        {
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            //
            gdvNombreEstatus.DataSource = Negocio.Catalogos.Estatus.Obtener(new Entidades.Estatus()
            {
                IdConceptoEstatus = Convert.ToInt32(ddlConceptoEstatus.SelectedValue ?? "0")

            }
            );
            gdvNombreEstatus.DataBind();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     //Este ID debe coincidir con el Menú registrado en la BD
     int IdPagina = 7;
     if (Negocio.Seguridad.Seguridad.AccesoPagina(IdPagina) == true)
     {
         if (!IsPostBack)
         {
             permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
             if (permisos.R == true)
     {
         llenarGdvSoporte();
         Empresas();
         llenarDdlMarcas();
         llenarDdlModelo();
         pnlResultado.Visible = false;
         //pnlResultado.Visible = false;
         txtFechaIni.Text = DateTime.Now.ToShortDateString();
         txtFechaFin.Text = DateTime.Now.ToShortDateString();
     }
             btnNuevo.Enabled = permisos.C;
         }
     }
     else
     {
         Response.Redirect("~/errorAcceso.aspx");
     }
 }