Exemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text == string.Empty || txtApellido.Text == string.Empty || txtDireccion.Text == string.Empty || txtTelefono.Text == string.Empty || txtEmail.Text == string.Empty || cbDepartamento.Text == string.Empty || cbTipoDocu.Text == string.Empty)
            {
                GetMessageError("Debe ingresar datos válidos");
            }
            else
            {
                var    result = true;
                string sexo   = "";
                if (rbSexo1.Checked)
                {
                    sexo = rbSexo1.Text;
                }
                else if (rbSexo2.Checked)
                {
                    sexo = rbSexo2.Text;
                }

                if (txtId.Text == string.Empty)
                {
                    empRules = new EmpleadoBL();
                    result   = empRules.Create(
                        txtNombre.Text
                        , txtApellido.Text
                        , dtFechaNac.Value
                        , sexo
                        , txtDireccion.Text
                        , txtTelefono.Text
                        , cbTipoDocu.Text
                        , txtNoDocu.Text
                        , txtEmail.Text
                        , cbDepartamento.Text
                        );
                }
                else
                {
                    int id = Convert.ToInt32(txtId.Text);
                    empRules = new EmpleadoBL();
                    result   = empRules.Update(
                        id
                        , txtNombre.Text
                        , txtApellido.Text
                        , dtFechaNac.Value
                        , sexo
                        , txtDireccion.Text
                        , txtTelefono.Text
                        , cbTipoDocu.Text
                        , txtNoDocu.Text
                        , txtEmail.Text
                        , cbDepartamento.Text
                        );
                }

                if (result)
                {
                    GetMessageInfo("Guardado con exito");
                }

                ClearTextBoxes(this.Controls);
                dglist.DataSource = null;
            }
        }