public void UpdateMethodStockOK() { ClsStockCollection AllAddresses = new ClsStockCollection(); ClsStock TestItem = new ClsStock(); Int32 PrimaryKey = 0; TestItem.ShoeID = 1; TestItem.Name = "AirForce"; TestItem.Release = DateTime.Now.Date; TestItem.QuantityStock = 1; TestItem.PriceStock = 1; TestItem.Size = 1; AllAddresses.ThisStock = TestItem; PrimaryKey = AllAddresses.Add(); TestItem.ShoeID = PrimaryKey; TestItem.ShoeID = 4; TestItem.Name = "AirForce1"; TestItem.Release = DateTime.Now.Date; TestItem.QuantityStock = 4; TestItem.PriceStock = 4; TestItem.Size = 4; AllAddresses.ThisStock = TestItem; AllAddresses.Update(); AllAddresses.ThisStock.Find(PrimaryKey); Assert.AreEqual(AllAddresses.ThisAddressList, TestItem); }
protected void Button1_Click(object sender, EventArgs e) { ClsStock Stock = new ClsStock(); //ShoeID = Convert.ToInt16(TextBox5.Text), //Name = TextBox1.Text, string Name = TextBox1.Text; //Release = Convert.ToDateTime(TextBox2.Text), string Release = Convert.ToString(TextBox2.Text); //QuantityStock = Convert.ToInt16(TextBox6.Text), string QuantityStock = Convert.ToString(TextBox4.Text); //PriceStock = Convert.ToInt16(TextBox4.Text), string PriceStock = Convert.ToString(TextBox4.Text); //Size = Convert.ToInt16(DropDownList1.Text) string Size = Convert.ToString(DropDownList1.Text); string Error = ""; Error = Stock.Valid(Name, Release, QuantityStock, PriceStock, Size); if (Error == "") { Stock.Name = Name; Stock.Release = Convert.ToDateTime(Release); Stock.QuantityStock = Convert.ToInt32(QuantityStock); Stock.PriceStock = Convert.ToInt32(PriceStock); Stock.Size = Convert.ToInt32(Size); TrainerTesting.ClsStockCollection StockList = new TrainerTesting.ClsStockCollection(); Int32 ShoeID = 0; if (ShoeID == -1) { StockList.ThisStock = ShoeID; StockList.Add(); } else { StockList.ThisStock.Find(ShoeID); StockList.ThisStock = ShoeID; StockList.Update(); } StockList.ThisStock = Stock; StockList.Add(); //Session["Stock"] = Stock; Response.Redirect("Stock.aspx"); } else { //lblError.Text = Error; } }