Jump to content

Taking input and sending it to another form?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
Justin88

Justin88

    Newbie

  • Members
  • Pip
  • 4 posts
Hey everyone,

Here is my issue and I believe it is simple but I am stuck.

I have a user login screen which is linked to the UserLogin database. There are three text boxes on the screen. One for User ID, Password, and then Security Level.

This then goes to the Main Menu of the program once it validates the login.

I have two buttons that I want to hide depending on the security level. The buttons are Customer Database and Employee Database which when clicked will allow whoever to view the two databases.

The Employee does not need to see either so the buttons should be hidden, PM should only see the Customer Database and Admin gets to see both.

How do I pull the input from the Security Level text to the Main Menu form so I can write an IF that will say if security = this then show or hide button.

#2
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
You get security from the form right? not the database? If from the form, you can declare the string static and pass it that way:
//Login form
public static string security = "High";//Or whatever you want

//Main Form
if(LoginFormName.security = "High")
{
//Logic
}
else
{
//logic
}
Hope thats what you needed. :)
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#3
Justin88

Justin88

    Newbie

  • Members
  • Pip
  • 4 posts
The security actually comes from the database. I have 3 columns. User ID, Password, and Security Level (1-3, 3 being highest).

#4
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
Are you using a Local Database or a Dataset along with the DataGridView?
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#5
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
why not use a Login control.They are made for this purpose ,u could even customize them

#6
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts

gokuajmes said:

why not use a Login control.They are made for this purpose ,u could even customize them
Are you sure he is using ASP and not Windows Forms?
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#7
Justin88

Justin88

    Newbie

  • Members
  • Pip
  • 4 posts
Hey everyone,

Yes, I am using Windows Forms. I have used C# before but it was like two years ago so everything is taking some time coming back to me. The database is just what we decided to do and the login works and everything I just can't get the Main Menu form to hide the buttons depending on the security level that is logged in.

#8
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts

Quote

Hey everyone,

Yes, I am using Windows Forms. I have used C# before but it was like two years ago so everything is taking some time coming back to me. The database is just what we decided to do and the login works and everything I just can't get the Main Menu form to hide the buttons depending on the security level that is logged in.
OK, what kind of database are you using? Access, SQL, Local? Or what? If you can get the login to work why can't the security work? assign a variable to the security value from the database then test against that.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#9
QuackWare

QuackWare

    Learning Programmer

  • Members
  • PipPipPip
  • 95 posts
If your looking to just transfer information between forms I did a video tutorial on it that hopefully will help you out.

How to transfer information between forms