コード例 #1
0
ファイル: BllCommon.cs プロジェクト: pentiumCM/GPS
    public static bool IsUserLogin(string sUserName, string sPwd, out int iUserID, out string sErr)
    {
        iUserID = -1;
        sErr    = "";
        System.Collections.Generic.List <Models.CSqlParameters> lstPar = new System.Collections.Generic.List <Models.CSqlParameters>();
        Models.CSqlParameters par = new Models.CSqlParameters();
        par.iLen       = sUserName.Length * 2;
        par.pDirection = System.Data.ParameterDirection.Input;
        par.sName      = "UserName";
        par.sqlDbType  = System.Data.SqlDbType.NVarChar;
        par.sValue     = sUserName;
        lstPar.Add(par);

        par            = new Models.CSqlParameters();
        par.iLen       = sPwd.Length * 2;
        par.pDirection = System.Data.ParameterDirection.Input;
        par.sName      = "Password";
        par.sqlDbType  = System.Data.SqlDbType.NVarChar;
        par.sValue     = sPwd;
        lstPar.Add(par);
        string sSql = "select ExpirationTime,UserID from usermain where username = @UserName and password = @Password and DelPurview = 0 ";

        System.Data.DataSet ds = BllSql.RunSqlSelectParameters(false, sSql, lstPar, out sErr);
        if (sErr.Length > 0)
        {
            return(false);
        }
        else
        {
            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                sErr = "4004";
                return(false);
            }
            else
            {
                try
                {
                    DateTime dtTime = DateTime.Parse(ds.Tables[0].Rows[0]["ExpirationTime"].ToString());
                    if (dtTime.Subtract(DateTime.Now).TotalMinutes > 0)
                    {
                        iUserID = Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"]);
                        return(true);
                    }
                    else
                    {
                        sErr = "4005";
                        return(false);
                    }
                    return(false);
                }
                catch { }
                sErr = "4006";
                return(false);
            }
        }
    }
コード例 #2
0
ファイル: BllCommon.cs プロジェクト: pentiumCM/GPS
    public static bool IsVehLogin(string sUserName, string sPwd, out int iUserID, out string sErr)
    {
        iUserID = -1;
        sErr    = "";
        System.Collections.Generic.List <Models.CSqlParameters> lstPar = new System.Collections.Generic.List <Models.CSqlParameters>();
        Models.CSqlParameters par = new Models.CSqlParameters();
        par.iLen       = sUserName.Length * 2;
        par.pDirection = System.Data.ParameterDirection.Input;
        par.sName      = "UserName";
        par.sqlDbType  = System.Data.SqlDbType.NVarChar;
        par.sValue     = sUserName;
        lstPar.Add(par);

        par            = new Models.CSqlParameters();
        par.iLen       = sPwd.Length * 2;
        par.pDirection = System.Data.ParameterDirection.Input;
        par.sName      = "Password";
        par.sqlDbType  = System.Data.SqlDbType.NVarChar;
        par.sValue     = sPwd;
        lstPar.Add(par);
        string sSql = "select Id from Vehicle where Cph = @UserName and WebPass = @Password and DelFlag = 0 ";

        System.Data.DataSet ds = BllSql.RunSqlSelectParameters(false, sSql, lstPar, out sErr);
        if (sErr.Length > 0)
        {
            return(false);
        }
        else
        {
            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                sErr = "4004";
                return(false);
            }
            else
            {
                try
                {
                    iUserID = Convert.ToInt32(ds.Tables[0].Rows[0]["Id"]);
                    return(true);
                }
                catch { }
                sErr = "4006";
                return(false);
            }
        }
    }