protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PhysicsBooking pb1 = new PhysicsBooking(); string s = Request.UrlReferrer.OriginalString; ViewState.Add("booking", pb1); ViewState.Add("ref", s); pb1.Load(Request.Params.Get("Id")); SimpleStaff staff1 = new SimpleStaff(pb1.StaffId); SimpleRoom room1 = new SimpleRoom(pb1.RoomId); Period p1 = new Period(pb1.PeriodId); s = "<h3>Booking for " + pb1.Date.ToShortDateString() + " " + p1.m_periodname; s += "<br/>Staff: " + staff1.m_StaffCode + " Room: " + room1.m_roomcode + "</br>"; s += "<p align=\"center\"><TABLE BORDER class= \"ResultsTbl\" ><TR><TD>Item</TD><TD>Location</TD></tr> "; PhysicsEquipmentItemList list1 = new PhysicsEquipmentItemList(); list1.LoadList(pb1); foreach (PhysicsEquipmentItem i in list1.m_list) { s += "<tr><td>" + i.EquipmentItemCode + "</td><td>" + i.EquipmentItemLocation + "</td></tr>"; } s += "</table>"; servercontent.InnerHtml = s + "<br/>Notes:<br/>" + pb1.Notes + "<br/>"; } }
void SetupEquipmentList() { PhysicsEquipmentItemList list1 = new PhysicsEquipmentItemList(); list1.LoadList_All(); foreach (PhysicsEquipmentItem p in list1.m_list) { ListItem l1 = new ListItem(p.EquipmentItemCode, p.EquipmentItemId.ToString()); DropDownList_Equipment.Items.Add(l1); } }
private void SetupEquipmentList() { PhysicsEquipmentItemList list1 = new PhysicsEquipmentItemList(); list1.LoadList_All(); foreach (PhysicsEquipmentItem i in list1.m_list) { ListItem l = new ListItem(i.EquipmentItemCode, i.EquipmentItemId.ToString()); DropDownList_Equipment.Items.Add(l); } PhysicsEquipmentItem i1 = new PhysicsEquipmentItem(); i1.Load(new Guid(DropDownList_Equipment.SelectedValue)); ViewState.Add("PhysicsEquipmentItem", i1); SetupEquipmentDetail(i1); }
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 Add_Controls(PhysicsBooking phb1) { Table tb1 = Table1; Table1.Visible = true; tb1.EnableViewState = true; tb1.Controls.Clear(); if (phb1.BookingId == Guid.Empty) { return; } TableRow r0 = new TableRow(); tb1.Controls.Add(r0); TableCell c01 = new TableCell(); r0.Controls.Add(c01); SetCellStyle(c01, tb1); TableCell c02 = new TableCell(); r0.Controls.Add(c02); SetCellStyle(c02, tb1); TableCell c03 = new TableCell(); r0.Controls.Add(c03); SetCellStyle(c03, tb1); c01.Text = "Equipment"; c02.Text = "Location"; c03.Text = "Edit"; PhysicsEquipmentItemList ItemList1 = new PhysicsEquipmentItemList(); ItemList1.LoadList(phb1);//output as table foreach (PhysicsEquipmentItem p in ItemList1.m_list) { TableRow r1 = new TableRow(); tb1.Controls.Add(r1); r1.BorderStyle = BorderStyle.Solid; r1.BorderColor = tb1.BorderColor; r1.BorderWidth = tb1.BorderWidth; TableCell c1 = new TableCell(); r1.Controls.Add(c1); SetCellStyle(c1, tb1); TableCell c2 = new TableCell(); r1.Controls.Add(c2); SetCellStyle(c2, tb1); TableCell c3 = new TableCell(); r1.Controls.Add(c3); SetCellStyle(c3, tb1); c1.Text = p.EquipmentItemCode; c2.Text = p.EquipmentItemLocation; Button b1 = new Button(); b1.ID = p.Bookings_EquipmentId.ToString(); c3.Controls.Add(b1); b1.Click += new EventHandler(b1_Click); b1.Text = "Remove"; } }
protected bool Check_Item_Available(Guid EquipmentItemId, PhysicsBooking phb1, ref PhysicsBooking bx) { PhysicsBookingList list1 = new PhysicsBookingList(); list1.LoadList_Date(phb1.Date); foreach (PhysicsBooking b in list1.m_list) { PhysicsEquipmentItemList list2 = new PhysicsEquipmentItemList(); list2.LoadList(b); foreach (PhysicsEquipmentItem i in list2.m_list) { if (i.EquipmentItemId == EquipmentItemId) { if (b.PeriodId == phb1.PeriodId) { bx = b; return(false); } } } } return(true); }
private void UpdateDisplay() { string[, ,] grid = new string[6, 30, 2]; int j1; for (int i = 0; i < 6; i++) { for (int j = 0; j < 30; j++) { grid[i, j, 0] = ""; } } //setup for 5 P labs.... grid[0, 0, 0] = "P1"; grid[0, 1, 0] = "P2"; grid[0, 2, 0] = "P3"; grid[0, 3, 0] = "P4"; grid[0, 4, 0] = "P5"; int n_rows = 5; string s = ""; s = "<div><h3>Bookings for " + Calendar1.SelectedDate.ToShortDateString() + "</h3></div>"; s += "<p align=\"center\"><TABLE BORDER class= \"ResultsTbl\" ><TR><TD>Room</TD> "; s += "<TD>Period 1</TD><TD>Period 2</TD><TD>Period 3</TD><TD>Period 4</TD><TD>Period 5</TD></tr>"; PhysicsBookingList pblist1 = new PhysicsBookingList(); pblist1.LoadList_Date(Calendar1.SelectedDate); if (pblist1.m_list.Count > 0) { foreach (PhysicsBooking p in pblist1.m_list) { SimpleRoom room1 = new SimpleRoom(p.RoomId); Period p1 = new Period(p.PeriodId); int p2 = System.Convert.ToInt32(p1.m_periodcode); SimpleStaff s1 = new SimpleStaff(p.StaffId); j1 = -1; for (int j = 0; j < n_rows; j++) { if (grid[0, j, 0] == room1.m_roomcode.Trim()) { j1 = j; break; } } if (j1 == -1) { grid[0, n_rows, 0] = room1.m_roomcode.Trim(); j1 = n_rows; n_rows++; } grid[p2, j1, 0] = s1.m_StaffCode + ":<br/>"; grid[p2, j1, 1] = p.BookingId.ToString(); PhysicsEquipmentItemList ff = new PhysicsEquipmentItemList(); ff.LoadList(p); foreach (PhysicsEquipmentItem i in ff.m_list) { grid[p2, j1, 0] += i.EquipmentItemCode + ", "; } } for (int j = 0; j < n_rows; j++) { s += "<tr>"; for (int i = 0; i < 6; i++) { s += "<td>"; if (grid[i, j, 0] == "") { } else { if (i != 0) { s += "<A HREF=\"DisplayBooking.aspx?Id=" + grid[i, j, 1] + " \">Booking</A>"; s += "<br/>staff: "; } s += grid[i, j, 0] + "<br/>"; } s += "</td>"; } s += "</tr>"; } s += "</table><br/>"; } else { s += "</table><br/>No Bookings on this date<br/>"; } s += "</table>"; servercontent.InnerHtml = s; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PhysicsBooking phb1 = new PhysicsBooking(); string s = Request.Params.Get("BookingId"); if (s != null) { phb1.Load(s); } else { Utility u = new Utility(); phb1.DayId = System.Convert.ToInt16(Request.Params.Get("Day")); phb1.StaffId = new Guid(u.Get_StaffID(Request.Params.Get("Staff"))); phb1.Date = System.Convert.ToDateTime(Request.Params.Get("Date"));//this is week beginning... phb1.Date = phb1.Date.AddDays(phb1.DayId); phb1.PeriodId = u.Get_PeriodId_fromcode(Request.Params.Get("Period")); phb1.RoomId = u.Get_RoomId_fromCode(Request.Params.Get("Room")); Group g1 = new Group(); g1.Load(Request.Params.Get("Group"), phb1.Date); phb1.GroupId = g1._GroupID; s = Request.Params.Get("Group"); if (s.StartsWith("10") || s.StartsWith("11")) { RadioButtonList1.SelectedIndex = 1; } if (s.StartsWith("12") || s.StartsWith("13")) { RadioButtonList1.SelectedIndex = 2; } if (s.StartsWith("7") || s.StartsWith("8") || s.StartsWith("9")) { RadioButtonList1.SelectedIndex = 0; } } DayList dlist1 = new DayList(); s = dlist1.FindDayName_fromId(phb1.DayId); servercontent.InnerHtml = "<h3>Booking for " + s + " Period " + Request.Params.Get("Period") + " for Group " + Request.Params.Get("Group") + " and Room " + Request.Params.Get("Room") + "</h3>"; if (phb1.FindBooking()) { Add_Controls(phb1); TextBox_Notes.Text = phb1.Notes; } ViewState.Add("PhysicsBooking", phb1); PhysicsEquipmentItemList list1 = new PhysicsEquipmentItemList(); list1.LoadList_All(); foreach (PhysicsEquipmentItem p in list1.m_list) { ListItem l = new ListItem(p.EquipmentItemCode, p.EquipmentItemId.ToString()); DropDownList_Items.Items.Add(l); } UpdateExptList(); //find previous booking??? Label2.Visible = false; TextBox_last.Visible = false; Button_AddLast.Visible = false; PhysicsBooking phb2 = new PhysicsBooking(); //for last booking for this group PhysicsBookingList list2 = new PhysicsBookingList(); list2.LoadList_Group(phb1.GroupId); //these are ordered with lates first... foreach (PhysicsBooking b in list2.m_list) { if (b.Date < phb1.Date) { Label2.Visible = true; TextBox_last.Visible = true; Button_AddLast.Visible = true; PhysicsEquipmentItemList list3 = new PhysicsEquipmentItemList(); list3.LoadList(b); TextBox_last.Text = ""; foreach (PhysicsEquipmentItem i in list3.m_list) { TextBox_last.Text += i.EquipmentItemCode + Environment.NewLine; } ViewState.Add("LastBooking", b); break; } } } else { PhysicsBooking b2 = (PhysicsBooking)ViewState["PhysicsBooking"]; Add_Controls(b2); } }