Ejemplo 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);
        }
Ejemplo 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();
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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.");
            }
        }