public void UpdateMethodOK() { //create an instance of the class clsMenuItemCollection AllMenuItems = new clsMenuItemCollection(); // create some test data to assign to the property clsMenuItem TestItem = new clsMenuItem(); // var to store the primary key Int32 PrimaryKey = 0; // set the properties of the test object TestItem.MenuItem = "Grapes"; TestItem.MenuItemPrice = 4; // set this menu item to the test data AllMenuItems.ThisMenuItem = TestItem; // add the record PrimaryKey = AllMenuItems.Add(); // set the primary key of the test data TestItem.MenuItemNo = PrimaryKey; // modify the test data TestItem.MenuItem = "Qiwi"; TestItem.MenuItemPrice = 2; // set the record based on the new test data AllMenuItems.ThisMenuItem = TestItem; // update the record AllMenuItems.Update(); // find the record AllMenuItems.ThisMenuItem.Find(PrimaryKey); // test to see that the two values are the same Assert.AreEqual(AllMenuItems.ThisMenuItem, TestItem); }
//function for update void Update() { //create an instance of the menu item book clsMenuItemCollection MenuItemBook = new clsMenuItemCollection(); //validate the data on the web form String Error = MenuItemBook.ThisMenuItem.Valid(txtMenuItem.Text, txtPrice.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to update MenuItemBook.ThisMenuItem.Find(MenuItemNo); // get the data entered by the user MenuItemBook.ThisMenuItem.MenuItem = txtMenuItem.Text; MenuItemBook.ThisMenuItem.MenuItemPrice = Convert.ToInt32(txtPrice.Text); //update the record MenuItemBook.Update(); // redirect back to the main page Response.Redirect("MenuDefault.aspx"); } else { // report an error lblError.Text = "There were too many problems with the data entered " + Error; } }
public void DeleteMethodOK() { //create an instance of the class clsMenuItemCollection AllMenuItems = new clsMenuItemCollection(); // create some test data to assign to the property clsMenuItem TestItem = new clsMenuItem(); // var to store the primary key Int32 PrimaryKey = 0; // set the properties of the test object TestItem.MenuItemNo = 1; TestItem.MenuItem = "Grapes"; TestItem.MenuItemPrice = 4; // set this menu item to the test data AllMenuItems.ThisMenuItem = TestItem; // add the record PrimaryKey = AllMenuItems.Add(); // set the primary key of the test data TestItem.MenuItemNo = PrimaryKey; // find the record AllMenuItems.ThisMenuItem.Find(PrimaryKey); // delete the record AllMenuItems.Delete(); // now find the record Boolean Found = AllMenuItems.ThisMenuItem.Find(PrimaryKey); // test to see that the two values are the same Assert.IsFalse(Found); }
public void InstanceOK() { //create an instance of the class clsMenuItemCollection AllMenuItems = new clsMenuItemCollection(); //test to see that it exists Assert.IsNotNull(AllMenuItems); }
//function to delete the selected record void Delete() { // create a new instance of the menu book clsMenuItemCollection MenuItemBook = new clsMenuItemCollection(); // find the record to delete MenuItemBook.ThisMenuItem.Find(MenuItemNo); // delete the record MenuItemBook.Delete(); }
//function for populating the county drop down list void DisplayMenuItem() { //create an instance of the address book clsMenuItemCollection MenuItemBook = new clsMenuItemCollection(); //find the record to update MenuItemBook.ThisMenuItem.Find(MenuItemNo); //display the data for this record txtMenuItem.Text = MenuItemBook.ThisMenuItem.MenuItem; txtPrice.Text = MenuItemBook.ThisMenuItem.MenuItemPrice.ToString(); }
// function to filter records in the list Int32 DisplayMenuItems(string MenuItemFilter) { // create an instance of menu item book clsMenuItemCollection MyMenuItemBook = new clsMenuItemCollection(); // var for record count Int32 RecordCount; // var for menu item string MenuItem; // var for menu item price string MenuItemPrice; // var for menu item no string MenuItemNo; // var for index to start at 0 Int32 Index = 0; // clear the list box lstMenuItems.Items.Clear(); // call the filter by menu item method MyMenuItemBook.ReportByMenuItem(MenuItemFilter); // store the count of records found RecordCount = MyMenuItemBook.Count; // while index is less than record count //loop through each record found using the index to point to each //record in the data table while (Index < RecordCount) { // get the menu item from the query results MenuItem = Convert.ToString(MyMenuItemBook.AllMenuItems[Index].MenuItem); // get the menu item price from the query results MenuItemPrice = Convert.ToString(MyMenuItemBook.AllMenuItems[Index].MenuItemPrice); // get the menu item no from the query results MenuItemNo = Convert.ToString(MyMenuItemBook.AllMenuItems[Index].MenuItemNo); //set up a new object of class list item ListItem NewItem = new ListItem(MenuItem + " ", MenuItemNo); //add the new item to the list lstMenuItems.Items.Add(NewItem); // increment the index Index++; } //return the number of records found return(RecordCount); //clsMenuItemCollection MenuItems = new clsMenuItemCollection(); //lstMenuItems.DataSource = MenuItems.AllMenuItems; //lstMenuItems.DataValueField = "MenuItemNo"; //lstMenuItems.DataTextField = "MenuItem"; //// bind the data to the list //lstMenuItems.DataBind(); }
public void ThisMenuItemPropertyOK() { //create an instance of the class clsMenuItemCollection AllMenuItems = new clsMenuItemCollection(); // create some test data to assign to the property clsMenuItem TestMenuItem = new clsMenuItem(); // set the properties of the test object TestMenuItem.MenuItemNo = 1; TestMenuItem.MenuItem = "Grapes"; TestMenuItem.MenuItemPrice = 4; // add the item to the test list AllMenuItems.ThisMenuItem = TestMenuItem; // test to see that the two values are the same Assert.AreEqual(AllMenuItems.ThisMenuItem, TestMenuItem); }
// function for retrieve prices void RetrievePrices() { clsOrderCollection OrderBook = new clsOrderCollection(); clsMenuItemCollection MenuBook = new clsMenuItemCollection(); int currentFirstChoice = Convert.ToInt32(ddlFirstChoice.SelectedValue); // Stores the MenuItemID int currentSecondChoice = Convert.ToInt32(ddlSecondChoice.SelectedValue); int currentThirdChoice = Convert.ToInt32(ddlThirdChoice.SelectedValue); int currentFirstPrice = MenuBook.ThisMenuItem.MenuItemNo; int currentSecondPrice = MenuBook.ThisMenuItem.MenuItemNo; int currentThirdPrice = MenuBook.ThisMenuItem.MenuItemNo; if (currentFirstChoice == MenuBook.ThisMenuItem.MenuItemNo) //if (currentFirstChoice == currentFirstPrice) { //GetMenuItemPrices(); currentFirstChoice = MenuBook.ThisMenuItem.MenuItemPrice; //currentFirstChoice = currentFirstPrice; } if (currentSecondChoice == MenuBook.ThisMenuItem.MenuItemNo) { //GetMenuItemPrices(); currentSecondChoice = MenuBook.ThisMenuItem.MenuItemPrice; } if (currentThirdChoice == MenuBook.ThisMenuItem.MenuItemNo) { //GetMenuItemPrices(); currentThirdChoice = MenuBook.ThisMenuItem.MenuItemPrice; } else { } // store the current first choice into the price text boxes txtFirstPrice.Text = currentFirstChoice.ToString(); txtSecondPrice.Text = currentSecondChoice.ToString(); txtThirdPrice.Text = currentThirdChoice.ToString(); }
//function for populating the menu items drop down list void DisplayMenuItems() { clsMenuItemCollection MenuItems = new clsMenuItemCollection(); // set the primary key to the list of menu items in the collection ddlFirstChoice.DataSource = MenuItems.AllMenuItems; ddlSecondChoice.DataSource = MenuItems.AllMenuItems; ddlThirdChoice.DataSource = MenuItems.AllMenuItems; // set the name of the primary key ddlFirstChoice.DataValueField = "MenuItemNo"; ddlSecondChoice.DataValueField = "MenuItemNo"; ddlThirdChoice.DataValueField = "MenuItemNo"; // set the data value field to display ddlFirstChoice.DataTextField = "MenuItem"; ddlSecondChoice.DataTextField = "MenuItem"; ddlThirdChoice.DataTextField = "MenuItem"; // bind the data to the list ddlFirstChoice.DataBind(); ddlSecondChoice.DataBind(); ddlThirdChoice.DataBind(); }
public void CountMatchesListOK() { //create an instance of the class clsMenuItemCollection MenuItems = new clsMenuItemCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsMenuItem> TestList = new List <clsMenuItem>(); //add an item to the list //create the item of test data clsMenuItem TestItem = new clsMenuItem(); // set its properties TestItem.MenuItemNo = 1; TestItem.MenuItem = "Grapes"; TestItem.MenuItemPrice = 4; // add the item to the test list TestList.Add(TestItem); // assign the data to the property MenuItems.AllMenuItems = TestList; // test to see that the two values are the same Assert.AreEqual(MenuItems.Count, TestList.Count); }