Esempio n. 1
0
        private void FormFindOld_Load(object sender, EventArgs e)
        {
            //关闭多余的窗体
            foreach (Form f in this.ParentForm.MdiChildren)
            {
                if (f.Name == this.Name && f.Handle != this.Handle)
                {
                    f.Dispose();
                }
            }

            //下拉框
            if (File.Exists(KeyWordTxt))
            {
                this.KeyWordList = File.ReadAllLines(KeyWordTxt).ToList <string>();
            }

            if (KeyWordList.Count > 1000)
            {
                for (int i = KeyWordList.Count - 1; i >= 1000; i--)
                {
                    KeyWordList.RemoveAt(i);
                }
            }

            if (Job != null)
            {
                KeyWordList_Add(GetString(Job.Cpmc));
            }
            if (KeyWordList.Count > 0)
            {
                this.comboBoxKeyword.Text = KeyWordList[0];
            }

            //**根据客户智能生产搜索关键字
            if (Job != null)
            {
                Regex regex = new Regex("\\d{8,}");

                if (regex.IsMatch(Job.Cpmc))
                {
                    this.comboBoxKeyword.Text = regex.Match(Job.Cpmc).Value;
                }
                else
                {
                    this.comboBoxKeyword.Text = Job.Cpmc.TrimEnd("-AB面".ToCharArray());
                }
            }
            comboBoxKeyword.Items.Clear();
            comboBoxKeyword.Items.AddRange(KeyWordList.ToArray());
            Comm_Method.Init_Tabel_Excel();
            Comm_Method.Init_PdfFileList();
            SearchOldFile();
        }
Esempio n. 2
0
        private void SearchOldFile()
        {
            Comm_Method.Init_Tabel_Excel();
            this.dgvExcel.DataSource = null;
            string kw = this.comboBoxKeyword.Text;

            if (string.IsNullOrWhiteSpace(kw))
            {
                return;
            }
            DataTable dt = Comm_Method.Table_Excel.Clone();

            dt.Columns.RemoveAt(dt.Columns.Count - 1);
            dt.Columns.RemoveAt(dt.Columns.Count - 1);
            dt.Columns.RemoveAt(dt.Columns.Count - 1);

            if (checkBoxSize.Checked)
            {
            }
            else
            {
                foreach (DataRow row in Comm_Method.Table_Excel.Rows)
                {
                    string cpmc = row[keyWordColumnName].ToString();

                    if (IsEachContain(cpmc, kw))
                    {
                        DataRow newRow = dt.NewRow();
                        foreach (DataColumn dc in dt.Columns)
                        {
                            newRow[dc] = row[dc.ColumnName];
                        }
                        dt.Rows.Add(newRow);
                    }
                }

                if (dt.Rows.Count > 0 && Job != null)
                {
                    DataRow newRow = dt.NewRow();
                    newRow["产  品   名   称"] = Job.Khjc + Job.Cpmc;
                    newRow["  制造尺寸"]       = Job.Zzcc.Replace("x", "*");
                    newRow["下料尺寸"]         = Job.Mzcc;
                    newRow["输出颜色"]         = "普:" + Job.Ss1 + " 专:" + Job.Ss2;
                    newRow["印刷机台"]         = Job.Sjjt;
                    dt.Rows.InsertAt(newRow, 0);
                }
                this.dgvExcel.DataSource = dt;

                //ListView
                this.listViewFile.Items.Clear();
                foreach (string file in Comm_Method.PdfFileList.FindAll(f => IsEachContain(Path.GetFileNameWithoutExtension(f), kw)))
                {
                    FileInfo fileInfo = new FileInfo(file);
                    if (fileInfo.Exists)
                    {
                        ListViewItem item = this.listViewFile.Items.Add(fileInfo.Name);
                        item.SubItems.Add(fileInfo.LastWriteTime.ToString());
                        item.SubItems.Add(Math.Round(1.0 * fileInfo.Length / 1024 / 1024, 2) + "MB");
                        item.SubItems.Add(fileInfo.DirectoryName);
                        item.Tag = file;
                    }
                }
            }


            KeyWordList_Add(kw);
            this.comboBoxKeyword.Items.Clear();
            this.comboBoxKeyword.Items.AddRange(this.KeyWordList.ToArray());
            this.listViewFile.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);


            //确定分割线的位置
            int dgvRowCount   = dgvExcel.RowCount;
            int listViewCount = listViewFile.Items.Count;

            if (dgvRowCount == 0 || listViewCount == 0)
            {
                dgvRowCount++;
                listViewCount++;
                this.splitContainer1.SplitterDistance =
                    Convert.ToInt32((1.0 * dgvRowCount / (dgvRowCount + listViewCount)
                                     * this.splitContainer1.Height));
            }
            else
            {
                this.splitContainer1.SplitterDistance =
                    Convert.ToInt32((1.0 * dgvRowCount / (dgvRowCount + listViewCount)
                                     * this.splitContainer1.Height));
            }

            //文字对齐
            dgvExcel.Columns["产  品   名   称"].DefaultCellStyle.Alignment
                = DataGridViewContentAlignment.MiddleRight;
        }