Пример #1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MyTest.Model.Sys_UserLogOnModel model)
 {
     return(dal.Update(model));
 }
Пример #2
0
        /*
         * /// <summary>
         * /// 分页获取数据列表
         * /// </summary>
         * public DataSet GetList(int PageSize,int PageIndex,string strWhere)
         * {
         *  SqlParameter[] parameters = {
         *          new SqlParameter("@tblName", SqlDbType.VarChar, 255),
         *          new SqlParameter("@fldName", SqlDbType.VarChar, 255),
         *          new SqlParameter("@PageSize", SqlDbType.Int),
         *          new SqlParameter("@PageIndex", SqlDbType.Int),
         *          new SqlParameter("@IsReCount", SqlDbType.Bit),
         *          new SqlParameter("@OrderType", SqlDbType.Bit),
         *          new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
         *          };
         *  parameters[0].Value = "Sys_User";
         *  parameters[1].Value = "F_Id";
         *  parameters[2].Value = PageSize;
         *  parameters[3].Value = PageIndex;
         *  parameters[4].Value = 0;
         *  parameters[5].Value = 0;
         *  parameters[6].Value = strWhere;
         *  return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
         * }*/

        #endregion  BasicMethod
        #region  ExtensionMethod


        public Sys_UserModel CheckLogin(string username, string password)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 F_Id,F_Account,F_RealName,F_NickName,F_HeadIcon,F_Gender,F_Birthday,F_MobilePhone,F_Email,F_WeChat,F_ManagerId,F_SecurityLevel,F_Signature,F_OrganizeId,F_DepartmentId,F_RoleId,F_DutyId,F_IsAdministrator,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,F_CreatorTime,F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId from Sys_User ");
            strSql.Append(" where F_Account=@F_Account ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Account", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = username;
            MyTest.Model.Sys_UserModel model = new MyTest.Model.Sys_UserModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model = DataRowToModel(ds.Tables[0].Rows[0]);
            }
            if (model != null)
            {
                if (model.F_EnabledMark == true)
                {
                    StringBuilder strSql1 = new StringBuilder();
                    strSql1.Append("select  top 1 F_Id,F_UserId,F_UserPassword,F_UserSecretkey,F_AllowStartTime,F_AllowEndTime,F_LockStartDate,F_LockEndDate,F_FirstVisitTime,F_PreviousVisitTime,F_LastVisitTime,F_ChangePasswordDate,F_MultiUserLogin,F_LogOnCount,F_UserOnLine,F_Question,F_AnswerQuestion,F_CheckIPAddress,F_Language,F_Theme from Sys_UserLogOn ");
                    strSql1.Append(" where F_UserId=@F_UserId ");
                    SqlParameter[] parameters1 =
                    {
                        new SqlParameter("@F_UserId", SqlDbType.VarChar, 50)
                    };
                    parameters1[0].Value = model.F_Id;
                    Sys_UserLogOnDAL ldal = new Sys_UserLogOnDAL();
                    MyTest.Model.Sys_UserLogOnModel lmodel = new MyTest.Model.Sys_UserLogOnModel();
                    DataSet ds1 = DbHelperSQL.Query(strSql1.ToString(), parameters1);
                    if (ds1.Tables[0].Rows.Count > 0)
                    {
                        lmodel = ldal.DataRowToModel(ds1.Tables[0].Rows[0]);
                    }

                    string dbPassword = Md5.md5(DESEncrypt.Encrypt(password.ToLower(), lmodel.F_UserSecretkey).ToLower(), 32).ToLower();
                    if (dbPassword == lmodel.F_UserPassword)
                    {
                        DateTime lastVisitTime = DateTime.Now;
                        int      LogOnCount    = (lmodel.F_LogOnCount).ToInt() + 1;
                        if (lmodel.F_LastVisitTime != null)
                        {
                            lmodel.F_PreviousVisitTime = lmodel.F_LastVisitTime.ToDate();
                        }
                        lmodel.F_LastVisitTime = lastVisitTime;
                        lmodel.F_LogOnCount    = LogOnCount;
                        ldal.Update(lmodel);
                        return(model);
                    }
                    else
                    {
                        throw new Exception("密码不正确,请重新输入");
                    }
                }
                else
                {
                    throw new Exception("账户被系统锁定,请联系管理员");
                }
            }
            else
            {
                throw new Exception("账户不存在,请重新输入");
            }
        }
Пример #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(MyTest.Model.Sys_UserLogOnModel model)
 {
     return(dal.Add(model));
 }