// Search button clicked events: private void SearchButton_Click(object sender, EventArgs e) { bool flag = File.Exists(HafalaHub.DirectoryPath + SearchTxtBox.Text + ".txt"); // A boolean value that indicates if the desired file exists. // If the file exists then it's opening the alert display form and if not it's showing host an error messege: if (flag) { string AlertText = File.ReadAllText(HafalaHub.DirectoryPath + SearchTxtBox.Text + ".txt"); passingText = AlertText; passingAlertGroup = SearchTxtBox.Text; passingPath = HafalaHub.DirectoryPath + SearchTxtBox.Text + ".txt"; Alert_Display alert_Display = new Alert_Display(); alert_Display.Show(); } else { if (SearchTxtBox.Text == "") { MessageBox.Show("Plese insert an alert group identifier!" , "oops", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("The alertgroup you have inserted is either wrong or doesn't exist yet in the archive." , "oops", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } // ---------------------------------------------------------------------------------------------------------- }
// Open button clicked events: private void OpenFileButton_Click(object sender, EventArgs e) { if (AlertGroupList.SelectedItem == null) { return; } string curAlertGroup = AlertGroupList.SelectedItem.ToString(); passingText = File.ReadAllText(HafalaHub.DirectoryPath + curAlertGroup + ".txt"); passingAlertGroup = curAlertGroup; passingPath = HafalaHub.DirectoryPath + curAlertGroup + ".txt"; Alert_Display alert_Display = new Alert_Display(); alert_Display.Show(); }
private void button4_Click(object sender, EventArgs e) { if (listBox1.SelectedItem == null) { return; } string curAlertGroup = listBox1.SelectedItem.ToString(); string AlertText = File.ReadAllText(@"c:\users\admin\db\" + curAlertGroup + ".txt"); passingText = AlertText; passingAlertGroup = curAlertGroup; passingPath = @"C:\users\admin\db\" + curAlertGroup + ".txt"; Alert_Display alert_Display = new Alert_Display(); alert_Display.Show(); }
private void button3_Click(object sender, EventArgs e) { string desired = textBox1.Text; bool flag = File.Exists(directory + @"\" + desired + ".txt"); if (flag) { string AlertText = File.ReadAllText(@"c:\users\admin\db\" + textBox1.Text + ".txt"); passingText = AlertText; passingAlertGroup = textBox1.Text; passingPath = @"C:\users\admin\db\" + textBox1.Text + ".txt"; Alert_Display alert_Display = new Alert_Display(); alert_Display.Show(); } else { MessageBox.Show("The alertgroup you have inserted is either wrong or doesn't exist yet in the archive." , "oops", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }