Esempio n. 1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        RequiredFieldValidator1.Enabled = false;
        RequiredFieldValidator3.Enabled = false;
        int Existe = 0;

        Existe = ValidaSiUsuarioExiste(0);
        if (Existe > 0)
        {
            //Response.Redirect("~/zPopup/ErrorClienteExistente.aspx");
            Label2.Text      = "Error:usuario ya registrado";
            Label2.ForeColor = System.Drawing.Color.Red;
            Label2.Visible   = true;
            LbError.Visible  = true;
            //Response.Write("<script language=javascript>alert('Ya existe un usuario con ese correo favor de proporcionar otro')</script>");
        }
        else
        {
            try
            {
                string   _temprasheconvert;
                DateTime Hoy          = DateTime.Today;
                string   fecha_actual = Hoy.ToString("dd/MM/yy");
                //Propiedades_tbl alta = new Propiedades_tbl();
                Usuario_tbl alta = new Usuario_tbl();

                alta.Usuario_Nombre   = txtNombre.Text;
                alta.Usuario_Telefono = txtCodAreaTel.Text + txtelefono.Text;
                alta.Usuario_Email    = txtCorreoR.Text;

                _temprasheconvert       = md5method(saltphrase);
                alta.Usuario_Contrasena = md5method(txtpass2.Text + _temprasheconvert); //txtpass2.Text;

                //string temp = md5method(txtpass2.Text + _temprasheconvert);
                alta.Usuario_Fecha    = Hoy;
                alta.Usuario_Inactivo = false;
                alta.Usuario_stat     = 0;
                dc.Usuario_tbl.InsertOnSubmit(alta);
                dc.SubmitChanges();
                Response.Write("<script language=javascript>alert('Tu has Registrado satifactoriamente Para ver si esta registrado Abre tu correo electronico')</script>");
                Session["Alta"] = 1;
                Response.Redirect("~/Default.aspx");

                //Label2.Visible = true;
            }
            catch (Exception ex)
            {
                LbError.Text = ex.Message;
                try
                {
                    int numeroError = ((System.Data.SqlClient.SqlException)(ex)).Number;

                    LbError.Text = numeroError.ToString();

                    LbError.Visible = true;

                    switch (numeroError)
                    {
                    case 8152: LbError.Text = "No debes de capturar un texto muy largo";
                        break;

                    case 2627: LbError.Text = "No puedes repetir el Codigo del articulo";
                        break;
                    }
                }
                catch { }
            }
        }
    }
Esempio n. 2
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        RequiredFieldValidator1.Enabled = false;
        RequiredFieldValidator3.Enabled = false;
        int Existe = 0;

        Existe = ValidaSiUsuarioExiste(0);
        if (Existe > 0)
        {
            //Response.Redirect("~/zPopup/ErrorClienteExistente.aspx");
            Label2.Text = "Error:usuario ya registrado";
            Label2.ForeColor = System.Drawing.Color.Red;
            Label2.Visible = true;
            LbError.Visible = true;
            //Response.Write("<script language=javascript>alert('Ya existe un usuario con ese correo favor de proporcionar otro')</script>");

        }
        else
        {
            try
            {
                string _temprasheconvert;
                DateTime Hoy = DateTime.Today;
                string fecha_actual = Hoy.ToString("dd/MM/yy");
                //Propiedades_tbl alta = new Propiedades_tbl();
                Usuario_tbl alta = new Usuario_tbl();

                alta.Usuario_Nombre = txtNombre.Text;
                alta.Usuario_Telefono = txtCodAreaTel.Text + txtelefono.Text;
                alta.Usuario_Email = txtCorreoR.Text;

                _temprasheconvert = md5method(saltphrase);
                alta.Usuario_Contrasena = md5method(txtpass2.Text + _temprasheconvert); //txtpass2.Text;

                //string temp = md5method(txtpass2.Text + _temprasheconvert);
                alta.Usuario_Fecha = Hoy;
                alta.Usuario_Inactivo = false;
                alta.Usuario_stat = 0;
                dc.Usuario_tbl.InsertOnSubmit(alta);
                dc.SubmitChanges();
                Response.Write("<script language=javascript>alert('Tu has Registrado satifactoriamente Para ver si esta registrado Abre tu correo electronico')</script>");
                Session["Alta"] = 1;
                Response.Redirect("~/Default.aspx");

                //Label2.Visible = true;
            }
            catch (Exception ex)
            {
                LbError.Text = ex.Message;
                try
                {
                    int numeroError = ((System.Data.SqlClient.SqlException)(ex)).Number;

                    LbError.Text = numeroError.ToString();

                    LbError.Visible = true;

                    switch (numeroError)
                    {
                        case 8152: LbError.Text = "No debes de capturar un texto muy largo";
                            break;
                        case 2627: LbError.Text = "No puedes repetir el Codigo del articulo";
                            break;
                    }
                }
                catch { }
            }
        }
    }