public void LoadLogRecord(int lintLogRec, Globals.ProjectStatus statusFilter = Globals.ProjectStatus.None) { string[] lstrTitleRec; rtbProjectNotes.Clear(); //first find the record we are looking for for (int i = 1; i < Globals.mstrLogFileLines.Length; i++) //skip header record { if (Globals.mstrLogFileLines[i].StartsWith("&&&")) { lstrTitleRec = Globals.mstrLogFileLines[i].Split(Globals.DELIM); if (lintLogRec == Int32.Parse(lstrTitleRec[0].Substring(3)) && (lstrTitleRec[2] == Enum.GetName(statusFilter.GetType(), statusFilter) || statusFilter == Globals.ProjectStatus.None)) { Globals.mintCurrentLogFileRec = Int32.Parse(lstrTitleRec[0].Substring(3)); cmbProjectStatus.SelectedIndex = cmbProjectStatus.FindString(lstrTitleRec[2]); txtStartDate.Text = Globals.FormatDateForDisplay(lstrTitleRec[3]); txtEndDate.Text = Globals.FormatDateForDisplay(lstrTitleRec[4]); if (lstrTitleRec[5] == "1") { chkStatus.Checked = true; } if (lstrTitleRec[6] == "1") { chkPriority.Checked = true; } //now load all the text until the next record i++; while (i < Globals.mstrLogFileLines.Length) { if (Globals.mstrLogFileLines[i].StartsWith("&&&") == false) { rtbProjectNotes.AppendText(Globals.mstrLogFileLines[i] + "\n"); i++; } else { break; } } } else { i += Int32.Parse(lstrTitleRec[7]); //go to next title record } } } }
private void LoadLogHeaderRecords(string lstrFileName, Globals.ProjectStatus statusFilter = Globals.ProjectStatus.None) { string[] lstrTitleRec; Globals.mintLastLogFileRec = 0; Globals.mstrLogFileLines = File.ReadAllLines(lstrFileName); if (Globals.mstrLogFileLines.Length == 0) //for some reason the file exists, but is blank, recreate it with header record { Globals.CreateNewTextFile(Globals.mstrCurTextFile); Globals.mstrLogFileLines = File.ReadAllLines(lstrFileName); } if (Globals.mstrLogFileLines.Length == 1) //file only has header record, get out { lblYearMonth.Text = Globals.mstrLogFileLines[0]; //set what month/year we are in currently return; } lblYearMonth.Text = Globals.mstrLogFileLines[0]; //set what month/year we are in currently for (int i = 1; i < Globals.mstrLogFileLines.Length; i++) //skip header record { if (Globals.mstrLogFileLines[i].StartsWith("&&&")) { lstrTitleRec = Globals.mstrLogFileLines[i].Split(Globals.DELIM); try { Globals.mintCurrentLogFileRec = Int32.Parse(lstrTitleRec[0].Substring(3)); if (Globals.mintCurrentLogFileRec > Globals.mintLastLogFileRec) { Globals.mintLastLogFileRec = Globals.mintCurrentLogFileRec; } if (lstrTitleRec[2] == Enum.GetName(statusFilter.GetType(), statusFilter) || statusFilter == Globals.ProjectStatus.None) { //Project title will be MM-DD-YYYY | Title | Rec Number cmbProjectTitle.Items.Add(Globals.FormatDateForDisplay(lstrTitleRec[3]) + " " + Globals.DELIM + " " + lstrTitleRec[1] + " " + Globals.DELIM + " " + lstrTitleRec[0].Substring(3)); } } catch (System.FormatException formatErr) { int lineNum = i + 1; MessageBox.Show("Error Loading Document on line " + lineNum.ToString() + ".", "", MessageBoxButtons.OK, MessageBoxIcon.Information); System.Environment.Exit(11); //bad format? } } } }