Exemple #1
0
        private void BtnAccept_Click(object sender, EventArgs e)
        {
            flag = 0;

            if (txtName.Text.Trim() == "")
            {
                Error.SetError(txtName, "Debe ingresar un nombre para registrar la actividad");
                flag = 1;
            }
            if (flag == 0)
            {
                validActivity = A.FindActivity(txtName.Text);
                if (validActivity == true)
                {
                    MessageBox.Show("Ya existe una actividad con el nombre " + "'" + txtName.Text + "'.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtName.Clear();
                    txtName.Focus();
                    flag = 1;
                }
            }

            if (flag == 0)
            {
                A.Name        = txtName.Text.Trim();
                A.Observation = txtDescription.Text.Trim();
                A.NewActivity(A);
                Combo.Combo2Campos(owner.cbActivity, "Id", "Name", "Activity");
                owner.BtnDelete.Enabled = true;
                owner.CargarGrilla();
                L.Action     = "El usuario " + Users.CacheUser.Nick + " registró una nueva actividad: " + txtName.Text.ToString();
                L.ActionDate = DateTime.Now;
                L._users.Id  = Users.CacheUser.Id;
                L.WriteLog(L);
                DialogResult answ = MessageBox.Show("Se ha guardado la actividad exitosamente." + "\n ¿Desea agregar feligreses a la actividad?", "Ok", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (answ == DialogResult.Yes)
                {
                    this.Dispose();
                    this.Close();
                    frmActivities     FA  = new frmActivities();
                    frmModifyActivity FMA = new frmModifyActivity(A.GetLastId(), FA);
                    FMA.txtName.Text        = A.GetActivityName(A.GetLastId());
                    FMA.txtDescription.Text = A.GetActivityObservation(A.GetLastId());
                    FMA.ShowDialog();
                }
                else
                {
                    txtName.Clear();
                    txtDescription.Clear();
                    Combo.Combo2Campos(owner.cbActivity, "Id", "Name", "Activity");
                    owner.CargarGrilla();
                    owner.CheckComboItems();
                }
            }
        }
 private void FrmModifyActivity_FormClosed(object sender, FormClosedEventArgs e)
 {
     Combo.Combo2Campos(owner.cbActivity, "Id", "Name", "Activity");
     owner.CargarGrilla();
     owner.CheckComboItems();
 }