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 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();
                }
            }
        }