public static bool PaymentExists(this Payment payment) { using (BeautySalonEntities context = new BeautySalonEntities()) { context.Database.Log = (s => Debug.Write(s)); return(context.Payments.Any(a => a.EmployeeId == payment.EmployeeId && a.AppointmentId == payment.AppointmentId)); } }
/// <summary> /// Check if appointments already exist for the same time and day /// </summary> /// <param name="appointment"></param> /// <returns></returns> public static bool AppointmentExists(this Appointment appointment) { using (BeautySalonEntities context = new BeautySalonEntities()) { context.Database.Log = (s => Debug.Write(s)); return(context.Appointments.Any(a => a.AppointmentDate == appointment.AppointmentDate && a.AppointmentTime == appointment.AppointmentTime)); } }
/// <summary> /// Checks if the client already exists in the DB /// </summary> /// <param name="client"></param> /// <returns></returns> public static bool ClientExists(this Client client) { using (BeautySalonEntities context = new BeautySalonEntities()) { context.Database.Log = (s => Debug.Write(s)); return(context.Clients.Any(c => c.ClientFirstName == client.ClientFirstName && c.ClientLastName == client.ClientLastName)); } }
/// <summary> /// Find the client ID with /// </summary> /// <param name="context"></param> /// <param name="clientFirstName"></param> /// <param name="clientLastName"></param> /// <returns></returns> private static Client FindClientId(BeautySalonEntities context, string clientFirstName, string clientLastName, string clientPhoneNumber) { Client client = context.Clients .Where(c => c.ClientFirstName == clientFirstName) .Where(c => c.ClientLastName == clientLastName) .Where(c => c.ClientPhoneNumber == clientPhoneNumber) .FirstOrDefault(); return(client); }
/// <summary> /// This method will load the controls /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void BeautySalonMainForm_Load(object sender, EventArgs e) { using (BeautySalonEntities context = new BeautySalonEntities()) { context.SeedDatabase(); } // ** CLIENTS listBox // Bind the listbox of clients to Clients Table listBoxAppointmentsClients.DataSource = Controller <BeautySalonEntities, Client> .SetBindingList(); // No client selected to start listBoxAppointmentsClients.SelectedIndex = -1; // ** PROFESSIONALS/EMPLOYEES listBox // Bind the listbox of professionals/employees to Employees table listBoxAppointmentsProfessionals.DataSource = Controller <BeautySalonEntities, Employee> .SetBindingList(); // No professional/employee selected to start listBoxAppointmentsProfessionals.SelectedIndex = -1; // ** APPOINTMENT TIME listBox // Declare array of appointmentTimes string[] appointmentTimes = { "9:00am", "10:00am", "11:00am", "12:00am", "1:00pm", "2:00pm", "3:00pm", "4:00pm", "5:00pm", "6:00pm", "7:00pm" }; // Add array elements to listbox listBoxAppointmentsSelectTime.Items.Clear(); for (int i = 0; i < appointmentTimes.Length; i++) { listBoxAppointmentsSelectTime.Items.Add(appointmentTimes[i]); } // ** SERVICES listBox // Bind the listbox of Services to Service table listBoxAppointmentsSelectService.DataSource = Controller <BeautySalonEntities, Service> .SetBindingList(); // No service selected to start listBoxAppointmentsSelectService.SelectedIndex = -1; // ** APPOINTMENTS gridview InitializeDataGridView <Appointment>(dataGridViewAppointmentsOfTheDay, new string[] { "AppointmentId", "EmployeeId" }); this.tabPageInventory.Controls.Add(new InventoryForm()); this.tabPageServices.Controls.Add(new ServicesForm()); this.tabPagePayments.Controls.Add(new PaymentForm()); this.tabPageSales.Controls.Add(new SalesForm()); }