//*******************************************************************************************************
        private void btnYes_Click(object sender, EventArgs e)       //Yes
        {
            string line       = null;
            string lineDelete = lblSelected.Text;                                   //get selected product

            using (StreamReader reader = new StreamReader("Appointments.txt"))
            {
                using (StreamWriter writer = new StreamWriter("Appointments2.txt"))        //need new text file to save updated information on
                {
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (String.Compare(line, lineDelete) == 0)                  //removes the line when match is found on the product
                        {
                            continue;
                        }
                        writer.WriteLine(line);
                    }
                }
            }
            MessageBox.Show("Appointment has been removed");

            using (StreamReader sr = new StreamReader("Appointments2.txt"))          //opens file reader, where stock was saved from main menu
            {
                var line2 = "";                                                      //decalration
                while ((line2 = sr.ReadLine()) != null)                              //read files untill there is nothing left
                {
                    DisplayForm.Appointments = line2;                                //add files to the list box
                }
            }
            this.Hide();                                                             //hides current form
            DisplayForm.Show();                                                      // Shows the Display form
        }
 //**********************************************************************************************
 private void btnBack_Click(object sender, EventArgs e)             //back
 {
     using (StreamReader sr = new StreamReader("Appointments.txt")) //opens file reader, where stock was saved from main menu
     {
         var line = "";                                             //decalration
         while ((line = sr.ReadLine()) != null)                     //read files untill there is nothing left
         {
             DisplayForm.Appointments = line;                       //add files to the list box
         }
     }
     this.Hide();                                                             //hides current form
     DisplayForm.Show();                                                      // Shows the Display form
 }
Exemplo n.º 3
0
        //********************************************************************************************************
        private void btnView_Click(object sender, EventArgs e)      //View Appointments
        {
            frmDisplay DisplayForm = new frmDisplay();

            using (StreamReader sr = new StreamReader("Appointments.txt"))          //opens file reader, where Appointments are saved
            {
                var line = "";                                                      //decalration
                while ((line = sr.ReadLine()) != null)                              //read files untill there is nothing left
                {
                    DisplayForm.Appointments = line;                                //add files to the list box
                }
            }
            this.Hide();
            DisplayForm.Show();
        }
Exemplo n.º 4
0
        //*******************************************************************************************
        private void btnSearch_Click(object sender, EventArgs e)
        {
            frmDisplay Display = new frmDisplay();

            using (StreamReader sr = new StreamReader("Appointments.txt"))             //loads text file
            {
                string line;
                while ((line = sr.ReadLine()) != null)                          //reads text file, until there is a match or no more lines to read
                {
                    if (line.Contains(txtSearch.Text))
                    {
                        Display.Appointments = line;
                    }
                }
            }
            MessageBox.Show("If no clients are displayed, it means there was no match found");
            this.Hide();
            Display.Show();
        }