private void Report_Load(object sender, EventArgs e) { button1.BackColor = System.Drawing.Color.Transparent; button2.BackColor = System.Drawing.Color.Transparent; button3.BackColor = System.Drawing.Color.Transparent; //button4.BackColor = System.Drawing.Color.Transparent; //button5.BackColor = System.Drawing.Color.Transparent; button6.BackColor = System.Drawing.Color.Transparent; //button7.BackColor = System.Drawing.Color.Transparent; //button8.BackColor = System.Drawing.Color.Transparent; pictureBox1.BackColor = System.Drawing.Color.Transparent; if (this.myProperty3 != null) // CHECK OUT { try { FileStream f = new FileStream("Buyer.txt", FileMode.Open); StreamReader s = new StreamReader(f); string str = s.ReadLine(); FileStream t = new FileStream(str.Trim() + ".txt", FileMode.Open); StreamReader sr = new StreamReader(t); string line = ""; while ((line = sr.ReadLine()) != null) { listBox1.Items.Add(line); listBox1.Items.Add("\n\n"); } button3.Visible = true; } catch (Exception err) { MessageBox.Show(err.Message); Phone a = new Phone(); this.Close(); a.Show(); } } else if (this.myProperty != null) // HISTORY { try { StreamReader sr = new StreamReader(this.myProperty + "_History" + ".txt"); string run = ""; while ((run = sr.ReadLine()) != null) { listBox1.Items.Add(run); listBox1.Items.Add("\n"); } } catch { MessageBox.Show("No Purchase History data"); Phone a = new Phone(); this.Close(); a.Show(); } } else if (this.myProperty2 != null) // LOG DATA { try { StreamReader sr1 = new StreamReader(@"Log_Workers\" + myProperty2.ToString().Trim() + ".txt"); // reading from CURRENT month file string run1 = ""; while ((run1 = sr1.ReadLine()) != null) { listBox1.Items.Add(run1); } } catch { MessageBox.Show("No data"); Workers a = new Workers(); this.Close(); a.Show(); } } else if (this.myProperty65 != null) // MESSAGE { button3.Visible = false; button2.Visible = false; try { StreamReader sr1 = new StreamReader("Message.txt"); // reading from CURRENT month file string run1 = ""; while ((run1 = sr1.ReadLine()) != null) { listBox1.Items.Add(run1); } sr1.Close(); } catch { MessageBox.Show("No data"); Phone a = new Phone(); this.Close(); a.Show(); } File.Delete("Message.txt"); // delete message after read } else if (this.mailingList != null) // Mailing show { try { StreamReader Mlist = new StreamReader("Mailing_List.txt"); string run2 = ""; while ((run2 = Mlist.ReadLine()) != null) { listBox1.Items.Add(run2); listBox1.Items.Add("\n"); } Mlist.Close(); } catch { MessageBox.Show("No Data"); Phone b = new Phone(); this.Close(); b.Show(); } } }