0

so i have created a log in app which is for registering for a conference, i need the userId and userPassword from the login form to the conference form the choose this is what i have if you need further info let me know

this is for the login form

  private void btnLogin_Click(object sender, EventArgs e)
                {
                    string userId = string.Empty;
                    string userPassword = string.Empty;

                    if (txtID.Text.StartsWith("m"))
                    {
                        string[] member = System.IO.File.ReadAllLines("Members.txt");
                        foreach (string line in member)
                        {
                            string trimmedLine = line;
                            if (trimmedLine.StartsWith("?"))
                            {
                                userId = trimmedLine.Substring(1);
                            }
                            else if (trimmedLine.StartsWith("*"))
                            {
                                userPassword = trimmedLine.Substring(1);
                            }

                            if (userId == txtID.Text && userPassword == txtPassword.Text)
                            {
                                this.Hide();
                                Conference_M_ con = new Conference_M_();
                                con.ShowDialog();
                                this.Close();
                                break;
                            }
                        }
                        if (userId != txtID.Text && userPassword != txtPassword.Text) 
                        {
                            MessageBox.Show("Incorrect password or ID.", "Invalid Entry");
                        }
                    }


                    if (txtID.Text.StartsWith("g"))
                    {
                        string[] guest = System.IO.File.ReadAllLines("Guests.txt");
                        foreach (string line in guest)
                        {
                            string trimmedLine = line.Trim();
                            if (trimmedLine.StartsWith("&"))
                            {
                                userId = trimmedLine.Substring(1);
                            }
                            else if (trimmedLine.StartsWith("*"))
                            {
                                userPassword = trimmedLine.Substring(1);
                            }

                            if (userId == txtID.Text && userPassword == txtPassword.Text)
                            {
                                this.Hide();
                                Conference_G_ conG = new Conference_G_();
                                conG.ShowDialog();
                                this.Close();
                                break;
                            }
                        }
                        if (userId != txtID.Text && userPassword != txtPassword.Text) 
                        {
                            MessageBox.Show("Incorrect password or ID.", "Invalid Entry");
                        }
                    }

                    if (txtID.Text.StartsWith("a"))
                    {

                        string[] advisor = System.IO.File.ReadAllLines("Advisors.txt");
                        foreach (string line in advisor)
                        {
                            string trimmedLine = line.Trim();
                            if (trimmedLine.StartsWith("@"))
                            {
                                userId = trimmedLine.Substring(1);
                            }
                            else if (trimmedLine.StartsWith("*"))
                            {
                                userPassword = trimmedLine.Substring(1);
                            }


                            if (userId == txtID.Text && userPassword == txtPassword.Text)
                            {
                                this.Hide();
                                Conference_A_ conA = new Conference_A_();
                                conA.ShowDialog();
                                this.Close();
                                break;
                            }
                        }
                        if (userId != txtID.Text && userPassword != txtPassword.Text)
                        {
                            MessageBox.Show("Incorrect password or ID.", "Invalid Entry");
                        }
                    }        


            }




