Exemplo n.º 1
0
        public void Test_detailsMid()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string details = "aaa";

            error = order.Validate("1", "1", "1", DateTime.Now.Date.ToString(), details);

            Assert.AreEqual(error, "");
        }
Exemplo n.º 2
0
        public void Test_detailsMinLessOne()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string details = "";

            error = order.Validate("1", "1", "1", details, "12/12/2020");

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 3
0
        public void Test_customerIdMid()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string customerId = "aaa";

            error = order.Validate("1", customerId, "1", DateTime.Now.Date.ToString(), "test");

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 4
0
        public void Test_DateInvalidData()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string dateAdded = "This is an invalid date";

            error = order.Validate("1", "1", "1", "1", dateAdded);

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 5
0
        public void Test_customerIdMinLessOne()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string customerId = "";

            error = order.Validate("1", customerId, "1", "1", "12/12/2020");

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 6
0
        public void Test_staffIdMax()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string staffId = "aaaaaa";

            error = order.Validate("1", "1", staffId, DateTime.Now.Date.ToString(), "test");

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 7
0
        public void Test_staffIdBlank()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string orderId = "";

            error = order.Validate(orderId, "1", "1", "1", "12/12/2020");

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 8
0
        public void Test_orderIdMaxLessOne()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string orderId = "aaaaa";

            error = order.Validate(orderId, "1", "1", DateTime.Now.Date.ToString(), "test");

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 9
0
        public void Test_detailsExtremeMax()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string details = "";

            details = details.PadRight(500, 'a');

            error = order.Validate("1", "1", "1", DateTime.Now.Date.ToString(), details);

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 10
0
        public void Test_detailsMaxLessOne()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string details = "";

            details = details.PadRight(99, 'a');

            error = order.Validate("1", "1", "1", DateTime.Now.Date.ToString(), details);

            Assert.AreEqual(error, "");
        }
Exemplo n.º 11
0
        public void Test_customerIdExtremeMax()
        {
            clsOrder order = new clsOrder();

            string error = "";

            string customerId = "";

            customerId = customerId.PadRight(500, 'a');

            error = order.Validate("1", customerId, "1", "1", "12/12/2020");

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 12
0
        public void Test_DateExtremeMin()
        {
            clsOrder order = new clsOrder();

            string error = "";

            DateTime testDate = DateTime.Now.Date;

            testDate = testDate.AddYears(100);

            string dateAdded = testDate.ToString();

            error = order.Validate("1", "1", "1", "1", dateAdded);

            Assert.AreNotEqual(error, "");
        }
Exemplo n.º 13
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        clsOrder AnOrder = new clsOrder();

        string orderId    = txtBxOrderId.Text;
        string staffId    = txtBxStaffId.Text;
        string customerId = txtBxCustomerId.Text;
        string date       = txtBxDate.Text;
        string details    = txtBxDetails.Text;

        string error = AnOrder.Validate(orderId, customerId, staffId, date, details);

        clssupplierCollection orders = new clssupplierCollection();

        if (error == "")
        {
            AnOrder.OrderId    = Convert.ToInt32(orderId);
            AnOrder.StaffId    = Convert.ToInt32(staffId);
            AnOrder.CustomerId = Convert.ToInt32(customerId);
            AnOrder.Date       = Convert.ToDateTime(date);
            AnOrder.Details    = details;

            Session["AnOrder"] = AnOrder;

            clssupplierCollection orderList = new clssupplierCollection();
            if (!AnOrder.exists(AnOrder.OrderId))
            {
                orderList.ThisOrder = AnOrder;
                orderList.Add();
            }
            else
            {
                orderList.ThisOrder = AnOrder;
                orderList.Update();
            }
        }
        else
        {
            lblError.Text = error;
        }

        Response.Redirect("OrderViewer.aspx");
    }