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;
        }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         using (CobranzasDataContext db = new CobranzasDataContext())
         {
             pnlOriginal.Visible = false;
             //try
             //{
             //    txtMensaje.InnerText = "<br/><br/><analisis>" + db.FirmaOperador(Convert.ToInt32(Request["idOperador"]));
             //}
             //catch { }
             if (Request["idPersona"] != null)
             {
                 idPersona = Convert.ToInt32(Request["idPersona"]);
                 Persona   = db.Personas.Single(x => x.idPersona == idPersona);
                 //txtCorreoPara.Value = Persona.Email;
                 //txtCorreoCC.Value = String.Join(",", Persona.PersonasContacto.Select(x => x.Email));
                 //txtCorreoAsunto.Value = "Análisis de Antigüedad al " + DateTime.Now.AFechaMuyCorta() + " - Veconinter - (" + Persona.Codigo + ")" + Persona.Nombre;
                 chkAnalisisAntiguedad.Checked = true;
                 //Seguridad.Ejecutar(CrearAdjuntos);
             }
             else
             {
                 chkAnalisisAntiguedad.Visible = false;
             }
             if (Request["idCorreo"] != null)
             {
                 chkAnalisisAntiguedad.Checked = false;
                 int idCorreo                 = Convert.ToInt32(Request["idCorreo"]);
                 Entidades.Correos Correo     = db.Correos.Single(x => x.idCorreo == idCorreo);
                 String            Encabezado = "<hr/>";
                 Encabezado           += "Correo Original Enviado el:" + Correo.FechaCreacion + "<br/>";
                 Encabezado           += "De: " + Correo.Remitente + "<br/>";
                 Encabezado           += "Para: " + Correo.Destinatarios + "<br/>";
                 Encabezado           += "CC: " + Correo.DestinatariosCopia + "<br/>";
                 Encabezado           += "Asunto: " + Correo.Asunto + "<br/>";
                 Encabezado           += "<br/>";
                 txtMensaje.InnerText += Encabezado;
                 if (Request["Accion"] != "Reenviar")
                 {
                     txtCorreoPara.Value   = Correo.Remitente;
                     txtCorreoAsunto.Value = Correo.Asunto.StartsWith("Re:", StringComparison.InvariantCultureIgnoreCase) ? Correo.Asunto : "Re:" + Correo.Asunto;
                 }
                 else
                 {
                     txtCorreoAsunto.Value = Correo.Asunto.StartsWith("Rv:", StringComparison.InvariantCultureIgnoreCase) ? Correo.Asunto : "Rv:" + Correo.Asunto;
                 }
                 if (Correo.RutaEml == null)
                 {
                     //txtMensaje.InnerText += Correo.Mensaje;
                 }
                 if (Request["Accion"] == "ResponderTodos")
                 {
                     txtCorreoCC.Value = Correo.Destinatarios + ";" + Correo.DestinatariosCopia;
                     while (txtCorreoCC.Value.StartsWith(";"))
                     {
                         txtCorreoCC.Value = txtCorreoCC.Value.Substring(1);
                     }
                 }
                 String RutaCorreo = (@"/Temp/Correo" + idCorreo + (true ? ".html" : ".txt"));
                 iframe.Attributes.Add("src", RutaCorreo);
                 pnlOriginal.Visible = true;
             }
         }
     }
     catch (Exception Ex)
     {
         Ex.Registrar();
     }
 }