示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Escolaridad tempEs = new Escolaridad();

            tempEs.grado = txtGrade.Text;
            tempEs.baja  = checkBox1.Checked;
            Operation <Escolaridad> operation = sc.addRecord(tempEs);

            if (operation.State)
            {
                obtenerEscolaridades();
            }
            else
            {
                MessageBox.Show(operation.Error);
            }
        }
示例#2
0
        private void btnSaveModify_Click(object sender, EventArgs e)
        {
            try {
                this.errorProvider.Clear();
                List <ControlErrorProvider> errorsProvider = FormValidators.validFormTest(getValidators());
                bool isValid = errorsProvider == null;
                if (isValid)
                {
                    bool        isNew       = selectedScholarship == null;
                    Escolaridad scholarship = new Escolaridad()
                    {
                        idEscolaridad = isNew ? 0 : selectedScholarship.idEscolaridad,
                        grado         = txtGrade.Text,
                        baja          = isNew ? true : chbStatus.Checked
                    };

                    Operation <Escolaridad> operation = isNew ? scholarshipController.addRecord(scholarship) :
                                                        scholarshipController.updateRecord(scholarship);
                    if (operation.State)
                    {
                        loadTable(getScholarship());
                        clearForm();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Algunos datos proporcionados son inválidos. Pase el puntero sobre los íconos de error para ver los detalles de cada campo.", "ERROR DE VALIDACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    foreach (ControlErrorProvider errorProvider in errorsProvider)
                    {
                        this.errorProvider.SetError(errorProvider.ControlName, errorProvider.ErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                FormUtils.defaultErrorMessage(ex);
            }
        }