示例#1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtProductName.Text))
     {
         MessageBox.Show("请输入商品名称");
     }
     if (string.IsNullOrEmpty(txtInPrice.Text))
     {
         MessageBox.Show("请输入进货价格");
     }
     if (string.IsNullOrEmpty(txtProductCode.Text))
     {
         MessageBox.Show("请输入商品编号");
     }
     //插入
     if (_opearType == "添加")
     {
         var sql = InsertSQL.InsertProduct(txtProductName.Text, txtInPrice.Text, txtOutPrice.Text,
                                           txtProductCode.Text, txtProductNum.Text, txtRemark.Text, _clientId, _pictureId);
         MessageBox.Show(InsertData.InsertIntoData(sql) ? "添加商品成功" : "添加商品失败");
     }
     //更新
     if (_opearType == "修改")
     {
         var updatesql = UpdateSQL.UpdateProduct(txtProductName.Text, txtInPrice.Text, txtOutPrice.Text,
                                                 txtProductCode.Text, txtProductNum.Text, txtRemark.Text, _clientId, _pictureId, _productId);
         MessageBox.Show(UpdateData.UpdateInfo(updatesql) ? "更新商品成功" : "更新商品失败");
     }
     Close();
 }