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

鮮花預定系統:登錄和退出[5]

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

    ()前面調用了ST_User類的ST_Login()和ST_GetUserInfo()方法其中ST_Login()方法用來驗證用戶輸入的用戶名和密碼是否正確即從數據庫中查詢有沒有與用戶輸入的數據相同的數據如果有則返回True說明用戶已存在
    public bool ST_Login()
    {
             //根據用戶名密碼創建查詢用戶ID的sql語句
             ST_strSQL = Select ST_Id from ST_UserInfo Where ST_Name=
                       + thisST_Name +
                       + And ST_Password= + ST_FunctionsST_Encrypt(thisST_Password) +;
             try
             {
                       ST_ExecuteSqlValue(ST_strSQL);
                       return true;
             }
             catch
             {
                       return false;
             }                         
    }
    ST_GetUserInfo()用來根據用戶名創建查詢用戶信息
    public bool ST_GetUserInfo()
    {
             //根據用戶名創建查詢用戶信息的sql語句
             ST_strSQL = Select * from ST_UserInfo Where ST_Name=
                       + thisST_Name + ;
             SqlConnection ST_myCn = new SqlConnection(ST_strConn);
             //打開連接
             ST_myCnOpen();
             SqlCommand ST_myCmd = new SqlCommand(ST_strSQLST_myCn);
             try
             {
                       ST_myCmdExecuteNonQuery();
                       SqlDataReader reader = ST_myCmdExecuteReader();
                       if(readerRead())
                       {
                                //獲取用戶ID
                                thisST_ID = readerGetInt();
                                //獲取用戶郵箱
                                thisST_Mail = readerGetString();
                                return true;
                       }
                       else
                       {
                                return false;
                       }
             }
             catch(SystemDataSqlClientSqlException e)
             {
                       throw new Exception(eMessage);
             }
             finally

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


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