private void SearchEventH() { string path = @"\\192.168.145.7\nstvnoise$\FCT_NOISE\" + cmbModelH.Text + "\\"; foreach (History cell in flpnlYeildShowH.Controls.OfType <History>()) { //cell.input = 0; //cell.output = 0; cell.dataH = new DataTable(); cell.dataH.Columns.Add("Date"); cell.dataH.Columns.Add("Input"); cell.dataH.Columns.Add("Output"); cell.dataH.Columns.Add("Yield"); double inputH = 0, outputH = 0; string yieldH = string.Empty; string nopath = path + cell.Name + "\\"; for (int i = dtpFromH.Value.Year; i <= dtpToH.Value.Year; i++) { string yearpath = nopath + i + "\\"; if (!Directory.Exists(yearpath)) { return; } for (int j = dtpFromH.Value.Month; j <= dtpToH.Value.Month; j++) { string monthpath = yearpath + j.ToString("00") + "\\"; if (!Directory.Exists(monthpath)) { return; } for (int k = dtpFromH.Value.Day; k <= dtpToH.Value.Day; k++) { string date = i + "-" + j.ToString("00") + "-" + k.ToString("00"); string[] files = Directory.GetFiles(monthpath); foreach (string f in files) { if (f.Contains(date)) { DataTable dt = new DataTable(); dt = CSVUtility.ConvertCSVtoDataTable(f); inputH = dt.Rows.Count; foreach (DataRow dr in dt.Rows) { if (dr["Judge"].ToString().Contains("OK")) { outputH++; } } yieldH = ((outputH / inputH) * 100).ToString("00.00") + "%"; cell.dataH.Rows.Add(date, inputH, outputH, yieldH); cell.Refresh(); dt.Clear(); inputH = 0; outputH = 0; } } } } } //if (cell.input > 0 && cell.output > 0) // cell.yeild = cell.output / cell.input; //else // cell.yeild = 0; //if (cell.yeild >= 0.85) // cell.color = Color.LimeGreen; //else if (cell.yeild >= 0.5 && cell.yeild < 0.85) // cell.color = Color.Yellow; //else if (cell.yeild < 0.5 && cell.input > 0) // cell.color = Color.Red; //else // cell.color = Color.Silver; //cell.lbYeild.Text = (cell.yeild * 100).ToString("0.##") + "%"; } }
private void SearchEvent() { string path = @"\\192.168.145.7\nstvnoise$\FCT_NOISE\" + cmbModel.Text + "\\"; foreach (InspectCell cell in flpnlYeildShow.Controls.OfType <InspectCell>()) { cell.input = 0; cell.output = 0; string nopath = path + cell.Name + "\\"; for (int i = dtpDateFrom.Value.Year; i <= dtpDateTo.Value.Year; i++) { string yearpath = nopath + i + "\\"; if (!Directory.Exists(yearpath)) { return; } for (int j = dtpDateFrom.Value.Month; j <= dtpDateTo.Value.Month; j++) { string monthpath = yearpath + j.ToString("00") + "\\"; if (!Directory.Exists(monthpath)) { return; } for (int k = dtpDateFrom.Value.Day; k <= dtpDateTo.Value.Day; k++) { string date = i + "-" + j.ToString("00") + "-" + k.ToString("00"); string[] files = Directory.GetFiles(monthpath); foreach (string f in files) { if (f.Contains(date)) { DataTable dt = new DataTable(); dt = CSVUtility.ConvertCSVtoDataTable(f); cell.input += dt.Rows.Count; foreach (DataRow dr in dt.Rows) { if (dr["Judge"].ToString().Contains("OK")) { cell.output++; } } dt.Clear(); } } } } } if (cell.input > 0 && cell.output > 0) { cell.yeild = cell.output / cell.input; } else { cell.yeild = 0; } if (cell.yeild >= 0.85) { cell.color = Color.LimeGreen; } else if (cell.yeild >= 0.5 && cell.yeild < 0.85) { cell.color = Color.Yellow; } else if (cell.yeild < 0.5 && cell.input > 0) { cell.color = Color.Red; } else { cell.color = Color.Silver; } cell.lbYeild.Text = (cell.yeild * 100).ToString("0.##") + "%"; } }
private void btnExport_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(noname)) { MessageBox.Show("Please select the machine number!!!", "Information", MessageBoxButtons.OK); return; } try { string path = @"\\192.168.145.7\nstvnoise$\FCT_NOISE\" + cmbModel.Text + "\\"; SaveFileDialog sf = new SaveFileDialog(); List <string[]> fr = new List <string[]>(); sf.Filter = "Excel Files (*.xlsx)|*.xlsx|All File (*.*)|*.*"; //sf.FileName = "Select Folder"; if (sf.ShowDialog() == DialogResult.OK) { //cell.input = 0; //cell.output = 0; string nopath = path + noname + "\\"; for (int i = dtpDateFrom.Value.Year; i <= dtpDateTo.Value.Year; i++) { string yearpath = nopath + i + "\\"; if (!Directory.Exists(yearpath)) { return; } for (int j = dtpDateFrom.Value.Month; j <= dtpDateTo.Value.Month; j++) { string monthpath = yearpath + j.ToString("00") + "\\"; if (!Directory.Exists(monthpath)) { return; } for (int k = dtpDateFrom.Value.Day; k <= dtpDateTo.Value.Day; k++) { string date = i + "-" + j.ToString("00") + "-" + k.ToString("00"); string[] files = Directory.GetFiles(monthpath); foreach (string f in files) { if (f.Contains(date)) // File.Copy(f, Path.GetDirectoryName(sf.FileName) + "\\" + Path.GetFileName(f)); { ExcelClass2019.OpenExcelWorkBook(@"\\192.168.145.7\nstvnoise$\Excel Form\Histogram FCT.xlsx", 2); Cursor.Current = Cursors.WaitCursor; CSVUtility.ConvertCSVtoDataTable(f).DatasetToExcel(); if (MessageBox.Show("Export Successfully." + Environment.NewLine + "Do you want open this?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { sf.FileName.SaveAndExit(true); } else { sf.FileName.SaveAndExit(false); } Cursor.Current = Cursors.Default; } } } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnPush_Click(object sender, EventArgs e) { try { string tempfolder = @"\\192.168.145.7\nstvnoise$\TEMP"; string errorfolder = @"\\192.168.145.7\nstvnoise$\ERROR"; List <string> errorlist = new List <string>(); site = "NSTV"; factory = "2B"; line = "L01"; process = "FCT"; multiinspect.Clear(); mutliprocess.Clear(); foreach (string item in lsbAllFileCSV.Items) { DataTable dt = new DataTable(); model = Path.GetFileName(item).Split('_')[1]; model = model.Replace('-', '_'); date = Path.GetFileName(item).Split('_')[2].Split('-')[0] + Path.GetFileName(item).Split('_')[2].Split('-')[1]; table = model + date; gData.CreateTable(table); gData.CreateTableData(table); CSVUtility.ConvertCSVtoDataTable(dt, item); foreach (DataRow dr in dt.Rows) { inspectdate = DateTime.Parse(dr["Date"].ToString()); serno = inspectdate.ToString("HHmmss") + dr["Number"].ToString(); lot = inspectdate.ToString("yyyyMMdd"); judge = dr["Judge"].ToString() == "OK" ? "0" : "1"; mutliprocess.Append("('").Append(serno).Append("','").Append(lot).Append("','"); mutliprocess.Append(model).Append("','").Append(site).Append("','").Append(factory).Append("','"); mutliprocess.Append(line).Append("','").Append(process).Append("','"); mutliprocess.Append(inspectdate.ToString("yyyy-MM-dd HH:mm:ss")).Append("','").Append(judge); mutliprocess.Append("','INITAL',''), "); //gData.InsertTable(table, serno, lot, model, site, factory, line, process, inspectdate.ToString("yyyy-MM-dd HH:mm:ss"), judge, "INITAL", ""); foreach (DataColumn dc in dt.Columns) { inspect = dc.ColumnName.Replace(" ", string.Empty); if (gData.CheckInspect(inspect)) { inspectdata = dr[dc.ColumnName].ToString(); if (inspectdata == "-" || !isDouble(inspectdata)) { continue; } multiinspect.Append("('").Append(serno).Append("','").Append(lot).Append("','"); multiinspect.Append(inspectdate.ToString("yyyy-MM-dd HH:mm:ss")).Append("','"); multiinspect.Append(inspect).Append("','").Append(inspectdata).Append("','"); multiinspect.Append(judge).Append("'), "); //gData.InsertTableData(table, serno, lot, inspectdate.ToString("yyyy-MM-dd HH:mm:ss"), inspect, inspectdata, judge); } } } multiinspect.Remove(multiinspect.Length - 2, 1); mutliprocess.Remove(mutliprocess.Length - 2, 1); if (!gData.InsertTableData(table, multiinspect.ToString()) && !gData.InsertTable(table, mutliprocess.ToString())) { if (!Directory.Exists(errorfolder)) { Directory.CreateDirectory(errorfolder); } File.WriteAllLines(errorfolder + "\\" + Path.GetFileName(item), errorlist); } if (!Directory.Exists(tempfolder)) { Directory.CreateDirectory(tempfolder); } File.Move(item, tempfolder + "\\" + Path.GetFileName(item)); } } catch { } }