Exemplo n.º 1
0
        public void SetUnitComb()
        {
            DataTable     myUnitDt      = new DataTable();
            BUProductUnit bUProductUnit = new BUProductUnit();

            myUnitDt = bUProductUnit.GetUnitInfo(string.Empty);
            comBoxUnit.DataSource    = myUnitDt;
            comBoxUnit.DisplayMember = "product_unit_name";
            comBoxUnit.ValueMember   = "product_unit_id";
        }
Exemplo n.º 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string        parmaUnitName   = this.txtBoxUnitSearch.Text;
            DataTable     myDt            = new DataTable();
            BUProductUnit myBUProductUnit = new BUProductUnit();

            myDt = myBUProductUnit.GetUnitInfo(parmaUnitName);
            if (myDt.Rows.Count == 0)
            {
                MessageBox.Show("对不起,您输入的计量单位不存在.请确认输入的查询单位是否正确", "温馨提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            this.gdcInfo.DataSource = myDt;
        }
Exemplo n.º 3
0
        private void btnAddProductUnit_Click(object sender, EventArgs e)
        {
            string        paramUnitName   = this.txtBoxProductUnitName.Text.Trim();
            string        paramRemark     = this.txtBoxRemark.Text.Trim();
            string        paramUnitCode   = this.txtBoxProductUnitCode.Text.Trim();
            BUProductUnit myBUProductUnit = new BUProductUnit();
            bool          isModifyUnitOK  = myBUProductUnit.UnitUpdate(paramUnitCode, paramUnitName, paramRemark);

            if (isModifyUnitOK)
            {
                MessageBox.Show("修改成功");
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("更新失败");
                this.DialogResult = DialogResult.OK;
            }
        }
Exemplo n.º 4
0
        private void btnAddProductUnit_Click(object sender, EventArgs e)
        {
            try
            {
                BUProductUnit myBUUnitadd = new BUProductUnit();

                string paramRemark   = this.txtBoxRemark.Text.ToString();
                string paramUnitName = this.txtBoxProductUnitName.Text.ToString();
                bool   isValue       = myBUUnitadd.IsExistsUnitName(paramUnitName);

                if (paramUnitName == string.Empty || paramUnitName.Trim() == "")
                {
                    MessageBox.Show("请输入正确计量单位!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!isValue)
                {
                    bool returnValue = myBUUnitadd.UnitAdd(paramUnitName, paramRemark);

                    if (returnValue)
                    {
                        MessageBox.Show("恭喜您,数据添加成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = DialogResult.OK;
                    }
                }
                else
                {
                    MessageBox.Show("计量单位重复!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                MessageBox.Show("添加失败");
                this.DialogResult = DialogResult.No;
            }
        }
Exemplo n.º 5
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;
         BUProductUnit myBUProductUnit = new BUProductUnit();
         DialogResult  dr = MessageBox.Show("确定删除此条信息吗?", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (dr == DialogResult.OK)
         {
             for (int i = 0; i < indexArr.Count(); i++)
             {
                 string paramUnitId = this.gdvInfo.GetDataRow(indexArr[i])["product_unit_id"].ToString();
                 ReturnValue = myBUProductUnit.UnitDelete(paramUnitId);
             }
             if (ReturnValue)
             {
                 MessageBox.Show("恭喜您,删除数据成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 btnRefresh_Click(sender, e);
             }
             else
             {
                 MessageBox.Show("操作错误或该类别已在使用!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 6
0
        private void btnBatchAdd_Click(object sender, EventArgs e)
        {
            string paramProductName = string.Empty;
            string paramProductCode = string.Empty;

            if (comBProductClass.Text.Length == 0)
            {
                MessageBox.Show("产品类别不能为空!");
                return;
            }
            OpenFileDialog theDlg = new OpenFileDialog();

            theDlg.Title      = "请选择文件";
            theDlg.Filter     = "数据(*.xlsx)|*.xlsx|数据(*.xls)|*.xls";
            theDlg.DefaultExt = ".xlsx";
            if (theDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            string         theFile    = theDlg.FileName;
            string         strCom     = string.Empty;
            WaitDialogForm wdf        = null;
            List <string>  thelstCom  = new List <string>();
            string         strError   = string.Empty;
            string         IndexCount = "0";

            try
            {
                wdf = new WaitDialogForm("正在导入数据,请稍后....", "温馨提示");
                DataTable dtData = null;
                if (Environment.Is64BitOperatingSystem)
                {
                    dtData = CreateXmlForData.ExecleToDataSet(theFile, 1).Copy();
                }
                else
                {
                    dtData = KSRCommonUtils.GetExcelData(theFile, "Sheet1").Tables[0];
                }
                if (dtData.Rows.Count > 0)
                {
                    IndexCount  = "0";
                    wdf.Caption = "共" + dtData.Rows.Count.ToString() + "条数据,正在导入第" + IndexCount + "条数据,请稍后....";
                    DataTable dtTemp = myBUProductListAdd.GetProductInfoByName(string.Empty, string.Empty);
                    for (int i = 0; i < dtData.Rows.Count; i++)
                    {
                        if (!myBUProductListAdd.IsExistsProduct(dtData.Rows[i][0].ToString()))
                        {
                            dtTemp.Clear();
                            DataRow dr = dtTemp.NewRow();
                            IndexCount  = (i + 1).ToString();
                            wdf.Caption = "共" + dtData.Rows.Count.ToString() + "条数据,正在导入第" + IndexCount + "条数据,请稍后....";
                            try
                            {
                                int ResultRow = 0;
                                dr["product_id"]   = "'" + dtData.Rows[i][0].ToString() + "'";
                                dr["product_name"] = "'" + dtData.Rows[i][1].ToString() + "'";
                                dr["product_spec"] = "'" + dtData.Rows[i][2].ToString() + "'";
                                BUProductClass bUProductClass = new BUProductClass();
                                dr["product_class_id"] = bUProductClass.GetProductClassByName(dtData.Rows[i][3].ToString()).Rows[0]["product_class_id"].ToString();;
                                BUProductUnit bUBUProductUnit = new BUProductUnit();
                                dr["product_unit_id"] = bUBUProductUnit.GetUnitInfo(dtData.Rows[i][4].ToString()).Rows[0]["product_unit_id"].ToString();
                                dr["createby"]        = "'" + txtEmployeeName.Text.ToString() + "'";
                                dr["create_date"]     = "'" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
                                dr["remark"]          = "'" + dtData.Rows[i][5].ToString() + "'";
                                dtTemp.Rows.Add(dr);

                                ResultRow = myBUProductListAdd.Excel_InsertProductList(dtTemp, i, dtData.Rows.Count);
                                MessageBox.Show("导入成功");
                                this.DialogResult = DialogResult.OK;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(dtData.Rows[i][0].ToString() + dtData.Rows[i][1].ToString() + ":" + ex.Message);
                                wdf.Close();
                                return;
                            }
                        }
                    }
                }
                else
                {
                    wdf.Close();
                    MessageBox.Show("记录为空");;
                }
            }
            finally
            {
                if (wdf != null)
                {
                    wdf.Close();
                }
            }
        }