/// <summary> /// Quit button, opens form quit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_quit_Click(object sender, EventArgs e) { HomeClass.WriteListsToFile(); Form_Quit quitfrm = new Form_Quit(); quitfrm.Show(); }
/// <summary> /// Method to load the combobox with the service list /// </summary> private void InitializeForm() { cmboBox_Services.DataSource = Enum.GetNames(typeof(HomeClass.ServiceList)); //show the name and ID on the form txtBox_Name.Text = HomeClass.GetCustName(); txtBox_CustId.Text = HomeClass.GetCustId(); }
/// <summary> /// Method to get the current stored list in Homeclass and placing it /// in custlist. Uses the custlist to show in combobox. /// </summary> private void LoadCustomers() { cmbBox_CustList.Items.Clear(); cmbBox_CustList.Text = "Select Customer"; List <string> custList = HomeClass.GetCustomerList(); foreach (string customer in custList) { string[] items = customer.Split(','); string eachClient = items[0] + " " + items[1] + " " + items[2] + " " + items[3]; cmbBox_CustList.Items.Add(eachClient); } }
/// <summary> /// Method button to get a selected customer and store the cust information /// in the SET methods in the homeclass. Will be used in the Add Services Form. /// Opens the Add Services Form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Services_Click(object sender, EventArgs e) { if (cmbBox_CustList.SelectedIndex == -1) { MessageBox.Show("Select a client from the list"); } else { string selectedCustomer = cmbBox_CustList.SelectedItem.ToString(); string[] custItems = selectedCustomer.Split(' '); HomeClass.SetCustName(custItems[0], custItems[1]); HomeClass.SetCustMail(custItems[2]); HomeClass.SetCustId(custItems[3]); Form_AddServices addServicesFrm = new Form_AddServices(); addServicesFrm.Show(); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); /*Run the methods to read the customer, customerID, and service files. (Capstone folder) * Loads/stores the information from files to the appropriate lists. * Lists in HomeClass are accessed by all the forms in the app.*/ HomeClass.SetCustomerList(); HomeClass.SetIdList(); HomeClass.SetCustomerServicesList(); /*Create and load a dictionary that has the service enums and costs. * Is accessible by the forms in the app.*/ HomeClass.InitializeServiceAndCost(); Application.Run(new frm_welcome()); }
/// <summary> /// Method validating and saving the user input for a new customer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_savecust_Click(object sender, EventArgs e) { if (txtbox_first.Text == "" || txtbox_last.Text == "" || txtbox_email.Text == "") { MessageBox.Show("All Fields Must be Filled Out"); } else { string nextCustomerId = HomeClass.GetNextCustomerID(); string customer = txtbox_first.Text + "," + txtbox_last.Text + "," + txtbox_email.Text + "," + nextCustomerId; HomeClass.CustList.Add(customer); MessageBox.Show("Customer Info Saved, Add Another Client or Go Back"); txtbox_first.Clear(); txtbox_last.Clear(); txtbox_email.Clear(); txtbox_first.Focus(); } }
/// <summary> /// Method button to validate the selection was made /// and update the transaction list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_AddService_Click(object sender, EventArgs e) { bool goodTransaction = false; double amount = 0; if (cmboBox_Services.SelectedItem == null) { MessageBox.Show("Must select a service."); } else { if (paymentSelected) { if (txtBox_Amount.Text == "") { MessageBox.Show("Please Enter a Payment Amount"); } else { double.TryParse(txtBox_Amount.Text, out amount); amount *= -1; goodTransaction = true; } } else { double.TryParse(txtBox_Amount.Text, out amount); goodTransaction = true; } if (goodTransaction) { //update transaction list string transactionDate = DateTime.Now.ToString("MM/dd/yyyy"); string custID = HomeClass.GetCustId(); string selectedService = cmboBox_Services.SelectedItem.ToString(); string newTransaction = custID + "," + transactionDate + "," + selectedService + "," + amount.ToString(); HomeClass.CustomerServicesList.Add(newTransaction); Btn_AddService.Enabled = false; MessageBox.Show("Transaction Complete. Go Back or Add Another."); } } }
/// <summary> /// Method to populate the text box with selected cust info. /// </summary> private void InitializeAddServiceForm() { txtBox_CustId.Text = "Cust ID " + HomeClass.GetCustId(); string custID = HomeClass.GetCustId(); txtBox_CustName.Text = HomeClass.GetCustName(); double total = 0; double amount; //headers listView_ServiceList.View = View.Details; listView_ServiceList.Columns.Add("Date", 100); listView_ServiceList.Columns.Add("Service", 100); listView_ServiceList.Columns.Add("Cost", -2); //go through the customer service list, write info based on customerID selected foreach (string transaction in HomeClass.CustomerServicesList) { string[] transactionItems = transaction.Split(','); //match the custID from selected customer with ID from the list if (transactionItems[0] == custID) { string transactionDate = transactionItems[1].ToString(); string transactionType = transactionItems[2].ToString(); string cost = transactionItems[3].ToString(); //totaling the amount due double.TryParse(cost, out amount); total = total + amount; //adding the matching transactions to the listView (box) listView_ServiceList.Items.Add(new ListViewItem(new string[] { transactionDate, transactionType, cost })); } } //show the total due txtBox_AmountDue.Text = total.ToString(); }