Пример #1
0
        public void UpdateMethodOK()
        {
            // create an instance for the class we want to create
            clsOrderlineCollection AllOrderline = new clsOrderlineCollection();

            // create the item of the test data
            clsOrderline TestItem = new clsOrderline();
            // var to store the primary key
            Int32 PrimaryKey = 0;

            // set it properties
            //TestItem.OrderlineId = 2;
            TestItem.OrderId     = 1;
            TestItem.Quantity    = 1;
            TestItem.InventoryId = 1;
            // set thisAdress to the test data
            AllOrderline.ThisOrderline = TestItem;
            // add the record
            PrimaryKey = AllOrderline.Add();
            // set the primary key TestI data
            TestItem.OrderlineId = PrimaryKey;
            // modify the test data
            TestItem.OrderId     = 2;
            TestItem.Quantity    = 2;
            TestItem.InventoryId = 1;
            // set the record based on the new test data
            AllOrderline.ThisOrderline = TestItem;
            // Update the record
            AllOrderline.Update();
            // find the record
            AllOrderline.ThisOrderline.Find(PrimaryKey);
            // test to see that the record was not found
            Assert.AreEqual(AllOrderline.ThisOrderline, TestItem);
        }
Пример #2
0
    protected void Button_OrderLOK_Click(object sender, EventArgs e)
    {
        clsOrderline AnOrderL = new clsOrderline();
        string       ONumber  = TextBox_OrderLONumber.Text;
        string       Quantity = TextBox_OrderLQuantity.Text;
        string       ShoeID   = TextBox_ShoeID.Text;
        string       Error    = "";

        Error = AnOrderL.Valid(ONumber, Quantity, ShoeID);
        if (Error == "")
        {
            AnOrderL.OLineNumber = OLineNumber;
            AnOrderL.ONumber     = Convert.ToInt32(ONumber);
            AnOrderL.Quantity    = Convert.ToInt32(Quantity);
            AnOrderL.ShoeID      = Convert.ToInt32(ShoeID);
            clsOrderlineCollection OrderlineList = new clsOrderlineCollection();

            if (OLineNumber == -1)
            {
                OrderlineList.ThisOrderline = AnOrderL;
                OrderlineList.Add();
            }
            else
            {
                OrderlineList.ThisOrderline.Find(OLineNumber);
                OrderlineList.ThisOrderline = AnOrderL;
                OrderlineList.Update();
            }
            Response.Redirect("OrderlineList.aspx");
        }
        else
        {
            Label_OrderLError.Text = Error;
        }
    }
Пример #3
0
        public void UpdateMethod()
        {
            //create an instance of a class
            clsOrderlineCollection AllOrderline = 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.BookingID = 1;
            TestItem.BookingNo = "CASD4";
            TestItem.Quantity  = 10;
            //set ThisOrderline to the test data
            AllOrderline.ThisOrderline = TestItem;
            //add the record
            PrimaryKey = AllOrderline.Add();
            //set the primary key of the test data
            TestItem.OrderlineID = PrimaryKey;
            //modify the test data
            TestItem.BookingID = 3;
            TestItem.BookingNo = "FGSD7";
            TestItem.Quantity  = 5;
            //set the record based on the new test data
            AllOrderline.ThisOrderline = TestItem;
            //update the record
            AllOrderline.Update();
            //find the record
            AllOrderline.ThisOrderline.Find(PrimaryKey);
            //test to see thisOrderline matches the test data
            Assert.AreEqual(AllOrderline.ThisOrderline, TestItem);
        }
    //function for updating new records
    void Update()
    {
        //create an instance of the Orderline Book
        clsOrderlineCollection OrderlineBook = new clsOrderlineCollection();
        //validate the data on the web form
        string Error = OrderlineBook.ThisOrderline.Valid(txtBookingNo.Text, txtQuantity.Text);

        //if the data is ok then add it to the object
        if (Error == "")
        {
            //find the record to update
            OrderlineBook.ThisOrderline.Find(OrderlineID);
            //get the data entered by the user
            OrderlineBook.ThisOrderline.BookingNo = txtBookingNo.Text;
            OrderlineBook.ThisOrderline.Quantity  = Convert.ToInt32(txtQuantity.Text);
            //update the record
            OrderlineBook.Update();
            //all done so redirect back to the main page
            Response.Redirect("OrderlineList.aspx");
        }
        else
        {
            //report an error
            lblError.Text = "There are problems with the data entered " + Error;
        }
    }
        public void UpdateMethodOK()
        {
            clsOrderlineCollection AllOrderlines = new clsOrderlineCollection();
            clsOrderline           TestItem      = new clsOrderline();
            Int32 PKey = 1;

            TestItem.OLineNumber        = 1;
            TestItem.ONumber            = 1;
            TestItem.Quantity           = 1;
            TestItem.ShoeID             = 1;
            AllOrderlines.ThisOrderline = TestItem;
            PKey = AllOrderlines.Add();
            TestItem.OLineNumber        = PKey;
            TestItem.OLineNumber        = 8;
            TestItem.ONumber            = 3;
            TestItem.Quantity           = 3;
            TestItem.ShoeID             = 2;
            AllOrderlines.ThisOrderline = TestItem;
            AllOrderlines.Update();
            AllOrderlines.ThisOrderline.Find(PKey);
            Assert.AreEqual(AllOrderlines.ThisOrderline, TestItem);
        }