Ejemplo n.º 1
0
 //添加商品
 private void addButton_Click(object sender, EventArgs e)
 {
     try
     {
         //调用数据库操作,添加商品
         DBOperation.AddProduct(
             Int32.Parse(this.productIdTextBox.Text),
             Double.Parse(this.productPriceTextBox.Text),
             Int32.Parse(this.productAmountTextBox.Text),
             this.productNameTextBox.Text,
             DBOperation.OrderCount - 1
             );
     }
     catch (FormatException exception)
     {
         MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 2
0
        //添加商品
        private void Button_Click(object sender, EventArgs e)
        {
            try
            {
                //根据输入的信息添加商品
                string name  = this.productNameTextBox.Text;
                double price = Double.Parse(
                    this.priceTextBox.Text);
                int amount = Int32.Parse(
                    this.amountTextBox.Text);
                int productId = Int32.Parse(
                    this.productIdtextBox.Text);

                //调用数据库操作
                DBOperation.AddProduct(productId, price, amount, name, this.orderId);

                //刷新表格
                data.DataSource = DBOperation.GetProductData(this.orderId);
            }catch (FormatException exception)
            {
                MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK);
            }
        }