string CheckVaile(string Userlogin,string UserPWD) { string MSG=""; if (Userlogin == "" || UserPWD == "") MSG = "请输入正确的用户名和密码!"; H_UserEntity users = new H_UserEntity(); users.UserLoginName = Userlogin; users.UserPWD = UserPWD; // var users = DataConvert<H_UserEntity>.ToList(dt); if (!db.IsVaileLogin(users)) MSG = "用户名密码错误!!!"; return MSG; }
// string strCon = StrCon(); //AccessHelper.conn_str; /// <summary> /// 登录是否有效 /// </summary> /// <param name="ue"></param> /// <returns></returns> public bool IsVaileLogin(H_UserEntity ue) { bool result = true; try { string SqlStr = "SELECT * FROM H_User where UserLoginName=@ul and UserPWD=@pwd"; OleDbParameter[] prams = { new OleDbParameter("@ul", ue.UserLoginName), new OleDbParameter("@pwd", ue.UserPWD) }; DataSet ds = AccessHelper.ExecuteDataSet(strCon(), SqlStr, prams); if (ds == null) result = false; else if (ds.Tables[0].Rows.Count == 0) result = false; else result = true; UserPublicClass.LoginValue = ue.UserLoginName; UserPublicClass.NameValue = ds.Tables[0].Rows[0]["UserName"].ToString(); UserPublicClass.PWDValue = ds.Tables[0].Rows[0]["UserPWD"].ToString(); } catch (Exception ex) { log.wrirteLog("数据库操作", "登录是否有效", ex.Message); result = false; } return result; }