コード例 #1
0
 protected void Regis_Click(object sender, EventArgs e)
 {
     if (userPass.Text == userPassConf.Text)
     {
         photo.SaveAs(System.AppDomain.CurrentDomain.BaseDirectory + userName.Text.Trim());
         if (photo.FileName.Trim().IndexOf(".jpg") > -1 || photo.FileName.Trim().IndexOf(".png") > -1 || photo.FileName.Trim().IndexOf(".gif") > -1)
         {
             cUsuarios obj     = new cUsuarios(0, name.Text, lastName.Text, sureName.Text, email.Text, userName.Text, userPass.Text, "images/Profiles/" + photo.FileName.Trim(), 0);
             String    mensaje = obj.GuardaUsuario();
             if (mensaje == "Usuario Registrado Correctamente")
             {
                 String script = "$.confirm({title: 'Genial!',    content: 'Usuario registrado correctamente',theme: 'material',buttons: {ok:{ btnClass: 'btn btn-info',action: function(window.location.replace('" + Request.ApplicationPath + "Default.aspx');){ }   }}}); ";
                 ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
             }
             else if (mensaje == "Usuario Registrado Anteriormente")
             {
                 String script = "$.confirm({title: 'Error!',    content: 'Nombre de usuario o correo registrado anteriormente',theme: 'material',buttons: {ok:{ btnClass: 'btn btn-info',action: function(){ }   }}}); ";
                 ScriptManager.RegisterStartupScript(this, GetType(),
                                                     "ServerControlScript", script, true);
             }
         }
         else
         {
             String script = "$.confirm({title: 'Error!',    content: 'La extensión del archivo debe ser .jpg, .png o .gif',theme: 'material',buttons: {ok:{ btnClass: 'btn btn-info',action: function(){ }   }}}); ";
             ScriptManager.RegisterStartupScript(this, GetType(),
                                                 "ServerControlScript", script, true);
         }
     }
     else
     {
         String script = "$.confirm({title: 'Error!',    content: 'Las contraseñas no coinciden',theme: 'material',buttons: {ok:{ btnClass: 'btn btn-info',action: function(){ }   }}}); ";
         ScriptManager.RegisterStartupScript(this, GetType(),
                                             "ServerControlScript", script, true);
     }
 }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["v"] != null)
            {
                switch (Convert.ToChar(Request.QueryString["v"].ToString()))
                {
                case '0':
                    mvUsuarios.ActiveViewIndex = 0;
                    if (idUsuario.Text == "0" || idUsuario.Text == "")
                    {
                    }
                    else
                    {
                    }
                    rellenaDropDown();
                    break;

                case '1':

                    mvUsuarios.ActiveViewIndex = 1;

                    break;
                }
                else if (txtTipoUs.Visible && txtTipoUs1.Visible && txtTipoUs2.Visible && txtTipoUs3.Visible && !txtTipoUs4.Visible && !txtTipoUs5.Visible && !txtTipoUs6.Visible && !txtTipoUs7.Visible)
                {
                    roles    = new int[4];
                    roles[0] = Convert.ToInt32(txtTipoUs.SelectedValue);
                    roles[1] = Convert.ToInt32(txtTipoUs1.SelectedValue);
                    roles[2] = Convert.ToInt32(txtTipoUs2.SelectedValue);
                    roles[3] = Convert.ToInt32(txtTipoUs3.SelectedValue);
                }
                else if (txtTipoUs.Visible && txtTipoUs1.Visible && txtTipoUs2.Visible && !txtTipoUs3.Visible && !txtTipoUs4.Visible && !txtTipoUs5.Visible && !txtTipoUs6.Visible && !txtTipoUs7.Visible)
                {
                    roles    = new int[3];
                    roles[0] = Convert.ToInt32(txtTipoUs.SelectedValue);
                    roles[1] = Convert.ToInt32(txtTipoUs1.SelectedValue);
                    roles[2] = Convert.ToInt32(txtTipoUs2.SelectedValue);
                }
                else if (txtTipoUs.Visible && txtTipoUs1.Visible && !txtTipoUs2.Visible && !txtTipoUs3.Visible && !txtTipoUs4.Visible && !txtTipoUs5.Visible && !txtTipoUs6.Visible && !txtTipoUs7.Visible)
                {
                    roles    = new int[2];
                    roles[0] = Convert.ToInt32(txtTipoUs.SelectedValue);
                    roles[1] = Convert.ToInt32(txtTipoUs1.SelectedValue);
                }
                else if (txtTipoUs.Visible && !txtTipoUs1.Visible && !txtTipoUs2.Visible && !txtTipoUs3.Visible && !txtTipoUs4.Visible && !txtTipoUs5.Visible && !txtTipoUs6.Visible && !txtTipoUs7.Visible)
                {
                    roles    = new int[1];
                    roles[0] = Convert.ToInt32(txtTipoUs.SelectedValue);
                }
                cUsuarios obj = new cUsuarios(0, txtnombre.Text, txtApPa.Text, txtApMa.Text, txtRFC.Text, txtTelefono.Text, txtCorreo.Text, roles, Convert.ToInt32(txtOficina.SelectedValue), txtIngreso.Text, txtContra1.Text, txtFoto.FileName, 1);
                obj.GuardaUsuario(Convert.ToInt32(Session["idUsuario"]));
            }
            else
            {
                String alert = "$.alert({title: 'Oh!',theme: 'material',content: 'No es un archivo de imagen válido',buttons:{cerrar: {text:'Cerrar',btnClass:'btn-info'}}}); ";
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", alert, true);
            }
        }
