1

さまざまなユーザーをさまざまな画面にリダイレクトするログイン画面を作成しようとしています。私はデータベーステーブルを持っています。フィールドは。SQLテーブルの設計

username Varchar(50)
password Varchar(50)
Designation Text
IsAdmin bit 

今、私はそれぞれログインボタンを持つ2つのテキストフィールドを持っています

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        string username = Login1.UserName;
        string password = Login1.Password;
        string CurrentName;

        string s;
        s = WebConfigurationManager.ConnectionStrings["ovmsConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(s);
        con.Open();
        string sqlUserName;

        //FOR NORMAL USERS

    if(username != null)
            {


            sqlUserName = "SELECT username,password FROM tblLogin WHERE username ='" + username + "' AND password ='" + password + "'";
            SqlCommand cmd = new SqlCommand(sqlUserName, con);


            CurrentName = (string)cmd.ExecuteScalar();

            if (CurrentName != null)
            {
                Session["UserAuthentication"] = username;
                Session.Timeout = 1;
                Response.Redirect("start.aspx");
            }
            else
            {
                Session["UserAuthentication"] = "";
            }
        }
    }
}

ログイン後にドライバーに別のページを表示し、管理者に別のページ(管理パネル)を表示したい。

管理者パネルのログイン、ユーザーのログイン画面、ドライバーのログイン画面を1つのフォームで作成したい2つのクエリがあります。

like :
Query for driver

SELECT     username, password, Designation
FROM         dbo.tblLogin
WHERE     (Designation LIKE 'driver')

and for Admin Login

SELECT     username, password, IsAdmin
FROM         dbo.tblLogin
WHERE     (IsAdmin = 1)
4

1 に答える 1