private void btnOK_Click(object sender, EventArgs e)
 {
     if (pm.ProductID1 == -1)
     {
         //新增
         string        name   = txtName.Text.Trim();
         string        jp     = txtJp.Text.Trim();
         string        type   = (cmdType.SelectedIndex + 1).ToString();
         double        price  = Convert.ToDouble(txtPrice.Text.Trim());
         ProductsModel pm2    = new ProductsModel(name, type, jp, price);
         int           result = ProductsBLL.getAddGoods(pm2);
         if (result > 0)
         {
             MessageBox.Show("OK");
             this.Close();
             GoodsForm gf = new GoodsForm();
             gf.Show();
         }
         else
         {
             MessageBox.Show("NO");
         }
     }
     else
     {
         //修改
         string        name   = txtName.Text.Trim();
         string        jp     = txtJp.Text.Trim();
         string        type   = (cmdType.SelectedIndex + 1).ToString();
         double        price  = Convert.ToDouble(txtPrice.Text.Trim());
         ProductsModel pm2    = new ProductsModel(pm.ProductID1, name, type, jp, price);
         int           result = ProductsBLL.getUpdateGoods(pm2);
         if (result > 0)
         {
             MessageBox.Show("OK");
             this.Close();
             GoodsForm gf = new GoodsForm();
             gf.Show();
         }
         else
         {
             MessageBox.Show("NO");
         }
     }
 }
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (ptype.PTID1 == -1)
     {
         //新增
         string           name   = txtType.Text.Trim();
         ProductTypeModel ptype2 = new ProductTypeModel();
         ptype2.PTName1 = name;
         int result = ProductsBLL.getAddType(ptype2);
         if (result > 0)
         {
             MessageBox.Show("OK");
             this.Close();
             GoodsForm gf = new GoodsForm();
             gf.Show();
         }
         else
         {
             MessageBox.Show("NO");
         }
     }
     else
     {
         //修改
         string           name   = txtType.Text.Trim();
         ProductTypeModel ptype2 = new ProductTypeModel(ptype.PTID1, name);
         int result = ProductsBLL.getUpdateType(ptype2);
         if (result > 0)
         {
             MessageBox.Show("OK");
             this.Close();
             GoodsForm gf = new GoodsForm();
             gf.Show();
         }
         else
         {
             MessageBox.Show("NO");
         }
     }
 }