Example #1
0
        // Кнопка добавления записи в Addresses
        private async void addressConfirmButton_Click(object sender, EventArgs e)
        {
            AddResult addResult     = AddResult.Failed;
            string    country       = addressCountryTextbox.Text;
            string    city          = addressCityTextbox.Text;
            string    street        = addressStreetTextbox.Text;
            string    house         = addressHouseTextbox.Text;
            string    resultMessage = "Something went wrong, try again";

            if (string.IsNullOrEmpty(country) || string.IsNullOrEmpty(city) || string.IsNullOrEmpty(street) || string.IsNullOrEmpty(house))
            {
                resultMessage = "Required fields are not filled, try again";
            }
            else
            {
                addResult = await addressManager.AddRecord(country, city, street, int.Parse(house));

                if (addResult == AddResult.Success)
                {
                    resultMessage = "Record was successfully added";
                }
            }

            MessageBox.Show(resultMessage, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            if (addResult == AddResult.Success)
            {
                OnAddressPanelLeave();
                await DataGridDataInitialize(DbTable.Addresses);
            }
        }