private void btnChkNAS_Click(object sender, EventArgs e) { if (dgvData.DataSource == null | dgvData.Rows.Count - 1 == 0) { sysMessage.NoData(); } else { DataTable tmpDT = new DataTable(); tmpDT.Columns.Add("料號"); tmpDT.Columns.Add("狀態"); PGB pgb = new PGB(); pgb.Text = "檢查中"; pgb.label1.Text = "檢查料號中,請稍候....."; pgb.progressBar1.Minimum = 0; pgb.progressBar1.Maximum = dgvData.Rows.Count - 1; pgb.progressBar1.Value = 0; pgb.Show(); Application.DoEvents(); string Path = @"\\n5200xxx\LDI_Source\Inn Layer"; string FilePath = ""; if (rdo310.Checked) { Path = @"\\n5200xxx\LDI_Source\Out Layer"; } for (int i = 0; i < dgvData.Rows.Count - 1; i++) { FilePath = Path + @"\" + dgvData.Rows[i].Cells["料號"].Value.ToString().Substring(0, 3); if (!System.IO.Directory.Exists(FilePath)) { DataRow row = tmpDT.NewRow(); row["料號"] = dgvData.Rows[i].Cells["料號"].Value.ToString(); row["狀態"] = "客戶代號資料夾不存在"; tmpDT.Rows.Add(row); } else { int result = 0; string[] Directory = System.IO.Directory.GetDirectories(FilePath); for (int x = 0; x < Directory.Length; x++) { if (Directory[x].Contains(dgvData.Rows[i].Cells["料號"].Value.ToString().Trim())) { result++; } } if (result == 0) { DataRow row = tmpDT.NewRow(); row["料號"] = dgvData.Rows[i].Cells["料號"].Value.ToString(); row["狀態"] = "料號資料夾不存在"; tmpDT.Rows.Add(row); } } pgb.progressBar1.Value++; } pgb.Dispose(); if (tmpDT.Rows.Count == 0) { sysMessage.sysMsg("檢查結果:OK", "訊息"); } else { tmpDT.DefaultView.Sort = "料號"; NewRTB nrtb = new NewRTB(); for (int i = 0; i < tmpDT.Rows.Count; i++) { nrtb.rtbMain.Text += tmpDT.Rows[i]["料號"].ToString().Trim() + " - " + tmpDT.Rows[i]["狀態"].ToString() + "\n"; } nrtb.Show(); } } }
private void btnToCheck_Click(object sender, EventArgs e) { if (dgvEwproject.DataSource == null & dgvAOI.DataSource == null) { sysMessage.sysMsg("您尚未查詢申報資料,請確認!", "訊息"); } else { var resultDT = new DataTable(); resultDT.Columns.Add("批號"); resultDT.Columns.Add("料號"); resultDT.Columns.Add("版序"); resultDT.Columns.Add("層別"); resultDT.Columns.Add("數量"); resultDT.Columns.Add("N/O數量"); resultDT.Columns.Add("補線數量"); resultDT.Columns.Add("差異"); foreach (DataGridViewRow aoiRow in dgvAOI.Rows) { var ewCount = 0; foreach (DataGridViewRow ewRow in dgvEwproject.Rows) { if (aoiRow.Cells["批號"].Value.ToString().Trim() == ewRow.Cells["批號"].Value.ToString().Trim()) { ewCount += Convert.ToInt32(ewRow.Cells["數量"].Value); } } var intResult = Convert.ToInt32(aoiRow.Cells["N/O數量"].Value) - ewCount; if (intResult != 0) { DataRow row = resultDT.NewRow(); row["批號"] = aoiRow.Cells["批號"].Value.ToString(); row["料號"] = aoiRow.Cells["料號"].Value.ToString(); row["版序"] = aoiRow.Cells["版序"].Value.ToString(); row["層別"] = aoiRow.Cells["層別"].Value.ToString(); row["數量"] = aoiRow.Cells["數量"].Value.ToString(); row["N/O數量"] = aoiRow.Cells["N/O數量"].Value.ToString(); row["補線數量"] = Convert.ToString(ewCount); row["差異"] = Convert.ToString(intResult); resultDT.Rows.Add(row); } } NewRTB nrtb = new NewRTB(); nrtb.Text = "稽核結果"; foreach(DataColumn col in resultDT.Columns) { if (col.Ordinal == resultDT.Columns.Count - 1) { nrtb.rtbMain.Text += col.ToString() + "\n"; } else { nrtb.rtbMain.Text += col.ToString() + "\t"; } } foreach (DataRow row in resultDT.Rows) { foreach (DataColumn col in resultDT.Columns) { nrtb.rtbMain.Text += row[col].ToString() + "\t"; } nrtb.rtbMain.Text += "\n"; } nrtb.Show(); } }