// Show booking grid with booking list from SQL Table public void showBookings() { workingHours_Txt.Text = DatabaseControl.getHoursOfBookingDate(dateTimePicker1.Value.Date).ToString(); note_Txt.Text = DatabaseControl.getBookingNote(dateTimePicker1.Value.Date); double workingHours = DatabaseControl.getHoursOfBookingDate(dateTimePicker1.Value.Date); BindingSource bs = new BindingSource(); GData.bookings = DatabaseControl.getBookings(); GData.customers = DatabaseControl.getCustomers(); List <Booking> bookings = GData.bookings.Where(b => b.bookingDate.Date == dateTimePicker1.Value.Date).ToList(); foreach (Booking booking in bookings) { //booking.estimatedTime = booking.timeOut - booking.timeIn; booking.timeRemaining = workingHours - booking.estimatedTime; workingHours -= booking.estimatedTime; } bs.DataSource = bookings.Select(b => new FilteredBooking() { id = b.id, jobNO = b.jobNO, jobType = b.jobType, customerName = GData.customers.Where(c => c.id == b.customerID).ToList()[0].name, vehicleModel = b.vehicleModel, regNo = b.regNo, bookedBy = b.bookedBy, loanCar = b.loanCar, jobDescription = b.jobDescription, timeRemaining = b.timeRemaining, timeIn = b.timeIn, timeOut = b.timeOut, bookingDate = b.bookingDate }).ToList(); dataGridView1.DataSource = bs; }
public void updateCustomers() { GData.customers = DatabaseControl.getCustomers(); existingCustomer_Cmb.Items.Clear(); existingCustomer_Cmb.Items.Add("(New)"); foreach (Customer customer in GData.customers) { existingCustomer_Cmb.Items.Add(customer.name); } if (customerName_Txt.Text != "") { existingCustomer_Cmb.Text = customerName_Txt.Text; } else { existingCustomer_Cmb.SelectedIndex = 0; } }
private void connect_Bt_Click(object sender, EventArgs e) { GData.hostAddress = hostAddress_Txt.Text; if (GData.hostAddress == "") { MessageBox.Show("Please input Host Address"); hostAddress_Txt.Focus(); return; } GData.userID = user_Txt.Text; if (GData.userID == "") { MessageBox.Show("Please input User ID"); user_Txt.Focus(); return; } GData.password = password_Txt.Text; GData.port = port_Txt.Text; GData.conStr = "Data Source=" + GData.hostAddress + "\\SQLEXPRESS," + GData.port + ";Network Library=DBMSSOCN;User ID=" + GData.userID + ";Password="******"Data Source=" + GData.hostAddress + "\\SQLEXPRESS," + GData.port + ";Network Library=DBMSSOCN;;Initial Catalog=HordernsDB;User ID=" + GData.userID + ";Password="******"Data Source=" + Info.hostAddress + // ";Integrated Security=SSPI;Initial Catalog=" + Info.database + ";"; // Connect to Database and get data of Booking, JobType, and Technicians if (DatabaseControl.CreateDBIfNotExists()) { GData.bookings = DatabaseControl.getBookings(); GData.jobTypes = DatabaseControl.getJobTypes(); GData.technicians = DatabaseControl.getTechnicians(); GData.customers = DatabaseControl.getCustomers(); UIControl.mainForm.Show(); this.Hide(); } }