Beispiel #1
0
        // Кнопка добавления записи в Clients
        private async void clientConfirmButton_Click(object sender, EventArgs e)
        {
            AddResult addResult     = AddResult.Failed;
            string    name          = clientNameTextBox.Text;
            string    surname       = clientSurnameTextBox.Text;
            string    patronymic    = clientPatronymicTextBox.Text;
            string    email         = clientEmailTextBox.Text;
            string    addressId     = clientAddressIDTextBox.Text;
            string    resultMessage = "Something went wrong, try again";

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(patronymic) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(addressId))
            {
                resultMessage = "Required fields are not filled, try again";
            }
            else
            {
                addResult = await clientManager.AddRecord(name, surname, patronymic, email, int.Parse(addressId));

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

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

            if (addResult == AddResult.Success)
            {
                OnClientPanelLeave();
                await DataGridDataInitialize(DbTable.Clients);
            }
        }