Example #1
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        clsOrder AnOrder = new clsOrder();

        Int32 orderId;

        Boolean found = false;

        try
        {
            orderId = Convert.ToInt32(txtBxOrderId.Text);
        }
        catch
        {
            throw new Exception("Order Id was not specified");
        }

        found = AnOrder.find(2);

        if (found)
        {
            txtBxOrderId.Text    = Convert.ToString(AnOrder.OrderId);
            txtBxCustomerId.Text = Convert.ToString(AnOrder.CustomerId);
            txtBxStaffId.Text    = Convert.ToString(AnOrder.StaffId);
            txtBxDetails.Text    = AnOrder.Details;
            txtBxDate.Text       = Convert.ToString(AnOrder.Date);
        }
    }
        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 FindOneOK()
        {
            int      data  = 5;
            clsOrder order = new clsOrder();
            clsOrder test  = new clsOrder();

            Assert.AreEqual(order.find(data), test.find(data));
        }
Example #4
0
        public void Test_findMethodExists()
        {
            // Create New Instance of class
            clsOrder order = new clsOrder();
            // Var to store result of method
            Boolean found = false;
            // Employee no to search for
            int orderId = 3;

            // Use the find method
            found = order.find(orderId);

            Assert.IsTrue(found);
        }
Example #5
0
        public void Test_DateIsFound()
        {
            clsOrder AnOrder = new clsOrder();

            Boolean found = false;

            Boolean ok = true;

            DateTime date = Convert.ToDateTime("21/03/2020");

            found = AnOrder.find(3);

            if (AnOrder.Date != date)
            {
                ok = false;
            }

            Assert.IsTrue(ok);
        }
Example #6
0
        public void Test_StaffIdIsFound()
        {
            clsOrder AnOrder = new clsOrder();

            Boolean found = false;

            Boolean ok = true;

            Int32 StaffId = 1;

            found = AnOrder.find(3);

            if (AnOrder.StaffId != StaffId)
            {
                ok = false;
            }

            Assert.IsTrue(ok);
        }
Example #7
0
        public void Test_CustomerIdIsFound()
        {
            clsOrder AnOrder = new clsOrder();

            Boolean found = false;

            Boolean ok = true;

            Int32 customerId = 12321;

            found = AnOrder.find(3);

            if (AnOrder.CustomerId != customerId)
            {
                ok = false;
            }

            Assert.IsTrue(ok);
        }
Example #8
0
        public void Test_DateAddedFound()
        {
            clsOrder AnOrder = new clsOrder();

            Boolean found = false;

            Boolean ok = true;

            Int32 OrderId = 3;

            found = AnOrder.find(OrderId);

            if (AnOrder.Date != Convert.ToDateTime("16/09/2015"))
            {
                ok = false;
            }

            Assert.IsTrue(found);
        }
Example #9
0
        public void Test_DetailsIsFound()
        {
            clsOrder AnOrder = new clsOrder();

            Boolean found = false;

            Boolean ok = true;

            string details = "text";

            found = AnOrder.find(3);

            if (AnOrder.Details != details)
            {
                ok = false;
            }

            Assert.IsTrue(ok);
        }
Example #10
0
        private void listboxdbl_click(object sender, EventArgs e)
        {
            var      data  = listBox1.SelectedItem.ToString().Split('-');
            clsOrder order = new clsOrder();
            int      cid   = Convert.ToInt32(data[0]);

            if (order.find(cid))
            {
                textBox1.Text        = order.Customer_Id.ToString();
                textBox2.Text        = order.Product_Id.ToString();
                textBox5.Text        = order.Product_Name;
                textBox4.Text        = order.Order_Quantity.ToString();
                checkBox1.Checked    = order.Dispatch;
                dateTimePicker1.Text = order.Date_Ordered.ToShortDateString();
            }
            else
            {
                MessageBox.Show("Record could not be matched");
            }
        }
Example #11
0
    protected void btnFind_Click1(object sender, EventArgs e)
    {
        clsOrder AnOrder = new clsOrder();

        Int32 orderId;

        Boolean found = false;

        orderId = Convert.ToInt32(txtBxOrderId.Text);

        found = AnOrder.find(2);

        if (found)
        {
            txtBxOrderId.Text    = Convert.ToString(AnOrder.OrderId);
            txtBxCustomerId.Text = Convert.ToString(AnOrder.CustomerId);
            txtBxStaffId.Text    = Convert.ToString(AnOrder.StaffId);
            txtBxDetails.Text    = AnOrder.Details;
            txtBxDate.Text       = Convert.ToString(AnOrder.Date);
        }
    }
Example #12
0
 private void edit_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem == null)
     {
         MessageBox.Show("Please select an item");
     }
     else
     {
         var      data  = listBox1.SelectedItem.ToString().Split('-');
         clsOrder order = new clsOrder();
         int      cid   = Convert.ToInt32(data[0]);
         if (order.find(cid))
         {
             order.Customer_Id    = Convert.ToInt32(textBox1.Text);
             order.Product_Id     = Convert.ToInt32(textBox2.Text);
             order.Product_Name   = textBox5.Text;
             order.Order_Quantity = Convert.ToInt32(textBox4.Text);
             order.Dispatch       = Convert.ToBoolean(checkBox1.CheckState);
             order.Date_Ordered   = Convert.ToDateTime(dateTimePicker1.Text);
             string Error = order.valid(order.Customer_Id, order.Product_Id, order.Product_Name, order.Order_Quantity, order.Dispatch, order.Date_Ordered);
             if (Error == "")
             {
                 col.mthisorder = order;
                 col.Update();
                 MessageBox.Show("Item has been updated");
             }
             else
             {
                 MessageBox.Show(Error);
             }
         }
         else
         {
             MessageBox.Show("Item could not be updated.");
         }
     }
 }
Example #13
0
 private void remove_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem == null)
     {
         MessageBox.Show("Please select an item");
     }
     else
     {
         var      data  = listBox1.SelectedItem.ToString().Split('-');
         clsOrder order = new clsOrder();
         int      cid   = Convert.ToInt32(data[0]);
         if (order.find(cid))
         {
             col.mthisorder = order;
             col.Delete();
             listBox1.Items.Remove(listBox1.SelectedItem);
             MessageBox.Show("Item has been deleted");
         }
         else
         {
             MessageBox.Show("Item could not be deleted.");
         }
     }
 }
Example #14
0
 public void FindOK()
 {
     Assert.IsTrue(order.find(4));
 }