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)
        {
            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);";
            Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
            if (ddlEstatusServidor.SelectedValue != "0" && ddlSO.SelectedValue != "0")
            {
                resultado.resultado = true;
                List<Entidades.ConfRed> consultaRed = new List<Entidades.ConfRed>();
                consultaRed = Negocio.Inventarios.ConfRed.Obtener(new Entidades.ConfRed() { DirIP = txtDirIP.Text.Trim() });
                if (consultaRed.Count > 0)
                {
                    Entidades.Logica.Error error = new Entidades.Logica.Error();
                    resultado.resultado = false;
                    error = new Entidades.Logica.Error();
                    error.idError = 4;
                    error.descripcionCorta = "Dirección de IP duplicada.";
                    resultado.errores.Add(error);
                }
                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                {
                    lblResultado.Text += error.descripcionCorta + "<br>";
                });
                Entidades.Servidor servidor = new Entidades.Servidor();
                if (resultado.resultado == true)
                {
                    servidor.AliasServidor = txtAliasServidor.Text.Trim();
                    servidor.DescripcionUso = txtDescripcionUso.Text.Trim();
                    servidor.Modelo = null;
                    servidor.Especificacion = null;
                    servidor.TipoServidor = null;
                    servidor.Estatus.IdEstatus = Convert.ToInt32(ddlEstatusServidor.SelectedValue);
                    resultado = Negocio.Inventarios.Servidor.Nuevo(servidor);
                    resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                    {
                        lblResultado.Text += error.descripcionCorta + "<br>";
                    });
                }
                if(resultado.resultado == true)
                {
                    List<Entidades.Servidor> consultaServidor = new List<Entidades.Servidor>();
                    consultaServidor = Negocio.Inventarios.Servidor.Obtener(servidor);
                    if (consultaServidor.Count > 0)
                    {
                        int idSer = consultaServidor.First().IdServidor;

                        Entidades.SOxServidor so = new Entidades.SOxServidor();
                        so.Servidor.IdServidor = idSer;
                        so.SO.IdSO = Convert.ToInt32(ddlSO.SelectedValue);
                        so.Estatus = null;
                        resultado = Negocio.Inventarios.SOxServidor.Nuevo(so);
                        resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                        {
                            lblResultado.Text += error.descripcionCorta + "<br>";
                        });

                        Entidades.ConfRed red = new Entidades.ConfRed();
                        red.Servidor.IdServidor = idSer;
                        red.InterfazRed = txtInterfazRed.Text.Trim();
                        //red.DirMac = txtDirMAC.Text.Trim();
                        red.DirIP = txtDirIP.Text.Trim();
                        red.MascaraSubRed = txtMascaraSubRed.Text.Trim();
                        if(!string.IsNullOrWhiteSpace(txtGateway.Text.Trim()))
                            red.Gateway = txtGateway.Text.Trim();
                        if (!string.IsNullOrWhiteSpace(txtDNS.Text.Trim()))
                            red.DNS = txtDNS.Text.Trim();
                        //if (!string.IsNullOrWhiteSpace(txtVlan.Text.Trim()))
                        //    red.VLAN = txtVlan.Text.Trim();
                        //red.Estatus.IdEstatus = Convert.ToInt32(ddlEstatusRed.SelectedValue);
                        red.Estatus = null;
                        resultado = Negocio.Inventarios.ConfRed.Nuevo(red);
                        resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                        {
                            lblResultado.Text += error.descripcionCorta + "<br>";
                        });

                        Entidades.BitacoraMantenimiento bitacora = new Entidades.BitacoraMantenimiento();
                        bitacora.FechaCaptura = DateTime.Now;
                        bitacora.FechaMantenimiento = DateTime.Now;
                        bitacora.DescripcionMantenimiento = "Servidor registrado en el sistema.";
                        bitacora.Observaciones = "Sin observaciones.";
                        resultado = Negocio.Bitacoras.BitacoraMantenimiento.Nuevo(bitacora);
                        resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                        {
                            lblResultado.Text += error.descripcionCorta + "<br>";
                        });

                        if (resultado.resultado == true)
                        {
                            List<Entidades.BitacoraMantenimiento> conBitacor = new List<Entidades.BitacoraMantenimiento>();
                            conBitacor = Negocio.Bitacoras.BitacoraMantenimiento.Obtener(bitacora);
                            if (conBitacor.Count > 0)
                            {
                                int idBit = conBitacor.First().IdBitacora;
                                Entidades.PersonaXservidor asoc = new Entidades.PersonaXservidor();
                                asoc.Servidor.IdServidor = idSer;
                                asoc.Bitacora.IdBitacora = idBit;
                                asoc.Personas.IdPersona = ((Entidades.Usuarios)Session["usuario"]).IdPersona.IdPersona;
                                resultado = Negocio.Inventarios.PersonaXservidor.Nuevo(asoc);
                                resultado.errores.ForEach(delegate (Entidades.Logica.Error error)
                                {
                                    lblResultado.Text += error.descripcionCorta + "<br>";
                                });

                                if(resultado.resultado ==  true)
                                {
                                    pnlNuevoServidor.Visible = false;
                                    pnlServidores.Visible = true;
                                    llenarRprServidores();
                                }
                            }
                        }
                    }
                }
                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);";
                }
            }
            else
            {
                lblResultado.Text = "Falta seleecionar algun item, revise y vuelva a intentar.";
            }
            pnlResultado.Visible = true;
        }
        protected void gdvInterfacesRed_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            lblResultado.Text = string.Empty;
            lblResultado.ForeColor = System.Drawing.Color.Red;
            permisos = Negocio.Seguridad.Seguridad.verificarPermisos();
            if(permisos.D == true)
            {
                Entidades.Logica.Ejecucion resultado = new Entidades.Logica.Ejecucion();
                Entidades.ConfRed red = new Entidades.ConfRed();
                red.IdConfRed = Convert.ToInt32(gdvInterfacesRed.Rows[e.RowIndex].Cells[1].Text);
                red.Servidor = null;
                red.Estatus = null;

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

                if (resultado.resultado == true)
                {
                    lblResultado.ForeColor = System.Drawing.Color.Green;
                    ObtenerParametros();
                    InterfacesRed();
                }
            }
            else
            {
                lblResultado.Text = "No tienes privilegios para eliminar información";
            }
        }