Exemplo n.º 1
0
        private void btnBorrar_Click(object sender, EventArgs e)
        {
            MysqlUsuario del = new MysqlUsuario();

            if (MessageBox.Show("Seguro que Deseas borrar este usuario", "Usuario", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                MessageBox.Show("Error Al intentar borrar");
            }
            else
            {
                try
                {
                    del.delet(Convert.ToInt32(txtid.Text));
                    Usuarios.Cargadatos(dGridUsuario);
                    txtid.Clear();
                    txtap1.Clear();
                    txtap2.Clear();
                    txtnombre.Clear();
                    txtusuario.Clear();
                    txtPass.Clear();

                    txtmail.Clear();
                    pcbFoto.Image = null;
                    imagen        = null;
                }
                catch (Exception)
                {
                    MessageBox.Show("Error Al intentar borrar");
                }
            }
        }
Exemplo n.º 2
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            MysqlUsuario add = new MysqlUsuario();

            try
            {
                if (!Validaciones.NombrePersonal(txtap2.Text))
                {
                    ErrorProvider1.SetError(txtap2, "Error solo letras porfavor, No puede estar vacio este campo ");
                    txtap2.SelectAll();
                }
                else
                {
                    ErrorProvider1.SetError(txtap2, "");
                    if (!Validaciones.NombrePersonal(txtnombre.Text))
                    {
                        ErrorProvider1.SetError(txtnombre, "Error solo letras porfavor, No puede estar vacio este campo ");
                        txtnombre.SelectAll();
                    }
                    else
                    {
                        ErrorProvider1.SetError(txtnombre, "");
                        if (!Validaciones.Usuario(txtusuario.Text))
                        {
                            ErrorProvider1.SetError(txtusuario, "Error solo letras y numeros porfavor, No puede estar vacio este campo ");
                            txtnombre.SelectAll();
                        }
                        else
                        {
                            ErrorProvider1.SetError(txtusuario, "");
                            if (!Validaciones.Contraseña(txtPass.Text))
                            {
                                ErrorProvider1.SetError(txtPass, "Error solo letras y numeros porfavor, No puede estar vacio este campo ");
                                txtPass.SelectAll();
                            }
                            else
                            {
                                ErrorProvider1.SetError(txtPass, "");
                                txtid.Clear();
                                add.add(txtap1.Text, txtap2.Text, txtnombre.Text, Convert.ToInt16(txtnivel.Items.Count.ToString()), txtusuario.Text, txtPass.Text, txtmail.Text, imagen);
                                Usuarios.Cargadatos(dGridUsuario);
                                txtap1.Clear();
                                txtap2.Clear();
                                txtnombre.Clear();
                                txtusuario.Clear();
                                txtPass.Clear();
                                txtmail.Clear();
                                pcbFoto.Image = null;
                                imagen        = null;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error al agregar");
            }
        }
Exemplo n.º 3
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            MysqlUsuario act = new MysqlUsuario();

            try
            {
                act.actualizar(Convert.ToInt16(txtid.Text), txtap1.Text, txtap2.Text, txtnombre.Text, Convert.ToInt16(txtnivel.Items.Count.ToString()), txtusuario.Text, txtPass.Text, txtmail.Text, imagen);
                Usuarios.Cargadatos(dGridUsuario);
                txtid.Clear();
                txtap1.Clear();
                txtap2.Clear();
                txtnombre.Clear();
                txtusuario.Clear();
                txtPass.Clear();

                txtmail.Clear();
                pcbFoto.Image = null;
                imagen        = null;
            }
            catch (Exception)
            {
                MessageBox.Show("Error Al intentar actualizar la informacion");
            }
        }