private void btnSiguiente_Click(object sender, EventArgs e)
 {
     if (validarEntrada())
     {
         decimal dni = Convert.ToDecimal(txtDni.Text);
         if (this.clientesTableAdapter1.GetDataByDni(dni).Count() != 0)
         {
             if (this.tipO_USUARIOTableAdapter1.GetDataByDni(dni).Count() != 0)
             {
                 MessageBox.Show("El DNI ingresado ya posee un usuario", "ERROR", MessageBoxButtons.OK);
             }
             else
             {
                 if (usuarioExistente)
                 {
                     DataRow usuario = this.usuarioTableAdapter1.GetDataByUsuario(contrasenia, nombre).First();
                     int     id      = Convert.ToInt32(usuario["ID_usuario"].ToString());
                     tipO_USUARIOTableAdapter1.UpdateUsuarioCliente(Convert.ToDecimal(txtDni.Text), id);
                     DataRow rol = rolTableAdapter1.GetDataById("Cliente").First();
                     usuariO_ROLTableAdapter1.InsertQuery(id, Convert.ToInt32(rol["ID_rol"]));
                     MessageBox.Show("Se ha agregado exitosamente", "Felicidades", MessageBoxButtons.OK);
                     login.Show();
                     cerrado = true;
                     Close();
                 }
                 else
                 {
                     tipO_USUARIOTableAdapter1.InsertarTipoUsuario(null, null, Convert.ToDecimal(txtDni.Text));
                     DataRow usuario = tipO_USUARIOTableAdapter1.GetDataByDni(Convert.ToDecimal(txtDni.Text)).First();
                     int     id      = Convert.ToInt32(usuario["ID_usuario"].ToString());
                     this.usuarioTableAdapter1.InsertarUsuario(id, contrasenia, nombre);
                     DataRow rol = rolTableAdapter1.GetDataById("Cliente").First();
                     usuariO_ROLTableAdapter1.InsertQuery(id, Convert.ToInt32(rol["ID_rol"]));
                     MessageBox.Show("Se ha agregado exitosamente", "Felicidades", MessageBoxButtons.OK);
                     login.Show();
                     cerrado = true;
                     Close();
                 }
             }
         }
         else
         {
             if (MessageBox.Show("No existe ningun cliente con ese DNI ¿Desea crear uno?", "ERROR", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 new AbmCliente.CrearYModificarCliente().Show();
             }
         }
     }
 }
Пример #2
0
 private void btnAdmin_Click(object sender, EventArgs e)
 {
     LoginYSeguridad.Login Login = new LoginYSeguridad.Login();
     Login.StartPosition = FormStartPosition.CenterScreen;
     Login.Show();
     this.Dispose();
 }
 private void btnSiguiente_Click(object sender, EventArgs e)
 {
     if (validarEntradas())
     {
         if (proveedorTableAdapter1.GetDataByPk(txtCuit.Text, txtRazonSocial.Text).Count() != 0)
         {
             if (tipO_USUARIOTableAdapter1.GetDataByCuitRazonsocial(txtCuit.Text, txtRazonSocial.Text).Count() != 0)
             {
                 MessageBox.Show("El Cuit y/o Razon social ingresado ya posee un usuario", "ERROR", MessageBoxButtons.OK);
             }
             else
             {
                 if (existencia)
                 {
                     DataRow usuario = this.usuarioTableAdapter1.GetDataByUsuario(contrasenia, nombre).First();
                     int     id      = Convert.ToInt32(usuario["ID_usuario"].ToString());
                     tipO_USUARIOTableAdapter1.UpdateQueryProveedor(txtCuit.Text, txtRazonSocial.Text, id);
                     DataRow rol = rolTableAdapter1.GetDataById("Proveedor").First();
                     usuariO_ROLTableAdapter1.InsertQuery(id, Convert.ToInt32(rol["ID_rol"]));
                     MessageBox.Show("Se ha agregado exitosamente", "Felicidades!", MessageBoxButtons.OK);
                     login.Show();
                     Close();
                 }
                 else
                 {
                     tipO_USUARIOTableAdapter1.InsertarTipoUsuario(txtCuit.Text, txtRazonSocial.Text, null);
                     DataRow usuario = tipO_USUARIOTableAdapter1.GetDataByCuitRazonsocial(txtCuit.Text, txtRazonSocial.Text).First();
                     int     id      = Convert.ToInt32(usuario["ID_usuario"].ToString());
                     this.usuarioTableAdapter1.InsertarUsuario(id, contrasenia, nombre);
                     DataRow rol = rolTableAdapter1.GetDataById("Proveedor").First();
                     usuariO_ROLTableAdapter1.InsertQuery(id, Convert.ToInt32(rol["ID_rol"]));
                     MessageBox.Show("Se ha agregado exitosamente", "Felicidades!", MessageBoxButtons.OK);
                     login.Show();
                     cerrado = true;
                     Close();
                 }
             }
         }
         else
         {
             if (MessageBox.Show("No existe ningun cliente con ese cuit y razon social ¿Desea crear uno?", "ERROR", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 new AbmProveedor.CrearProveedor().Show();
             }
         }
     }
 }