private void updateLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (GoValidation() == false) { return; } else { if (memberIDTextBox.Text != "" & memberNameTextBox.Text != "" & ICnumberTextBox.Text != "" & addressTextBox.Text != "" & countryTextBox.Text != "" & postalTextBox.Text != "" & contactNumTextbox.Text != "" & emailTextBox.Text != "" & comboBox1.Text != "") { int i = Convert.ToInt16(memberIDTextBox.Text); mList[posn].MemberID = i; mList[posn].MemberName = memberNameTextBox.Text; mList[posn].ICNumber = ICnumberTextBox.Text; mList[posn].Address = addressTextBox.Text; mList[posn].Country = countryTextBox.Text; mList[posn].Postcode = postalTextBox.Text; mList[posn].ContactNumber = contactNumTextbox.Text; if (comboBox1.Text == "Female") { mList[posn].ContactTitle = "Ms"; } else if (comboBox1.Text == "Male") { mList[posn].ContactTitle = "Mr"; } mList[posn].DateofBirth = memberBDPicker.Value; mList[posn].EmailAddress = emailTextBox.Text; mList[posn].Gender = comboBox1.Text; } DialogResult res = MessageBox.Show("Are you sure you want to Update?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { context.SaveChanges(); MessageBox.Show("Update Success!"); FunctionRefresh(); memGridView.DataSource = mList; } if (res == DialogResult.Cancel) { memberIDTextBox.Text = ""; memberNameTextBox.Text = ""; ICnumberTextBox.Text = ""; memberBDPicker.Value = DateTime.Today; addressTextBox.Text = ""; countryTextBox.Text = ""; postalTextBox.Text = ""; contactNumTextbox.Text = ""; emailTextBox.Text = ""; comboBox1.Text = ""; posn = 0; } } }
public void Create() { form.BookingFromTime.Value = new DateTime(form.BookingDateDtTimePckr.Value.Year, form.BookingDateDtTimePckr.Value.Month, form.BookingDateDtTimePckr.Value.Day, form.BookingFromTime.Value.Hour, 00, 00); form.BookingToTime.Value = new DateTime(form.BookingDateDtTimePckr.Value.Year, form.BookingDateDtTimePckr.Value.Month, form.BookingDateDtTimePckr.Value.Day, form.BookingToTime.Value.Hour, 00, 00); b1 = new Booking(); int count = ctx.Bookings.Count(); count++; b1.BookingID = count; b1.BookingDateFrom = form.BookingFromTime.Value; //BookingDateDtTimePckr.Value.Date + BookingFromTime.Value.TimeOfDay; b1.BookingDateTo = form.BookingToTime.Value; //BookingDateDtTimePckr.Value.Date + BookingToTime.Value.TimeOfDay; fa = (from x in ctx.Facilities where (x.FacilityName == "Badminton Court 4") select x).First(); b1.FacilitiesID = fa.FacilityID; b1.MemberID = Int32.Parse(form.txtMemberID.Text); b1.IssueDate = DateTime.Today; b1.NumberofPax = Int32.Parse(form.txtNoOfpax.Text); ctx.Bookings.Add(b1); ctx.SaveChanges(); }
private void updateLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (GoValidation() == false) { return; } else { if (FacilityIDTextBox.Text != "" & FacilityNameTextBox.Text != "" & FacilityTypeTextBox.Text != "" & LocationTextBox.Text != "" & AllowedHoursTextBox.Text != "") { int i = Convert.ToInt16(FacilityIDTextBox.Text); int j = Convert.ToInt16(AllowedHoursTextBox.Text); fList[posn].FacilityID = i; fList[posn].FacilityName = FacilityNameTextBox.Text; fList[posn].FacilityType = FacilityTypeTextBox.Text; fList[posn].Location = LocationTextBox.Text; fList[posn].AllowedHours = j; fList[posn].MaintenanceDate = MaintenanceDateDPicker.Value; } DialogResult res = MessageBox.Show("Are you sure you want to Update?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { context.SaveChanges(); MessageBox.Show("Update Success!"); this.FunctionRefresh(); FactGridView.DataSource = fList; } if (res == DialogResult.Cancel) { FacilityIDTextBox.Text = ""; FacilityNameTextBox.Text = ""; FacilityTypeTextBox.Text = ""; LocationTextBox.Text = ""; AllowedHoursTextBox.Text = ""; MaintenanceDateDPicker.Value = DateTimePicker.MinimumDateTime; posn = 0; } } }
private void Modifybtn_Click(object sender, EventArgs e) { BookingFromTime.Value = new DateTime(BookingDateDtTimePckr.Value.Year, BookingDateDtTimePckr.Value.Month, BookingDateDtTimePckr.Value.Day, BookingFromTime.Value.Hour, 00, 00); BookingToTime.Value = new DateTime(BookingDateDtTimePckr.Value.Year, BookingDateDtTimePckr.Value.Month, BookingDateDtTimePckr.Value.Day, BookingToTime.Value.Hour, 00, 00); b.BookingDateFrom = BookingDateDtTimePckr.Value.Date + BookingFromTime.Value.TimeOfDay; b.BookingDateTo = BookingDateDtTimePckr.Value.Date + BookingToTime.Value.TimeOfDay; b.MemberID = Int32.Parse(txtMemberID.Text); b.NumberofPax = Int32.Parse(txtNoOfPax.Text); // convert booking date from int BookingTimeFrom = BookingFromTime.Value.Hour; int BookingTimeTo = BookingToTime.Value.Hour; DateTime bkgdt = BookingFromTime.Value.Date; bool value; //Checking whether slots are available value = Program.ValidateBooking(bkgdt, f.FacilityName, BookingTimeFrom, BookingTimeTo); if (value) { ctx.SaveChanges(); refToAvailabiltyForm.RenderDataGrid(); MessageBox.Show("Booking Successfully Modified"); DialogResult res = MessageBox.Show("Do you want to print a receipt?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { MessageBox.Show("Printing Receipt"); } Close(); } else { MessageBox.Show("Slot is not available"); } }
private void updateBooking_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (GoValidation() == false) { return; } else { if (numOfPaxTextBox.Text != "") { int i = Convert.ToInt16(memberIDTextBox.Text); bList[posn].IssueDate = BookingDatePicker.Value; bList[posn].BookingDateFrom = dateTimePickerFrom.Value; bList[posn].BookingDateTo = dateTimePickerTo.Value; bList[posn].NumberofPax = int.Parse(numOfPaxTextBox.Text); } DialogResult res = MessageBox.Show("Are you sure you want to Update?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { context.SaveChanges(); MessageBox.Show("Update Success!"); this.FunctionRefresh(); bookingGridView.DataSource = bList; } if (res == DialogResult.Cancel) { BookingIDTextBox.Text = ""; memberNameTextBox.Text = ""; memberIDTextBox.Text = ""; facilityNameTextBox.Text = ""; locationTextBox.Text = ""; numOfPaxTextBox.Text = ""; BookingDatePicker.Value = DateTime.Today; dateTimePickerTo.Value = DateTime.Today; dateTimePickerFrom.Value = DateTime.Today; posn = 0; } } }
private void NewMemberAddButton_Click(object sender, EventArgs e) { if (GoValidation() == false) { return; } else { if (ICNumberTextBox.Text != "" & MemberNameTextBox.Text != "" & AddressTextBox.Text != "" & CountryTextBox.Text != "" & PostalCodeTextBox.Text != "" & ContactNumberTextBox.Text != "" & EmailTextBox.Text != "" & ContactTitleTextBox.Text != "") { Member newmember = new Member(); newmember.MemberID = mList[mList.Count - 1].MemberID + 1; newmember.MemberName = MemberNameTextBox.Text.ToString(); newmember.ICNumber = ICNumberTextBox.Text.ToString(); newmember.DateofBirth = memberBDPicker.Value; newmember.Address = AddressTextBox.Text.ToString(); newmember.Country = CountryTextBox.Text.ToString(); newmember.Postcode = PostalCodeTextBox.Text.ToString(); newmember.ContactTitle = ContactTitleTextBox.Text.ToString(); newmember.ContactNumber = ContactNumberTextBox.Text.ToString(); newmember.EmailAddress = EmailTextBox.Text.ToString(); newmember.Gender = genderComboBox.Text.ToString(); context.Members.Add(newmember); } DialogResult res = MessageBox.Show("Are you sure you want to Insert?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { context.SaveChanges(); MessageBox.Show("New Member Insertion Success!"); FunctionRefresh(); this.Close(); } if (res == DialogResult.Cancel) { ICNumberTextBox.Text = ""; MemberNameTextBox.Text = ""; AddressTextBox.Text = ""; CountryTextBox.Text = ""; PostalCodeTextBox.Text = ""; ContactNumberTextBox.Text = ""; EmailTextBox.Text = ""; ContactTitleTextBox.Text = ""; FunctionRefresh(); } } }
private void NewFacilityAddButton_Click(object sender, EventArgs e) { if (GoValidation() == false) { return; } else { if (FacilityNameTextBox.Text != "" || FacilityTypeTextBox.Text != "" || LocationTextBox.Text != "") { newfact.FacilityID = fList[fList.Count - 1].FacilityID + 1; newfact.FacilityName = FacilityNameTextBox.Text.ToString(); newfact.FacilityType = FacilityTypeTextBox.Text.ToString(); newfact.Location = LocationTextBox.Text.ToString(); newfact.AllowedHours = Convert.ToInt32(AllowedHoursTextBox.Text); context.Facilities.Add(newfact); } DialogResult res = MessageBox.Show("Are you sure you want to Insert?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { context.SaveChanges(); MessageBox.Show("New Facility Insertion Success!"); FunctionRefresh(); this.Close(); } if (res == DialogResult.Cancel) { FacilityNameTextBox.Text = ""; FacilityTypeTextBox.Text = ""; LocationTextBox.Text = ""; AllowedHoursTextBox.Text = ""; FunctionRefresh(); } } }
private void Okbtn_Click_1(object sender, EventArgs e) { BookingFromTime.MinDate = BookingDateDtTimePckr.Value.Date + fromts; BookingToTime.MaxDate = BookingDateDtTimePckr.Value.Date + tots; // convert booking date from int BookingTimeFrom = BookingFromTime.Value.Hour; int BookingTimeTo = BookingToTime.Value.Hour; DateTime bkgdt = BookingFromTime.Value.Date; bool value; TimeSpan s = new TimeSpan(BookingTimeTo, 0, 0); TimeSpan t = new TimeSpan(BookingTimeFrom, 0, 0); BookingToTime.Value = BookingDateDtTimePckr.Value.Date + s; BookingFromTime.Value = BookingDateDtTimePckr.Value.Date + t; //assign f according to facility booked. f = ctx.Facilities.Where(x => x.FacilityName == facilityList.Text).First(); b = new Booking(); // table values try { b.BookingID = bList[bList.Count - 1].BookingID + 1; b.BookingDateFrom = BookingFromTime.Value; b.BookingDateTo = BookingToTime.Value; b.FacilitiesID = f.FacilityID; b.MemberID = Int32.Parse(txtMemberID.Text); b.IssueDate = DateTime.Today; b.NumberofPax = Int32.Parse(txtNoOfPax.Text); } catch { MessageBox.Show("Please ensure all fields are filled."); return; } // check if value = Program.ValidateBooking(bkgdt, f.FacilityName, BookingTimeFrom, BookingTimeTo); if (value) { ctx.Bookings.Add(b); ctx.SaveChanges(); MessageBox.Show("Booking Successfully Saved"); FunctionRefresh(); DialogResult res = MessageBox.Show("Do you want to print a receipt?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { BookingReceipt br = new BookingReceipt(b.BookingID); br.ShowDialog(); Close(); } else { Close(); } if (refToAvailabiltyForm != null) { refToAvailabiltyForm.RenderDataGrid(); } } else { MessageBox.Show("Slot is not available"); } }