//function for updating records void Update() { //create an instance of the Order Collection clsOrderCollection OrderCollection = new clsOrderCollection(); //validate the data on the web form Boolean OK = OrderCollection.ThisOrder.Valid(txtHouseNo.Text, txtStreet.Text, txtTown.Text, txtPostcode.Text, txtOrderDate.Text); //if the data is ok then add it to the object if (OK == true) { //find the record to update OrderCollection.ThisOrder.Find(OrderID); //get the data entered by the user OrderCollection.ThisOrder.ProductID = Convert.ToInt32(txtProductID.Text); OrderCollection.ThisOrder.ProductSize = txtProductSize.Text; OrderCollection.ThisOrder.Quantity = Convert.ToInt32(txtQuantity.Text); OrderCollection.ThisOrder.HouseNo = txtHouseNo.Text; OrderCollection.ThisOrder.Street = txtStreet.Text; OrderCollection.ThisOrder.Town = txtTown.Text; OrderCollection.ThisOrder.Postcode = txtPostcode.Text; OrderCollection.ThisOrder.StandardDelivery = chkStandardDelivery.Checked; OrderCollection.ThisOrder.NextDayDelivery = chkNextDayDelivery.Checked; OrderCollection.ThisOrder.OrderDate = Convert.ToDateTime(txtOrderDate.Text); //update the record OrderCollection.Update(); } else { //report an error lblError.Text = "There were problems with the data entered"; } }
public void UpdateMethodOK() { clsOrderCollection orders = new clsOrderCollection(); clsOrder testItem = new clsOrder(); testItem.OrderId = 6; testItem.OrderNumber = 2; testItem.OrderName = "Name"; testItem.OrderQuantity = 44; testItem.OrderDate = Convert.ToDateTime("05/18/2020"); testItem.OrderTotal = 400; orders.ThisOrder = testItem; Int32 PrimaryKey = orders.Add(); testItem.OrderId = PrimaryKey; testItem.OrderNumber = 2; testItem.OrderName = "Different Name"; testItem.OrderQuantity = 55; testItem.OrderDate = Convert.ToDateTime("05/18/2020"); testItem.OrderTotal = 300; orders.ThisOrder = testItem; orders.Update(); orders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(orders.ThisOrder, testItem); }
public void Update() { //create an instance of the Inventory Collection clsOrderCollection AllOrders = new clsOrderCollection(); //validate the data on the Windows Form string Error = AllOrders.ThisOrder.Valid(txtEmail.Text, txtTotalPrice.Text, txtDateOrdered.Text, txtShippingAddress.Text, txtPhonenum.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to UPDATE AllOrders.ThisOrder.Find(mOrderId); //get the data entered by the user AllOrders.ThisOrder.Email = txtEmail.Text; AllOrders.ThisOrder.TotalPrice = Convert.ToDecimal(txtTotalPrice.Text); AllOrders.ThisOrder.DateOrdered = Convert.ToDateTime(txtDateOrdered.Text); AllOrders.ThisOrder.ShippingAddress = Convert.ToString(txtShippingAddress.Text); AllOrders.ThisOrder.Phonenum = txtPhonenum.Text; //UPDATE the record AllOrders.Update(); //All done so redirect back to the main page OrderManageForm OM = new OrderManageForm(); this.Hide(); OM.ShowDialog(); this.Close(); } else { lblError.Text = "There were problems with the data entered: " + Error; } }
void Update() { //create an instance of the Orderlog clsOrderCollection OrderLog = new clsOrderCollection(); //validate the date on the web form String Error = OrderLog.ThisOrder.Valid(txtItemName.Text, txtQuantity.Text, txtDate.Text, txtPrice.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to update OrderLog.ThisOrder.Find(OrderID); // recieve data from the user OrderLog.ThisOrder.ItemName = txtItemName.Text; OrderLog.ThisOrder.Quantity = Convert.ToInt32(txtQuantity.Text); OrderLog.ThisOrder.Price = Convert.ToInt32(txtPrice.Text); OrderLog.ThisOrder.Date = txtDate.Text; OrderLog.ThisOrder.Quality = chkNew.Checked = true; OrderLog.ThisOrder.ItemType = ddlItemType.Text; //update the record OrderLog.Update(); //redirect back to the main page Response.Redirect("Order.aspx"); } else { //report an error lblError.Text = "There were problems with the data entry" + Error; } }
public void UpdateMethodOK() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; //test data to update TestItem.StaffId = 349; TestItem.DeliveryAddress = "SA70 8SQ"; TestItem.ItemColour = "Green"; TestItem.ItemPrice = 17; TestItem.OrderPlaced = DateTime.Now.Date; TestItem.ItemDescription = "Single Player"; TestItem.ItemAvailability = true; AllOrders.ThisOrder = TestItem; TestItem.OrderNo = PrimaryKey; //new test data TestItem.StaffId = 350; TestItem.DeliveryAddress = "SA71 8SQ"; TestItem.ItemColour = "Purple"; TestItem.ItemPrice = 20; TestItem.OrderPlaced = DateTime.Now.Date; TestItem.ItemDescription = "Multi Player"; TestItem.ItemAvailability = true; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateMethodOk() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; TestItem.Shipment = true; TestItem.GameTitle = "game1"; //first set of attributes TestItem.TotalPrice = 1; TestItem.DeliveryDate = DateTime.Now.Date; AllOrders.ThisOrder = TestItem; PrimaryKey = AllOrders.Add(); TestItem.orderID = PrimaryKey; TestItem.Shipment = false; TestItem.GameTitle = "game2"; //second set of attributes TestItem.TotalPrice = 2; TestItem.DeliveryDate = DateTime.Now.Date; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem);//check if they are the same }
public void UpdateMethodOK() { //create an instance of the class we want to create clsOrderCollection AllOrders = new clsOrderCollection(); //create the item of test data clsOrder TestItem = new clsOrder(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.OrderNo = 1; TestItem.DeliveryDate = DateTime.Now.Date; TestItem.OrderDate = DateTime.Now.Date; //set ThisCustomer to the test data AllOrders.ThisOrder = TestItem; //add the record PrimaryKey = AllOrders.Add(); //set the primary key of the test data TestItem.OrderNo = PrimaryKey; //modify the test data TestItem.DeliveryDate = DateTime.Now.Date; //set the record based on the new test data AllOrders.ThisOrder = TestItem; //update the record AllOrders.Update(); //find the record AllOrders.ThisOrder.Find(PrimaryKey); //test to see ThisCustomer matches the test data Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
//update the order void Update() { //create an instance of the order clsOrderCollection Orders = new clsOrderCollection(); //validate the data on the web form String Error = Orders.ThisOrder.Valid(txtCustomerID.Text, txtStaffID.Text, txtOrderDate.Text, txtOrderStatus.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to update Orders.ThisOrder.Find(OrderID); //get the data entered by the user Orders.ThisOrder.CustomerID = Convert.ToInt32(txtCustomerID.Text); Orders.ThisOrder.StaffID = Convert.ToInt32(txtStaffID.Text); Orders.ThisOrder.OrderDate = Convert.ToDateTime(txtOrderDate.Text); Orders.ThisOrder.OrderStatus = txtOrderStatus.Text; //update the order Orders.Update(); //redirect to the main page Response.Redirect("OrderList.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered: <br /><br /><br /><br /> " + Error; } }
void Update() { //create an instance of the OrderCollection class clsOrderCollection Orders = new clsOrderCollection(); //validate the data on the web form String Error = Orders.ThisOrder.Valid(txtComputerNo.Text, txtCustomerNo.Text, txtItemName.Text, txtCustomerName.Text, txtInvoice.Text, txtDeliveryDate.Text, txtOrderDate.Text, ddlStatus.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to update Orders.ThisOrder.Find(OrderNo); //get the data entered by the user Orders.ThisOrder.ComputerNo = Convert.ToInt32(txtComputerNo.Text); Orders.ThisOrder.CustomerNo = Convert.ToInt32(txtCustomerNo.Text); Orders.ThisOrder.ItemName = txtItemName.Text; Orders.ThisOrder.CustomerName = txtCustomerName.Text; Orders.ThisOrder.Invoice = Convert.ToInt32(txtInvoice.Text); Orders.ThisOrder.DeliveryDate = Convert.ToDateTime(txtDeliveryDate.Text); Orders.ThisOrder.OrderDate = Convert.ToDateTime(txtOrderDate.Text); Orders.ThisOrder.Status = ddlStatus.Text; //update the new record Orders.Update(); //all done so redirect back to the main page Response.Redirect("Order.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
public void UpdateMethodOK() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; TestItem.Delivered = true; TestItem.CustomerId = 1; TestItem.OrderPrice = 1; TestItem.DateReceived = DateTime.Now.Date; TestItem.Description = "Blue Shirt"; TestItem.Quantity = 1; AllOrders.ThisOrder = TestItem; PrimaryKey = AllOrders.Add(); TestItem.OrderId = PrimaryKey; TestItem.Delivered = false; TestItem.CustomerId = 2; TestItem.OrderPrice = 2; TestItem.DateReceived = DateTime.Now.Date; TestItem.Description = "Pink Shirt"; TestItem.Quantity = 2; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
//function for updating records void Update() { // create an instance of the class clsOrderCollection OrderBook = new clsOrderCollection(); // validate the data on the web form String Error = OrderBook.ThisOrder.Valid(txtFirstPrice.Text, txtSecondPrice.Text, txtThirdPrice.Text, txtOrderTotal.Text); // if the data is OK then add it to the object if (Error == "") { // find the record to update OrderBook.ThisOrder.Find(OrderNo); // get the data entered by the user OrderBook.ThisOrder.FirstChoice = Convert.ToInt32(ddlFirstChoice.SelectedValue); OrderBook.ThisOrder.SecondChoice = Convert.ToInt32(ddlSecondChoice.SelectedValue); OrderBook.ThisOrder.ThirdChoice = Convert.ToInt32(ddlThirdChoice.SelectedValue); OrderBook.ThisOrder.FirstPrice = Convert.ToInt32(txtFirstPrice.Text); OrderBook.ThisOrder.SecondPrice = Convert.ToInt32(txtSecondPrice.Text); OrderBook.ThisOrder.ThirdPrice = Convert.ToInt32(txtThirdPrice.Text); OrderBook.ThisOrder.OrderTotal = Convert.ToInt32(txtOrderTotal.Text); // update the record OrderBook.Update(); //all done so redirect back to the main page Response.Redirect("OrderDefault.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
public void UpdateMethodOK() { //instance of class clsOrderCollection AllOrders = new clsOrderCollection(); //create item for test data clsOrder TestItem = new clsOrder(); //var to store the primary key Int32 PrimaryKey = 0; //set properties TestItem.OrderId = 1; TestItem.ShippingMethod = "sameday"; TestItem.DateOrdered = DateTime.Now.Date; TestItem.Dispatched = true; //set ThisOrder to the test data AllOrders.ThisOrder = TestItem; //add the record PrimaryKey = AllOrders.Add(); //set the primary key of the test data TestItem.OrderId = PrimaryKey; //modify the test data TestItem.OrderId = 3; TestItem.ShippingMethod = "nextday"; TestItem.DateOrdered = DateTime.Now.Date; TestItem.Dispatched = false; //set the record based on the new test data AllOrders.ThisOrder = TestItem; //update the record AllOrders.Update(); //find the record AllOrders.ThisOrder.Find(PrimaryKey); //test if values are the same Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateMethodOK() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; TestItem.Payed = true; TestItem.OrderNumber = 1; TestItem.OrderPrice = 10; TestItem.ItemCount = 2; TestItem.Address = "ankara"; TestItem.Date = DateTime.Now.Date; AllOrders.ThisOrder = TestItem; PrimaryKey = AllOrders.Add(); TestItem.OrderNumber = PrimaryKey; TestItem.Payed = true; TestItem.OrderNumber = 1; TestItem.OrderPrice = 10; TestItem.ItemCount = 2; TestItem.Address = "ankara"; TestItem.Date = DateTime.Now.Date; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpddateMethodOK() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; //test data to update TestItem.CustomerNo = 10; TestItem.CustomerAddress = "45 Linton Street"; TestItem.ItemColour = "white"; TestItem.ItemPrice = 19; TestItem.OrderDate = DateTime.Now.Date; TestItem.ProductDescription = "white shirt"; TestItem.StaffID = 15; TestItem.Availability = true; AllOrders.ThisOrder = TestItem; TestItem.OrderID = PrimaryKey; //new test data TestItem.CustomerNo = 12; TestItem.CustomerAddress = "36 Linton Street"; TestItem.ItemColour = "white"; TestItem.ItemPrice = 21; TestItem.OrderDate = DateTime.Now.Date; TestItem.ProductDescription = "white shirt"; TestItem.StaffID = 18; TestItem.Availability = true; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateMethodOK() { clsOrderCollection AllOrder = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; TestItem.BookName = "The Good Times"; TestItem.Quantity = 2; TestItem.OrderDate = DateTime.Now.Date; TestItem.Price = 20; TestItem.Dispatched = true; AllOrder.ThisOrder = TestItem; PrimaryKey = AllOrder.Add(); TestItem.OrderNo = PrimaryKey; TestItem.BookName = "In The Name Of 2020"; TestItem.Quantity = 1; TestItem.OrderDate = DateTime.Now.Date; TestItem.Price = 10; TestItem.Dispatched = false; AllOrder.ThisOrder = TestItem; AllOrder.Update(); AllOrder.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrder.ThisOrder, TestItem); }
public void UpdateMethodOK() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; TestItem.CustomerID = 1; TestItem.ShippingAddress = "AddressTest"; TestItem.OrderDate = DateTime.Now.Date; TestItem.OrderShipped = true; AllOrders.ThisOrder = TestItem; PrimaryKey = AllOrders.Add(); TestItem.OrderID = PrimaryKey; TestItem.CustomerID = 2; TestItem.ShippingAddress = "AddressTest2Edited"; TestItem.OrderDate = DateTime.Now.Date; TestItem.OrderShipped = false; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateMethodOK() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; TestItem.ItemAvailable = true; TestItem.OrderID = 1234; TestItem.TotalItem = 10; TestItem.TotalPrice = 15.55; TestItem.DeliveryAddress = "1, A Street, LE1 5AB, Leicester"; TestItem.DateOrdered = DateTime.Now.Date; AllOrders.ThisOrder = TestItem; PrimaryKey = AllOrders.Add(); TestItem.OrderID = PrimaryKey; TestItem.ItemAvailable = false; TestItem.OrderID = 4567; TestItem.TotalItem = 15; TestItem.TotalPrice = 17.99; TestItem.DeliveryAddress = "2, B Street, LE1 5AB, Leicester"; TestItem.DateOrdered = DateTime.Now.Date; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateMethodOK() { //create an instance of the class we want to create clsOrderCollection AllOrders = new clsOrderCollection(); //create the item of test Customer clsOrder TestItem = new clsOrder(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties of the test Customer object TestItem.OrderId = 2; TestItem.ShippingAddress = "99 Granby Street, Leicester, UK"; TestItem.Phonenum = "1111111111111111"; TestItem.Email = "*****@*****.**"; TestItem.DateOrdered = DateTime.Now.Date; //assign the data to the property AllOrders.ThisOrder = TestItem; //add the record PrimaryKey = AllOrders.Add(); //set the primary key of the test data TestItem.OrderId = PrimaryKey; //modify the test data TestItem.ShippingAddress = "102 Jaguar Lane, London"; TestItem.Phonenum = "1111111111111111"; TestItem.Email = "*****@*****.**"; TestItem.DateOrdered = DateTime.Now.Date; //set the record based on the new test data AllOrders.ThisOrder = TestItem; //update the record AllOrders.Update(); //find the record AllOrders.ThisOrder.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateMethodOK() { clsOrderCollection AllOrder = new clsOrderCollection(); clsOrders TestItem = new clsOrders(); Int32 PrimaryKey = 0; TestItem.OrderId = 89; TestItem.DeliveryAddress = "An Address"; TestItem.DispatchedStatus = true; TestItem.UnitPrice = 5.99; TestItem.Quantity = 2; TestItem.OrderDate = DateTime.Now.Date; TestItem.ProductCode = "ABC1234"; TestItem.ItemId = 1; AllOrder.ThisOrder = TestItem; PrimaryKey = AllOrder.Add(); TestItem.OrderId = PrimaryKey; TestItem.DeliveryAddress = "A new Address"; TestItem.DispatchedStatus = false; TestItem.UnitPrice = 6.99; TestItem.Quantity = 5; TestItem.OrderDate = DateTime.Now.Date; TestItem.ProductCode = "ABC1245"; TestItem.ItemId = 1; AllOrder.ThisOrder = TestItem; AllOrder.Update(); AllOrder.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrder.ThisOrder, TestItem); }
public void UpdateMethodOK() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; TestItem.customerID = 3; TestItem.dateOrdered = DateTime.Now.Date; TestItem.deliveryAddress = "Ellistown, Amazon BHX2, LE16 1GQ"; TestItem.paid = true; TestItem.staffID = 4; TestItem.totalPrice = 15.00; AllOrders.ThisOrder = TestItem; PrimaryKey = AllOrders.Add(); TestItem.orderID = PrimaryKey; TestItem.customerID = 4; TestItem.dateOrdered = DateTime.Now.Date; TestItem.deliveryAddress = "Another Address, not Amazon"; TestItem.paid = false; TestItem.staffID = 6; TestItem.totalPrice = 18.15; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateMethodOk() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder TestItem = new clsOrder(); Int32 PrimaryKey = 0; TestItem.OrderDate = DateTime.Now.Date; TestItem.OrderTotal = 200; TestItem.CustomerId = 5; TestItem.StaffId = 2; TestItem.OrderStatus = true; TestItem.OrderProgress = "test"; AllOrders.ThisOrder = TestItem; PrimaryKey = AllOrders.Add(); TestItem.OrderId = PrimaryKey; TestItem.OrderDate = DateTime.Now.Date; TestItem.OrderTotal = 250; TestItem.CustomerId = 5; TestItem.StaffId = 1; TestItem.OrderStatus = false; TestItem.OrderProgress = "test"; AllOrders.ThisOrder = TestItem; AllOrders.Update(); AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateOK() { clsOrderCollection col = new clsOrderCollection(); clsDataConnection db = new clsDataConnection(); clsOrder order = new clsOrder(); order.Product_Id = 1; order.Customer_Id = 1; order.Date_Ordered = DateTime.Today; order.Dispatch = true; order.Order_Quantity = 4; order.Product_Name = "Gym gloves"; col.mthisorder = order; col.Add(); int key = order.Product_Id; clsOrder test = new clsOrder(); test.Product_Id = key; test.Customer_Id = 2; test.Date_Ordered = DateTime.Today; test.Dispatch = false; test.Product_Name = "boxes"; test.Order_Quantity = 5; col.mthisorder = test; col.Update(); Assert.AreEqual(test.find(key), true); }
public void UpdateMethodOK() { //create intance of class to create clsOrderCollection AllOrders = new clsOrderCollection(); //create test data to assign to the property clsOrder TestItem = new clsOrder(); //var to store primary key Int32 PrimaryKey = 0; //set properties TestItem.DateOrdered = DateTime.Now.Date; TestItem.ProductName = "Logitech M220 Silent Wireless Mouse "; TestItem.QuantityNo = 3; TestItem.OrderPrice = 50; //set thisorder to test data AllOrders.ThisOrder = TestItem; //add record PrimaryKey = AllOrders.Add(); //set primary key of the test data TestItem.OrderNo = PrimaryKey; //MODIFY TEST DATA TestItem.DateOrdered = DateTime.Now.Date; TestItem.ProductName = "Logitech 11 Wireless Mouse "; TestItem.QuantityNo = 2; TestItem.OrderPrice = 20; AllOrders.ThisOrder = TestItem; //UPDATE RECORD AllOrders.Update(); //find the record AllOrders.ThisOrder.Find(PrimaryKey); //test to see the values are the same Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
protected void btnOK_Click(object sender, EventArgs e) { //create an instance of the class clsOrder AnOrder = new clsOrder(); //create a set of string variables string cID = txtCustomerId.Text; string cAddress = txtCustomerAddress.Text; string itemName = txtItemName.Text; string dateDispatch = txtDispatchDate.Text; string itemQuantity = txtItemQuantity.Text; string Error = ""; Error = AnOrder.Valid(cID, cAddress, dateDispatch, itemName, itemQuantity); if (Error == "") { //capture OrderId AnOrder.OrderId = OrderId; //capture CustomerId AnOrder.CustomerId = Convert.ToInt32(cID); //Capture the address AnOrder.Address = cAddress; //capture the item name AnOrder.ItemName = itemName; //capture the item quantity AnOrder.ItemQuantity = Convert.ToInt32(itemQuantity); //capture the date for dispatch AnOrder.DateDispatch = Convert.ToDateTime(dateDispatch); //capture the order made AnOrder.Made = chkActive.Checked; //create a new instance of the order collection clsOrderCollection OrderList = new clsOrderCollection(); //if this is a new record then add the data if (OrderId != -1) { //set the ThisOrder property OrderList.ThisOrder = AnOrder; //add the new record OrderList.Add(); } //otherwsie it has to be an update else { //fidn the property OrderList.ThisOrder.Find(OrderId); //set the ThisOrder property OrderList.ThisOrder = AnOrder; //update the record OrderList.Update(); } Response.Redirect("OrderList.aspx"); } else { //display the error message lblError.Text = Error; } }
protected void BtnOK_Click1(object sender, EventArgs e) { //create a new instance of clsOrder clsOrder AnOrder = new clsOrder(); //capture the order id string OrderId = txtOrderId.Text; //capture the shipping method string ShippingMethod = txtShippingMethod.Text; //capture the date string DateOrdered = txtDateOrdered.Text; //var for error messages string Error = ""; //validate the data Error = AnOrder.Valid(ShippingMethod, DateOrdered); if (Error == "") { //capture the order id AnOrder.OrderId = this.OrderID; //capture the shipping method AnOrder.ShippingMethod = ShippingMethod; //capture the date AnOrder.DateOrdered = Convert.ToDateTime(DateOrdered); //capture dispatched AnOrder.Dispatched = chkDispatched.Checked; //store the order in the session object //Session["AnOrder"] = AnOrder; //navigate to the viewer page //Response.Write("OrdersViewer.aspx"); //create new instance of the order collection clsOrderCollection OrderList = new clsOrderCollection(); if (this.OrderID == -1) { //set the ThisOrder property OrderList.ThisOrder = AnOrder; //add the new record OrderList.Add(); }//otherwise it must be an update else { //find the record to update OrderList.ThisOrder.Find(OrderID); //set the ThisOrder property OrderList.ThisOrder = AnOrder; //update the record OrderList.Update(); } //redirect back to the listpage Response.Redirect("OrderList.aspx"); } else { //display error message Label1.Text = Error; } }
protected void OkBtn_Click(object sender, EventArgs e) { clsOrder AnOrder = new clsOrder(); string NumberPlate = txtNumberPlate.Text; string CustomerID = txtCustID.Text; string Quantity = txtQuantity.Text; string DateOrdered = txtOrderDate.Text; string Price = txtPrice.Text; string Error = ""; Error = AnOrder.Valid(DateOrdered, NumberPlate, CustomerID, Quantity, Price); if (Error == "") { // capture order id AnOrder.orderID = Convert.ToInt32(OrderID); // capture number plate AnOrder.numberPlate = NumberPlate; // capture customer id AnOrder.customerID = Convert.ToInt32(CustomerID); // capture quantity AnOrder.quantity = Convert.ToInt32(Quantity); // capture order date AnOrder.dateOrdered = Convert.ToDateTime(DateOrdered); // capture price AnOrder.price = Convert.ToDouble(Price); // new instance of order collection clsOrderCollection OrderList = new clsOrderCollection(); // if this is a new record if (Convert.ToInt32(OrderID) == -1) { OrderList.ThisOrder = AnOrder; // add new record OrderList.Add(); } // otherwise update else { // find record to update OrderList.ThisOrder.Find(Convert.ToInt32(OrderID)); // set the this address property OrderList.ThisOrder = AnOrder; // update record OrderList.Update(); } // redirect to list page Response.Redirect("OrderList.aspx"); } else { // display error lblError.Text = Error; } }
protected void btnAccept_Click(object sender, EventArgs e) { clsOrders AnOrder = new clsOrders(); int OrderId = Convert.ToInt32(txtOrderId.Text); int ItemId = Convert.ToInt32(txtItemId.Text); DateTime OrderDate = Convert.ToDateTime(txtOrderDate.Text); string DeliveryAddress = txtDeliveryAddress.Text; Double UnitPrice = Convert.ToDouble(txtUnitPrice.Text); int Quantity = Convert.ToInt32(txtQuantity.Text); string ProductCode = txtProductCode.Text; bool DispatchedStatus = chkDispatched.Checked; string Error = ""; Error = AnOrder.Valid(OrderId, ItemId, OrderDate, DeliveryAddress, DispatchedStatus, UnitPrice, Quantity, ProductCode); if (Error == "") { AnOrder.OrderId = OrderId; AnOrder.ItemId = ItemId; AnOrder.OrderDate = Convert.ToDateTime(OrderDate); AnOrder.DeliveryAddress = DeliveryAddress; AnOrder.UnitPrice = UnitPrice; AnOrder.Quantity = Quantity; AnOrder.ProductCode = ProductCode; AnOrder.DispatchedStatus = DispatchedStatus; clsOrderCollection OrdersList = new clsOrderCollection(); if (OrderId == -1) { OrdersList.ThisOrder = AnOrder; OrdersList.Add(); } else { OrdersList.ThisOrder.Find(OrderId); OrdersList.ThisOrder = AnOrder; OrdersList.Update(); } Response.Redirect("OrdersList.aspx"); } else { lblError.Text = Error; } }
protected void btnOK_Click(object sender, EventArgs e) { clsOrder AOrder = new clsOrder(); string OrderID = txtOrderID.Text; string CustomerNo = txtCustomerNo.Text; string CustomerAddress = txtCustomerAddress.Text; string ItemColour = txtItemColour.Text; string ItemPrice = txtItemPrice.Text; string OrderDate = txtOrderDate.Text; string ProductDescription = txtProductDescription.Text; string StaffID = txtStaffID.Text; string Error = ""; Error = AOrder.Valid(OrderID, CustomerNo, CustomerAddress, OrderDate, ItemPrice, ItemColour, ProductDescription, StaffID); if (Error == "") { AOrder.OrderID = Convert.ToInt32(OrderID); AOrder.CustomerNo = Convert.ToInt32(CustomerNo); AOrder.CustomerAddress = txtCustomerAddress.Text; AOrder.ItemColour = txtItemColour.Text; AOrder.ItemPrice = Convert.ToDecimal(ItemPrice); AOrder.OrderDate = Convert.ToDateTime(OrderDate); AOrder.ProductDescription = txtProductDescription.Text; AOrder.Availability = chkAvailability.Checked; AOrder.StaffID = Convert.ToInt32(StaffID); clsOrderCollection OrderList = new clsOrderCollection(); if (this.OrderID == -1) { OrderList.ThisOrder = AOrder; OrderList.Add(); } else { OrderList.ThisOrder.Find(Convert.ToInt32(OrderID)); OrderList.ThisOrder = AOrder; OrderList.Update(); } Response.Redirect("OrderList.aspx"); } else { //display error message lblError.Text = Error; } }
public void UpdateMethodOK() { //create an instance of the class we want to create clsOrderCollection AllOrders = new clsOrderCollection(); //create the item of test data clsOrder TestItem = new clsOrder(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.ProductID = 5; TestItem.ProductSize = "5"; TestItem.Quantity = 5; TestItem.HouseNo = "5"; TestItem.Street = "TestStreet"; TestItem.Town = "TestTown"; TestItem.Postcode = "xxx xxx"; TestItem.StandardDelivery = true; TestItem.NextDayDelivery = false; TestItem.OrderDate = DateTime.Now.Date; //set ThisOrder to the test data AllOrders.ThisOrder = TestItem; //add the record PrimaryKey = AllOrders.Add(); //set the primary key of the test data TestItem.OrderID = PrimaryKey; //modify the test data TestItem.ProductID = 6; TestItem.ProductSize = "6"; TestItem.Quantity = 6; TestItem.HouseNo = "6"; TestItem.Street = "TestStreet2"; TestItem.Town = "TestTown2"; TestItem.Postcode = "xxx xxp"; TestItem.StandardDelivery = false; TestItem.NextDayDelivery = true; TestItem.OrderDate = DateTime.Now.Date; //set the record based on the new test data AllOrders.ThisOrder = TestItem; //update the record AllOrders.Update(); //find the record AllOrders.ThisOrder.Find(PrimaryKey); //test to see ThisOrder matches the test data Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
protected void btnOK_Click(object sender, EventArgs e) { clsOrder Order = new clsOrder(); string ProductName = txtProductName.Text; string ProductNo = txtProductNo.Text; //capture the StaffID string OrderNo = txtOrderNo.Text; //capture the Batch number string Price = txtPrice.Text; string Date = txtDate.Text; //string Dispatched = txtDispatched.Text; // varlable to store any error messages string Error = ""; //validate the data Error = Order.Valid(ProductNo, ProductName, OrderNo, Price, Date); if (Error == "") { Order.ProductName = txtProductName.Text; Order.ProductNo = Convert.ToInt32(txtProductNo.Text); Order.OrderNo = Convert.ToInt32(txtOrderNo.Text); Order.Price = Convert.ToChar(txtPrice.Text); Order.Date = Convert.ToDateTime(txtDate.Text); //Order.Dispatched = chkDispatched.Checked; Order.ProductName = txtProductName.Text; clsOrderCollection OrderList = new clsOrderCollection(); if (OrderID == -1) { OrderList.ThisOrder = Order; OrderList.Add(); } else { OrderList.ThisOrder.Find(OrderID); OrderList.ThisOrder = Order; OrderList.Update(); } Response.Redirect("OrderList.aspx"); lblError.Text = Error; } }