Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Login
- private void button1_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(txtUser.Text))
- {
- //Show warning
- }
- else if (string.IsNullOrEmpty(txtPass.Text))
- {
- //Show warning
- }
- using (DataTable dt = LookupUser(txtUser.Text)) //Look into SQL data table for username and password
- {
- if (dt.Rows.Count == 0)
- {
- //Show warning
- }
- else
- {
- string dbPassword = Convert.ToString(dt.Rows[0]["pass"]);
- string appPassword = Encrypt(txtPass.Text);
- if (string.Compare(dbPassword, appPassword) == 0)
- {
- //I need to pass username value to myForm...
- DialogResult = DialogResult.OK;
- }
- else
- {
- //Show warning
- }
- }
- }
- //Program.cs
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- DialogResult result;
- using (var loginForm = new Login())
- result = loginForm.ShowDialog();
- if (result == DialogResult.OK)
- {
- Application.Run(new myForm());
- }
- }
- public string UserName {get; private set;}
- if (string.Compare(dbPassword, appPassword) == 0)
- {
- UserName = txtUser.Text;
- //I need to pass username value to myForm...
- DialogResult = DialogResult.OK;
- }
- else
- {
- //Show warning
- }
- DialogResult result;
- using (var loginForm = new Login())
- result = loginForm.ShowDialog();
- if (result == DialogResult.OK)
- {
- var username = loginForm.UserName;
- Application.Run(new myForm(username));
- }
- }
- Siman_dbEntities db = new Siman_dbEntities();
- public string UserNameLogedIn;
- private void btnLogin_Click(object sender, EventArgs e)
- {
- var login = from b in db.Tbl_Users.Where(b => b.Username == txtUsername.Text && b.Password == txt_Password.Text)
- select b;
- if (login.Count()==1)
- {
- this.Hide();
- main frmmain = new main();
- frmmain.Show();
- }
- var query = db.Tbl_Users.Where(c => c.Username == txtUsername.Text).Single();
- UserNameLogedIn = query.Name.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement