示例#1
0
 /// <summary>
 /// Event-hanler for click event of update menu item of customer menu
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void updateToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Perform updation only when some customers already present.
     if (lstCustomers.Items.Count != 0)
         {
             int index = lstCustomers.SelectedIndex;
             //if no index is selected show error
             if (index == -1)
             {
                 MessageBox.Show("Please select an index", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             string str = lstCustomers.SelectedItem.ToString();
             CustomerForm frmCustomer = new CustomerForm("Update Customer Info", InputUtility.GetWords(str));
             customerMngr.Customers = storedCustomers;
             customerMngr.Names = storeNames;
             //if the customer clicks on OK button of the customer form then continue with the updation
             if (frmCustomer.ShowDialog() == DialogResult.OK)
             {
                 customerMngr.ChangeCustomer(frmCustomer.CustomerData, lstCustomers.SelectedIndex);
                 storedCustomers = customerMngr.Customers;
                 storeNames = customerMngr.Names;
                 //update the customer list
                 ChangedCustomerList();
             }
         }
     else
         {
                 //if listbox is empty show error
                 ShowError();
                 return;
         }
 }
示例#2
0
 /// <summary>
 /// event-hanlre for the add customer menu item of customer Menu.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void addCustomerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //show customerform to enter the values
     frmCustomer = new CustomerForm ("Add New Customer Info");
     if (frmCustomer.ShowDialog() == DialogResult.OK)
     {
         //add new customer with help of customerMngr object
         customerMngr.AddCustomer(frmCustomer.CustomerData);
         //Update the customer list and updates the files
         UpdateCustomerList();
     }
 }