コード例 #3
0
    protected void btnGuardarUsuario_Click(object sender, EventArgs e)
    {
        String Mensaje = "";
        String Foto    = "";

        if (txtPsw.Text == txtPsw2.Text)
        {
            Boolean fileOK = false;
            String  path   = Server.MapPath("~/Administracion/user/photo/");

            if (fuFoto.HasFile)
            {
                String fileExtension =
                    System.IO.Path.GetExtension(fuFoto.FileName).ToLower();
                String[] allowedExtensions = { ".jpg", ".png", ".gif" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        fileOK = true;
                    }
                }
            }


            if (fileOK)
            {
                try
                {
                    fuFoto.SaveAs(path + fuFoto.FileName);

                    cUsuarios cs = new cUsuarios(Convert.ToInt32(lblidUsuario.Text), txtNombreU.Text, txtAPU.Text, txtAMU.Text, txtRFC.Text, txtTelefono.Text, txtCorreo.Text, Convert.ToInt32(ddlTipoUsuario.SelectedValue.ToString()), Convert.ToInt32(ddlOficina.SelectedValue.ToString()), txtFechaIngreso.Text, txtUsuario.Text, txtPsw.Text, fuFoto.FileName, 1);



                    Mensaje           = cs.GuardaUsuario(1);
                    lblidUsuario.Text = cs.PersonID.ToString();
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "swal(\"Listo!\",\"" + Mensaje + "\", \"success\");", true);
                    pnlDatosAdicionales.Visible = true;
                    Extras ex = new Extras();
                    ex.sendMail2(txtCorreo.Text, "PROMORISK MÉXICO <br/> Se ha actualizado tu Información", "Modificación del Sistema");
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "swal(\"Oh...\", \"Ha ocurrido un error D:\", \"error\");", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "swal(\"Oh...\", \"No es un archivo valido debe ser una imagen\", \"error\");", true);
            }
        }
        else
        {
            Mensaje = "Las Contraseñas no Coinciden";
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "swal(\"Listo!\",\"" + Mensaje + "\", \"success\");", true);
        }
    }
コード例 #4
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        cUsuarios obj = new cUsuarios((int)Session["idUser"]);

        obj.TraeInfoUsuario();
        obj.userOP = 1;
        obj.GuardaUsuario();

        String script = "$.confirm({title: 'Genial!',    content: 'Tu cuenta ha sido eliminada',theme: 'material',buttons: {ok:{ btnClass: 'btn btn-info',action: function(){ }   }}}); ";

        ScriptManager.RegisterStartupScript(this, GetType(),
                                            "ServerControlScript", script, true);
        Session.Abandon();
        Response.Redirect("Default.aspx");
    }
コード例 #5
0
    protected void Modify_Click(object sender, EventArgs e)
    {
        photo.SaveAs(System.AppDomain.CurrentDomain.BaseDirectory + userName.Text.Trim());
        cUsuarios obj = new cUsuarios((int)Session["idUser"], name.Text.Trim(), lastName.Text.Trim(), sureName.Text.Trim(), email.Text.Trim(), userName.Text.Trim(), userPass.Text.Trim(), "images/Profiles/" + photo.FileName.Trim(), 2);

        if (userPass.Text == userPassConf.Text)
        {
            String msj = obj.GuardaUsuario();
            if (msj == "Datos de Usuario Modificados")
            {
                String script = "$.confirm({title: 'Genial!',    content: 'Tus datos han sido modificados',theme: 'material',buttons: {ok:{ btnClass: 'btn btn-info',action: function(){ }   }}}); ";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
            }
        }
        //
    }