/// <summary> /// The method updates the chosen question /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void QuestionUpdate_Click(object sender, EventArgs e) { //initialize variables string newQuestion = DescriptionTextBox.Text.Trim(); int questionID = Convert.ToInt32(QuestionDDL.SelectedValue); MessageUserControl.TryRun(() => { //allows access to the question text controller QuestionTextController sysmgr = new QuestionTextController(); //updates the text sysmgr.UpdateQuestionsText(questionID, newQuestion); editQuestion.Visible = true; editResponse.Visible = true; }, "Success", headerText.InnerText + " has been successfully updated"); // display success message }
/// <summary> /// This method Populates/refreshes the list all employee for selction /// It turns On/Off all necessary/unnecessary column(s) on the EmployeeGridView /// </summary> protected void RefreshCrewMember() { MessageUserControl.TryRun(() => { //Retrieve all employees EmployeeController EmployeeManager = new EmployeeController(); List <Driver> employees = EmployeeManager.GetEmployees(int.Parse(YardID.Text)); employees.Sort((x, y) => x.Name.CompareTo(y.Name)); EmployeeGridView.DataSource = employees; EmployeeGridView.DataBind(); EmployeeGridView.Columns[4].Visible = false; EmployeeGridView.Columns[5].Visible = false; EmployeeGridView.Columns[6].Visible = false; EmployeeGridView.Columns[7].Visible = true; EmployeeGridView.Visible = true; }); }
protected void ReservationSummaryListView_ItemCommand(object sender, ListViewCommandEventArgs e) { //this is the method which will gather the seating //information for reserations and pass to the BLL //for processing //no processing will be done unless the e.CommandName is //equal to "Seat" if (e.CommandName.Equals("Seat")) { //execution of the code will under the control //of the MessageUserControl MessageUserControl.TryRun(() => { //gather the necessary data from the web controls int reservationid = int.Parse(e.CommandArgument.ToString()); int waiterid = int.Parse(WaiterDropDownList.SelectedValue); DateTime when = Mocker.MockDate.Add(Mocker.MockTime); //we need to collect possible multiple values from the ListBox control which //contains the selected tables to be assigned to this group of customers List <byte> selectedTables = new List <byte>(); //walk through the listBox row by row foreach (ListItem item_tableid in ReservationTableListBox.Items) { if (item_tableid.Selected) { selectedTables.Add(byte.Parse(item_tableid.Text.Replace("Table ", ""))); } } //with all data gathered, connect to your library controller, //and send data to processing AdminController sysmgr = new AdminController(); sysmgr.SeatCustomer(when, reservationid, selectedTables, waiterid); //refresh the page SeatingGridView.DataBind(); ReservationsRepeater.DataBind(); ReservationTableListBox.DataBind(); }, "Customer Seated", "Reservation customer has arrived and has been seated." ); } }
protected void Place_OnClick(object sender, EventArgs e) { //BLL Method will take vendorID, orderID and data -- data = PurchaseOrderDetails //Will set the OrderDate and a new PurchaseOrderNumber for the current order - BLL //Will update the QuantityOnOrder for each part item on the purchase order //OrderDate and PurchaseOrderNumber are found on the PurchaseOrder table //OrderDate = OrderDate = DateTime.Today //QuantityOnOrder is found on the Parts table MessageUserControl.TryRun(() => { PurchaseOrderInfo order = BuildPurchaseOrderInfo(); int employeeID = int.Parse(Employee.Text); int vendorID = int.Parse(VendorDropDownList.SelectedIndex.ToString()); var controller = new PurchasingController(); controller.PlaceOrder(vendorID, employeeID, order); }, "Placed", "Purchase Order has been placed."); }
protected void RentalSelected_Click(object sender, ListViewCommandEventArgs e) { int rentalID = int.Parse(e.CommandArgument.ToString()); RentalID.Text = rentalID.ToString(); MessageUserControl.TryRun(() => { RentalController rntlmgr = new RentalController(); List <RentalDetail> rentals = rntlmgr.Get_RentalDetailsByRentalID(rentalID); RentalListListview.DataSource = rentals; RentalListListview.DataBind(); }, "Customer Selected", "Please select a rental by this customer"); CustomerList.DataBind(); //list rentals and display them same as did customers }
protected void DeleteTrack_Click(object sender, EventArgs e) { //code to go here if (PlayList.Rows.Count == 0) { MessageUserControl.ShowInfo("warning", "No playlist has been retrieved."); } else { if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Warning", "Playlist name is required"); } else { //collect the selected tracks to delete List <int> trackstodelete = new List <int>(); int selectedrows = 0; CheckBox playlistselection = null; for (int i = 0; i < PlayList.Rows.Count; i++) { playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox; if (playlistselection.Checked) { trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text)); selectedrows++; } } if (selectedrows == 0) { MessageUserControl.ShowInfo("Information", "No Playlist tracks have been selected"); } else { // at this point you have the required data to send to BLL for processing MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> playlistdata = sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, trackstodelete); PlayList.DataSource = playlistdata; PlayList.DataBind(); }, "Removed", "Tracks have been removed"); } } } }
protected void AlbumFetch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(AlbumTitle.Text)) { //using MessageUserControl to display a message. MessageUserControl.ShowInfo("Missing Data", "Enter Partial Album Name."); } else { MessageUserControl.TryRun(() => { SearchArg.Text = AlbumTitle.Text; TracksBy.Text = "Album"; TracksSelectionList.DataBind();//Causes the ODS to execute. }, "Tracks Search", "Select from the following list to add to yotur Playlist"); } }
protected void DeleteTrack_Click(object sender, EventArgs e) { //code to go here string username = "******"; if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name"); } else { if (PlayList.Rows.Count == 0) { MessageUserControl.ShowInfo("Missing Data", "Playlist has no tracks to remove."); } else { List <int> tracksToDelete = new List <int>(); int rowsSelected = 0; CheckBox playlistSelection = null; for (int i = 0; i < PlayList.Rows.Count; i++) { playlistSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox; if (playlistSelection.Checked) { rowsSelected++; tracksToDelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackID") as Label).Text)); if (rowsSelected == 0) { MessageUserControl.ShowInfo("No data", "You must select at least one track to remove"); } else { MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.DeleteTracks(username, PlaylistName.Text, tracksToDelete); List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }, "Remove Tracks", "Track(s) have been Removed"); } } } } } }
protected void DeleteButton_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { int purchaseOrderID = 0; foreach (ListViewItem item in CurrentPOListView.Items) { purchaseOrderID = int.Parse((item.FindControl("PurchaseOrderIDLabel2") as Label).Text.ToString()); } PurchasingController sysmgr = new PurchasingController(); sysmgr.PurchaseOrder_Delete(purchaseOrderID); hideAll(); }, "Removed", "Purchase order has been removed."); }
protected void PlaceOrderButton_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { var controller = new SalesController(); var paymentType = paymentRadioButton.SelectedValue; var coupon = controller.GetCoupon(CouponTextBox.Text); if (coupon != null) { controller.PlaceOrder(User.Identity.Name, paymentType, coupon.CouponID); } else { controller.PlaceOrder(User.Identity.Name, paymentType, 0); } }, "Place Order", "You place a order, thank you for shopping"); }
// Final processing for this page to add courses to our system. protected void AddCourse_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { // 1) Extract the data from the form DateTime start; DateTime.TryParse(StartsOn.Text, out start); var courseInfo = new CourseOffering(CourseName.Text, start); RetrieveAssignments(); // 2) Send the data to the BLL for processing var controller = new StudentGradesController(); controller.CreateCourse(courseInfo, 7, Assignments); Courses.DataBind(); }, "Course Added", $"Successfully added the {CourseName.Text} course"); }
protected void MoveTrack(int trackid, int tracknumber, string direction) { //code to go here MessageUserControl.TryRun(() => { //standard call to a BLL method //update call PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.MoveTrack(User.Identity.Name, PlaylistName.Text, trackid, tracknumber, direction); //referesh the list //query call List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist(PlaylistName.Text, User.Identity.Name); PlayList.DataSource = results; PlayList.DataBind(); }, "Success", "Track Moved"); }
protected void deleteRental_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { if (string.IsNullOrEmpty(selectedCustomerRental.Text)) { throw new Exception("No form to delete"); } else { RentalController mgr = new RentalController(); mgr.deleteRental(int.Parse(selectedCustomerRental.Text)); RentalEquipmentListview.DataBind(); clearUserControls(); } }, "Deleted Rental Order", "Order has beem successfully deleted."); }
protected void FetchWaiter_Click(object sender, EventArgs e) { //to properly interfact with our MessageUserControl //We will delegte the execution of this Click Event //under the MessageUserControl. if (WaiterList.SelectedIndex == 0) { //issue our own error message MessageUserControl.ShowInfo("please select a waiter to process."); } else { //execute the necessary standard lookup code under the //control of the MessageUserControl MessageUserControl.TryRun((ProcessRequest)GetWaiterInfo); } }
protected void Update_Click(object sender, EventArgs e) { if (Page.IsValid) { string editID = EditAlbumID.Text; int albumID = 0; if (string.IsNullOrEmpty(editID)) { MessageUserControl.ShowInfo("Error", "Must have album to edit."); } else if (!int.TryParse(editID, out albumID)) { MessageUserControl.ShowInfo("Error", "Invalid album ID"); } else { string title = EditTitle.Text; int year = int.Parse(EditReleaseYear.Text); string label = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text; int artist = int.Parse(EditAlbumArtistList.SelectedValue); int editAlbumID = int.Parse(EditAlbumID.Text); Album newAlbum = new Album(); newAlbum.AlbumId = editAlbumID; newAlbum.ArtistId = artist; newAlbum.Title = title; newAlbum.ReleaseYear = year; newAlbum.ReleaseLabel = label; MessageUserControl.TryRun(() => { AlbumController controller = new AlbumController(); int rows = controller.Album_Update(newAlbum); if (rows > 0) { AlbumList.DataBind(); } else { throw new Exception("No album found. Try again."); } }, "Sucessful!", "Album updated."); } } }
protected void AddToCartBtn_Click(object sender, EventArgs e) { LinkButton linkBtn = (LinkButton)sender; string username = User.Identity.Name; GridViewRow grdrow = (GridViewRow)((LinkButton)sender).NamingContainer; int productid = int.Parse(linkBtn.CommandArgument.ToString()); int quantity = int.Parse((grdrow.Cells[2].FindControl("AddQtyValue") as TextBox).Text); MessageUserControl.TryRun(() => { ShoppingCartItemController sysmgr = new ShoppingCartItemController(); sysmgr.Add_Product_To_ShoppingCart(username, productid, quantity); var loggedInGridview = (GridView)ProductsLoggedIn.FindControl("ProductListByCatLoged"); loggedInGridview.DataBind(); DisplayCurrentCartQty(); }, "Added Product", "Product added to shopping cart!"); }
protected void Delete_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { var poid = Convert.ToInt32((CurrentOrderGridView.Rows[0].FindControl("PurchaseOrderID") as HiddenField).Value); if (poid == 0) { throw new Exception("empty"); } FinalOrder purchase = new FinalOrder(); purchase.PurchaseOrderID = Convert.ToInt32((CurrentOrderGridView.Rows[0].FindControl("PurchaseOrderID") as HiddenField).Value); purchase.VendorID = int.Parse(VendorDropDown.SelectedValue); purchase.Subtotal = decimal.Parse(Subtotal.Text.Substring(1)); purchase.GST = decimal.Parse(GST.Text.Substring(1)); List <CurrentOrder> orderDetails = new List <CurrentOrder>(); foreach (GridViewRow row in CurrentOrderGridView.Rows) { var partid = row.FindControl("PartID") as Label; var qty = row.FindControl("Qty") as TextBox; var price = row.FindControl("Price") as TextBox; if (partid != null) { var details = new CurrentOrder(); details.PartID = int.Parse(partid.Text); details.Qty = int.Parse(qty.Text); details.Price = decimal.Parse(price.Text); orderDetails.Add(details); } else { throw new Exception("Empty"); } } var controller = new PurchasingController(); controller.DeleteCurrentOrder(purchase); OrderDetailsPanel.Enabled = false; OrderDetailsPanel.Visible = false; VendorDropDown.SelectedIndex = 0; VendorName.Text = ""; Location.Text = ""; Phone.Text = ""; }, "Success", "Order deleted"); }
protected void Update_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { CalculateTotals(); FinalOrder purchase = new FinalOrder(); purchase.PurchaseOrderID = Convert.ToInt32((CurrentOrderGridView.Rows[0].FindControl("PurchaseOrderID") as HiddenField).Value); purchase.PurchaseOrderDetailID = Convert.ToInt32((CurrentOrderGridView.Rows[0].FindControl("PurchaseOrderDetailID") as HiddenField).Value); purchase.VendorID = int.Parse(VendorDropDown.SelectedValue); purchase.Subtotal = decimal.Parse(Subtotal.Text.Substring(1)); purchase.GST = decimal.Parse(GST.Text.Substring(1)); List <CurrentOrder> orderDetails = new List <CurrentOrder>(); foreach (GridViewRow row in CurrentOrderGridView.Rows) { var partid = row.FindControl("PartID") as Label; var qty = row.FindControl("Qty") as TextBox; var price = row.FindControl("Price") as TextBox; if (int.Parse(qty.Text) < 0) { throw new Exception("Quantity cannot be a negative number"); } if (decimal.Parse(price.Text) <= 0) { throw new Exception("Price cannot be a negative number"); } if (partid != null) { var details = new CurrentOrder(); details.PartID = int.Parse(partid.Text); details.Qty = int.Parse(qty.Text); details.Price = decimal.Parse(price.Text); orderDetails.Add(details); } else { throw new Exception("Empty"); } } var controller = new PurchasingController(); purchase.OrderDetails = orderDetails; controller.UpdateCurrentOrder(purchase); }, "Sucess", "Order updated."); }
protected void ArtistFetch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ArtistName.Text)) { //using MessageUserControl to display a message MessageUserControl.ShowInfo("Missing Data", "Enter a partial artist name."); } else { MessageUserControl.TryRun(() => { SearchArg.Text = ArtistName.Text; TracksBy.Text = "Artist"; TracksSelectionList.DataBind(); //causes the ODS to execute }, "Track Search", "Select from the following list to add to your playlist"); } }
protected void Update_Click(object sender, EventArgs e) { if (Page.IsValid) { int editalbumid = 0; string albumid = EditAlbumID.Text; if (string.IsNullOrEmpty(albumid)) { MessageUserControl.ShowInfo("Attention", "Look up the album before editing"); } else if (int.TryParse(albumid, out editalbumid)) { MessageUserControl.ShowInfo("Attention", "Current Album ID is Invalid, Look Again!"); } else { //string albumtitle = //int albumyear = //string albumlabel = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text; //int albumartist = int.Parse(EditAlbumArtistList.SelectedValue); Album theAlbum = new Album(); theAlbum.AlbumId = editalbumid; theAlbum.Title = EditTitle.Text; theAlbum.ArtistId = int.Parse(EditAlbumArtistList.SelectedValue); theAlbum.ReleaseYear = int.Parse(EditReleaseYear.Text); theAlbum.ReleaseLabel = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text; MessageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); int rowsaffected = sysmgr.Album_Update(theAlbum); EditAlbumID.Text = albumid.ToString(); if (rowsaffected > 0) { AlbumList.DataBind(); } else { throw new Exception("Album was not found. Look up again"); } }, "Successful", "Album Updated"); } } }
//This Method loads the Unit Drop Down List protected void LoadDDLUnits() { MessageUserControl.TryRun(() => { //Populate the Units Dropdown List int yardId = int.Parse(YardID.Text); UnitControllers unitManager = new UnitControllers(); List <YardUnits> unit = unitManager.GetUnits(int.Parse(YardID.Text)); UnitsDDL.DataSource = unit; UnitsDDL.DataTextField = nameof(YardUnits.Number); UnitsDDL.DataValueField = nameof(YardUnits.UnitID); UnitsDDL.DataBind(); UnitsDDL.Items.Insert(0, "Select a Unit..."); }); UnitsDDL.Visible = true; UnitLabel.Visible = true; }
protected void PlayListFetch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(PlayListName.Text)) { MessageUserControl.ShowInfo("Warning", "Playlist name is required."); } else { MessageUserControl.TryRun(() => { string userName = User.Identity.Name; PlayListTrackController sysmgr = new PlayListTrackController(); List <UserPlayListTrack> playList = sysmgr.List_TracksForPlayList(PlayListName.Text, userName); PlayList.DataSource = playList; PlayList.DataBind(); }); } }
protected void DeleteItemBtn_Click(object sender, EventArgs e) { LinkButton cmdBtn = (LinkButton)sender; int shoppingcartitemid = int.Parse(cmdBtn.CommandArgument); MessageUserControl.TryRun(() => { SalesController sysmgr = new SalesController(); sysmgr.DeleteItem(User.Identity.Name, shoppingcartitemid); ShoppingCartListView.DataBind(); ShoppingCartTotal(); DisplayCurrentCartQty(); if (!CheckForItemsInCart()) { checkoutButton.HRef = "~/Sales/PartsCatalog.aspx"; } }, "Removal Successful", "Item has been removed from your cart."); }
protected void SuggestedItems_RowCommand(object sender, GridViewCommandEventArgs e) { if (PurchaseOrderDisplay.Text != "") { if (e.CommandName.Equals("RemoveOrder")) { MessageUserControl.TryRun(() => { int purchaseorderid = int.Parse(PurchaseOrderDisplay.Text); int stockitemid = int.Parse(e.CommandArgument.ToString()); PurchasingController po = new PurchasingController(); po.RemoveFromOrder(purchaseorderid, stockitemid); SuggestedItems.DataBind(); NonSuggestedItems.DataBind(); }, "Item Removed", "Item has been removed from purchase order"); } } }
protected void DisplayOrder_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { var controller = new ReceivingController(); OrderPanel.Enabled = true; OrderPanel.Visible = true; var grvRow = (GridViewRow)((LinkButton)sender).NamingContainer; // Populate vendor information labels PONumLabel.Text = grvRow.Cells[0].Text; Vendor.Text = grvRow.Cells[2].Text; VendorPhone.Text = grvRow.Cells[3].Text; // Populate GridView through a dataSource var orderDetails = controller.GetPurchaseOrderDetails(Convert.ToInt32((grvRow.FindControl("POid") as HiddenField).Value)); PurchaseOrderDetailsGridView.DataSource = orderDetails; PurchaseOrderDetailsGridView.DataBind(); }, "Success", "Order found!"); }
protected void Refresh_Click(object sender, EventArgs e) { MessageUserControl.TryRun(() => { var controller = new SalesController(); var coupon = controller.GetCoupon(CouponTextBox.Text); if (coupon == null) { Discount.Text = "$0.00"; Total.Text = SubTotal.Text; throw new Exception("This coupon doesn't exist. Try again."); } else { Discount.Text = (coupon.CouponDiscount / 100.0 * double.Parse(SubTotal.Text.Substring(1))).ToString("C"); Total.Text = (double.Parse(SubTotal.Text.Substring(1)) - double.Parse(Discount.Text.Substring(1))).ToString("C"); } }, "Refresh", "updated discount"); }
//walk through the listBox row by row // foreach (ListItem item_tableid) in ReservationTableListBox.Items) // { // if (item_tableid.Selected) // { // selectedTables.Add(byte.Parse // (item_tableid.Text.Replace("Table ", ""))); // } // //with all data gathered, connect to your library controller, and send data for // //processing // AdminController sysmgr = new AdminController(); // sysmgr.SeatCustomer (when, reservationid, selectedTables, waiterid); // //refresh the page, get info and refresh the page // SeatingGridView.DataBind(); // ReservationRepeater.DataBind(); //ReservationTableListBox.Items.Clear(); //ReservationTableListBox.DataBind(); // }, "Customer Seated", "Reservation customer has arrived and has been seated;); // } // //} protected bool ShowReservationSeating() { bool anyReservationsToday = false; // call the BLL to indicate if there are any reservations today MessageUserControl.TryRun(()=> { DateTime when = Mocker.MockDate.Add (Mocker.MockTime); AdminController sysmgr = new AdminController(); anyReservationsToday = sysmgr.ReservationsForToday (when); }); return anyReservationsToday; //} }
protected void SeatingGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { MessageUserControl.TryRun(() => { GridViewRow agvrow = SeatingGridView.Rows[e.NewSelectedIndex]; //accessing a web control on the girdview row usings .FindControl("xxx") as datatype string tablenumber = (agvrow.FindControl("TableNumber") as Label).Text; string numberinparty = (agvrow.FindControl("NumberInParty") as TextBox).Text; string waiterid = (agvrow.FindControl("WaiterList") as DropDownList).SelectedValue; var when = Mocker.MockerDate.Add(Mocker.MockerTime); //standard call to insert a record into the database AdminController sysmgr = new AdminController(); sysmgr.SeatCustomer(when, byte.Parse(tablenumber), int.Parse(numberinparty), int.Parse(waiterid)); SeatingGridView.DataBind(); }, "Customer Seated", "New walk-in customer has been saved"); }
protected void RefundButton_Click(object sender, EventArgs e) { SalesController sc = new SalesController(); MessageUserControl.TryRun(() => { RefundInvoiceTextBoxDisplay.Text = sc.Do_RefundTransaction(DumpGridView()).ToString(); }, "Success", "Refund Completed"); TextBox textBox = new TextBox(); foreach (GridViewRow row in InvoiceGridView.Rows) { textBox = (TextBox)row.FindControl("Reason"); textBox.ReadOnly = true; } RefundButton.Enabled = false; }
protected void EquipmentSearchButton_Click(object sender, EventArgs e) { //search for all equipment with the selected description //get by description and throw in listview MessageUserControl.ShowInfo("Search for Equipment: " + EquipmentDescriptionSearch.Text); MessageUserControl.TryRun(() => { RentalController sysmgr = new RentalController(); List <RentalEquipment> results = sysmgr.List_RentalEquipmentByDescriptionSearch(EquipmentDescriptionSearch.Text); if (results.Count() == 0) { MessageUserControl.ShowInfo("No results, check your search criteria"); } AvalibleEquipmentListview.DataSource = results; AvalibleEquipmentListview.DataBind(); }); }