30/09/2018, 19:08
Create Checking Permission function in LINQ C#
I create 1 loginForm, this form will check email and password, if them typed like info in database, redirect to mainForm.
Addition, I want to create and check id, if id = ‘1’ => admin, show mainForm, if not show Error Msg.
Because anyone can Login and manage info in database
my database have 1 table included 7 fields: id, email, password, fullname, sex, birth, address
AccountBUS.Cs:
AccountManagementDataContext AccMgr = new AccountManagementDataContext();
public bool CheckLogin(string email, string password)
{
int account = (from acc in AccMgr.BasicInfos
where acc.email == email && acc.password == password
select acc).Count();
if (account == 1)
return true;
else
return false;
}
public IEnumerable<BasicInfo> SelectAll()
{
IEnumerable<BasicInfo> account = from acc in AccMgr.BasicInfos
select acc;
return account;
}
public bool CheckAccount(string email)
{
int account = (from acc in AccMgr.BasicInfos
where acc.email == email
select acc).Count();
if (account == 1)
return true;
else
return false;
}
How I can make checking id function?
Bài liên quan
trong điều kiện if bạn set thêm giá trị account.id == 1 để kiểm tra có phải là admin không