Ejemplo n.º 1
0
        public void CheckForCorrect()
        {
            string filePath = "userpass.txt";
            //Reading File Info:
            FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            StreamReader reader = new StreamReader(file);
            const char   Delim  = ',';
            string       data   = reader.ReadToEnd();

            string[] field = data.Split(Delim);

            reader.Close();
            file.Close();

            //Unnecessary Step
            //StringConversion
            string username = field[0];
            string password = field[1];

            //Authenticating
            int tries = 1;

            //while (tries <= 3)
            //{
            if (username_txt.Text == username && password_txt.Text == password && tries <= 3)
            {
                this.Hide();
                DatEntryForm form = new DatEntryForm();
                form.Show();
            }//if
            else
            {
                if (tries <= 3)
                {
                    output_lbl.Text = "Username or Password are incorrect!";
                    tries++;
                    Clear();
                }

                else
                {
                    output_lbl.Text = "Your account is locked!";
                    Disable();
                } //3rd tries
            }     //else
             //}//while
             //output_lbl.Text = "Your account is locked!";
        }//Authentication
Ejemplo n.º 2
0
        }//CancelButton

        #region Reading from a file
        //public void ReadingFromFile()
        //{
        //    FileStream file = new FileStream(@"C:\College\COMP 123\Final\FinalExam\FinalExam\userpass.txt", FileMode.Open, FileAccess.Read);
        //
        //    StreamReader reader = new StreamReader(file);
        //    const char Delim = ',';
        //    string data = reader.ToString();
        //
        //    string[] field = data.Split(Delim);
        //
        //}//ReadingFromFile
        #endregion

        public void CheckForCorrect()
        {
            //Reading File Info:
            FileStream file = new FileStream(@"username", FileMode.Open, FileAccess.Read);

            StreamReader reader = new StreamReader(file);
            const char   Delim  = ',';
            string       data   = reader.ToString();

            string[] field = data.Split(Delim);

            reader.Close();
            file.Close();

            //StringConversion
            string username = "******"; //field[0];
            string password = "******";     //field[1];

            //Authenticating
            int tries = 1;

            while (tries <= 3)
            {
                if (username_txt.Text == username && password_txt.Text == password)
                {
                    this.Close();
                    FinalExam.DatEntryForm form = new DatEntryForm();
                    form.Show();
                }//if
                else
                {
                    output_lbl.Text = "Username or Password are incorrect!";
                } //else
            }     //while
            output_lbl.Text = "Your account is locked!";
        }         //Authentication