public void UpdateMethodOK() { //create an instance of the class we want to create clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); //create the item of test data clsOrderLine TestItem = new clsOrderLine(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.OrderID = "5"; TestItem.ProductID = "5"; //set ThisOrder to the test data AllOrderLines.ThisOrderLine = TestItem; //add the record PrimaryKey = AllOrderLines.Add(); //set the primary key of the test data TestItem.OrderLineID = PrimaryKey; //modify the test data TestItem.OrderID = "6"; TestItem.ProductID = "6"; //set the record based on the new test data AllOrderLines.ThisOrderLine = TestItem; //update the record AllOrderLines.Update(); //fnd the record AllOrderLines.ThisOrderLine.Find(PrimaryKey); //test to see thisorderline matches the test data Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
public void UpdateMethodOk() { // create instance of class to test clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); // create test data clsOrderLine TestItem = new clsOrderLine(); // primary key var Int32 PrimaryKey = 0; // set properties for test data TestItem.orderID = 1; TestItem.staffID = 1; TestItem.orderComplete = true; // set ThisAddress to the test data AllOrderLines.ThisOrderLine = TestItem; // add the record PrimaryKey = AllOrderLines.Add(); // set primary key of test data TestItem.orderLineID = PrimaryKey; // modify test data TestItem.orderID = 3; TestItem.staffID = 1; TestItem.orderComplete = true; // set record based on new test data AllOrderLines.ThisOrderLine = TestItem; // update the record AllOrderLines.Update(); // find record AllOrderLines.ThisOrderLine.Find(PrimaryKey); // test that ThisOrderLine matches the test data Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
protected void btnOKOrderLine_Click(object sender, EventArgs e) { clsOrderLine AnOrderLine = new clsOrderLine(); string orderID = OrderIDFind.Text; string productID = ProductIDFind.Text; string selectionDescription = SelectionDescriptionFind.Text; string quantity = QuantityList.Text; string Error = ""; Error = AnOrderLine.Valid(orderID, productID, quantity, selectionDescription); if (Error == "") { AnOrderLine.orderID = Convert.ToInt32(OrderIDFind.Text); AnOrderLine.productID = Convert.ToInt32(ProductIDFind.Text); AnOrderLine.selectionDescription = SelectionDescriptionFind.Text; AnOrderLine.quantity = Convert.ToInt32(QuantityList.Text); clsOrderLineCollection OrderLineList = new clsOrderLineCollection(); if (OrderLineID == -1) { OrderLineList.ThisOrderLine = AnOrderLine; OrderLineList.Add(); } else { OrderLineList.ThisOrderLine.Find(OrderLineID); OrderLineList.ThisOrderLine = AnOrderLine; OrderLineList.Update(); } Response.Redirect("OrderLineList.aspx"); } else { Label2.Text = Error; } }
public void UpdateMethodOk() { clsOrderLineCollection AllLines = new clsOrderLineCollection(); clsOrderLine TestItem = new clsOrderLine(); Int32 PrimaryKey = 0; TestItem.OrderLineId = 1; TestItem.OrderId = 1; TestItem.ItemNo = 1; TestItem.ItemDescription = "Test Item"; TestItem.Quantity = 1; TestItem.UnitCost = 15; AllLines.ThisOrderLine = TestItem; PrimaryKey = AllLines.Add(); TestItem.OrderLineId = PrimaryKey; TestItem.OrderId = 2; TestItem.ItemNo = 8; TestItem.ItemDescription = "Test Item 2"; TestItem.Quantity = 2; TestItem.UnitCost = 25; AllLines.ThisOrderLine = TestItem; AllLines.Update(); AllLines.ThisOrderLine.Find(PrimaryKey); Assert.AreEqual(AllLines.ThisOrderLine, TestItem); }
protected void btnOK_Click(object sender, EventArgs e) { //create new instance of the class clsOrderLine AnOrderLine = new clsOrderLine(); string OrderId = txtOrderId.Text; string ProductId = txtProductId.Text; string Price = txtPrice.Text; string Quantity = txtQuantity.Text; //var for error messages string Error = ""; //validate the data Error = AnOrderLine.Valid(ProductId, Price, Quantity); if (Error == "") { //capture the order id AnOrderLine.OrderId = this.OrderID; //capture the product id AnOrderLine.ProductId = ProductId; //capture the price AnOrderLine.Price = Convert.ToDouble(Price); //capture the quantity AnOrderLine.Quantity = Convert.ToInt32(Quantity); //capture available AnOrderLine.Available = chkAvailable.Checked; //store the order in the session object Session["AnOrder"] = AnOrderLine; //navigate to the viewer page Response.Write("OrderLineViewer.aspx"); //create new instance of the order collection clsOrderLineCollection OrderLineList = new clsOrderLineCollection(); if (this.OrderID == -1) { //set the ThisOrder property OrderLineList.ThisOrderLine = AnOrderLine; //add the new record OrderLineList.Add(); }//otherwise it must be an update else { //find the record to update OrderLineList.ThisOrderLine.Find(OrderID); //set the ThisOrder property OrderLineList.ThisOrderLine = AnOrderLine; //update the record OrderLineList.Update(); } //redirect back to the listpage Response.Redirect("OrderLineList.aspx"); } else { //display error message lblError.Text = Error; } }
protected void btnOK_Click(object sender, EventArgs e) { // create new instance clsOrderLine AnOrderLine = new clsOrderLine(); // capture staff id string StaffID = txtStaffID.Text; // capture order id string OrderID = txtOrderID.Text; // Error string string Error = ""; // validate data Error = AnOrderLine.Valid(OrderID, StaffID); if (Error == "") { // capture orderline ID AnOrderLine.orderLineID = OrderLineID; // capture order ID AnOrderLine.orderID = Convert.ToInt32(OrderID); // capture staff ID AnOrderLine.staffID = Convert.ToInt32(StaffID); // capture order Complete AnOrderLine.orderComplete = chkOrderComplete.Checked; // new istance of order line collection clsOrderLineCollection OrderLineList = new clsOrderLineCollection(); // if this is a new record if (OrderLineID == -1) { // set thisOrderLine OrderLineList.ThisOrderLine = AnOrderLine; // add new record OrderLineList.Add(); } // otherwise must be update else { // find record to update OrderLineList.ThisOrderLine.Find(OrderLineID); // set thisOrderLine OrderLineList.ThisOrderLine = AnOrderLine; // update record OrderLineList.Update(); } // redirect to list page Response.Redirect("OrderLineList.aspx"); } else { // display error message lblError.Text = Error; } }
protected void btnOK_Click(object sender, EventArgs e) { clsOrderLine orderLine = new clsOrderLine(); string orderLineId = txtBxOrderLineId.Text; string orderId = txtBxOrderId.Text; string productId = txtBxProductId.Text; string quantity = txtBxQuantity.Text; string error = orderLine.Validate(orderLineId, orderId, productId, quantity); clsOrderLineCollection OrderLineList = new clsOrderLineCollection(); if (error == "") { orderLine.OrderLineId = Convert.ToInt32(orderLineId); orderLine.OrderId = Convert.ToInt32(orderId); orderLine.ProductId = Convert.ToInt32(productId); orderLine.Quantity = Convert.ToInt32(quantity); Session["orderLine"] = orderLine; clsOrderLineCollection orders = new clsOrderLineCollection(); clsOrderLine orderLineTemp = new clsOrderLine { OrderId = Convert.ToInt32(txtBxOrderId.Text), OrderLineId = Convert.ToInt32(txtBxOrderLineId.Text), ProductId = Convert.ToInt32(txtBxProductId.Text), Quantity = Convert.ToInt32(txtBxQuantity.Text), }; if (!orderLineTemp.exists(orderLineTemp.OrderLineId)) { orders.ThisOrderLine = orderLine; orders.Add(); } else { OrderLineList.ThisOrderLine = orderLine; OrderLineList.Update(); } } else { lblError.Text = error; } Response.Redirect("OrderLineViewer.aspx"); }
protected void btnOK_Click(object sender, EventArgs e) { //create a new instance of clsOrderline clsOrderLine anOrderLine = new clsOrderLine(); //capture the equipment ordered string EquipmentOrdered = txtEquipmentOrdered.Text; //capture customer name string CustomerName = txtCustomerName.Text; //capture date ordered string DateProcessed = txtDateProcessed.Text; //store the address in the session object string Error = ""; Error = anOrderLine.Valid(CustomerName, DateProcessed, EquipmentOrdered); if (Error == "") { anOrderLine.OrderNo = OrderNo; anOrderLine.CustomerName = CustomerName; anOrderLine.DateProcessed = Convert.ToDateTime(DateProcessed); anOrderLine.EquipmentOrdered = EquipmentOrdered; anOrderLine.OrderProcessed = chkProcessed.Checked; clsOrderLineCollection OrderLineList = new clsOrderLineCollection(); if (OrderNo == -1) { OrderLineList.ThisOrderLine = anOrderLine; OrderLineList.Add(); } else { OrderLineList.ThisOrderLine.Find(OrderNo); OrderLineList.ThisOrderLine = anOrderLine; OrderLineList.Update(); } Response.Redirect("OrderLineList.aspx"); } else { //display the error message lblError.Text = Error; } }
public void UpdateMethodOK() { clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); clsOrderLine TestItem = new clsOrderLine(); Int32 PrimaryKey = 1; TestItem.orderID = 1; TestItem.selectionDescription = "Jordan Air"; TestItem.productID = 1; TestItem.quantity = 4; AllOrderLines.ThisOrderLine = TestItem; PrimaryKey = AllOrderLines.Add(); TestItem.orderID = 2; TestItem.selectionDescription = "Jordan Air but different"; TestItem.productID = 2; TestItem.quantity = 3; AllOrderLines.ThisOrderLine = TestItem; AllOrderLines.Update(); AllOrderLines.ThisOrderLine.Find(PrimaryKey); Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
protected void btnOk_Click(object sender, EventArgs e) { string Error = ""; clsOrderLine AnOrderLine = new clsOrderLine(); string OrderId = txtOrderId.Text; string ItemNo = txtItemNo.Text; string ItemDescription = txtItemDescription.Text; string Quantity = txtQuantity.Text; string UnitCost = txtUnitCost.Text; Error = AnOrderLine.Valid(OrderId, ItemNo, ItemDescription, Quantity, UnitCost); if (Error == "") { AnOrderLine.OrderLineId = OrderLineId; AnOrderLine.OrderId = Convert.ToInt32(OrderId); AnOrderLine.ItemNo = Convert.ToInt32(ItemNo); AnOrderLine.ItemDescription = ItemDescription; AnOrderLine.Quantity = Convert.ToInt32(Quantity); AnOrderLine.UnitCost = Convert.ToDecimal(UnitCost); clsOrderLineCollection OrderLineList = new clsOrderLineCollection(); if (OrderLineId == -1) { OrderLineList.ThisOrderLine = AnOrderLine; OrderLineList.Add(); } else { OrderLineList.ThisOrderLine.Find(OrderLineId); OrderLineList.ThisOrderLine = AnOrderLine; OrderLineList.Update(); } Response.Redirect("OrderLineList.aspx"); } else { lblError.Text = Error; } }
//function for updating records void Update() { //create an instance of the Order Collection clsOrderLineCollection OrderLineCollection = new clsOrderLineCollection(); //validate the data on the web form Boolean OK = OrderLineCollection.ThisOrderLine.Valid(txtOLOrderID.Text, txtOLProductID.Text); //if the data is ok then add it to the object if (OK == true) { //find the record to update OrderLineCollection.ThisOrderLine.Find(OrderLineID); //get the data entered by the user OrderLineCollection.ThisOrderLine.OrderID = txtOLOrderID.Text; OrderLineCollection.ThisOrderLine.ProductID = txtOLProductID.Text; //update the record OrderLineCollection.Update(); } else { //report an error lblOLError.Text = "There were problems with the data entered"; } }
public void UpdateMethodOK() { //instance of class clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); //create item for test data clsOrderLine TestItem = new clsOrderLine(); //var to store the primary key Int32 PrimaryKey = 0; //set properties TestItem.OrderId = 1; TestItem.ProductId = "123abc"; TestItem.Price = 24.99; TestItem.Quantity = 3; TestItem.Available = true; //set ThisOrder to the test data AllOrderLines.ThisOrderLine = TestItem; //add the record PrimaryKey = AllOrderLines.Add(); //set the primary key of the test data TestItem.OrderId = PrimaryKey; //modify the test data TestItem.OrderId = 2; TestItem.ProductId = "124vbc"; TestItem.Price = 36; TestItem.Quantity = 1; TestItem.Available = false; //set the record based on the new test data AllOrderLines.ThisOrderLine = TestItem; //update the record AllOrderLines.Update(); //find the record AllOrderLines.ThisOrderLine.Find(PrimaryKey); //test if values are the same Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
void Update() { Int32 OrderLineID; OrderLineID = Convert.ToInt32(lstOrderLine.SelectedValue); //create an instance of order collection class clsOrderLineCollection OrderLineCollection = new clsOrderLineCollection(); clsDataConnection DB = new clsDataConnection(); //validate the data on the web form String Error = OrderLineCollection.ThisOrderLine.Valid(txtTrainerID.Text, txtOrderNo.Text, txtQuantity.Text, txtPrice.Text); //if there is no error if (Error == "") { //find the record using primary key to update OrderLineCollection.ThisOrderLine.Find(OrderLineID); //get the data entered by the user OrderLineCollection.ThisOrderLine.TrainerID = Convert.ToInt32(txtTrainerID.Text); //capture orderNo OrderLineCollection.ThisOrderLine.OrderNo = Convert.ToInt32(txtOrderNo.Text); //capture Price OrderLineCollection.ThisOrderLine.Price = Convert.ToInt32(txtPrice.Text); //capture quantity OrderLineCollection.ThisOrderLine.OrderQty = Convert.ToInt32(txtQuantity.Text); //updatethe record OrderLineCollection.Update(); Clear(); lblError.Text = DisplayOrders() + " Orders found"; lblError1.Text = "The order has been updated."; } else { //report an error lblError1.Text = "There were problems with the data entered " + Error; } }//end of edit
public void UpdateMethodOK() { clsOrderLineCollection AllOrderLines = new clsOrderLineCollection(); clsOrderLine TestItem = new clsOrderLine(); Int32 PrimaryKey = 0; TestItem.CustomerName = "Emma Wang"; TestItem.DateProcessed = DateTime.Now.Date; TestItem.EquipmentOrdered = "Weights"; TestItem.TotalCost = 5; TestItem.OrderProcessed = true; AllOrderLines.ThisOrderLine = TestItem; PrimaryKey = AllOrderLines.Add(); TestItem.OrderNo = PrimaryKey; TestItem.CustomerName = "Mark Stone"; TestItem.DateProcessed = DateTime.Now.Date; TestItem.EquipmentOrdered = "Treadmill"; TestItem.TotalCost = 2; TestItem.OrderProcessed = true; AllOrderLines.ThisOrderLine = TestItem; AllOrderLines.Update(); AllOrderLines.ThisOrderLine.Find(PrimaryKey); Assert.AreEqual(AllOrderLines.ThisOrderLine, TestItem); }
public void UpdateMethodOK() { clsOrderLineCollection orderLines = new clsOrderLineCollection(); clsOrderLine orderLine = new clsOrderLine { OrderLineId = 1, OrderId = 3, ProductId = 1, Quantity = 10 }; Int32 primaryKey = 0; orderLines.ThisOrderLine = orderLine; primaryKey = orderLines.Add(); orderLine.OrderLineId = primaryKey; orderLine = new clsOrderLine { OrderLineId = 1, OrderId = 4, ProductId = 2, Quantity = 5 }; orderLines.ThisOrderLine = orderLine; orderLines.Update(); orderLines.ThisOrderLine.find(primaryKey); Assert.AreEqual(orderLines.ThisOrderLine, orderLine); }