Esempio n. 1
0
        private async void btnAdd_Click(object sender, EventArgs e)
        {
            if (btnAdd.Text == "Add")
            {
                if (AddValidated())
                {
                    Barangay brgy = new Barangay();
                    brgy.BrgyName = txtBarangay.Text;
                    await repository.AddBarangayAsync(brgy);
                    await LoadBarangay();

                    frmSettings setting = (frmSettings)Application.OpenForms["frmSettings"];
                    await setting.LoadBarangay();

                    this.Close();
                }
            }

            if (btnAdd.Text == "Update")
            {
                if (UpdateValidated())
                {
                    Barangay brgy = await repository.GetBarangayByIdAsync(frmSettings.barangayID);

                    brgy.BrgyName = txtBarangay.Text;
                    await repository.UpdateBarangayAsync(brgy);
                    await LoadBarangay();

                    frmSettings setting = (frmSettings)Application.OpenForms["frmSettings"];
                    await setting.LoadBarangay();

                    btnAdd.Text = "Add";
                    this.Close();
                }
            }
        }