示例#1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MyTest.Model.Sys_UserModel GetModel(string F_Id)
        {
            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_Id=@F_Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Id", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = F_Id;

            MyTest.Model.Sys_UserModel model = new MyTest.Model.Sys_UserModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#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_UserModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sys_User(");
            strSql.Append("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)");
            strSql.Append(" values (");
            strSql.Append("@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)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Id",               SqlDbType.VarChar,    50),
                new SqlParameter("@F_Account",          SqlDbType.VarChar,    50),
                new SqlParameter("@F_RealName",         SqlDbType.VarChar,    50),
                new SqlParameter("@F_NickName",         SqlDbType.VarChar,    50),
                new SqlParameter("@F_HeadIcon",         SqlDbType.VarChar,    50),
                new SqlParameter("@F_Gender",           SqlDbType.Bit,         1),
                new SqlParameter("@F_Birthday",         SqlDbType.DateTime),
                new SqlParameter("@F_MobilePhone",      SqlDbType.VarChar,    20),
                new SqlParameter("@F_Email",            SqlDbType.VarChar,    50),
                new SqlParameter("@F_WeChat",           SqlDbType.VarChar,    50),
                new SqlParameter("@F_ManagerId",        SqlDbType.VarChar,    50),
                new SqlParameter("@F_SecurityLevel",    SqlDbType.Int,         4),
                new SqlParameter("@F_Signature",        SqlDbType.VarChar,   500),
                new SqlParameter("@F_OrganizeId",       SqlDbType.VarChar,    50),
                new SqlParameter("@F_DepartmentId",     SqlDbType.VarChar,   500),
                new SqlParameter("@F_RoleId",           SqlDbType.VarChar,   500),
                new SqlParameter("@F_DutyId",           SqlDbType.VarChar,   500),
                new SqlParameter("@F_IsAdministrator",  SqlDbType.Bit,         1),
                new SqlParameter("@F_SortCode",         SqlDbType.Int,         4),
                new SqlParameter("@F_DeleteMark",       SqlDbType.Bit,         1),
                new SqlParameter("@F_EnabledMark",      SqlDbType.Bit,         1),
                new SqlParameter("@F_Description",      SqlDbType.VarChar,   500),
                new SqlParameter("@F_CreatorTime",      SqlDbType.DateTime),
                new SqlParameter("@F_CreatorUserId",    SqlDbType.VarChar,    50),
                new SqlParameter("@F_LastModifyTime",   SqlDbType.DateTime),
                new SqlParameter("@F_LastModifyUserId", SqlDbType.VarChar,    50),
                new SqlParameter("@F_DeleteTime",       SqlDbType.DateTime),
                new SqlParameter("@F_DeleteUserId",     SqlDbType.VarChar, 500)
            };
            parameters[0].Value  = model.F_Id;
            parameters[1].Value  = model.F_Account;
            parameters[2].Value  = model.F_RealName;
            parameters[3].Value  = model.F_NickName;
            parameters[4].Value  = model.F_HeadIcon;
            parameters[5].Value  = model.F_Gender;
            parameters[6].Value  = model.F_Birthday;
            parameters[7].Value  = model.F_MobilePhone;
            parameters[8].Value  = model.F_Email;
            parameters[9].Value  = model.F_WeChat;
            parameters[10].Value = model.F_ManagerId;
            parameters[11].Value = model.F_SecurityLevel;
            parameters[12].Value = model.F_Signature;
            parameters[13].Value = model.F_OrganizeId;
            parameters[14].Value = model.F_DepartmentId;
            parameters[15].Value = model.F_RoleId;
            parameters[16].Value = model.F_DutyId;
            parameters[17].Value = model.F_IsAdministrator;
            parameters[18].Value = model.F_SortCode;
            parameters[19].Value = model.F_DeleteMark;
            parameters[20].Value = model.F_EnabledMark;
            parameters[21].Value = model.F_Description;
            parameters[22].Value = model.F_CreatorTime;
            parameters[23].Value = model.F_CreatorUserId;
            parameters[24].Value = model.F_LastModifyTime;
            parameters[25].Value = model.F_LastModifyUserId;
            parameters[26].Value = model.F_DeleteTime;
            parameters[27].Value = model.F_DeleteUserId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MyTest.Model.Sys_UserModel DataRowToModel(DataRow row)
 {
     MyTest.Model.Sys_UserModel model = new MyTest.Model.Sys_UserModel();
     if (row != null)
     {
         if (row["F_Id"] != null)
         {
             model.F_Id = row["F_Id"].ToString();
         }
         if (row["F_Account"] != null)
         {
             model.F_Account = row["F_Account"].ToString();
         }
         if (row["F_RealName"] != null)
         {
             model.F_RealName = row["F_RealName"].ToString();
         }
         if (row["F_NickName"] != null)
         {
             model.F_NickName = row["F_NickName"].ToString();
         }
         if (row["F_HeadIcon"] != null)
         {
             model.F_HeadIcon = row["F_HeadIcon"].ToString();
         }
         if (row["F_Gender"] != null && row["F_Gender"].ToString() != "")
         {
             if ((row["F_Gender"].ToString() == "1") || (row["F_Gender"].ToString().ToLower() == "true"))
             {
                 model.F_Gender = true;
             }
             else
             {
                 model.F_Gender = false;
             }
         }
         if (row["F_Birthday"] != null && row["F_Birthday"].ToString() != "")
         {
             model.F_Birthday = DateTime.Parse(row["F_Birthday"].ToString());
         }
         if (row["F_MobilePhone"] != null)
         {
             model.F_MobilePhone = row["F_MobilePhone"].ToString();
         }
         if (row["F_Email"] != null)
         {
             model.F_Email = row["F_Email"].ToString();
         }
         if (row["F_WeChat"] != null)
         {
             model.F_WeChat = row["F_WeChat"].ToString();
         }
         if (row["F_ManagerId"] != null)
         {
             model.F_ManagerId = row["F_ManagerId"].ToString();
         }
         if (row["F_SecurityLevel"] != null && row["F_SecurityLevel"].ToString() != "")
         {
             model.F_SecurityLevel = int.Parse(row["F_SecurityLevel"].ToString());
         }
         if (row["F_Signature"] != null)
         {
             model.F_Signature = row["F_Signature"].ToString();
         }
         if (row["F_OrganizeId"] != null)
         {
             model.F_OrganizeId = row["F_OrganizeId"].ToString();
         }
         if (row["F_DepartmentId"] != null)
         {
             model.F_DepartmentId = row["F_DepartmentId"].ToString();
         }
         if (row["F_RoleId"] != null)
         {
             model.F_RoleId = row["F_RoleId"].ToString();
         }
         if (row["F_DutyId"] != null)
         {
             model.F_DutyId = row["F_DutyId"].ToString();
         }
         if (row["F_IsAdministrator"] != null && row["F_IsAdministrator"].ToString() != "")
         {
             if ((row["F_IsAdministrator"].ToString() == "1") || (row["F_IsAdministrator"].ToString().ToLower() == "true"))
             {
                 model.F_IsAdministrator = true;
             }
             else
             {
                 model.F_IsAdministrator = false;
             }
         }
         if (row["F_SortCode"] != null && row["F_SortCode"].ToString() != "")
         {
             model.F_SortCode = int.Parse(row["F_SortCode"].ToString());
         }
         if (row["F_DeleteMark"] != null && row["F_DeleteMark"].ToString() != "")
         {
             if ((row["F_DeleteMark"].ToString() == "1") || (row["F_DeleteMark"].ToString().ToLower() == "true"))
             {
                 model.F_DeleteMark = true;
             }
             else
             {
                 model.F_DeleteMark = false;
             }
         }
         if (row["F_EnabledMark"] != null && row["F_EnabledMark"].ToString() != "")
         {
             if ((row["F_EnabledMark"].ToString() == "1") || (row["F_EnabledMark"].ToString().ToLower() == "true"))
             {
                 model.F_EnabledMark = true;
             }
             else
             {
                 model.F_EnabledMark = false;
             }
         }
         if (row["F_Description"] != null)
         {
             model.F_Description = row["F_Description"].ToString();
         }
         if (row["F_CreatorTime"] != null && row["F_CreatorTime"].ToString() != "")
         {
             model.F_CreatorTime = DateTime.Parse(row["F_CreatorTime"].ToString());
         }
         if (row["F_CreatorUserId"] != null)
         {
             model.F_CreatorUserId = row["F_CreatorUserId"].ToString();
         }
         if (row["F_LastModifyTime"] != null && row["F_LastModifyTime"].ToString() != "")
         {
             model.F_LastModifyTime = DateTime.Parse(row["F_LastModifyTime"].ToString());
         }
         if (row["F_LastModifyUserId"] != null)
         {
             model.F_LastModifyUserId = row["F_LastModifyUserId"].ToString();
         }
         if (row["F_DeleteTime"] != null && row["F_DeleteTime"].ToString() != "")
         {
             model.F_DeleteTime = DateTime.Parse(row["F_DeleteTime"].ToString());
         }
         if (row["F_DeleteUserId"] != null)
         {
             model.F_DeleteUserId = row["F_DeleteUserId"].ToString();
         }
     }
     return(model);
 }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MyTest.Model.Sys_UserModel model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(MyTest.Model.Sys_UserModel model)
 {
     return(dal.Add(model));
 }