// Edit and Delete bookings by click buttons. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == dataGridView1.NewRowIndex || e.RowIndex < 0) { return; } int id = (int)dataGridView1.Rows[e.RowIndex].Cells["id"].Value; if (e.ColumnIndex == dataGridView1.Columns["dataGridViewEditButton"].Index) { UIControl.showForm(UIControl.editBookingForm); UIControl.editBookingForm.bookingToEdit = GData.bookings.Where(b => b.id == id).ToList()[0]; UIControl.editBookingForm.getDescription(); } if (e.ColumnIndex == dataGridView1.Columns["customer"].Index) { UIControl.showForm(UIControl.bookingDetailForm); Booking booking = GData.bookings.Where(b => b.id == id).ToList()[0]; UIControl.bookingDetailForm.getDescription(booking); } }
private void MainForm_Load(object sender, EventArgs e) { this.FormBorderStyle = FormBorderStyle.None; UIControl.bookingDetailForm.TopLevel = false; UIControl.bookingDetailForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.bookingGridForm.TopLevel = false; UIControl.bookingGridForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.editBookingForm.TopLevel = false; UIControl.editBookingForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.newBookingForm.TopLevel = false; UIControl.newBookingForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.technicianGridForm.TopLevel = false; UIControl.technicianGridForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.newTechnicianForm.TopLevel = false; UIControl.newTechnicianForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.editTechnicianForm.TopLevel = false; UIControl.editTechnicianForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.jobTypesGridForm.TopLevel = false; UIControl.jobTypesGridForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.newJobTypeForm.TopLevel = false; UIControl.newJobTypeForm.Dock = System.Windows.Forms.DockStyle.Fill; UIControl.editJobTypeForm.TopLevel = false; UIControl.editJobTypeForm.Dock = System.Windows.Forms.DockStyle.Fill; contentPanel.Controls.Add(UIControl.bookingDetailForm); contentPanel.Controls.Add(UIControl.bookingGridForm); contentPanel.Controls.Add(UIControl.editBookingForm); contentPanel.Controls.Add(UIControl.newBookingForm); contentPanel.Controls.Add(UIControl.technicianGridForm); contentPanel.Controls.Add(UIControl.newTechnicianForm); contentPanel.Controls.Add(UIControl.editTechnicianForm); contentPanel.Controls.Add(UIControl.jobTypesGridForm); contentPanel.Controls.Add(UIControl.newJobTypeForm); contentPanel.Controls.Add(UIControl.editJobTypeForm); UIControl.showForm(UIControl.bookingGridForm); showClock(); timer1.Enabled = true; timer1.Tick += Timer1_Tick; }
private void save_Btn_Click(object sender, EventArgs e) { // Check if a technician name is not empty if (name_Txt.Text == "") { MessageBox.Show("Name field can not be empty. Please input!"); name_Txt.Focus(); return; } // Check if a working hours is not empty if (workingHours_Txt.Text == "") { MessageBox.Show("Working Hours can not be empty. Please input!"); workingHours_Txt.Focus(); return; } // Check if a working hours is numeric value double d; if (!double.TryParse(workingHours_Txt.Text, out d)) { MessageBox.Show("Invalid Input! Working hours should be numeric value. Please input!"); workingHours_Txt.Focus(); return; } technicianToEdit.name = name_Txt.Text; technicianToEdit.workingHours = Convert.ToDouble(workingHours_Txt.Text); technicianToEdit.date = dateTimePicker1.Value; if (DatabaseControl.updateTechnician(technicianToEdit)) { MessageBox.Show("Technician data has been updated successfully!"); UIControl.technicianGridForm.showTechnicians(); UIControl.showForm(UIControl.technicianGridForm); } }
private void save_Btn_Click(object sender, EventArgs e) { // Check if a Job Type name is not empty if (name_Txt.Text == "") { MessageBox.Show("Job Type Name can not be empty. Please input!"); name_Txt.Focus(); return; } jobTypeToEdit.typeName = name_Txt.Text; jobTypeToEdit.background = background_Lbl.Text; if (DatabaseControl.updateJobType(jobTypeToEdit)) { MessageBox.Show("Job type data has been updated successfuly!"); UIControl.newBookingForm.updateJobTypes(); UIControl.editBookingForm.updateJobTypes(); UIControl.bookingGridForm.updateColumnColor(); UIControl.jobTypesGridForm.showJobTypes(); UIControl.showForm(UIControl.jobTypesGridForm); } }
private void backToList_Btn_Click(object sender, EventArgs e) { UIControl.showForm(UIControl.bookingGridForm); }
private void cancel_Btn_Click(object sender, EventArgs e) { UIControl.showForm(UIControl.technicianGridForm); }
//public void addJobType(JobType newJobType) //{ // string query = String.Format("insert into JobType ([Type Name], [Background Color]) values ('{0}', '{1}')", // newJobType.typeName, newJobType.background); // if (DatabaseControl.executeQuery(query)) // { // Info.jobTypes.Add(newJobType); // showJobTypes(); // MessageBox.Show("New Job Type has been added succesfully!"); // } //} //public void updateJobType(JobType jobType) //{ // string query = String.Format("UPDATE JobType SET [Type Name] = '{0}', [Background Color] = '{1}' WHERE [Id] = '{2}'", // jobType.typeName, jobType.background, jobType.id); // if (DatabaseControl.executeQuery(query)) // { // showJobTypes(); // } //} private void add_Btn_Click(object sender, EventArgs e) { UIControl.showForm(UIControl.newJobTypeForm); }
private void cancel_Btn_Click(object sender, EventArgs e) { UIControl.showForm(UIControl.jobTypesGridForm); }
private void save_Btn_Click(object sender, EventArgs e) { // Check if Job NO is not empty if (jobNO_Txt.Text == "") { MessageBox.Show("Job No can not be empty. Please input!"); jobNO_Txt.Focus(); return; } // Check if Job NO is not empty if (jobType_Cmb.Text == "") { MessageBox.Show("Job Type can not be empty. Please input!"); jobType_Cmb.Focus(); return; } // Check if a Customer filed is not empty if (customerName_Txt.Text == "") { MessageBox.Show("Customer field can not be empty. Please input!"); customerName_Txt.Focus(); return; } // Check if an Address filed is not empty. if (address1_Txt.Text == "") { MessageBox.Show("Address field can not be empty. Please input!"); address1_Txt.Focus(); return; } if (address2_Txt.Text == "") { MessageBox.Show("Address field can not be empty. Please input!"); address2_Txt.Focus(); return; } if (address3_Txt.Text == "") { MessageBox.Show("Address field can not be empty. Please input!"); address3_Txt.Focus(); return; } // Check if an Post Code filed is not empty. if (postCode_Txt.Text == "") { MessageBox.Show("Post Code can not be empty. Please input!"); postCode_Txt.Focus(); return; } // Check if an email filed is not empty. if (email_Txt.Text == "") { MessageBox.Show("Email field can not be empty. Please input!"); email_Txt.Focus(); return; } // Check if an Tel filed is not empty. if (tel_Txt.Text == "") { MessageBox.Show("Tel field can not be empty. Please input!"); tel_Txt.Focus(); return; } // Check if an Vehicle Model filed is not empty. if (vehicleModel_Txt.Text == "") { MessageBox.Show("Vehicle Model field can not be empty. Please input!"); vehicleModel_Txt.Focus(); return; } // Check if an Vehicle Reg.No filed is not empty. if (vehicleRegNo_Txt.Text == "") { MessageBox.Show("Vehicle Reg.NO field can not be empty. Please input!"); vehicleRegNo_Txt.Focus(); return; } // Check if an Booked By filed is not empty. if (bookedBy_Cmb.Text == "") { MessageBox.Show("Booked By field can not be empty. Please input!"); bookedBy_Cmb.Focus(); return; } // Check if an Job Description filed is not empty. if (jobDescription_Txt.Text == "") { MessageBox.Show("Work Title field can not be empty. Please input!"); jobDescription_Txt.Focus(); return; } // Compare Time in and Time Out if (timeIn_Dtp.Value.Hour * 60 + timeIn_Dtp.Value.Minute > timeOut_Dtp.Value.Hour * 60 + timeOut_Dtp.Value.Minute) { MessageBox.Show("Time in should be less than Time Out!"); timeIn_Dtp.Focus(); return; } int customerId = 0; Customer customer = new Customer { honor = honor_Cmb.Text, name = customerName_Txt.Text, address1 = address1_Txt.Text, address2 = address2_Txt.Text, address3 = address3_Txt.Text, postCode = postCode_Txt.Text, email = email_Txt.Text, tel = tel_Txt.Text }; if (existingCustomer_Cmb.SelectedIndex == 0) { customerId = DatabaseControl.addCustomer(customer); } else { customerId = GData.customers[existingCustomer_Cmb.SelectedIndex - 1].id; DatabaseControl.updateCustomer(customer, customerId); } bookingToEdit.jobNO = jobNO_Txt.Text; bookingToEdit.jobType = jobType_Cmb.Text; bookingToEdit.customerID = customerId; bookingToEdit.servicePlan = servicePlan_Cmb.Text; bookingToEdit.vehicleMake = vehicleMake_Txt.Text; bookingToEdit.vehicleModel = vehicleModel_Txt.Text; bookingToEdit.regNo = vehicleRegNo_Txt.Text; bookingToEdit.mileage = Convert.ToDouble(mileage_Txt.Text); bookingToEdit.loanCar = loanCar_Cmb.Text; bookingToEdit.timeIn = timeIn_Dtp.Value; bookingToEdit.timeOut = timeOut_Dtp.Value; bookingToEdit.bookedBy = bookedBy_Cmb.Text; bookingToEdit.estimatedTime = Convert.ToDouble(estimatedTime_Txt.Text); //bookingToEdit.timeRemaining = DatabaseControl.getBookingDates(bookingToEdit.bookingDate.Date) - bookingToEdit.estimatedTime; //if (bookingToEdit.timeRemaining < 0) // bookingToEdit.timeRemaining = 0; bookingToEdit.insuranceRequired = insurance_Cmb.Text; bookingToEdit.jobDescription = jobDescription_Txt.Text; bookingToEdit.notes = notes_Txt.Text; if (DatabaseControl.updateBooking(bookingToEdit)) { MessageBox.Show("Booking data has been updated succesfully!"); UIControl.bookingGridForm.showBookings(); UIControl.showForm(UIControl.bookingGridForm); updateCustomers(); UIControl.newBookingForm.updateCustomers(); } }
private void add_Btn_Click(object sender, EventArgs e) { UIControl.showForm(UIControl.newTechnicianForm); }
private void add_Btn_Click(object sender, EventArgs e) { UIControl.showForm(UIControl.newBookingForm); UIControl.newBookingForm.newBookingDate = dateTimePicker1.Value; }