熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

連鎖中心配送系統:登錄系統[3]

2022-06-13   來源: .NET編程 
    ——此文章摘自《ASPNET +SQL Server網絡應用系統開發案例精解》定價 特價 詳細>>http://tracklinktechcn/?m_id=dangdang&a_id=A&l=&l_type= width= height= border= nosave>

             string STconnection = ConfigurationSettingsAppSettings[strconnection];
             //創建數據庫連接
             SqlConnection STconn = new SqlConnection(STconnection);
             //打開數據庫連接
             STconnOpen();
             //根據用戶名和密碼創建sql語句
             string STstrsql = select * from STUser where STNickName = +STUserNickName + and STUserPwd = + STUserPwd+;
             //創建SqlCommand對象對sql語句進行操作
             SqlCommand STcmd = new SqlCommand(STstrsqlSTconn);
             //通過調用ExecuteReader()從數據庫中檢索行創建SqlDataReader實例
             SqlDataReader STsdr = STcmdExecuteReader();
             //判斷是否有數據
             if(STsdrRead())
             {
                       //將獲得的STNickName保存到Session中
                       Session[STNickName] = STsdr[STNickName];
                       //將獲得的STNoAdmin保存到Session中
                       Session[STNoAdmin] = STsdr[STNoAdmin];
                       //判斷管理權限
                       if(Session[STNoAdmin]ToString()==)
                       {
           //如果是一般用戶就定向到STUserLoginaspx頁面
     ResponseRedirect(STUser\\STUserLoginaspx);
                       }
                       else if(Session[STNoAdmin]ToString() == )
                       {
             //如果是管理員就定向到STManagerLoginaspx頁面
     ResponseRedirect(STManager\\STManagerLoginaspx);
                       }
             }
             else
             {
                       //用戶名密碼不正確就彈出警告錯誤!
                       ResponseWrite(<script language=javascript>alert(登錄失敗!);</script>)
             }
    }
    //當用戶輸入完用戶名和密碼後單擊重填按鈕就會觸發此事件的執行
    private void STReset_Click(object sender SystemEventArgs e)
    {
             //定向到Indexaspx頁面
             ResponseRedirect(Indexaspx);
    }

right>[http://developcsaicn/dotnet_ASP/htm>]  [http://developcsaicn/dotnet_ASP/htm>]  []  


From:http://tw.wingwit.com/Article/program/net/201311/15320.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.