예제 #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            Gestion ges  = new Gestion();
            string  rpta = "";

            if (cmbTipo.Text == string.Empty || cmbEstado.Text == string.Empty)
            {
                MensajeError("Falta Ingresar algunos datos");
            }
            else
            {
                if (cmbTipo.SelectedItem.ToString() == "Admin")
                {
                    tipo = 1;
                }
                if (cmbTipo.SelectedItem.ToString() == "Ventas")
                {
                    tipo = 2;
                }
                if (cmbTipo.SelectedItem.ToString() == "Expedicion")
                {
                    tipo = 3;
                }
                if (cmbEstado.SelectedItem.ToString() == "Activo")
                {
                    estado = 1;
                }
                if (cmbEstado.SelectedItem.ToString() == "Desactivado")
                {
                    estado = 0;
                }
                if (txtDNI.Text == string.Empty || txtUsuario.Text == string.Empty || txtPass.Text == string.Empty)
                {
                    MensajeError("Falta Ingresar algunos datos");
                }
                else
                {
                    if (IsNuevo)
                    {
                        rpta = ges.NuevoUsuario(txtDNI.Text.Trim().ToUpper(), txtUsuario.Text, txtPass.Text, tipo, estado);
                    }
                    else
                    {
                        rpta = ges.EditarUsuario(txtDNI.Text.Trim().ToUpper(), txtUsuario.Text, txtPass.Text, tipo, estado);
                    }
                    if (rpta.Equals("OK"))
                    {
                        if (IsNuevo)
                        {
                            MessageBox.Show("Se inserto de forma correcta el registro ", "WR Gestion");
                        }
                        else
                        {
                            MessageBox.Show("Se actualizo de forma correcta el registro ", "WR Gestion");
                        }
                    }
                    else
                    {
                        MensajeError("Error no se efectuo la operacion correctamente");
                    }
                }
                IsNuevo  = false;
                IsEditar = false;
                Botones();
                Limpiar();
                mostrar();
            }
        }