Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string paramProductID      = this.txtBoxProductID.Text.Trim();
            string paramProductClassID = this.ProductClassID;
            string paramProductName    = this.txtBoxProductName.Text.Trim();
            string paramProductSpec    = this.txtBoxSpec.Text.Trim();
            string paramUnitID         = this.comBoxUnit.SelectedValue.ToString();
            string paramEmployeeName   = this.txtEmployeeName.Text.ToString();
            string paramRemark         = this.txtRemark.Text.ToString();
            string paramProductName_s  = string.Empty;

            if (paramProductID_2.Length == 0)
            {
                try
                {
                    BUProductList myBUProductList = new BUProductList();
                    bool          isValue         = myBUProductList.IsExistsProduct(paramProductID);
                    if (paramProductName == "" || paramProductID == "")
                    {
                        MessageBox.Show("请输入正确商品名和编码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (!isValue)
                    {
                        bool returnValue = myBUProductList.CheckProductAdd(paramProductID, paramProductClassID, paramProductName, paramProductSpec, paramUnitID, paramEmployeeName, paramRemark);
                        if (returnValue)
                        {
                            MessageBox.Show("恭喜您,数据添加成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.DialogResult = DialogResult.OK;
                        }
                    }
                    else
                    {
                        MessageBox.Show("商品名称重复!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                bool isModifyProductListOK = myBUProductListAdd.UpdateProductList(paramProductID, paramProductClassID, paramProductName, paramProductSpec, paramUnitID, paramEmployeeName, paramRemark);
                if (isModifyProductListOK)
                {
                    MessageBox.Show("修改成功");
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("更新失败");
                    this.DialogResult = DialogResult.OK;
                }
            }
        }
Пример #2
0
        private void btnSaveNew_Click(object sender, EventArgs e)
        {
            try
            {
                BUProductList myBUProductListadd = new BUProductList();

                string paramProductID      = this.txtBoxProductID.Text.Trim();
                string paramProductClassID = this.ProductClassID;
                string paramProductName    = this.txtBoxProductName.Text.Trim();
                string paramProductSpec    = this.txtBoxSpec.Text.Trim();
                string paramUnitID         = this.comBoxUnit.SelectedValue.ToString();
                string paramEmployeeName   = this.txtEmployeeName.Text.ToString();
                string paramRemark         = this.txtRemark.Text.ToString();
                string paramProductName_s  = string.Empty;

                bool isValue = myBUProductListadd.IsExistsProduct(paramProductID);

                if (paramProductName == "" || paramProductID == "")
                {
                    MessageBox.Show("请输入正确商品名和编码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (!isValue)
                {
                    bool returnValue = myBUProductListadd.CheckProductAdd(paramProductID, paramProductClassID, paramProductName, paramProductSpec, paramUnitID, paramEmployeeName, paramRemark);
                    if (returnValue)
                    {
                        MessageBox.Show("恭喜您,数据添加成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtBoxProductID.Text   = string.Empty;
                        txtBoxProductName.Text = string.Empty;
                        txtBoxSpec.Text        = string.Empty;
                        txtRemark.Text         = string.Empty;
                    }
                }
                else
                {
                    MessageBox.Show("商品编码重复!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                MessageBox.Show("添加失败");
            }
        }