Advertisement
Guest User

Untitled

a guest
May 30th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1.  private int? CheckUserPass()
  2.         {
  3.             // take text boxes
  4.             // user and pass
  5.             // go into db
  6.             // get matching userid
  7.            
  8.  
  9.             var matchedUser = from userRow
  10.                 in dc.Users
  11.                 where userRow.UserName == txtUsername.Text &&
  12.                 userRow.Password == txtPassword.Text
  13.                 select userRow.UserID;
  14.  
  15.             if (matchedUser.Any())
  16.                 return matchedUser.Single();
  17.             else
  18.             {
  19.                 MessageBox.Show("Invalid user or pass");
  20.                 // focus clear etc
  21.  
  22.                 return null;
  23.             }
  24.  
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement