2016-05-25 3 views
-1

私は4つのテーブルstudent、tpo、admin、campanyとそれぞれのテーブルにcoloumn電子メールとパスワードを持っています。質問すべてのテーブルとテーブルが適切な電子メールとパスワードを持っているかどうかを確認することができますが、ログイン資格がtpoに属していればtpoページが表示され、ログイン資格が学生に属していれば他のプロセスが同じ方法で行えます。フォームコードはasp.netであり、C#でサポートされています。それぞれの電子メールとパスワードを持つ異なるテーブルを使用してログインを検証する

答えて

0

このロジックを持つ手順pro_login your.csページで

Create Procedure pro_login 
@Email varchar(max), 
@Password varchar(max) 
Begin 
if exists(select userid from student where [email protected] and [email protected]) 
    Begin 
    select 1 
    End 
    else if exists(select userid from tpo where [email protected] and [email protected]) 
    Begin 
    select 2 
    End 
    else if exists(select userid from admin where [email protected] and [email protected]) 
    Begin 
    select 3 
    End 
    else if exists(select userid from campany where [email protected] and [email protected]) 
    Begin 
    select 4 
    End 
End 

&書き込みコード

int res=Login(txtuser.text, txtpass.text); 
if(res==1) 
{ 
Response.Redirect("student.aspx"); 
} 
else if(res==2) 
{ 
Response.Redirect("tpo.aspx"); 
} 
else if(res==3) 
{ 
Response.Redirect("admin.aspx"); 
} 
else if(res==4) 
{ 
Response.Redirect("campany.aspx"); 
} 
を作成します。
1

他のフォームを起動するLogInフォームがあると思います。あなたはログイン方法は、それがユーザーまたはそれが見つからていない場合は-1、それはあなたがすべてのquerysのクラスを持っている考えを作っています

public static int LogIn(String email, String psw) 
{ 
    if((from c in context.student 
     where c.email==email and c.psw==psw 
     select c).Any()) { 
     return 1; 
    } 
    if((from c in context.tpo 
     where c.email==email and c.psw==psw 
     select c).Any()) { 
     return 2; 
    } 
    if((from c in context.admin 
     where c.email==email and c.psw==psw 
     select c).Any()) { 
     return 3; 
    } 
    if((from c in context.campany 
     where c.email==email and c.psw==psw 
     select c).Any()) { 
     return 4; 
    } 
    return -1 
} 

、ypuない場合を発見したテーブルに応じて、int型を返す作ることができますあなたが戻ってくるのではなく、あなたが望むものを起動することができます。

関連する問題