Beispiel #1
0
        //Click events for buttons
        private void btnAdd_Click(object sender, EventArgs e)
        {
            /*By not defining a FormClosing event on CustomersAdd.cs, I can add an individual closing event per form
             * object that is created. Allows for flexibility when creating forms ie Can call the add customer form from the
             * add sale form and not have to worry about the form closing event running everytime (This would close form and
             * launch the view customers form)
             */
            GlobalVariable.selectedCustomerID = 0;

            frmCustomersAdd customersAdd = new frmCustomersAdd();

            customersAdd.FormClosing += new FormClosingEventHandler(frmCustomersAdd_FormClosing);
            customersAdd.ShowDialog();
            void frmCustomersAdd_FormClosing(object bender, FormClosingEventArgs formClosingEvent)
            {
                frmCustomersView customersView = new frmCustomersView();

                customersView.Show();
                Hide();
            }

            lvCustomers.Items.Clear();
            DisplayCustomers();
            Hide();
        }
Beispiel #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            /*
             * Prompts user for selection if nothing has been selected. Assigns CustomerID to
             * selectedCustomerID variable. Loads edit screen with selected customers information
             */

            if (lvCustomers.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select a customer to update", "Update Customer",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            GlobalVariable.selectedCustomerID = int.Parse(lvCustomers.SelectedItems[0].SubItems[1].Text);

            frmCustomersAdd editForm = new frmCustomersAdd();

            editForm.FormClosing += new FormClosingEventHandler(frmCustomersAdd_FormClosing);
            editForm.ChangeAddToEdit("Edit Customer Details", " Edit Customer Details", "Update");
            editForm.ShowDialog();
            void frmCustomersAdd_FormClosing(object bender, FormClosingEventArgs formClosingEvent)
            {
                frmCustomersView customersView = new frmCustomersView();

                customersView.Show();
                Hide();
            }

            lvCustomers.Items.Clear();
            DisplayCustomers();
            Hide();
        }
Beispiel #3
0
        private void customersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCustomersView customersView = new frmCustomersView();

            customersView.Show();
            Hide();
        }