this is for the conference form, the problem i am having is that its reads the file but only takes the first ID and password that is in the text file so i figured if i passed the the Id and password that was used to log in that i could use an if statement so it writes the correct ID and password of who is logged in

 private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {


                if (radNov14.Checked == false && radNov15.Checked == false)
                {
                    MessageBox.Show("Please select a date and time.", "Conference Confirm");
                }
                if (radNov14.Checked == true)
                {
                    if (radAdvisor.Checked == true)
                    {
                        StreamWriter Washington = new StreamWriter("Minneapolis Conference.txt", true);

                        StreamReader user = new StreamReader("Members.txt");

                        Washington.Write("Members registered for the Minneapolis conference.");
                        Washington.WriteLine();
                        Washington.WriteLine("Name: " + user.ReadLine());
                        Washington.WriteLine("Participant Type: " + user.ReadLine());
                        user.ReadLine();
                        user.ReadLine();
                        Washington.WriteLine("Chapter Number: " + user.ReadLine());
                        Washington.WriteLine("Conference Code: " + user.ReadLine() + "5678");
                        Washington.WriteLine("Conference Date: November 14");
                        Washington.WriteLine();
                        Washington.Close();
                        user.Close();
                        MessageBox.Show("You habe sucessfully register for the Minneapolis Conference.");

                        StreamWriter WashCarShop = new StreamWriter("Minneapolis Advisor Workshop.txt", true);
                        StreamReader userW = new StreamReader("Members.txt");
                        WashCarShop.Write("Members Registered for Minneapolis Advisor Workshop: ");
                        WashCarShop.WriteLine();
                        WashCarShop.WriteLine("Name: " + userW.ReadLine());
                        WashCarShop.WriteLine("Participant Type: " + userW.ReadLine());
                        userW.ReadLine();
                        userW.ReadLine();
                        WashCarShop.WriteLine("Chapter Number: " + userW.ReadLine());
                        WashCarShop.WriteLine("Conference Code: " + userW.ReadLine() + "5678");
                        WashCarShop.WriteLine("Conference Date: November 14");
                        WashCarShop.WriteLine();
                        WashCarShop.Close();
                        userW.Close();
                        MessageBox.Show("You have sucessfully register for the Minneapolis Advisor Workshop.");

                    }
                }
                 if (radNov14.Checked == true)
                {
                     if (radFirstImpressions.Checked == true)
                    {

                        StreamWriter Washington = new StreamWriter("Minneapolis Conference.txt", true);
                        StreamReader user = new StreamReader("Members.txt");
                        Washington.Write("Members registered for the Minneapolis Conference.");
                        Washington.WriteLine();
                        Washington.WriteLine("Name: " + user.ReadLine());
                        Washington.WriteLine("Participant Type: " + user.ReadLine());
                        user.ReadLine();
                        user.ReadLine();
                        Washington.WriteLine("Chapter Number: " + user.ReadLine());
                        Washington.WriteLine("Conference Code: " + user.ReadLine() + "5678");
                        Washington.WriteLine("Conference Date: November 14");
                        Washington.WriteLine();
                        Washington.Close();
                        user.Close();
                        MessageBox.Show("You have sucessfully register for the Minneapolis Conference.");


                        StreamWriter WashCarShop = new StreamWriter("Minneapolis First Impressions Workshop.txt", true);
                        StreamReader userW = new StreamReader("Members.txt");
                        WashCarShop.Write("Members Registered for the Minneapolis First Impressions Workshop: ");
                        WashCarShop.WriteLine();
                        WashCarShop.WriteLine("Name: " + userW.ReadLine());
                        WashCarShop.WriteLine("Participant Type: " + userW.ReadLine());
                        userW.ReadLine();
                        userW.ReadLine();
                        WashCarShop.WriteLine("Chapter Number: " + userW.ReadLine());
                        WashCarShop.WriteLine("Conference Code: " + userW.ReadLine() + "5678");
                        WashCarShop.WriteLine("Conference Date: November 14");
                        WashCarShop.WriteLine();
                        WashCarShop.Close();
                        userW.Close();
                        MessageBox.Show("You have sucessfully register for the Minneapolis First Impressions Workshop.");

                    }
                }
                 if (radNov14.Checked == true)
                {
                    if (radStressOut.Checked == true)
                    {
                        StreamWriter Washington = new StreamWriter("Minneapolis Conference.txt", true);
                        StreamReader user = new StreamReader("Members.txt");
                        Washington.Write("Members registered for the Minneapolis Conference.");
                        Washington.WriteLine();
                        Washington.WriteLine("Name: " + user.ReadLine());
                        Washington.WriteLine("Participant Type: " + user.ReadLine());
                        user.ReadLine();
                        user.ReadLine();
                        Washington.WriteLine("Chapter Number: " + user.ReadLine());
                        Washington.WriteLine("Conference Code: " + user.ReadLine() + "5678");
                        Washington.WriteLine("Conference Date: November 14");
                        Washington.WriteLine();
                        Washington.Close();
                        user.Close();
                        MessageBox.Show("You have sucessfully register for Minneapolis Conference.");


                        StreamWriter WashCarShop = new StreamWriter("Minneapolis Stressed Out Workshop.txt", true);
                        StreamReader userW = new StreamReader("Members.txt");
                        WashCarShop.Write("Members Registered for the Minneapolis Stressed Out Workshop: ");
                        WashCarShop.WriteLine();
                        WashCarShop.WriteLine("Name: " + userW.ReadLine());
                        WashCarShop.WriteLine("Participant Type: " + userW.ReadLine());
                        userW.ReadLine();
                        userW.ReadLine();
                        WashCarShop.WriteLine("Chapter Number: " + userW.ReadLine());
                        WashCarShop.WriteLine("Conference Code: " + userW.ReadLine() + "5678");
                        WashCarShop.WriteLine("Conference Date: November 14");
                        WashCarShop.WriteLine();
                        WashCarShop.Close();
                        userW.Close();
                        MessageBox.Show("You have sucessfully register for the Minneapolis Stressed Out Workshop.");

                    }
                }




                 if (radNov15.Checked == true)
                {
                    if (radAdvisor.Checked == true)
                    {
                        StreamWriter Minneapolis = new StreamWriter("Minneapolis Conference.txt", true);

                        StreamReader user = new StreamReader("Members.txt");
                        Minneapolis.Write("Members registered for the Minneapolis Conference.");
                        Minneapolis.WriteLine();
                        Minneapolis.WriteLine("Name: " + user.ReadLine());
                        Minneapolis.WriteLine("Participant Type: " + user.ReadLine());
                        user.ReadLine();
                        user.ReadLine();
                        Minneapolis.WriteLine("Chapter Number: " + user.ReadLine());
                        Minneapolis.WriteLine("Conference Code: " + user.ReadLine() + "5678");
                        Minneapolis.WriteLine("Conference Date: November 15");
                        Minneapolis.WriteLine();
                        Minneapolis.Close();
                        user.Close();
                        MessageBox.Show("You have sucessfully register for Minneapolis Conference.");

                        StreamWriter MinnCarShop = new StreamWriter("Minneapolis Advisor Workshop.txt", true);
                        StreamReader userW = new StreamReader("Members.txt");
                        MinnCarShop.Write("Members Registered for Minneapolis Advisor Workshop:  ");
                        MinnCarShop.WriteLine();
                        MinnCarShop.WriteLine("Name: " + userW.ReadLine());
                        MinnCarShop.WriteLine("Participant Type: " + userW.ReadLine());
                        userW.ReadLine();
                        userW.ReadLine();
                        MinnCarShop.WriteLine("Chapter Number: " + userW.ReadLine());
                        MinnCarShop.WriteLine("Conference Code: " + userW.ReadLine() + "5678");
                        MinnCarShop.WriteLine("Conference Date: November 15");
                        MinnCarShop.WriteLine();
                        MinnCarShop.Close();
                        userW.Close();
                        MessageBox.Show("You have sucessfully register for the Minneapolis Advisor Workshop.");

                    }
                }
                 if (radNov15.Checked == true)
                {
                    if (radFirstImpressions.Checked == true)
                    {

                        StreamWriter Washington = new StreamWriter("Minneapolis Conference.txt", true);
                        StreamReader user = new StreamReader("Members.txt");
                        Washington.Write("Members registered for the Minneapolis Conference.");
                        Washington.WriteLine();
                        Washington.WriteLine("Name: " + user.ReadLine());
                        Washington.WriteLine("Participant Type: " + user.ReadLine());
                        user.ReadLine();
                        user.ReadLine();
                        Washington.WriteLine("Chapter Number: " + user.ReadLine());
                        Washington.WriteLine("Conference Code: " + user.ReadLine() + "5678");
                        Washington.WriteLine("Conference Date: November 15");
                        Washington.WriteLine();
                        Washington.Close();
                        user.Close();
                        MessageBox.Show("You have sucessfully register for Minneapolis Conference.");


                        StreamWriter WashCarShop = new StreamWriter("Minneapolis First Impressions Workshop.txt", true);
                        StreamReader userW = new StreamReader("Members.txt");
                        WashCarShop.Write("Members Registered for Minneapolis First Impressions Workshop: ");
                        WashCarShop.WriteLine();
                        WashCarShop.WriteLine("Name: " + userW.ReadLine());
                        WashCarShop.WriteLine("Participant Type: " + userW.ReadLine());
                        userW.ReadLine();
                        userW.ReadLine();
                        WashCarShop.WriteLine("Chapter Number: " + userW.ReadLine());
                        WashCarShop.WriteLine("Conference Code: " + userW.ReadLine() + "5678");
                        WashCarShop.WriteLine("Conference Date: November 15");
                        WashCarShop.WriteLine();
                        WashCarShop.Close();
                        userW.Close();
                        MessageBox.Show("You have sucessfully register for the Minneapolis First Impressions Workshop.");

                    }
                }
                 if (radNov15.Checked == true)
                {
                    if (radStressOut.Checked == true)
                    {
                        StreamWriter Washington = new StreamWriter("Minneapolis Conference.txt", true);
                        StreamReader user = new StreamReader("Members.txt");
                        Washington.Write("Members registered for the Minneapolis Conference.txt.");
                        Washington.WriteLine();
                        Washington.WriteLine("Name: " + user.ReadLine());
                        Washington.WriteLine("Participant Type: " + user.ReadLine());
                        user.ReadLine();
                        user.ReadLine();
                        Washington.WriteLine("Chapter Number: " + user.ReadLine());
                        Washington.WriteLine("Conference Code: " + user.ReadLine() + "5678");
                        Washington.WriteLine("Conference Date: November 15");
                        Washington.WriteLine();
                        Washington.Close();
                        user.Close();
                        MessageBox.Show("You have sucessfully register for Minneapolis Conference.");


                        StreamWriter WashCarShop = new StreamWriter("Minneapolis Stressed Out Workshop.txt", true);
                        StreamReader userW = new StreamReader("Members.txt");
                        WashCarShop.Write("Members Registered for Minneapolis Stressed Out Workshop: ");
                        WashCarShop.WriteLine();
                        WashCarShop.WriteLine("Name: " + userW.ReadLine());
                        WashCarShop.WriteLine("Participant Type: " + userW.ReadLine());
                        userW.ReadLine();
                        userW.ReadLine();
                        WashCarShop.WriteLine("Chapter Number: " + userW.ReadLine());
                        WashCarShop.WriteLine("Conference Code: " + userW.ReadLine() + "5678");
                        WashCarShop.WriteLine("Conference Date: November 15");
                        WashCarShop.WriteLine();
                        WashCarShop.Close();
                        userW.Close();
                        MessageBox.Show("You have sucessfully register for the Minneapolis Stressed Out Workshop.");
                    }
                }
            }


            catch (Exception I)
            {
                MessageBox.Show("Error: " + I.Message, "Conference Error");
            }
        }
2
Contributors
1
Reply
20
Views
2 Years
Discussion Span
Last Post by cgeier
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.