// display exceptions in grid view private void DisplayException() { if (InvokeRequired) { Invoke(new Action(DisplayException)); return; } gridViewRuntimes.Rows.Clear(); foreach (int index in exceptionIndexList) { RunTime runtime = allList[index]; string[] line = new string[11]; line[0] = runtime.soNum.ToString(); line[1] = runtime.woNum; line[2] = runtime.part; line[3] = runtime.seqNum.ToString(); if (runtime.startTime.Year > 1) { line[4] = runtime.startTime.ToString(); } if (runtime.stopTime.Year > 1) { line[5] = runtime.stopTime.ToString(); } if (runtime.runTime > 0.00001) { line[6] = runtime.runTime.ToString("F2"); } line[7] = runtime.stdTime.ToString("F2"); if (runtime.hasSolarsoftTime) { line[8] = runtime.slsTime.ToString("F2"); } else { line[8] = "----"; } if (runtime.actualTime > 0.00001) { line[9] = runtime.actualTime.ToString("F2"); } if (runtime.slsDate.Year > 1) { line[10] = runtime.slsDate.ToString("yyyy-MM-dd"); } gridViewRuntimes.Rows.Add(line); } gridViewRuntimes.Refresh(); // enable show normal buttonShowNormal.Enabled = true; buttonShowException.Enabled = false; buttonSubmit.Enabled = true; // enable search textBoxPieceNum.Enabled = true; buttonGo.Enabled = true; radioButtonSO.Enabled = true; radioButtonWO.Enabled = true; }
// deep copy public RunTime DeepCopy() { RunTime runtime = new RunTime(); runtime.woNum = woNum; runtime.stopTime = stopTime; runtime.stdTime = stdTime; runtime.startTime = startTime; runtime.soNum = soNum; runtime.slsTime = slsTime; runtime.seqNum = seqNum; runtime.runTime = runTime; runtime.actualTime = actualTime; runtime.resCode = resCode; runtime.part = part; runtime.isUsingStdTime = isUsingStdTime; runtime.hasSolarsoftTime = hasSolarsoftTime; runtime.empNum = empNum; runtime.depCode = depCode; runtime.type = type; runtime.slsDate = slsDate; return(runtime); }
// get piece's info public void GetInfo(Database database, Dictionary <string, Dictionary <int, SeqTemplate> > seqTemplateMap, Dictionary <string, Scrap> scrapMap, Dictionary <int, List <Task> > sparkMap, Dictionary <int, List <Task> > wireMap, DateTime date) { if (!seqTemplateMap.ContainsKey(wo)) { return; } Dictionary <int, SeqTemplate> seqMap = seqTemplateMap[wo]; foreach (SeqTemplate seqTemplate in seqMap.Values) { Seq seq = new Seq(seqTemplate.seqNum, seqTemplate.runtime, type, part, wo, so); // get description based on sequence number seq.GetSeqInfo(database, sparkMap, wireMap, date); seq.runtimeList[0].seqNum = seq.seqNum; seq.runtimeList[0].part = part; seq.runtimeList[0].woNum = wo; seq.runtimeList[0].soNum = so; seq.runtimeList[0].type = type; seq.runtimeList[0].stdTime = seq.stdTime; seqList.Add(seq); } // check scrap if (scrapMap.ContainsKey(wo)) { Scrap scrap = scrapMap[wo]; foreach (Seq seq in seqList) { if (seq.seqNum <= scrap.seq) { RunTime runtime = seq.runtimeList[seq.runtimeList.Count - 1].DeepCopy(); runtime.taskList.Clear(); seq.runtimeList.Add(runtime); } } } // get solarsoft time ExcoODBC odbcConnection = ExcoODBC.Instance; odbcConnection.Open(database); foreach (Seq seq in seqList) { if (seq.seqNum != 320 && seq.seqNum != 320 && seq.seqNum != 330 && seq.seqNum != 340 && seq.seqNum != 350 && seq.seqNum != 360) { string query = "select fwdept, fwresc, fwtime, fwdate, fwqtyc from cmsdat.jcsta where fwjobn='" + wo + "' and fwoseq=" + seq.seqNum.ToString() + " order by fwdate"; OdbcDataReader reader = odbcConnection.RunQuery(query); int i = 0; while (reader.Read()) { seq.runtimeList[i].quantity += Convert.ToInt32(reader["fwqtyc"]); seq.runtimeList[i].seqNum = seq.seqNum; seq.runtimeList[i].part = part; seq.runtimeList[i].woNum = wo; seq.runtimeList[i].empNum = 99999; seq.runtimeList[i].depCode = reader["fwdept"].ToString().Trim().Replace("001", "");; seq.runtimeList[i].resCode = reader["fwresc"].ToString().Trim();; seq.runtimeList[i].soNum = so; seq.runtimeList[i].stdTime = seq.stdTime; seq.runtimeList[i].slsTime += Convert.ToDouble(reader["fwtime"]); seq.runtimeList[i].slsDate = Convert.ToDateTime(reader["fwdate"].ToString().Trim()); seq.runtimeList[i].hasSolarsoftTime = true; if (seq.runtimeList.Count > i + 1) { i++; } } reader.Close(); // adjust quantity when meets scrap if (seq.runtimeList.Count > 1) { if (seq.runtimeList.Count > 1 && seq.runtimeList[0].quantity > 1) { if (seq.runtimeList[1].quantity < 1) { seq.runtimeList[0].quantity = 1; seq.runtimeList[1].quantity = 1; } } } } else { if (!seqTemplateMap[seq.woNum].ContainsKey(seq.seqNum)) { throw new Exception("failed to find sequence number " + seq.seqNum.ToString() + " in sequence template " + wo); } seq.runtimeList[0].quantity = seqTemplateMap[seq.woNum][seq.seqNum].compQuant; seq.runtimeList[0].seqNum = seq.seqNum; seq.runtimeList[0].part = part; seq.runtimeList[0].woNum = wo; seq.runtimeList[0].soNum = so; seq.runtimeList[0].stdTime = seq.stdTime; if (seq.runtimeList[0].quantity > 0) { seq.runtimeList[0].slsTime = seq.runtimeList[0].stdTime; seq.runtimeList[0].hasSolarsoftTime = true; } } } }
// display all records in grid view private void DisplayAll() { if (InvokeRequired) { Invoke(new Action(DisplayAll)); return; } runtimeIndexList.Clear(); gridViewRuntimes.Rows.Clear(); string wo = string.Empty; int decadeTaskCount = 0; for (int i = 0; i < allList.Count; i++) { RunTime runtime = allList[i]; string[] line = new string[12]; if (0 != runtime.woNum.CompareTo(wo)) { if (wo.Length > 0) { runtimeIndexList.Add(-1); gridViewRuntimes.Rows.Add(new string[10]); } wo = runtime.woNum; line[0] = runtime.soNum.ToString(); line[1] = runtime.woNum; line[2] = runtime.part; decadeTaskCount = 0; } line[3] = runtime.seqNum.ToString(); if (runtime.startTime.Year > 1) { line[4] = runtime.startTime.ToString(); } if (runtime.stopTime.Year > 1) { line[5] = runtime.stopTime.ToString(); } if (runtime.runTime > 0.0001 || runtime.startTime.Year > 1) { line[6] = runtime.runTime.ToString("F2"); } line[7] = runtime.stdTime.ToString("F2"); if (runtime.hasSolarsoftTime) { line[8] = runtime.slsTime.ToString("F2"); } else { line[8] = "----"; } if (runtime.actualTime > 0.00001 || runtime.taskList.Count > 0) { line[9] = runtime.actualTime.ToString("F2"); } if (runtime.slsDate.Year > 1) { line[10] = runtime.slsDate.ToString("yyyy-MM-dd"); } if (decadeTaskCount < 4) { if (process.decadeTasks.ContainsKey(runtime.soNum)) { if (process.decadeTasks[runtime.soNum].Count > decadeTaskCount) { line[11] = process.decadeTasks[runtime.soNum][decadeTaskCount]; decadeTaskCount++; if (process.decadeTasks[runtime.soNum].Count == decadeTaskCount) { decadeTaskCount = 99; } } } } runtimeIndexList.Add(i); gridViewRuntimes.Rows.Add(line); // mark scarp as red if (process.scrapMap.ContainsKey(wo)) { gridViewRuntimes.Rows[gridViewRuntimes.Rows.Count - 1].Cells[1].Style.BackColor = Color.Red; } // adjust exception style if (exceptionIndexList.Contains(i)) { for (int j = 0; j < 10; j++) { gridViewRuntimes.Rows[gridViewRuntimes.Rows.Count - 1].Cells[j].Style.BackColor = Color.Aqua; } } } gridViewRuntimes.Refresh(); // disable show normal buttonShowNormal.Enabled = false; buttonShowException.Enabled = true; buttonSubmit.Enabled = true; // enable search textBoxPieceNum.Enabled = true; buttonGo.Enabled = true; radioButtonSO.Enabled = true; radioButtonWO.Enabled = true; }