protected void btnConfirmReservation_Click(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); Reservation res = db.Reservations.Single(p=> p.ReservationID == Convert.ToInt16(lblReservationNumber.Text)); res.ReservationStatus = 'C'; db.SubmitChanges(); }
protected void btnLocateReservation_Click(object sender, EventArgs e) { if (txtFirstName.Text == String.Empty && txtPhone.Text == String.Empty && txtResNumber.Text == String.Empty && txtSurName.Text == String.Empty) { lblNothingSelected.Text = "Please enter information into at least one box"; return; } lblNothingSelected.Text = String.Empty; //Locates guest in database based on the values given TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var guest = from g in db.Guests join r in db.Reservations on g.GuestID equals r.GuestID where ((r.ReservationID.ToString() == txtResNumber.Text || g.GuestFirstName == txtFirstName.Text || g.GuestSurName == txtSurName.Text || g.GuestPhone == txtPhone.Text) && (r.ReservationStatus == 'U' || r.ReservationStatus == 'C' || r.ReservationStatus == 'A')) select new {r.ReservationID, g.GuestFirstName, g.GuestSurName, g.GuestPhone}; gvGuest.DataSource = guest.ToList(); gvGuest.DataBind(); if (gvGuest.Rows.Count == 0) { lblNothingSelected.Text = "No records were found"; btnSelectReservation.Enabled = false; } }
protected void btnNewGuest_Click(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var gu = from g in db.Guests.Where(g => g.GuestFirstName == txtFirstName.Text && g.GuestSurName == txtSurName.Text && g.GuestPhone == txtPhone.Text) select g; gvGuest.DataSource = gu.ToList(); gvGuest.DataBind(); if (gvGuest.Rows.Count == 0) { //USes an linq to sql to insert a guest into the guest table Guest addGuest = new Guest(); addGuest.GuestFirstName = txtFirstName.Text; addGuest.GuestSurName = txtSurName.Text; addGuest.GuestPhone = txtPhone.Text; db.Guests.InsertOnSubmit(addGuest); db.SubmitChanges(); lblResFirstName.Text = txtFirstName.Text; lblResSurName.Text = txtSurName.Text; lblResPhone.Text = txtPhone.Text; reserving.GuestID = addGuest.GuestID; reserving.view = 2; btnNewGuest.CommandArgument = "2"; } else { lblErrorInsertGuest.Text = "Guest already exists please select below or enter a new guest"; btnNewGuest.CommandArgument = "0"; reserving.view = 0; } }
protected void btnAddStatuses_Click(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); RoomStatus status = new RoomStatus(); status.RoomStatus1 = Convert.ToChar(txtStatus.Text); status.RoomStatusDescription = txtDescription.Text; db.RoomStatus.InsertOnSubmit(status); db.SubmitChanges(); GridView1.DataBind(); }
protected void btnReadyforGuest_Click(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var roo = db.Rooms.Single(r => r.RoomID == Convert.ToInt16(gvMaintenance.SelectedRow.Cells[0].Text)); roo.RoomStatus = 'A'; db.SubmitChanges(); gvMaintenance.DataBind(); check(); }
protected void gvCollections_RowUpdating(object sender, GridViewUpdateEventArgs e) { int collectionID = Convert.ToInt32(gvCollections.Rows[e.RowIndex].Cells[0].Text); TextBox txtamount = (TextBox)(gvCollections.Rows[e.RowIndex].FindControl("Textbox1")); decimal amount = Convert.ToDecimal(txtamount.Text); TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); Collection updateCollection = db.Collections.Single(c => c.CollectionsID == collectionID); updateCollection.CollectionsAmountOwed = amount; db.SubmitChanges(); gvCollections.DataBind(); }
protected void btnAddBilling_Click(object sender, EventArgs e) { //Insert Values into discounts table using linq TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); BillingCategory addBilling = new BillingCategory(); addBilling.BillingCategoryDescription = txtDesciption.Text; addBilling.BillingCategoryTaxable = cbTaxable.Checked; db.BillingCategories.InsertOnSubmit(addBilling); db.SubmitChanges(); gvBilling.DataBind(); }
//Adds the selected Ingredient to the selected menu item protected void btnAddIngredientToMenuItem_Click(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); MenuItemIngredient mii = new MenuItemIngredient(); mii.IngredientID = Convert.ToInt16(ddlIngredients.SelectedValue); mii.MenuItemID = Convert.ToInt16(ddlMenuItemIngredients.SelectedValue); mii.MenuItemIngredientQty = Convert.ToDecimal(txtMenuItemIngredientQty.Text); db.MenuItemIngredients.InsertOnSubmit(mii); db.SubmitChanges(); lbMenuItems.DataBind(); lblIngredientInsert.Visible = false; }
protected void btnReadyforGuest_Click(object sender, EventArgs e) { lblHousekeeping.Text = ""; btnReadyforGuest.Visible = true; btnNeedsMaintenance.Visible = true; TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var roo = db.Rooms.Single(r => r.RoomID == Convert.ToInt16(gvHouseKeeping.SelectedRow.Cells[0].Text)); roo.RoomStatus = 'A'; db.SubmitChanges(); gvHouseKeeping.DataBind(); check(); }
protected void btnAddRoomType_Click(object sender, EventArgs e) { //USes an linq to sql to insert a guest into the guest table TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); HotelRoomType type = new HotelRoomType(); type.HotelID = Convert.ToInt16(ddlHotel.SelectedValue); type.RoomType = txtRoomType.Text; type.RoomTypeDescription = txtDescription.Text; type.RoomTypeRackRate = Convert.ToDecimal(txtRackRate.Text); db.HotelRoomTypes.InsertOnSubmit(type); db.SubmitChanges(); gvRoomTpyes.DataBind(); }
protected void btnUpdatePin_Click(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var pin = from p in db.aspnet_Memberships where p.Pin == txtPin.Text select new { p.Pin }; if (pin.Count() != 0 && pin.First().Pin != lblPin.Text) { Label_StatusMsg.Text = "This is not a valid pin"; } else if(pin.Count() != 0 && pin.First().Pin == lblPin.Text) { Label_StatusMsg.Text = "This is your current pin"; } else { Label_StatusMsg.Text = "Pin Changed"; var query = from p in db.aspnet_Memberships join u in db.aspnet_Users on p.UserId equals u.UserId where u.UserName == Request.QueryString["user"] select p; foreach (var result in query) { result.Pin = txtPin.Text; } db.SubmitChanges(); var pinrefresh = from p in db.aspnet_Memberships join u in db.aspnet_Users on p.UserId equals u.UserId where u.UserName == Request.QueryString["user"] select new { p.Pin }; if (pinrefresh.Count() == 0) { lblPin.Text = "No Pin"; } else { lblPin.Text = pin.First().Pin; } txtPin.Text = ""; } }
protected void btnCancelReservation_Click(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var deleteRows = from rs in db.ReservationDetails where rs.ReservationID == Convert.ToInt16(lblReservationNumber.Text) select rs; db.ReservationDetails.DeleteAllOnSubmit(deleteRows); db.SubmitChanges(); var deleteRes = from r in db.Reservations where r.ReservationID == Convert.ToInt16(lblReservationNumber.Text) select r; db.Reservations.DeleteAllOnSubmit(deleteRes); db.SubmitChanges(); }
protected void btnLocateGuest_Click(object sender, EventArgs e) { //Locates guest in database based on the values given TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var guest = from g in db.Guests where g.GuestFirstName == txtFirstName.Text || g.GuestSurName == txtSurName.Text || g.GuestPhone == txtPhone.Text select g; gvGuest.DataSource = guest.ToList(); gvGuest.DataBind(); if (gvGuest.Rows.Count == 0) { lblErrorNoGuest.Text = "No guests where found please create a new guest"; } else { lblErrorNoGuest.Text = ""; } }
protected void RegisterUser_CreatedUser(object sender, EventArgs e) { //FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); //string continueUrl = RegisterUser.ContinueDestinationPageUrl; //if (String.IsNullOrEmpty(continueUrl)) //{ // continueUrl = "~/"; //} TextBox user = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Username"); TextBox pin = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Pin"); TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); aspnet_User u = db.aspnet_Users.Single(us => us.UserName == user.Text); aspnet_Membership mem = db.aspnet_Memberships.Single(m => m.UserId == u.UserId); Response.Redirect("ManageUsers.aspx"); }
protected void btnInsertDiscount_Click(object sender, EventArgs e) { //Insert Values into discounts table using linq TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); Discount addDiscount = new Discount(); addDiscount.DiscountDescription = txtDiscountDescription.Text; addDiscount.DiscountExpiration = Convert.ToDateTime(txtDiscountExpiration.Text); addDiscount.DiscountRules = txtDiscountRules.Text; addDiscount.DiscountAmount = Convert.ToDecimal(txtDiscountAmount.Text); if (cbIsPercentage.Checked) { addDiscount.IsPrecentage = true; } else { addDiscount.IsPrecentage = false; } db.Discounts.InsertOnSubmit(addDiscount); db.SubmitChanges(); GridView1.DataBind(); }
/// <summary> /// When the check in button is pressed, the entered data is updated. All or none of the data may be entered. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCheckIn_Click(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var room = from rd in db.ReservationDetails join r in db.Rooms on rd.RoomID equals r.RoomID where (r.RoomNumbers == txtShowRoomNum.Text) && (r.RoomStatus == 'C') select new { r.RoomNumbers }; if (room.Count()==0) { //SQL command to update the guests entered information App_Code.GuestDB.updateGuestInformation(txtCompany.Text, txtAddress.Text, txtCity.Text, txtRegion.Text, txtPostalCode.Text, txtCountry.Text, txtFax.Text, txtEmail.Text, txtComments.Text, txtIdNumber.Text, txtIdCountry.Text, txtIdComments.Text, Convert.ToInt32(lblCustomerId.Text)); //updates the roomStatus to checked in, and updates the reservationdetail to active var id = from i in db.Rooms where i.RoomNumbers == txtShowRoomNum.Text select new { i.RoomID }; Int16 a = Convert.ToInt16(id.First().RoomID); App_Code.GuestDB.updateRoomStatus('C', Convert.ToInt16(id.First().RoomID)); App_Code.GuestDB.updateReservationDetail('A', Convert.ToInt16(lblReservationDetailID.Text)); //Updates the Reservation status to Active if all reservation detail status associated with the reservation are set to active if (App_Code.GuestDB.countConfirmedReservationDetail(Convert.ToInt32(txtShowReservationNum.Text)) == 0) { App_Code.GuestDB.updateReservationStatus('A', Convert.ToInt32(txtShowReservationNum.Text)); } mvLocateGuest.ActiveViewIndex = 2; } else { lblRoomcheckedin.Visible = true; } }
protected void btnConfirm_Click(object sender, EventArgs e) { if (gvUnconfirmedGuest.SelectedIndex == -1) lblErrorMessage2.Text = "You must select a guest"; else { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); Reservation res = db.Reservations.Single(r=> r.ReservationID == Convert.ToInt32(gvUnconfirmedGuest.SelectedRow.Cells[3].Text)); res.ReservationStatus = 'C'; db.SubmitChanges(); //switches to the next view mvLocateGuest.ActiveViewIndex = 1; //get the discount ArrayList myArrList = new ArrayList(); myArrList = App_Code.GuestDB.getGuestInformation(Convert.ToInt32(gvUnconfirmedGuest.SelectedRow.Cells[3].Text)); //if there are no items in the arrayList then there is no discount if (myArrList.Count != 0) { txtShowReservationNum.Text = myArrList[0].ToString(); txtShowRoomType.Text = myArrList[1].ToString(); txtShowRoomNum.Text = myArrList[2].ToString(); txtShowNumGuests.Text = (Convert.ToInt32(myArrList[3]) + Convert.ToInt32(myArrList[4])).ToString(); txtShowFirstName.Text = myArrList[5].ToString(); txtShowSurname.Text = myArrList[6].ToString(); txtShowPhone.Text = myArrList[7].ToString(); txtShowCheckOut.Text = string.Format("{0:dd/MM/yyyy}", (Convert.ToDateTime(myArrList[8]).AddDays(Convert.ToInt32(myArrList[9])))); lblCustomerId.Text = App_Code.GuestDB.getGuestID(Convert.ToInt32(txtShowReservationNum.Text)).ToString(); lblReservationDetailID.Text = gvUnconfirmedGuest.SelectedRow.Cells[0].Text; } } }
private void getMenuItemIngredientsDatabind() { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var menuItemIngred = from mii in db.MenuItemIngredients join i in db.Ingredients on mii.IngredientID equals i.IngredientID where mii.MenuItemID == Convert.ToInt16(ddlMenuItemIngredients.SelectedValue) select i ; /*foreach (Ingredient item in menuItemIngred) { lbMenuItems.Items.Add(new ListItem(item.IngredientName, item.IngredientID.ToString())); } lbMenuItems.DataBind();*/ }
/// <summary> /// Gets all the drink categories or the menu item categories /// </summary> /// <param name="isMenuItem">the category type to return</param> /// <returns>food or drink categories</returns> private object getCategories(char isMenuItem) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); if (isMenuItem == 'F') { return from fdc in db.FoodDrinkCategories where fdc.FoodDrinkCategoryTypeID == "F" select fdc; } else if(isMenuItem == 'D') { return from fdc in db.FoodDrinkCategories where fdc.FoodDrinkCategoryTypeID =="D" select fdc; } else { return from fdc in db.FoodDrinkCategories where fdc.FoodDrinkCategoryTypeID != "D" & fdc.FoodDrinkCategoryTypeID != "F" select fdc; } }
/// <summary> /// Gets a list of all the ingredient names and ids /// </summary> /// <returns></returns> private object getAllIngredients() { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); return from i in db.Ingredients join mii in db.MenuItemIngredients on i.IngredientID equals mii.IngredientID join mi in db.MenuItems on mii.MenuItemID equals mi.MenuItemID where mi.FoodDrinkCategoryID > 3 select new { i.IngredientName, i.IngredientID }; }
private object getAllCategories() { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); return from fdc in db.FoodDrinkCategories select fdc; }
void displayTypeCategories() { if (ddlChooseItem.SelectedItem.Text=="Beverages") { lblAddMenuItemName.Text = "Drink name"; var foodDrinkCat = getCategories('A'); ddlAddGetCategory.DataSource = foodDrinkCat; ddlAddGetCategory.DataValueField = "FoodDrinkCategoryID"; ddlAddGetCategory.DataTextField = "FoodDrinkCategoryName"; ddlAddGetCategory.DataBind(); ddlAddCategory.DataSource = foodDrinkCat; ddlAddCategory.DataValueField = "FoodDrinkCategoryID"; ddlAddCategory.DataTextField = "FoodDrinkCategoryName"; ddlAddCategory.DataBind(); lblAddMenuItemName.Text = "Drink Name"; } else if(ddlChooseItem.SelectedItem.Text == "Discounts") { lblAddMenuItemName.Text = "Discount name"; var foodDrinkCat = getCategories('D'); ddlAddGetCategory.DataSource = foodDrinkCat; ddlAddGetCategory.DataValueField = "FoodDrinkCategoryID"; ddlAddGetCategory.DataTextField = "FoodDrinkCategoryName"; ddlAddGetCategory.DataBind(); ddlAddCategory.DataSource = foodDrinkCat; ddlAddCategory.DataValueField = "FoodDrinkCategoryID"; ddlAddCategory.DataTextField = "FoodDrinkCategoryName"; ddlAddCategory.DataBind(); lblAddMenuItemName.Text = "Discount Name"; } else { try { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var foodDrinkCat = getCategories('F'); ddlAddGetCategory.DataSource = foodDrinkCat; ddlAddGetCategory.DataValueField = "FoodDrinkCategoryID"; ddlAddGetCategory.DataTextField = "FoodDrinkCategoryName"; ddlAddGetCategory.DataBind(); ddlAddCategory.DataSource = foodDrinkCat; ddlAddCategory.DataValueField = "FoodDrinkCategoryID"; ddlAddCategory.DataTextField = "FoodDrinkCategoryName"; ddlAddCategory.DataBind(); gvMenuItems.DataBind(); lblAddMenuItemName.Text = "Menu Item Name"; } catch (Exception) { throw; } } }
protected string GetItemName(string IngredientID) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var ingredientName = from items in db.Ingredients where items.IngredientID == Convert.ToInt16(IngredientID) select items; foreach (var i in ingredientName) { return i.IngredientName; } return ""; }
/// <summary> /// Creates a purchase and saves it do the database /// </summary> protected void btnSubmitPurchase_Click(object sender, EventArgs e) { //insert drink purchase if (ddlChooseItemForPurchase.SelectedIndex==0) { if (Session["drinklist"] != null) { drinkPurchase = (List<IngredientPurchaseHistory>)Session["drinklist"]; //create a database connection TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); IngredientPurchase addDrinkPurchase = new IngredientPurchase(); addDrinkPurchase.PurchaseDate= DateTime.Now; db.IngredientPurchases.InsertOnSubmit(addDrinkPurchase); db.SubmitChanges(); var pch = (from i in db.IngredientPurchases select i.PurchaseID).Max(); foreach (var dp in drinkPurchase) { dp.PurchaseID = System.Convert.ToInt16(pch.ToString()); db.IngredientPurchaseHistories.InsertOnSubmit(dp); db.SubmitChanges(); } } } //enter food purchase else { if (Session["ingredientlist"] != null) { purchase = (List<IngredientPurchaseHistory>)Session["ingredientlist"]; //create a database connection TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); //Create Ingredient Purchase IngredientPurchase addIngredientPurchase = new IngredientPurchase();//create new purchase object addIngredientPurchase.PurchaseDate = DateTime.Now;//get today db.IngredientPurchases.InsertOnSubmit(addIngredientPurchase); db.SubmitChanges(); //System.Diagnostics.Debug.WriteLine(""); //Query Recently added Purchase to get Purchase ID var pch = (from i in db.IngredientPurchases select i.PurchaseID).Max();//db.IngredientPurchases.Last(); //from p in db.IngredientPurchases select p.PurchaseDate//.Where(p => p. == purchaseTime ) //select p; System.Diagnostics.Debug.WriteLine(pch.ToString()); //for each add to database foreach (var ph in purchase) { ph.PurchaseID = System.Convert.ToInt16(pch.ToString()); db.IngredientPurchaseHistories.InsertOnSubmit(ph); db.SubmitChanges(); } Session["ingredientlist"] = null; gvshowIngredientPurchases.DataSource = null; gvshowIngredientPurchases.DataBind(); } }; gvshowIngredientPurchases.DataSource = null; gvshowIngredientPurchases.DataBind(); btnSubmitPurchase.Enabled = false; btnManageCategories.Enabled = true; btnManageMenuItems.Enabled = true; btnEnterPurchase.Enabled = true; btnIngredients.Enabled = true; btnClear.Enabled = false; }
protected void btnRemoveIngredient_Click(object sender, EventArgs e) { if (lbMenuItems.SelectedIndex>-1) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var deleteMenuItemIngredient = from details in db.MenuItemIngredients where details.MenuItemIngredientID == Convert.ToInt16(lbMenuItems.SelectedValue) select details; foreach (var detail in deleteMenuItemIngredient) { db.MenuItemIngredients.DeleteOnSubmit(detail); } db.SubmitChanges(); lbMenuItems.DataBind(); lblIngredientInsert.Visible = false; } }
/// <summary> /// The item new item is added to the menu item table or the drink table based on /// the selected category. The fields are then hidden. /// </summary> protected void btnAddSubmit_Click(object sender, EventArgs e) { //the item to be added is a drink //gets the nonalcohol or alcohol tage from the drop down list if (ddlChooseItem.SelectedIndex == 0) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); TreasureLand.DBM.MenuItem d = new DBM.MenuItem(); d.MenuItemName = txtAddMenuItemName.Text; d.MenuItemPrice = Convert.ToDecimal(txtAddPrice.Text); d.IsCurrentItem = true; d.FoodDrinkCategoryID = Convert.ToByte(ddlAddCategory.SelectedIndex + 1); db.MenuItems.InsertOnSubmit(d); db.SubmitChanges(); } //the item to be added is a discount else if (ddlChooseItem.SelectedItem.Text=="Discounts") { try { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); TreasureLand.DBM.MenuItem d = new DBM.MenuItem(); d.MenuItemName = txtAddMenuItemName.Text; d.MenuItemPrice = Convert.ToDecimal(txtAddPrice.Text); d.IsCurrentItem = true; d.FoodDrinkCategoryID = Convert.ToByte(3); db.MenuItems.InsertOnSubmit(d); db.SubmitChanges(); } catch (Exception) { throw; } } else { //The item to be added is a menu item //gets the value from the category drop down list and adds 4 to that value //2 for drink categories, 1 for dicount category, and 1 since the first location is 0 TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); TreasureLand.DBM.MenuItem mi = new TreasureLand.DBM.MenuItem(); mi.FoodDrinkCategoryID = Convert.ToSByte(ddlAddCategory.SelectedIndex + 4); mi.MenuItemName = txtAddMenuItemName.Text; mi.MenuItemPrice = Convert.ToDecimal(txtAddPrice.Text); mi.IsCurrentItem = true; db.MenuItems.InsertOnSubmit(mi); db.SubmitChanges(); } disableButtons(true); gvMenuItems.DataBind(); ddlMenuItemIngredients.DataBind(); }
/// <summary> /// creates a new category /// checks to see if the category to be entered is already in the database /// if it doesn't exist it is created and added to the database /// </summary> protected void btnAddNewCategory(object sender, EventArgs e) { //Hides the error message lblCatAddError.Text = ""; //If input is blank if (txtCategory.Text == "") { lblCatAddError.Text = "You have not entered a Category"; } else { //Change View Over to ManageCategories View. containerView.ActiveViewIndex = 1; //populate grid TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var ing = from fdc in db.FoodDrinkCategories.Where(fdc => fdc.FoodDrinkCategoryName == txtCategory.Text) select fdc; //checks to see if the item is in the database if (ing.Any()) { //If something exists, then don't add //print error message lblCatAddError.Text = "Category Is Already In the Hotel Restaurant"; //reset txtIngredient to " " txtCategory.Text = ""; } else { //else if something exists //add record to database //USes an linq to sql to insert a guest into the guest table FoodDrinkCategory addfdc = new FoodDrinkCategory(); addfdc.FoodDrinkCategoryName = txtCategory.Text; addfdc.FoodDrinkCategoryTypeID = "F"; db.FoodDrinkCategories.InsertOnSubmit(addfdc); db.SubmitChanges(); } //repopulate dropdownlist ddlCategory.DataSource = getAllCategories(); ddlCategory.DataBind(); gvEditCategories.DataBind(); ddlAddGetCategory.DataBind(); txtCategory.Text = ""; } }
protected void btnAddListItemIngredient_Click1(object sender, EventArgs e) { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); var ing = from fdc in db.Ingredients.Where(fdc => fdc.IngredientName == txtIngredient.Text) select fdc; //checks to see if the item is in the database if (ing.Any()) { //If something exists, then don't add //print error message lblIngredientInsert.Text = "Ingredient Is Already In the Hotel Restaurant"; lblIngredientInsert.Visible = true; //reset txtIngredient to " " txtCategory.Text = ""; } else { //add ingredient to database Ingredient addIngredient = new Ingredient(); addIngredient.IngredientName = txtIngredient.Text; //addIngredient.IngredientDescription = txtIngredientComments.Text; db.Ingredients.InsertOnSubmit(addIngredient); db.SubmitChanges(); lblIngredientInsert.Text = "Insert Successful"; lblIngredientInsert.Visible = true; ddlIngredients.DataBind(); txtIngredient.Text = ""; txtIngredientComments.Text = ""; //make text box invisible again. //make text box } }
/// <summary> /// Creates the select statements for the room reports /// </summary> /// <returns></returns> private IQueryable getRoomsSelect() { TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); if (m_reportName == "RoomsOccupied") { return from r in db.Rooms join rd in db.ReservationDetails on r.RoomID equals rd.RoomID join res in db.Reservations on rd.ReservationID equals res.ReservationID join g in db.Guests on res.GuestID equals g.GuestID where r.RoomStatus == 'A' select new { r.RoomNumbers, g.GuestFirstName, g.GuestSurName, rd.CheckinDate, rd.Nights }; } else if (m_reportName == "Payments") { return from r in db.Rooms join rd in db.ReservationDetails on r.RoomID equals rd.RoomID join res in db.Reservations on rd.ReservationID equals res.ReservationID join g in db.Guests on res.GuestID equals g.GuestID where res.ReservationStatus == 'C' select new { r.RoomNumbers, g.GuestFirstName, g.GuestSurName, rd.CheckinDate, rd.Nights }; } else { return from r in db.Rooms select r; } }
/// <summary> /// Populates the first dropdown list with all the rooms in the hotel /// </summary> private void getRooms() { ddlFirstParameter.Items.Clear(); TreasureLandDataClassesDataContext db = new TreasureLandDataClassesDataContext(); IEnumerable<Room> room = from r in db.Rooms select r; ddlFirstParameter.DataSource = LinqDataSource1; ddlFirstParameter.DataValueField = "RoomID"; ddlFirstParameter.DataTextField = "RoomNumbers"; ddlFirstParameter.Items.Insert(0, new ListItem("All Rooms", "0")); ddlFirstParameter.DataBind(); ddlFirstParameter.Visible = true; }