Help Adding a Login Form

Soli
by Soli · 7 posts
5 years ago in .Net (C#, VB, etc)
Posted 5 years ago · Author
Hi. I created a windows forms application with c# and I wanted to add a login. I created a login on a separate program and imported it to the main app but I couldnt figure out how to call the main app after my login successful.
Code
private void btnLogin_Click(object sender, EventArgs e)
        {
            dsUsers.ReadXml(XMLlocation);
            for (int i = 0; i < dsUsers.Tables["LoginUsers"].Rows.Count; i++)
            {
                USerID = dsUsers.Tables["LoginUsers"].Rows[i]["UserId"].ToString();
                Password = dsUsers.Tables["LoginUsers"].Rows[i]["PAssword"].ToString();
                if(txtBxUserID.Text == USerID && txtBxPassword.Text==Password)
                {
                    LoginSuccess = true;
                    this.Hide();
                   

                }

            }
            if (LoginSuccess==true)
            {
                MessageBox.Show("Login Successful"); //I removed this here and wanted to add a line below this ro run new form1. I cant recall the code I typed now. 
            }
            else
            {
                MessageBox.Show("Login Failed");
            }
        }


I ended up with one solution and two forms and tried this code again but it still said i needed a using statement. I got tired after hours of trying and screwing up my app. I ended up having to recreate from scratch. This is actually something I'm going to donate to a non profit church group. Just a basic app they need but I want it to look nice.

Right now, I deleted the login and I want to know if anyone has any advice on how to go about adding it in.

Thank you.
Posted 5 years ago
Import your Form.cs and Form.Designer.cs file into your solution. Then replace the namespace in the two files. Finally, in your main form.cs file create a new instance of the new form then you can access the methods and properties of it.
Posted 5 years ago · Author
Why do I need to Rename?
Posted 5 years ago
Because the namespace needs to match across all your files in the solution. Unless you have separate solutions in one project in which case you need to reference your solutions via using statements.
Posted 5 years ago · Author
ok... so right now I have two completely separate files because I restarted the login. Do I import it by adding existing project? thats what i did last time. was that part correct or is there a better way? this will import the entire project and then I added it to the solution from there but the code got all mixed up. my memos code was in the main app and it ended up inside the login app. screwed up everything until i found it and deleted it.
Posted 5 years ago
I would simply take the 2 files and and drag them into your solution and rename the namespaces like I mentioned before. You don't need the entire solution to add a second form.
Posted 5 years ago · Author
You are AMAZING!! it's finally finished and it's got a login :dancingbannana: Thank you for all the help :awesome14:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts