コード例 #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);
        }
コード例 #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();
        }