private void btnModificar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNombre.Text == string.Empty || txtApellido.Text == string.Empty || txtMatricula.Text == string.Empty)
                {
                    errorIcono.SetError(txtMatricula, "Ingrese la matricula");
                    errorIcono.SetError(txtNombre, "Ingrese el nombre");
                    errorIcono.SetError(txtApellido, "Ingrese apellido");
                }
                else
                {
                    DialogResult resul = MessageBox.Show("Realmente desea modificar el registro", "Modificar registro", MessageBoxButtons.YesNo);
                    if (resul == DialogResult.Yes)
                    {
                        NUsuario.Editar(Convert.ToInt32(txtIdUser.Text), this.txtMatricula.Text, this.txtNombre.Text, this.txtApellido.Text, this.txtcbCarrera.Text,
                                        this.txtcbSexo.Text, this.txtcbTipoUsuario.Text, this.txtEmail.Text);

                        MessageBox.Show("Registro modificado");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 2
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                string resp = "";
                if (this.txtNome.Text == string.Empty)
                {
                    MensagemErro("Preencha todos os campos");
                    errorIcone.SetError(txtNome, "Informe o nome");
                }
                else
                {
                    if (this.eNovo)
                    {
                        resp = NUsuario.Inserir(this.txtNome.Text.Trim(), txtSenha.Text.Trim(), this.cbbAcesso.Text);
                    }
                    else
                    {
                        resp = NUsuario.Editar(Convert.ToInt32(this.txtCodigo.Text), this.txtNome.Text.Trim(), txtSenha.Text.Trim(), this.cbbAcesso.Text);
                    }

                    if (resp.Equals("OK"))
                    {
                        if (this.eNovo)
                        {
                            this.MensagemOK("Registro salvo com sucesso");
                        }
                        else
                        {
                            this.MensagemOK("Registro editado com sucesso");
                        }
                    }
                    else
                    {
                        this.MensagemErro(resp);
                    }

                    this.eNovo   = false;
                    this.eEditar = false;
                    this.Botoes();
                    this.Limpar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 3
0
 private void bntGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         string rpta = "";
         if (this.txtNombre.Text == string.Empty)
         {
             MensajeError("Falta Datos");
         }
         else
         {
             if (this.IsNuevo)
             {
                 rpta = NUsuario.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.txtCi.Text.Trim().ToUpper(), this.txtCorreo.Text.Trim().ToUpper(), this.txtEdad.Text.Trim().ToUpper(), this.cbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text, this.txtEstado.Text.Trim().ToUpper());
             }
             else
             {
                 rpta = NUsuario.Editar(Convert.ToInt32(this.txtIdusuario.Text), this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.txtCi.Text.Trim().ToUpper(), this.txtCorreo.Text.Trim().ToUpper(), this.txtEdad.Text.Trim().ToUpper(), this.cbAcceso.Text, this.txtUsuario.Text, this.txtPassword.Text, this.txtEstado.Text.Trim().ToUpper());
             }
             if (rpta.Equals("OK"))
             {
                 if (this.IsNuevo)
                 {
                     this.MensajeOK("Se Inserto");
                 }
                 else
                 {
                     this.MensajeOK("Se Actualizo");
                 }
             }
             else
             {
                 this.MensajeError(rpta);
             }
             this.IsNuevo  = false;
             this.IsEditar = false;
             this.Botones();
             this.Limpiar();
             this.Mostrar();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Esempio n. 4
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (Editar == true)
     {
         if (Comprobar_Campos())
         {
             if (Obtener_Id(AuxiliarNombre) == 0)
             {
                 MessageBox.Show("Error: id no encontrado!");
             }
             else
             {
                 if (AuxiliarNombre == tbUsuario.Text)
                 {
                     MessageBox.Show(NUsuario.Editar(Obtener_Id(tbUsuario.Text), tbUsuario.Text, tbContraseña.Text, cbNivelAcceso.Text));
                     Limpiar_Campos();
                     Editar = false;
                     HabilitarCampos(false);
                     HabilitarGuardarLimpiar(false);
                 }
                 else if (NombreExistente(tbUsuario.Text))
                 {
                     MessageBox.Show(string.Format("Error: el nombre '{0}' ya se encuentra en uso!", tbUsuario.Text));
                 }
                 else
                 {
                     MessageBox.Show(NUsuario.Editar(Obtener_Id(AuxiliarNombre), tbUsuario.Text, tbContraseña.Text, cbNivelAcceso.Text));
                     Limpiar_Campos();
                     Editar = false;
                     HabilitarCampos(false);
                     HabilitarGuardarLimpiar(false);
                 }
             }
         }
         else
         {
         }
     }
     else
     {
         if (Comprobar_Campos())
         {
             if (NombreExistente(tbUsuario.Text))
             {
                 MessageBox.Show(string.Format("Error: el nombre '{0}' ya se encuentra en uso!", tbUsuario.Text));
             }
             else
             {
                 MessageBox.Show(NUsuario.Insertar(tbUsuario.Text, tbContraseña.Text, cbNivelAcceso.Text));
                 Limpiar_Campos();
                 HabilitarCampos(false);
                 HabilitarGuardarLimpiar(false);
             }
         }
         else
         {
             Comprobar_Campos();
         }
     }
     Mostrar();
 }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string Rpta = "";
                if (this.txtNombre.Text == string.Empty || this.txtApellidos.Text == string.Empty || this.txtTelefono.Text == string.Empty || this.txtUsuario.Text == string.Empty || this.txtPassword.Text == string.Empty || this.txtCodigoCargo.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    errorIcono.SetError(txtNombre, "Ingrese el nombre");
                    errorIcono.SetError(txtApellidos, "Ingrese el apellido");
                    errorIcono.SetError(txtPassword, "Ingrese el password");
                    errorIcono.SetError(txtUsuario, "Ingrese el usuaurio");
                    errorIcono.SetError(txtTelefono, "Ingrese el telefono");
                    errorIcono.SetError(cbSexo, "Ingrese el sexo");
                    errorIcono.SetError(cbCargo, "Ingrese el telefono");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        Rpta = NUsuario.Insertar(Convert.ToInt32(txtCodigoCargo.Text),
                                                 this.txtNombre.Text,
                                                 this.txtApellidos.Text,
                                                 txtDireccion.Text,
                                                 Convert.ToDateTime(DateTime.Now.ToShortTimeString()),
                                                 Convert.ToInt32(txtTelefono.Text),
                                                 cbSexo.Text,
                                                 "ACTIVO",
                                                 txtUsuario.Text,
                                                 txtPassword.Text
                                                 );
                    }
                    else
                    {
                        Rpta = NUsuario.Editar(Convert.ToInt32(txtCodigo.Text),
                                               Convert.ToInt32(txtCodigoCargo.Text),
                                               this.txtNombre.Text,
                                               this.txtApellidos.Text,
                                               txtDireccion.Text,
                                               Convert.ToInt32(txtTelefono.Text),
                                               cbSexo.Text,
                                               cbEstado.Text,
                                               txtUsuario.Text,
                                               txtPassword.Text
                                               );
                    }

                    if (Rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se insertó de forma correcta el registro");
                            errorIcono.Clear();
                            txtCodigo.Visible = true;
                            label10.Visible   = true;
                        }
                        else
                        {
                            this.MensajeOk("Se actualizó de forma correcta el registro");
                            errorIcono.Clear();
                        }
                    }
                    else
                    {
                        this.MensajeError(Rpta);
                    }
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                    dgvRegistros.Enabled   = true;
                    label14.Visible        = true;
                    l.Visible              = true;
                    txtDescripcion.Visible = true;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            this.BorrarErrorProvider();
            try
            {
                string rpta = "";

                //verificamos que no haya texbox o comboBox vacios
                if (this.txtNombre.Text == string.Empty || this.txtCuit.Text == string.Empty || this.cbSexo.Text == string.Empty || this.cbAcceso.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");

                    //recorremos los comboBox verificando cuales estan vacios
                    foreach (Control c in groupBox1.Controls.OfType <ComboBox>())
                    {
                        if (c is ComboBox & c.Text.Trim() == "")
                        {
                            errorIcono.SetError(c, "Ingrese un Valor");
                        }
                    }

                    //recorremos los texbox verificando cuales estan vacios
                    foreach (Control c in groupBox1.Controls)
                    {
                        if (c is TextBox & c.Text.Trim() == "")
                        {
                            errorIcono.SetError(c, "Ingrese un Valor");
                        }
                    }

                    errorIcono.SetError(txtIdusuario, String.Empty);
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NUsuario.Insertar(this.txtNombre.Text.Trim().ToUpper(),
                                                 this.txtApellidos.Text.Trim().ToUpper(),
                                                 this.cbSexo.Text, dtFechaNac.Value,
                                                 txtCuit.Text, txtDireccion.Text.ToUpper(), txtTelefono.Text,
                                                 txtEmail.Text, cbAcceso.Text, txtUsuarios.Text.ToUpper(), txtClave.Text);

                        this.BorrarErrorProvider();
                    }
                    else
                    {
                        rpta = NUsuario.Editar(Convert.ToInt32(this.txtIdusuario.Text),
                                               this.txtNombre.Text.Trim().ToUpper(),
                                               this.txtApellidos.Text.Trim().ToUpper(),
                                               this.cbSexo.Text, dtFechaNac.Value,
                                               txtCuit.Text, txtDireccion.Text.ToUpper(), txtTelefono.Text,
                                               txtEmail.Text, cbAcceso.Text, txtUsuarios.Text.ToUpper(), txtClave.Text);

                        this.BorrarErrorProvider();
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se Insertó de forma correcta el registro");
                        }
                        else
                        {
                            this.MensajeOk("Se Actualizó de forma correcta el registro");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }