Exemplo n.º 1
0
        public void AddMethodOK()
        {
            // 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;
            // find the record
            AllOrderline.ThisOrderline.Find(PrimaryKey);

            // test to see that the two values are the same
            Assert.AreEqual(AllOrderline.ThisOrderline, TestItem);
        }
Exemplo n.º 2
0
        public void DeleteMethodOK()
        {
            // 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     = 4;
            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;
            // find the record
            AllOrderline.ThisOrderline.Find(PrimaryKey);
            // delete the record
            AllOrderline.Delete();
            //now find the record
            Boolean Found = AllOrderline.ThisOrderline.Find(PrimaryKey);

            // test to see that the record was not found
            Assert.IsFalse(Found);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        public void DeleteMethod()
        {
            //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.OrderlineID = 1;
            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;
            //find the record
            AllOrderline.ThisOrderline.Find(PrimaryKey);
            //delete the record
            AllOrderline.Delete();
            //now find the record
            Boolean Found = AllOrderline.ThisOrderline.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
Exemplo n.º 5
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;
        }
    }
        public void AddMethodOK()
        {
            clsOrderlineCollection AllOrderlines = new clsOrderlineCollection();
            clsOrderline           TestItem      = new clsOrderline();
            Int32 PKey = 0;

            TestItem.OLineNumber        = 1;
            TestItem.ONumber            = 1;
            TestItem.Quantity           = 1;
            TestItem.ShoeID             = 1;
            AllOrderlines.ThisOrderline = TestItem;
            PKey = AllOrderlines.Add();
            TestItem.OLineNumber = PKey;
            AllOrderlines.ThisOrderline.Find(PKey);
            Assert.AreEqual(AllOrderlines.ThisOrderline, TestItem);
        }
        public void DeleteMethodOK()
        {
            clsOrderlineCollection AllOrderlines = new clsOrderlineCollection();
            clsOrderline           TestItem      = new clsOrderline();
            Int32 PKey = 0;

            TestItem.OLineNumber        = 1;
            TestItem.ONumber            = 1;
            TestItem.Quantity           = 1;
            TestItem.ShoeID             = 1;
            AllOrderlines.ThisOrderline = TestItem;
            PKey = AllOrderlines.Add();
            TestItem.OLineNumber = PKey;
            AllOrderlines.ThisOrderline.Find(PKey);
            AllOrderlines.Delete();
            Boolean Found = AllOrderlines.ThisOrderline.Find(PKey);

            Assert.IsFalse(Found);
        }
Exemplo n.º 8
0
        public void AddMethod()
        {
            //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.OrderlineID = 1;
            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;
            //find the record
            AllOrderline.ThisOrderline.Find(PrimaryKey);
        }
    //function for adding new records
    void Add()
    {
        //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 == "")
        {
            //get the data entered by the user
            OrderlineBook.ThisOrderline.BookingNo = txtBookingNo.Text;
            OrderlineBook.ThisOrderline.Quantity  = Convert.ToInt32(txtQuantity.Text);
            //add the record
            OrderlineBook.Add();
            //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;
        }
    }