Example #1
0
        protected void btnRegistrarse_Click(object sender, EventArgs e)
        {
            if (txtNombres.Text.Trim() == "" || txtNombres.Text.Length < 3) { txtNombres.Focus(); return; }
            if (txtApellidos.Text.Trim() == "" || txtApellidos.Text.Length < 4) { txtApellidos.Focus(); return; }
            if (txtCorreo.Text.Trim() == "" || txtCorreo.Text.Length <= 8) { txtCorreo.Focus(); return; }
            entCliente c = new entCliente();
            entNacionalidad objNacionalidad = new entNacionalidad();
            bool retorno, band=false;
            try
            {
                c.Nombres = txtNombres.Text;
                c.Apellidos = txtApellidos.Text;
                c.Sexo = Convert.ToChar(ddlSexo.SelectedValue[0]);
                c.Direccion = txtDireccion.Text;
                c.Telefono = txtTelefono.Text;
                c.Correo = txtCorreo.Text;
                c.NroDocumento = txtNroDocumento.Text;
                objNacionalidad = negNacionalidad.Instancia.BuscarNacionalidadxNombre(ddlNacionalidad.SelectedValue);
                c.Nacionalidad = objNacionalidad;
                c.TipoCliente = ddlTipoCliente.SelectedValue;
                c.RUC = txtRUC.Text;
                c.RazonSocial = txtRazonSocial.Text;
                c.Password = txtPassword.Text;

                retorno = negCliente.Instancia.RegistrarCliente(c);

                if (retorno)
                {
                    Response.Write("<script>alert('Registrado con exito')</script>");
                    band = true;
                }
                else
                {
                    Response.Write("<script>alert('No se pudo registrar con exito')</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex + "')</script>");

            }
            LimpiarControles();
            if (band)
            {
                Response.Redirect("login.aspx");
            }
        }
Example #2
0
 public entCliente BuscarXNroDocumento(String NroDocumento)
 {
     entCliente c = null;
     SqlCommand cmd = null;
     SqlDataReader dr = null;
     try
     {
         SqlConnection conex = Conexion.Instancia.Conectar();
         cmd = new SqlCommand("Buscar_X_NroDocumento", conex);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@NroDocumento", NroDocumento);
         conex.Open();
         dr = cmd.ExecuteReader();
         if (dr.Read())
         {
             c = new entCliente();
             c.IdPersona = Convert.ToInt32(dr["IDPERSONA"]);
             c.Nombres = dr["NOMBRES"].ToString();
             c.Apellidos = dr["APELLIDOS"].ToString();
             c.Sexo = Convert.ToChar(dr["SEXO"]);
             c.Direccion = dr["DIRECCION"].ToString();
             c.Telefono = dr["TELEFONO"].ToString();
             c.Correo = dr["CORREO"].ToString();
             c.NroDocumento = dr["NRODOCUMENTO"].ToString();
             c.TipoCliente = dr["TIPOCLIENTE"].ToString();
             entNacionalidad n = new entNacionalidad();
             n.IdNacionalidad = Convert.ToInt32(dr["IDNACIONALIDAD"]);
             n.Nombre = dr["NOMBRE"].ToString();
             c.Nacionalidad = n;
         }
     }
     catch (Exception e)
     {
         c = null;
         throw e;
     }
     finally
     {
         cmd.Connection.Close();
     }
     return c;
 }