Пример #1
0
 public void Log_InsUsu(Usuario_Enc Usu)
 {
     using (SqlConnection cn = new SqlConnection(consulta))
     {
         using (SqlCommand cmdInsCli = new SqlCommand("SP_InsUsu", cn))
         {
             cmdInsCli.Connection.Open();
             cmdInsCli.CommandType = CommandType.StoredProcedure;
             cmdInsCli.Parameters.Add("@Nom", SqlDbType.NVarChar, 50).Value   = Usu.Nom;
             cmdInsCli.Parameters.Add("@Ape", SqlDbType.NVarChar, 50).Value   = Usu.Ape;
             cmdInsCli.Parameters.Add("@Dir", SqlDbType.NVarChar, 50).Value   = Usu.Dir;
             cmdInsCli.Parameters.Add("@Tel", SqlDbType.NVarChar, 20).Value   = Usu.Tel;
             cmdInsCli.Parameters.Add("@Email", SqlDbType.NVarChar, 50).Value = Usu.Ema;
             cmdInsCli.Parameters.Add("@Usu", SqlDbType.NVarChar, 50).Value   = Usu.Usu;
             cmdInsCli.Parameters.Add("@Pass", SqlDbType.NVarChar, 50).Value  = Usu.Pass;
             cmdInsCli.ExecuteNonQuery();
         }
     }
 }
Пример #2
0
 public void Log_InsUsu(Usuario_Enc Usu)
 {
     log.Log_InsUsu(Usu);
 }
        private void btnReg_Click_1(object sender, EventArgs e)
        {
            ///Valida los campos de texto
            if (txtNom.Text == "")
            {
                MessageBox.Show("Ingrese su nombre", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNom.Focus();
            }
            else if (txtApe.Text == "")
            {
                MessageBox.Show("Ingrese su apellido", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtApe.Focus();
            }
            else if (txtDir.Text == "")
            {
                MessageBox.Show("Ingrese su dirección", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtDir.Focus();
            }
            else if (txtTel.Text == "")
            {
                MessageBox.Show("Ingrese su teléfono", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTel.Focus();
            }
            else if (txtEma.Text == "")
            {
                MessageBox.Show("Ingrese su correo electrónico", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtEma.Focus();
            }
            else if (txtUsu.Text == "")
            {
                MessageBox.Show("Ingrese un usuario", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUsu.Focus();
            }
            else if (txtCon.Text == "")
            {
                MessageBox.Show("Ingrese una contraseña", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtCon.Focus();
            }
            else
            {
                ///Valida el campo de texto Email
                bool valor = false;
                try
                {
                    new System.Net.Mail.MailAddress(txtEma.Text);
                    valor = true;
                }
                catch
                {
                    valor = false;
                }

                ///Valida el valor
                if (!valor)
                {
                    MessageBox.Show("Correo ingresado es inválido", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtEma.Focus();
                    return;
                }

                ///Guardamos los textos en la entidad
                Usuario_Enc Usu = new Usuario_Enc();
                Usu.Nom  = txtNom.Text;
                Usu.Ape  = txtApe.Text;
                Usu.Dir  = txtDir.Text;
                Usu.Tel  = txtTel.Text;
                Usu.Ema  = txtEma.Text;
                Usu.Usu  = txtUsu.Text;
                Usu.Pass = txtCon.Text;

                ///Ejecutamos el procedimiento
                log.Log_InsUsu(Usu);
                MessageBox.Show("Se registro correctamene", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);

                RegCli_LimText();
            }
        }