コード例 #1
0
        private void add_Click(object sender, EventArgs e)
        {
            clsOrder order = new clsOrder();

            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.Add();
                MessageBox.Show("Item has been added");
            }
        }
コード例 #2
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.");
         }
     }
 }
コード例 #3
0
        public void ValidOK()
        {
            string Error = "";

            Assert.AreEqual(Error, order.valid(1, 1, "product", 2, true, DateTime.Today));
        }