Ejemplo n.º 1
0
        //-------------------------------
        // ADD CUSTOMER BUTTON METHODS  |
        //-------------------------------
        private void btnAddCustomer_Click(object sender, EventArgs e)
        {
            Customer_AddForm caf = new Customer_AddForm();

            caf.ShowDialog();        //Validation happens at Customer_AddForm.cs

            if (caf.Cancel == false) //Meaning, will add the Customer. If Cancel is true, nothing happens.
            {
                //---ADD the new Customer to the ArrayList
                customerList.Add(new Customer(customerIDCounter,
                                              caf.BusinessName,
                                              caf.FullTinNumber,
                                              caf.CustomerName,
                                              caf.CustomerPerson,
                                              caf.CustomerNumber,
                                              caf.AccountNumber,
                                              caf.CustomerEmail,
                                              caf.CustomerAddress));

                //---DISPLAY the newly added Customer in the Main Screen DGV
                dgvCustomers.Rows.Add(caf.CustomerName, caf.CustomerPerson, caf.CustomerNumber, caf.CustomerEmail);

                //---SAVE in Database
                Customer newCustomer = (Customer)customerList[(customerList.Count - 1)]; //Casting
                sql.InsertCustomer(newCustomer);

                //---MESSAGEBOX FOR DEBUG PURPOSES

                /*MessageBox.Show("CREATE " + customerIDCounter + ", " + caf.BusinessName + ", " + caf.FullTinNumber + ", " + caf.CustomerName
                 + ", " + caf.CustomerPerson + ", " + caf.CustomerNumber + ", " + caf.CustomerEmail + ", " + caf.CustomerAddress
                 + "Inserted to Array " + (customerList.Count - 1));*/

                customerIDCounter++;
            }
        }