private void DeleteAppointment() { bool converted = false; DateTime date; DBcontroler DB = new DBcontroler(); do { Console.Write("Old date of the appointment (dd-mm-yyyy): "); converted = DateTime.TryParse(Console.ReadLine(), out date); if (converted == false) { Console.WriteLine(); Console.WriteLine("Wrong input! Try again!"); Console.ReadKey(); Console.Clear(); } } while (converted == false); string phoneInput = TakingPhoneNumber(); DB.DeleteAppointment(phoneInput, date); Console.WriteLine("The appointment was deleted from the system!"); Console.ReadKey(); }
public void MakeNewAppointment() { string startTime = ""; string endTime = ""; bool converted = false; DateTime date; DBcontroler DB = new DBcontroler(); do { Console.Write("Date (dd-mm-yyyy): "); converted = DateTime.TryParse(Console.ReadLine(), out date); if (converted == false) { Console.WriteLine(); Console.WriteLine("Wrong input! Try again!"); Console.ReadKey(); Console.Clear(); } } while (converted == false); ShowAvailableTime(date); do { Console.Write("Start time (hh:mm): "); startTime = Console.ReadLine(); } while (CheckHours(startTime) == false || CheckMinutes(startTime) == false); do { Console.Write("End time (hh:mm): "); endTime = Console.ReadLine(); } while (CheckHours(endTime) == false || CheckMinutes(endTime) == false); Console.Write("Notes: "); string notes = Appointment.ChangeNotes(Console.ReadLine()); string phone = ""; bool phoneIsRight = false; do { phoneIsRight = false; Console.Write("Customer's phone number: "); phone = Console.ReadLine(); if (PhoneNumberChecking(phone) == true) { phoneIsRight = true; phone = Customer.SplitPhoneNumber(phone); } } while (phoneIsRight == false); Customer customer = cuRepo.Load(phone); Appointment appointment = new Appointment(date, startTime, endTime, notes, customer); DB.InsertAppointment(appointment); Console.WriteLine("The appointment was made!"); Console.ReadKey(); }
private void ChangeAppointmentDateTime() { using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); SqlCommand cmdChangeAppointmentByPhone = new SqlCommand("SP_CHANGE_APPOINTMENT_DATE_AND_TIME", con); cmdChangeAppointmentByPhone.CommandType = CommandType.StoredProcedure; SearchAppointmentByCustomerPhone(); string startTime = ""; string endTime = ""; string phoneNum = ""; DateTime oldDate; bool converted = false; DateTime date; DBcontroler DB = new DBcontroler(); Console.Write("Choose the date you want to change (dd-mm-yyyy): "); oldDate = Convert.ToDateTime(Console.ReadLine()); do { Console.Write("New date to set the appointment (dd-mm-yyyy): "); converted = DateTime.TryParse(Console.ReadLine(), out date); if (converted == false) { Console.WriteLine(); Console.WriteLine("Wrong input! Try again!"); Console.ReadKey(); Console.Clear(); } } while (converted == false); ShowAvailableTime(date); Console.ReadKey(); do { Console.Write("New start time for the appointment (hh:mm): "); startTime = Console.ReadLine(); } while (CheckHours(startTime) == false || CheckMinutes(startTime) == false); do { Console.Write("New end time for the appointment (hh:mm): "); endTime = Console.ReadLine(); } while (CheckHours(endTime) == false || CheckMinutes(endTime) == false); do { Console.Write("Confirm customer's phone number : "); phoneNum = Console.ReadLine(); } while (PhoneNumberChecking(phoneNum) == false); DB.ChangeAppointment(phoneNum, date, startTime, endTime, oldDate); Console.ReadKey(); } }
private void DeleteAppointment() { bool converted = false; string phoneInput = ""; bool inputCorrect = true; DateTime date; DBcontroler DB = new DBcontroler(); do { Console.Write("Old date of the appointment (dd-mm-yyyy): "); converted = DateTime.TryParse(Console.ReadLine(), out date); if (converted == false) { Console.WriteLine(); Console.WriteLine("Wrong input! Try again!"); Console.ReadKey(); Console.Clear(); } } while (converted == false); do { inputCorrect = false; Console.Clear(); Console.WriteLine("(Press x if you want to exit.)"); Console.WriteLine(); Console.Write("Customer's phone number for the appointment: "); phoneInput = Console.ReadLine(); if (phoneInput.ToLower() != "x") { inputCorrect = PhoneNumberChecking(phoneInput); } else { inputCorrect = true; } } while (inputCorrect == false); Console.Clear(); DB.DeleteAppointment(phoneInput, date); }
public void InsertCustomer() { Customer customer = new Customer(); DBcontroler DB = new DBcontroler(); string firstName = InputCustomer("first name"); Console.Clear(); string lastName = InputCustomer("last name"); Console.Clear(); string phone = InputCustomer("telephone number"); customer.FirstName = Customer.ChangeName(firstName); customer.LastName = Customer.ChangeName(lastName); customer.Phone = Customer.SplitPhoneNumber(phone); DB.InsertCustomer(customer); Console.WriteLine("The customer was added to the system!"); Console.ReadKey(); }