Пример #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (CheckTextBox())
            {
                var proi = new ProductInfo();
                proi.ProCost  = Convert.ToDecimal(txtCost.Text);
                proi.ProName  = txtName.Text;
                proi.ProNum   = txtNum.Text;
                proi.ProPrice = Convert.ToDecimal(txtPrice.Text);
                proi.ProSpell = txtSpell.Text;
                proi.ProStock = Convert.ToDecimal(txtStock.Text);
                proi.ProUnit  = txtUnit.Text;
                proi.Remark   = txtRemark.Text;
                proi.CatId    = Convert.ToInt32(cmbCategory.SelectedValue);

                if (_tp == 1)//新增
                {
                    proi.DelFlag = 0;
                    proi.SubTime = DateTime.Now;
                    proi.SubBy   = 1;
                }
                else if (_tp == 2)//修改
                {
                    proi.ProId = Convert.ToInt32(labId.Text);
                }

                var proiBLL = new ProductInfoBLL();
                var msg     = proiBLL.SaveProductInfo(_tp, proi) ? "操作成功" : "操作失败";
                MessageBox.Show(msg);
                this.Close();
            }
        }
Пример #2
0
        //确定增加还是修改
        private void btnOk_Click(object sender, EventArgs e)
        {
            //判断标识
            if (CheckEmpty())
            {
                //获取对象中的属性的值
                ProductInfoBLL bll = new ProductInfoBLL();
                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);
                }
                string msg = bll.SaveProductInfo(pro, this.TP) ? "操作成功" : "操作失败";
                MessageBox.Show(msg);
                this.Close();
            }
        }