Exemplo n.º 1
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            OrderServices os1 = new OrderServices();

            allOrders = os1.removeOrder(allOrders, Convert.ToInt32(IDbox.Value));
            os1.Export(allOrders);
        }
Exemplo n.º 2
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            OrderServices os1   = new OrderServices();
            int           value = Convert.ToInt32(IDbox.Value);

            allOrders = os1.removeOrder(allOrders, value);
            os1.Export(allOrders);
            MessageBox.Show("The order with id: " + value.ToString() + " is deleted.");

            //在orderdetail中删除一行
            MySqlConnection connection = new MySqlConnection(conString);

            connection.Open();
            if (connection.State == System.Data.ConnectionState.Open)
            {
                using (connection)
                {
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.Connection  = connection;
                    cmd.CommandText = "DELETE FROM `order` WHERE ID=" + value.ToString();
                    cmd.ExecuteNonQuery();
                }
            }
            connection.Close();
        }
Exemplo n.º 3
0
 public AddOrder()
 {
     InitializeComponent();
     if (File.Exists("order.xml"))
     {
         OrderServices os1 = new OrderServices();
         allOrders = os1.Import();
     }
 }
Exemplo n.º 4
0
        private void finishButton_Click(object sender, EventArgs e)
        {
            //完善new order信息
            od1.id           = allOrders.Count() + 1;
            od1.customerName = userNameTB.Text;
            od1.getAllPrice();

            //将new order加入orders
            allOrders.Add(od1);

            //更新数据库
            OrderServices os1 = new OrderServices();

            os1.Export(allOrders);
        }
Exemplo n.º 5
0
        private void finishButton_Click(object sender, EventArgs e)
        {
            if (ifFinished == false)
            {
                ifFinished = true;
                //完善new order信息
                od1.id           = allOrders[allOrders.Count() - 1].id + 1;
                od1.customerName = userNameTB.Text;
                od1.getAllPrice();

                //将new order加入orders
                allOrders.Add(od1);

                //更新xml和数据库
                OrderServices os1 = new OrderServices();
                os1.Export(allOrders);

                //在order中插入一行
                MySqlConnection connection = new MySqlConnection(conString);
                connection.Open();
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    using (connection)
                    {
                        MySqlCommand cmd = new MySqlCommand();
                        cmd.Connection  = connection;
                        cmd.CommandText = "INSERT INTO `order`(ID,userName,totalPrice) VALUES  (@ID, @userName, @totalPrice)";

                        cmd.Prepare();
                        cmd.Parameters.AddWithValue("@ ID", allOrders[allOrders.Count() - 1].id + 1);
                        cmd.Parameters.AddWithValue("@userName", userNameTB.Text);
                        cmd.Parameters.AddWithValue("@totalPrice", od1.totalPrice);

                        cmd.ExecuteNonQuery();
                    }
                }
                connection.Close();
            }
            else  //避免重复添加
            {
                MessageBox.Show("The order has already added.");
            }
        }
Exemplo n.º 6
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            flowLayoutPanel1.Controls.Clear();
            int searchByIndex = SearchByComboBox.SelectedIndex;

            if (File.Exists("order.xml"))
            {
                OrderServices os1 = new OrderServices();
                allOrders = os1.Import();

                if (searchByIndex == 0)
                {
                    string uname = inputUsernameTextBox.Text;
                    allOrders = os1.searchOrderByName(uname, allOrders);
                }
                else
                {
                    int max = Convert.ToInt32(inputMaxPriceTextBox.Text);
                    int min = Convert.ToInt32(inputMinPriceTextBox.Text);
                    allOrders = os1.searchOrderByMoney(min, max, allOrders);
                }
            }
            showAllOds();
        }