Example #1
0
 public void Clear()
 {
     IDText.Clear();
     FullNameText.Clear();
     UserNameText.Clear();
     PasswordText.Clear();
 }
Example #2
0
        private void Save_Click(object sender, EventArgs e)
        {
            if (IDText.Text == "" || FullNameText.Text == "" || UserNameText.Text == "" || PasswordText.Text == "")
            {
                MessageBox.Show("Please fill in all the boxes");
                IDText.Clear();
                FullNameText.Clear();
                UserNameText.Clear();
                PasswordText.Clear();
            }
            if (System.Text.RegularExpressions.Regex.IsMatch(IDText.Text, "[^0-9]"))
            {
                MessageBox.Show("Please enter only numbers");
                IDText.Clear();
            }
            else if (IDText.Text != "" && FullNameText.Text != "" && UserNameText.Text != "" && PasswordText.Text != "")
            {
                ReadingInTextFile();
                if (inuse == false)
                {
                    List <EmployeeDetails> Listofemployees = new List <EmployeeDetails>();
                    Listofemployees.Add(new EmployeeDetails(int.Parse(IDText.Text), FullNameText.Text, UserNameText.Text, PasswordText.Text));

                    MessageBox.Show("Employee has been added to the system");
                    using (StreamWriter tw = new StreamWriter("Savedlist.txt", true))
                    {
                        foreach (EmployeeDetails s in Listofemployees)
                        {
                            tw.WriteLine(s.ID + "," + s.FullName + "," + s.UserName + "," + s.Password);
                            tw.Close();
                        }
                    }
                    Clear();
                }
            }
            inuse = false;
        }