private void EditStylistButton_Click(object sender, EventArgs e) { string[] name = ListofStylists.Text.Split(' '); for (int i = 0; i < name.Length; i++) { switch (i) { case 0: StylistFirstName = name[i]; break; case 1: StylistLastName = name[i]; break; } } edit = true; StylistSearch.Clear(); Hide(); StylistInfo Stylist = new StylistInfo(); Stylist.EditStylistClicked(); Stylist.Closed += (s, args) => this.Show(); Stylist.Show(); }
private void BookChairButton_Click(object sender, EventArgs e) { if (ListofStylists.SelectedIndex == -1) { MessageBox.Show("Please select a stylist who would like to book"); } else { ReadInTransaction(); if (date == false) { string[] selectedstylist = ListofStylists.SelectedItem.ToString().Split(' '); string StylistFirstName = ""; string StylistLastName = ""; for (int i = 0; i < selectedstylist.Length; i++) { switch (i) { case 0: StylistFirstName = selectedstylist[i]; break; case 1: StylistLastName = selectedstylist[i]; break; } } double rate = 0; //Gets the hourly rate of the stylist if (StylistRate.ContainsKey(ListofStylists.SelectedItem.ToString())) { StylistRate.TryGetValue(ListofStylists.SelectedItem.ToString(), out rate); } ReadingInListOfTransactions.Add(new SnippetsBackend.Transaction(StylistFirstName, StylistLastName, "Chair Booking", dateTimePicker1.Value.ToShortDateString(), "NA", rate)); //Add to textfile using (StreamWriter tw = new StreamWriter("Transactions.txt", false)) { foreach (SnippetsBackend.Transaction s in ReadingInListOfTransactions) { tw.WriteLine(s.FirstName + "," + s.LastName + "," + s.ChairOrAppointment + "," + s.DateandTime + "," + s.Duration + "," + s.Rate); } tw.Close(); } MessageBox.Show("Stylist has booked a chair"); StylistSearch.Clear(); } } }