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;
                }
            }
        }
Esempio n. 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string paramProductName = this.txtBoxProductName.Text.ToString();
            string paramProductCode = this.txtBoxProductCode.Text.ToString();

            DataTable     dt = new DataTable();
            BUProductList myBUProductList = new BUProductList();

            dt = myBUProductList.GetProductInfoByName(paramProductName, paramProductCode);
            if (dt.Rows.Count > 0)
            {
                this.gdcInfo.DataSource = dt;
            }
            else
            {
                MessageBox.Show("查无记录");
            }
        }
        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("添加失败");
            }
        }
Esempio n. 4
0
 private void btnDelProduct_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.gdvInfo.SelectedRowsCount == 0)
         {
             MessageBox.Show("请选择要删除的信息!");
             return;
         }
         int[]        indexArr    = this.gdvInfo.GetSelectedRows();
         bool         ReturnValue = false;
         DialogResult dr          = MessageBox.Show("确定删除此条信息吗?", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (dr == DialogResult.OK)
         {
             for (int i = 0; i < indexArr.Count(); i++)
             {
                 string        paramProductID  = this.gdvInfo.GetDataRow(indexArr[i])["product_id"].ToString();
                 BUProductList myBUProductList = new BUProductList();
                 ReturnValue = myBUProductList.ProductDelete(paramProductID);
             }
             if (ReturnValue)
             {
                 MessageBox.Show("恭喜您,删除数据成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 btnSearch_Click(sender, e);
             }
             else
             {
                 MessageBox.Show("操作错误或该产品已进入库房", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }