/// <summary> /// Adds a table to the database from user entered data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void addTableButton_Click(Object sender, EventArgs e) { //Uses ASP.NET function IsValid() to test user input and the current error state before proceeding if (Page.IsValid) { TableModel newTable = new TableModel(); BuildingModel bm = new BuildingModel(); RoomModel rm = new RoomModel(); //Selects single selected building form buildinglist bm = buildings.Where(b => b.BuildingID == Int32.Parse(buildingDropdown.Text)).FirstOrDefault(); int id = bm.BuildingID; //Fills the list for the next to take it rooms = RoomBL.fillRoomsList(id); //Selects single selected building from roomlist rm = rooms.Where(r => r.RoomID == Int32.Parse(roomDropdown.Text)).FirstOrDefault(); //Sets the table values from user data newTable.RoomID = rm.RoomID; newTable.Category = inTableCatagory.Value; newTable.PersonCapacity = Convert.ToInt32(inTableCapacity.Value); //Adds a new table to the database TableBL.ProcessAddNewTable(newTable); //Visually displays recognition of successful table creation ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Table Created!" + "');", true); } }
public int UpdateTable() { //Khai báo đối tượng Food và lấy đối tượng hiện hành Table table = tableCurrent; // Kiểm tra nếu các ô nhập khác rỗng if (txtName.Text == "" || txtStatus.Text == "" || txtCapacity.Text == "") { MessageBox.Show("Chưa nhập dữ liệu cho các ô, vui lòng nhập lại"); } else { table.Name = txtName.Text; txtStatus.Text = table.Status.ToString(); txtCapacity.Text = table.Capacity.ToString(); int status = 0; try { // Chuyển giá trị từ kiểu văn bản qua kiểu int status = int.Parse(txtStatus.Text); } catch { // Nếu sai, gán giá = 0 status = 0; } table.Status = status; TableBL tableBL = new TableBL(); // Cập nhật dữ liệu trong bảng return(tableBL.Update(table)); } return(-1); }
public int InsertTable() { //Khai báo đối tượng Food từ tầng DataAccess Table table = new Table(); table.ID = 0; // Kiểm tra nếu các ô nhập khác rỗng if (txtName.Text == "" || txtStatus.Text == "" || txtCapacity.Text == "") { MessageBox.Show("Chưa nhập dữ liệu cho các ô, vui lòng nhập lại"); } else { table.Name = txtName.Text; txtStatus.Text = table.Status.ToString(); txtCapacity.Text = table.Capacity.ToString(); int status = 0; try { // Cố gắng lấy giá trị status = int.Parse(txtStatus.Text); } catch { // Nếu sai, gán giá = 0 status = 0; } table.Status = status; TableBL tablebl = new TableBL(); // Chèn dữ liệu vào bảng return(tablebl.Insert(table)); } return(-1); }
/// <summary> /// Update list of rooms on change of content /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ddlroomDropDown_SelectedIndexChanged(object sender, EventArgs e) { BuildingModel bm = new BuildingModel(); //Selects single selected building bm = buildings.Where(b => b.BuildingID == Int32.Parse(buildingDropdown.Text)).FirstOrDefault(); int id = bm.BuildingID; //Pull all rooms from the database rooms = RoomBL.fillRoomsList(id); RoomModel rm = new RoomModel(); //Selects single selected building rm = rooms.Where(r => r.RoomID == Int32.Parse(roomDropdown.Text)).FirstOrDefault(); int rid = rm.RoomID; tables = TableBL.FillTableList(rid); //Update values from user input tableDropdown.DataSource = tables; tableDropdown.DataValueField = "TableID"; tableDropdown.DataTextField = "TableID"; tableDropdown.DataBind(); }
protected void btnDirections_Click(object sender, EventArgs e) { int ID = Int32.Parse(Request.QueryString["ID"]); int buildingID = BuildingBL.getBuildingByID(RoomBL.getRoomByID(TableBL.GetTableByID(ID).RoomID).BuildingID).BuildingID; // directions module string URL = DirectionModuleBL.start(buildingID); Response.Redirect(URL); }
protected void notifyGroup(string email, int tableID, DateTime date, string sHour) { //The details that are send to the group members NotifyBL.startNotifyGroupMember(UserBL.passUserSearch(Session["login"].ToString()).FirstName.ToString(), email, TableBL.GetTableByID(tableID).TableID.ToString(), RoomBL.getRoomByID(TableBL.GetTableByID(tableID).RoomID).RoomName.ToString(), BuildingBL.getBuildingByID(RoomBL.getRoomByID(TableBL.GetTableByID(tableID).RoomID).BuildingID).BuildingName.ToString(), date.ToString("dd-MM-yyyy"), sHour + "00"); }
protected void Page_Load(object sender, EventArgs e) { int ID = Int32.Parse(Request.QueryString["ID"]); TableModel ThisTable = TableBL.GetTableByID(ID); lblgetID.Text = ThisTable.TableID.ToString(); lblgetCategory.Text = ThisTable.Category; lblgetSeatingCapacity.Text = ThisTable.PersonCapacity.ToString(); DateTime today = DateTime.Now; //HH = 24hours, hh = 12hours, M = month, m = minute, d = day, y = year. lblHeading.Text = "Select Hour: "; //updates the dropdown list for book Today section List <string> hoursList = new List <String>(); int x = Convert.ToInt32(today.ToString("HH"));; RoomModel thisRoom = RoomBL.getRoomByID(TableBL.GetTableByID(ID).RoomID); if (x >= thisRoom.ClosingTime.TotalHours) //check if room is closed { btnBook.Enabled = false; } while (x < thisRoom.ClosingTime.TotalHours) //will loop each hour until the end of the room's closing time { if (!TableBL.CheckTableHourAvailability(Int32.Parse(Request.QueryString["ID"]), x, today)) { hoursList.Add(x.ToString() + ": " + "is free"); } else { hoursList.Add(x.ToString() + ": Occupied"); } x++; } if (!IsPostBack) { hourDropdown.DataSource = hoursList; hourDropdown.DataBind(); } if (hourDropdown.SelectedValue.ToString().Contains("Occupied")) { btnBook.Visible = false; lblStatus.Text = "THE TABLE IS CURRENTLY OCCUPIED"; } showCalInputBoxes((TableBL.GetTableByID(ID).PersonCapacity) - 1); // -1 because the user takes up 1 spot showInputBoxes((TableBL.GetTableByID(ID).PersonCapacity) - 1); }
protected void Page_Load(object sender, EventArgs e) { int ID = Int32.Parse(Request.QueryString["ID"]); DateTime today = DateTime.Now; //HH = 24hours, hh = 12hours, M = month, m = minute, d = day, y = year. //testButton1.Text = today.ToShortDateString(); //testButton1.Text = today.ToString("dd-MM-yyyy"); //testButton1.Text = today.ToString("yyyy-MM-dd"); //testButton1.Text = today.ToString("HH"); lblStatus.Text = TableBL.checkTableStatus(ID).ToString(); //need to create a drop down for available times for the rest of the day //need to create a booking page, that lets the user select a date //add user session to see who booked it. }
private void btnDelete_Click(object sender, EventArgs e) { // Hỏi người dùng có chắc chắn xoá hay không? Nếu đồng ý thì if (MessageBox.Show("Bạn có chắc chắn muốn xoá mẫu tin này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { TableBL tablebl = new TableBL(); if (tablebl.Delete(tableCurrent) > 0)// Nếu xoá thành công { MessageBox.Show("Xoá bàn thành công"); // Tải tữ liệu lên ListView LoadTableDataToListView(); } else { MessageBox.Show("Xoá không thành công"); } } }
protected void Page_Load(object sender, EventArgs e) { int ID = Int32.Parse(Request.QueryString["ID"]); lblRoomHeading.Text = "Room: " + RoomBL.getRoomByID(ID).RoomName; tables = TableBL.FillTableList(ID); if (!IsPostBack) //need this to stop it reverting to the top value every button click { tableDropdown.DataSource = tables; tableDropdown.DataValueField = "TableID"; tableDropdown.DataTextField = "TableID"; tableDropdown.DataBind(); } if (tableDropdown.Items.Count < 1) { lblAboveDropdown.Text = "No tables currently available"; tableDropdown.Visible = false; goToTableButton.Visible = false; } // List <TableModel> drawtables = new List <TableModel>(); drawtables = TableBL.FillTableList(ID); int iLenght = drawtables.Count(); int x = 0; /*/////////////////////// * TextBox textBox = new TextBox(); * textBox.ID = "textBox1"; * textBox.Text = iLenght.ToString(); * div1.Controls.Add(textBox); * ////////////////////////*/ while (x < iLenght) { createImageTable(Convert.ToInt32(drawtables[x].TableID.ToString()), drawtables[x].Category); x++; } }
protected void Page_Load(object sender, EventArgs e) { int ID = Int32.Parse(Request.QueryString["ID"]); tables = TableBL.fillTableList(ID); if (!IsPostBack) //need this to stop it reverting to the top value every button click { tableDropdown.DataSource = tables; tableDropdown.DataValueField = "TableID"; tableDropdown.DataTextField = "TableID"; tableDropdown.DataBind(); } if (tableDropdown.Items.Count < 1) { lblAboveDropdown.Text = "No rooms currently available"; tableDropdown.Visible = false; goToTableButton.Visible = false; } }
public void LoadTableDataToListView() { TableBL tableBl = new TableBL(); // Lấy dữ liệu listTable = tableBl.GetAll(); int count = 1; // Biến số thứ tự // Xoá dữ liệu trong ListView lsvTable.Items.Clear(); // Duyệt mảng dữ liệu để đưa vào ListView foreach (var table in listTable) { // Số thứ tự ListViewItem item = lsvTable.Items.Add(count.ToString()); item.SubItems.Add(table.Name); item.SubItems.Add(table.Status.ToString()); item.SubItems.Add(table.Capacity.ToString()); count++; } }
protected void MyCalendar_SelectionChanged(object sender, EventArgs e) { //Updates the calander section whenever a new selection is made lblCalCheck.Text = "You selected date: "; CalHourDropDown.Visible = true; lblHourHelper.Visible = true; foreach (DateTime dt in Cal.SelectedDates) { lblCalCheck.Text += dt.ToLongDateString() + "<br />"; } int ID = Int32.Parse(Request.QueryString["ID"]); RoomModel thisRoom = RoomBL.getRoomByID(TableBL.GetTableByID(ID).RoomID); List <string> hoursList = new List <String>(); double x = thisRoom.OpeningTime.TotalHours; //building opening time while (x < thisRoom.ClosingTime.TotalHours) //will loop until the end of the day's booking aka 2300. Can change to room closing time { if (!TableBL.CheckTableHourAvailability(Int32.Parse(Request.QueryString["ID"]), Convert.ToInt32(x), Cal.SelectedDate)) { hoursList.Add(x.ToString() + ": " + "is free"); } else { hoursList.Add(x.ToString() + ": Occupied"); } x++; } CalHourDropDown.DataSource = hoursList; CalHourDropDown.DataBind(); if (CalHourDropDown.SelectedValue.ToString().Contains("Occupied")) { btnBookCalander.Visible = false; } }
/// <summary> /// Generates relevant booking information, as acquired from the user's booking information supplied /// </summary> /// <param name="bookingID"></param> protected void MainWorker(int bookingID) { //Get booking by the ID provided BookingModel booking = BookingBL.SearchBookingByID(bookingID); UserModel user = new UserModel(); TableModel table = new TableModel(); RoomModel room = new RoomModel(); BuildingModel building = new BuildingModel(); //Get all values by their identifiers (table, users & room) table = TableBL.GetTableByID(booking.tableID); user = UserBL.passUserSearch(booking.emailAddress); room = RoomBL.getRoomByID(table.RoomID); building = BuildingBL.getBuildingByID(room.BuildingID); string name = user.FirstName; string day = booking.bookingDate.ToString("yyyy-MM-d"); string hour = booking.bookingHour.ToString() + ":00"; string bTable = table.TableID.ToString(); string roomName = room.RoomName; string buildingName = building.BuildingName; //Generate a string from acquired data string buildingAddress = building.street + " " + building.suburb + Environment.NewLine + "<br />" + " " + building.provence + " " + building.country; //Update relevant data from user input booking information lblName.Text = name; lblDay.Text = day; lblHour.Text = hour; lblTable.Text = bTable; lblRoom.Text = roomName; lblBuilding.Text = buildingName; lblAddress.Text = buildingAddress; lblbuildingid.Text = building.BuildingID.ToString(); }
private void LoadTable() { TableBL tableBL = new TableBL(); listTable = tableBL.GetAll(); }
protected void createImageTable(int tableNumber, string category) { string url = ConfigurationManager.AppSettings["UnsecurePath"] + "Table.aspx?id=" + tableNumber; ///////////////// Image imageTable = new Image(); imageTable.ID = "imgBox" + tableNumber.ToString(); //determine height if (category.ToLower() == "lounge") { imageTable.Attributes.Add("height", "32"); } else if (category.ToLower() == "small") { imageTable.Attributes.Add("height", "32"); } else { imageTable.Attributes.Add("height", "42"); } //Determine width if (category.ToLower() == "large") { imageTable.Attributes.Add("width", "72"); } else if (category.ToLower() == "lounge") { imageTable.Attributes.Add("width", "72"); } else if (category.ToLower() == "small") { imageTable.Attributes.Add("width", "32"); } else { imageTable.Attributes.Add("width", "42"); } imageTable.Attributes.Add("class", "img-circle"); imageTable.Attributes.Add("style", "border-radius:14px;margin-bottom:20px; "); HyperLink imageHL = new HyperLink(); imageHL.ID = "hLink" + tableNumber.ToString(); imageHL.Attributes.Add("style", "margin-left:20px; "); //imageHL.Text = "hLink" + tableNumber.ToString(); imageHL.Controls.Add(imageTable);//adds image to the hyperlink /*if (TableBL.checkTableStatus(tableNumber)) * { * imageTable.BackColor = System.Drawing.Color.Green; * imageHL.NavigateUrl = url; //will only genertate url if table is available * }*/ if (!TableBL.CheckTableHourAvailability(tableNumber, Int32.Parse(DateTime.Now.ToString("HH")), DateTime.Now)) //returning false means it is free { //returning true means table exists, therefor is booked imageTable.BackColor = System.Drawing.Color.Green; imageHL.NavigateUrl = url; //will only genertate url if table is available } else { imageTable.BackColor = System.Drawing.Color.Red; } divTableImages.Controls.Add(imageHL); }
protected void btnBookCalander_Click(Object sender, EventArgs e) { if (Session["user"] == null) { string url = Request.Url.AbsoluteUri; Session["LoginFallback"] = url; Response.Redirect("Login.aspx"); } int ID = Int32.Parse(Request.QueryString["ID"]); string sHour = CalHourDropDown.SelectedValue.ToString(); sHour = new string(sHour.TakeWhile(Char.IsDigit).ToArray()); DateTime date = Cal.SelectedDate; BookingModel newBooking = new BookingModel(); newBooking.tableID = ID; newBooking.bookingDate = Cal.SelectedDate.Date; newBooking.emailAddress = Session["Login"].ToString(); newBooking.bookingHour = Int32.Parse(sHour); newBooking.memberEmail1 = InputCalEmail1.Value; newBooking.memberEmail2 = InputCalEmail2.Value; newBooking.memberEmail3 = InputCalEmail3.Value; newBooking.memberEmail4 = InputCalEmail4.Value; newBooking.memberEmail5 = InputCalEmail5.Value; //if bool returns true, booking is successfully made - so we need to send emails to groupmembers below if (BookingBL.ProcessCalanderBookTable(newBooking)) { lblHeading.Text = "Table was booked"; lblStatus.Text = "Table: " + TableBL.GetTableByID(ID).TableID + "<br />Room Name: " + RoomBL.getRoomByID(TableBL.GetTableByID(ID).RoomID).RoomName.ToString() + "<br />in building: " + BuildingBL.getBuildingByID(RoomBL.getRoomByID(TableBL.GetTableByID(ID).RoomID).BuildingID).BuildingName + "<br />at: " + sHour + "00 -" + (Convert.ToInt32(sHour) + 1).ToString() + "00" + "<br /> was successfully booked"; if (InputCalEmail1.Value != null) { notifyGroup(InputCalEmail1.Value, ID, date, sHour); } if (InputCalEmail2.Value != null) { notifyGroup(InputCalEmail2.Value, ID, date, sHour); } if (InputCalEmail3.Value != null) { notifyGroup(InputCalEmail3.Value, ID, date, sHour); } if (InputCalEmail4.Value != null) { notifyGroup(InputCalEmail4.Value, ID, date, sHour); } if (InputCalEmail5.Value != null) { notifyGroup(InputCalEmail5.Value, ID, date, sHour); } //(string email, int tableID,DateTime date, string sHour) btnDirections.Visible = true; int receipt = BookingBL.GetBookingIDByBookingModel(newBooking); string url = ConfigurationManager.AppSettings["UnsecurePath"] + "BookingReceipt.aspx?id=" + receipt; Response.Redirect(url); } }
public static void startEmailWorker() { // main Email worker, searches for any bookings in the next hour // via the booking table, searches user, room and building tables for associated data // loops through each booking sending email notifications via NotifyBL List <BookingModel> groups = new List <BookingModel>(); groups = BookingDAL.loadBookingListattime(); // loops through each booking returned by BookingDAL.loadBookingListattime(); foreach (BookingModel booking in groups) { List <string> dataset1 = new List <string>(); string URL = "https://www.etabletap.com/UL/BookingReceipt.aspx?id=" + booking.bookingID; UserModel user = new UserModel(); TableModel table = new TableModel(); RoomModel room = new RoomModel(); BuildingModel building = new BuildingModel(); table = TableBL.GetTableByID(booking.tableID); user = UserBL.passUserSearch(booking.emailAddress); room = RoomBL.getRoomByID(table.RoomID); building = BuildingBL.getBuildingByID(room.BuildingID); // main user NotifyBL.startNotifyBooking(user.FirstName + " " + user.LastName, user.phoneNum, user.Email, table.TableID.ToString(), room.RoomName, building.BuildingName, booking.bookingDate.ToString(), booking.bookingHour.ToString() + ":00", URL); //booking member 1 try { NotifyBL.startNotifyBooking(user.FirstName + " " + user.LastName, user.phoneNum, booking.memberEmail1, table.TableID.ToString(), room.RoomName, building.BuildingName, booking.bookingDate.ToString(), booking.bookingHour.ToString() + ":00", URL); } catch { } // booking member 2 try { NotifyBL.startNotifyBooking(user.FirstName + " " + user.LastName, user.phoneNum, booking.memberEmail2, table.TableID.ToString(), room.RoomName, building.BuildingName, booking.bookingDate.ToString(), booking.bookingHour.ToString() + ":00", URL); } catch { } // groupmember 3 try { NotifyBL.startNotifyBooking(user.FirstName + " " + user.LastName, user.phoneNum, booking.memberEmail3, table.TableID.ToString(), room.RoomName, building.BuildingName, booking.bookingDate.ToString(), booking.bookingHour.ToString() + ":00", URL); } catch { } // booking member 4 try { NotifyBL.startNotifyBooking(user.FirstName + " " + user.LastName, user.phoneNum, booking.memberEmail4, table.TableID.ToString(), room.RoomName, building.BuildingName, booking.bookingDate.ToString(), booking.bookingHour.ToString() + ":00", URL); } catch { } // groupmember 5 try { NotifyBL.startNotifyBooking(user.FirstName + " " + user.LastName, user.phoneNum, booking.memberEmail5, table.TableID.ToString(), room.RoomName, building.BuildingName, booking.bookingDate.ToString(), booking.bookingHour.ToString() + ":00", URL); } catch { } } }