private void Button_Click_Add(object sender, RoutedEventArgs e) { string massage = ""; Employee newEmployee = new Employee(); newEmployee.FirstName = First_Name.Text; newEmployee.LastName = Last_Name.Text; newEmployee.StartDate = StartDate.SelectedDate.Value.Date.ToLongDateString(); if (!string.IsNullOrEmpty(Salary.Text)) { newEmployee.Salary = Convert.ToInt32(Salary.Text); } else { newEmployee.Salary = 0; } validitor.Check(newEmployee); if (!validitor.IsValid()) { foreach (var error in validitor.Erorrs) { massage = string.Join(" and ", validitor.Erorrs); } MessageBox.Show(massage); } else { repo.Add(newEmployee); } this.EmployeeList.ItemsSource = repo.GetAll(); First_Name.Clear(); Last_Name.Clear(); Salary.Clear(); }
private void button1_Click(object sender, EventArgs e) ///This is what is going to be outputted into the output file { if (First_Name.Text == "" | Last_Name.Text == "" | Genre.Text == "" | FilmBox.Text == "" | SR.Text == "" | Rows.Text == "" | Seats.Text == "") { MessageBox.Show("Please complete all sections", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); /// Error Box } else { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"H:\app\booking.txt", true)) /// Change this location to somewhere on your own computer or it wont work. { file.WriteLine("First Name\r\n " + First_Name.Text + "\r\n\r\nLastName\r\n" + Last_Name.Text + "\r\n\r\nFilm\r\n" + FilmBox.Text + "\r\n\r\nSpecial Requirements\r\n" + SR.Text + "\r\n\r\nRows\r\n" + Rows.Text + "\r\n\r\nSeats\r\n" + Seats.Text + "\r\n\r\n_____________________\r\n\r\n"); /// This is how the message is formatted in the output file } First_Name.Clear(); Last_Name.Clear(); Genre.SelectedIndex = -1; FilmBox.Items.Clear(); SR.Items.Clear(); Rows.Items.Clear(); Seats.Items.Clear(); ///Upon submit button being clicked it clears all of the boxes } }