示例#1
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtNombreUsuario.Text) == false)
            {
                MessageBox.Show("Llene todos los campos obligatorios");
                return;
            }

            int ver = Base_de_datos.validarNomUsuario(txtNombreUsuario.Text, txtCodigoUsuario.Text);

            if (ver != 1)
            {
                MessageBox.Show("Usuario ya existente");
                return;
            }

            string estado;

            if (cmbestado.Text == "Activo")
            {
                estado = "ACT";
            }

            else
            {
                estado = "INC";
            }

            Base_de_datos.Actualizar_usuario(int.Parse(txtCodigoUsuario.Text), txtNombreUsuario.Text, estado);

            MessageBox.Show("Usuario modificado.");

            Base_de_datos busc = new Base_de_datos();

            busc.BuscarUsuario();
            dataGridView1.DataSource = busc.Mostrar_Resultados();

            txtCodigoUsuario.Clear();
            txtNombreUsuario.Clear();
            cmbestado.Text       = "";
            btnModificar.Enabled = false;
        }