I have a very basic login form, and and account form. when you login your account page with balance etc. opens up. Sound good in theory, but how do I do it in practice. I have the information in a txt file that is read during the login_click event. Please help

8 Years
Discussion Span
Last Post by jay_el_em

Thought I had a mini brainwave: create an instance of login form on the account form, then use the same variable that I used as the filename for the streamReader, to to read the information onto the form. Doesn't work?

//click event on login form
private void button1_Click(object sender, EventArgs e)
            int pin;
            loginName = txtLoginUsername.Text;
            loginPin = int.Parse(txtLoginPin.Text);
            fileNames = txtLoginUsername.Text + ".txt";
            if (File.Exists(fileNames))
                StreamReader sr = new StreamReader(fileNames);
                string userName = sr.ReadLine();
                pin = int.Parse(sr.ReadLine());

                if (pin == loginPin)
                    MainAccountFrm nFrm = new MainAccountFrm();


// account form
private void MainAccountFrm_Load(object sender, EventArgs e)
            LoginFrm Frm = new LoginFrm();
            lblUser.Text = Frm.fileNames;

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.