protected void Button1_Click(object sender, EventArgs e) { //add item... PhysicsEquipmentBooking b1 = new PhysicsEquipmentBooking(); PhysicsBooking b2 = (PhysicsBooking)ViewState["PhysicsBooking"]; if (b2.BookingId == Guid.Empty) { b2.Save(); //to get id } b2.Notes = TextBox_Notes.Text; b2.Save(); ViewState.Remove("PhysicsBooking"); ViewState.Add("PhysicsBooking", b2); b1.BookingId = b2.BookingId; string s = DropDownList_Items.SelectedValue; PhysicsBooking clash = new PhysicsBooking(); Guid b3 = new Guid(s); if (Check_Item_Available(b3, b2, ref clash)) { b1.EquipmentId = b3; b1.Save(); Add_Controls(b2); } else { Response.Redirect("BookingFailure.aspx?BookingId=" + b2.BookingId.ToString() + "&EquipmentCode=" + DropDownList_Items.SelectedItem.Text + "&ClashedBookingId=" + clash.BookingId.ToString()); } }
protected void b1_Click(object sender, EventArgs e) { //this is remove the item..... Button b1 = (Button)sender; string s = b1.ID;//is Bookings_EquipmentID PhysicsEquipmentBooking pb1 = new PhysicsEquipmentBooking(); pb1.Id = new Guid(s); pb1.Delete_by_Id(); PhysicsBooking b2 = (PhysicsBooking)ViewState["PhysicsBooking"]; Add_Controls(b2); }
protected void Button_AddLast_Click(object sender, EventArgs e) { //add items from previous list... string not_booked = ""; PhysicsBooking b_last = (PhysicsBooking)ViewState["LastBooking"]; if (b_last.BookingId == Guid.Empty) { return; } PhysicsEquipmentBooking b1 = new PhysicsEquipmentBooking(); PhysicsBooking b2 = (PhysicsBooking)ViewState["PhysicsBooking"]; if (b2.BookingId == Guid.Empty) { b2.Save(); //to get id } b2.Notes = TextBox_Notes.Text; b2.Save(); ViewState.Remove("PhysicsBooking"); ViewState.Add("PhysicsBooking", b2); PhysicsBooking clash = new PhysicsBooking(); PhysicsEquipmentItemList list2 = new PhysicsEquipmentItemList(); list2.LoadList(b_last); foreach (PhysicsEquipmentItem i in list2.m_list) { if (Check_Item_Available(i.EquipmentItemId, b2, ref clash)) { b1.BookingId = b2.BookingId; b1.EquipmentId = i.EquipmentItemId; b1.Save(); } else { not_booked += i.EquipmentItemCode + " , "; } } if (not_booked.Length > 0) { Response.Redirect("BookingFailure.aspx?BookingId=" + b2.BookingId.ToString() + "&EquipmentCode=" + not_booked + "&ClashedBookingId=" + clash.BookingId.ToString()); } Add_Controls(b2); }
protected void Button_AddExperiment_Click(object sender, EventArgs e) { string not_booked = ""; PhysicsExperiment PhEx = new PhysicsExperiment(); PhEx.Id = new Guid(DropDownList_Expt.SelectedValue); PhEx.Load(); PhysicsBooking b2 = (PhysicsBooking)ViewState["PhysicsBooking"]; if (b2.BookingId == Guid.Empty) { b2.Save(); //to get id } b2.Notes = "[Expt: " + PhEx.ExperimentCode + PhEx.ExperimentDescription + "]" + TextBox_Notes.Text; b2.Save(); PhysicsBooking clash = new PhysicsBooking(); // now to add the Equipment to the booking..... foreach (PhysicsEquipmentItem ei in PhEx.EquipmentList.m_list) { PhysicsEquipmentBooking b1 = new PhysicsEquipmentBooking(); if (Check_Item_Available(ei.EquipmentItemId, b2, ref clash)) { b1.BookingId = b2.BookingId; b1.EquipmentId = ei.EquipmentItemId; b1.Save(); } else { not_booked += ei.EquipmentItemCode + " , "; } } ViewState.Remove("PhysicsBooking"); ViewState.Add("PhysicsBooking", b2); if (not_booked.Length > 0) { Response.Redirect("BookingFailure.aspx?BookingId=" + b2.BookingId.ToString() + "&EquipmentCode=" + not_booked + "&ClashedBookingId=" + clash.BookingId.ToString()); } Add_Controls(b2); }