//新增和修改产品 private void btnOk_Click(object sender, EventArgs e) { if (CheckEmpty()) { ProductInfo pro = new ProductInfo(); pro.CatId = Convert.ToInt32(cmbCategory.SelectedValue); pro.ProCost = Convert.ToDecimal(txtCost.Text); pro.ProName = txtName.Text; pro.ProNum = txtNum.Text; pro.ProPrice = Convert.ToDecimal(txtPrice.Text); pro.ProSpell = txtSpell.Text; pro.ProStock = Convert.ToDecimal(txtStock.Text); pro.ProUnit = txtUnit.Text; pro.Remark = txtRemark.Text; if (this.Tp == 3)//新增 { pro.DelFlag = 0; pro.SubBy = 1; pro.SubTime = System.DateTime.Now; } else if (this.Tp == 4)//修改 { pro.ProId = Convert.ToInt32(labId.Text); } ProductInfoBLL bll = new ProductInfoBLL(); string msg = bll.SaveProduct(pro, this.Tp) ? "操作成功" : "操作失败"; MessageBox.Show(msg); this.Close(); } }