Пример #1
0
        /// <summary>
        /// Event handle for the Add customer button of the AddNewCustomerWindow
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddCustomerDataButton_Click(object sender, EventArgs e)
        {
            List <string> existingCustomer = new List <string>();
            bool          addCustomer;

            addCustomer = ValidateCustomerFields();
            if (addCustomer)
            {
                DialogResult dialogResult = MessageBox.Show("Are these the correct customer details?", "Add New Customer", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    FirstName   = EnterFirstNameTextBox.Text;
                    LastName    = EnterLastNameTextbox.Text;
                    PhoneNumber = EnterPhoneNumberTextbox.Text;
                    if (!select.checkDatabaseNewCustomer(derivedAPI, FirstName, LastName, PhoneNumber))
                    {
                        PoS.CurrentCustomer = FirstName + " " + LastName;
                        insert.AddNewCustomer(derivedAPI, FirstName, LastName, PhoneNumber);
                        this.Close();
                    }
                    else
                    {
                        PoS.CurrentCustomer = "";
                        MessageBox.Show("Customer already exists in database.");
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    EnterFirstNameTextBox.Text   = "";
                    EnterLastNameTextbox.Text    = "";
                    EnterPhoneNumberTextbox.Text = "";
                }
            }
        }