Ejemplo n.º 1
0
        private void btnInsertar_Click(object sender, EventArgs e)
        {
            try
            {
                string Rpta = "";


                if (txtNombre.Text == string.Empty)
                {
                    this.MensajeError("Faltan ingresar algunos datos en los campos....");
                    errorAlerta.SetError(txtNombre, "Ingrese Nombre"); //error provider
                }
                else if (txtApellido.Text == string.Empty)
                {
                    this.MensajeError("Faltan ingresar algunos datos en los campos....");
                    errorAlerta.SetError(txtApellido, "Ingrese Apellido");
                }
                else if (txtCargo.Text == string.Empty)
                {
                    this.MensajeError("Faltan ingresar algunos datos en los campos....");
                    errorAlerta.SetError(txtCargo, "Ingrese Cargo");
                }
                else if (txtDireccion.Text == string.Empty)
                {
                    this.MensajeError("Faltan ingresar algunos datos en los campos....");
                    errorAlerta.SetError(txtDireccion, "Ingrese Cargo");
                }
                else if (txtCelular.Text == string.Empty)
                {
                    this.MensajeError("Faltan ingresar algunos datos en los campos....");
                    errorAlerta.SetError(txtCelular, "Ingrese Cargo");
                }
                else if (txtEstado.Text == string.Empty)
                {
                    this.MensajeError("Faltan ingresar algunos datos en los campos....");
                    errorAlerta.SetError(txtEstado, "Ingrese Cargo");
                }
                else
                {
                    Rpta = EmpleadoNegocio.Insertar(txtDni.Text.Trim(), txtNombre.Text.Trim(), txtApellido.Text.Trim(), txtCargo.Text.Trim(), txtDireccion.Text.Trim(), txtCelular.Text.Trim(), txtEstado.Text.Trim());
                    if (Rpta.Equals("Correcto"))
                    {
                        this.MensajeCorrecto("Se grabo el registro en la BD correctamente...");
                        this.Limpiar();
                        this.Visualizar();
                        this.Listar();
                    }
                    else
                    {
                        this.MensajeError(Rpta);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }