Exemple #1
0
 /// <summary>
 /// 新增User对象
 /// </summary>
 /// <param name="User">需要新增的对象</param>
 /// <returns>新插入数据的UserID</returns>
 public Int32 AddUser(User obj)
 {
     if(obj != null)
     {
         return Convert.ToInt32(_dal.InsertReturnID(obj));
     }
     return -1;
 }
Exemple #2
0
        /// <summary>
        /// 插入一条数据并返回UserID
        /// </summary>
        /// <param name="User">需要插入的对象</param>
        /// <returns>新插入数据的UserID</returns>
        public Object InsertReturnID(User obj)
        {
            //声明参数数组并赋值
            SqlParameter[] param = new SqlParameter[]{
                new SqlParameter("@Name",obj.Name),
                new SqlParameter("@Email",obj.Email),
                new SqlParameter("@GroupID",obj.GroupID),
                new SqlParameter("@Salt",obj.Salt),
                new SqlParameter("@Password",obj.Password),
                new SqlParameter("@Status",obj.Status)
            };

            return SqlHelper.ExecuteScalar(SqlHelper.connectionString, _SQL_INSERT_RETURNID, CommandType.Text, param);
        }
Exemple #3
0
        /// <summary>
        /// 插入一条数据
        /// </summary>
        /// <param name="User">需要插入的对象</param>
        /// <returns>影响行数</returns>
        public Int32 Insert(User obj)
        {
            //声明参数数组并赋值
            SqlParameter[] param = new SqlParameter[]{
                new SqlParameter("@Name",obj.Name),
                new SqlParameter("@Email",obj.Email),
                new SqlParameter("@GroupID",obj.GroupID),
                new SqlParameter("@Salt",obj.Salt),
                new SqlParameter("@Password",obj.Password),
                new SqlParameter("@Status",obj.Status)
            };

            return SqlHelper.ExecuteNonQuery(SqlHelper.connectionString, _SQL_INSERT, CommandType.Text, param);
        }
Exemple #4
0
 /// <summary>
 /// 修改User对象
 /// </summary>
 /// <param name="User">需要修改的对象</param>
 /// <returns>影响行数</returns>
 public Int32 SetUser(User obj)
 {
     if(obj != null)
     {
         return _dal.Update(obj);
     }
     return -1;
 }
Exemple #5
0
 public static void Insert(Int32 UserID, User obj)
 {
     CacheDependency cd = null;//new CacheDependency(@"F:\Project\trunk\Thewho\Thewho.Web\Configs\players.xml");
     CacheHelper<User>.Insert(M_USER + UserID, obj, cd, USER_EXPIRES, CacheItemPriority.Default);
 }
Exemple #6
0
        protected void Page_Init(object sender, EventArgs e)
        {
            //是否回传
            if (!IsPostBack)
            {
                //if (Request.Url != null)
                //{
                //    Response.Redirect("/Again.aspx?url=" + Server.UrlEncode(Request.Url.ToString()));
                //}
                //Response.Redirect("/Again.aspx");
                //thisUser = _currentUser.GetThisUser();
                //if (thisUser == null)
                //{
                //    Response.Redirect("/Default.aspx");
                //}

                currentUser = _currentUser.GetCurrentUser();
                if (currentUser == null) //没有登录
                {
                    Response.Redirect("~/Default.aspx");
                }

            }

            #region 记录
            //Request获取的信息
            //Request.AppRelativeCurrentExecutionFilePath                  ~/SysOption/BillingSetup1.aspx
            //Request.ApplicationPath                                      /
            //Request.CurrentExecutionFilePath                             /SysOption/BillingSetup1.aspx
            //Request.FilePath                                             /SysOption/BillingSetup1.aspx
            //Request.Path                                                 /SysOption/BillingSetup1.aspx
            //Request.PathInfo                                             什么都没有(待测其他用法)
            //Request.PhysicalApplicationPath                              D:\VssWorkFolder\British_School_MIS\src\WebSite\
            //Request.PhysicalPath                                         D:\VssWorkFolder\British_School_MIS\src\WebSite\SysOption\BillingSetup1.aspx
            //Request.UserHostAddress                                      192.168.1.6
            //Request.UserHostName                                         192.168.1.6
            //Request.Url.ToString()                                       http://192.168.1.6/SysOption/BillingSetup1.aspx?x=d
            //Request.UrlReferrer                                          空引用或者跳转源页面地址
            //Request.ServerVariables集合中获取到的相关信息:
            //左列是服务器变量名,右侧是值,值是通过Request.ServerVariables[服务器变量名]获取的
            //APPL_MD_PATH : /LM/W3SVC/894523/Root
            //APPL_PHYSICAL_PATH : D:\VssWorkFolder\British_School_MIS\src\WebSite\
            //INSTANCE_META_PATH : /LM/W3SVC/894523
            //LOCAL_ADDR : 192.168.1.6
            //PATH_INFO : /SysOption/BillingSetup1.aspx
            //PATH_TRANSLATED : D:\VssWorkFolder\British_School_MIS\src\WebSite\SysOption\BillingSetup1.aspx
            //REMOTE_ADDR : 192.168.1.6
            //REMOTE_HOST : 192.168.1.6
            //SCRIPT_NAME : /SysOption/BillingSetup1.aspx
            //SERVER_NAME : 192.168.1.6
            //URL : /SysOption/BillingSetup1.aspx
            #endregion
        }
Exemple #7
0
        /// <summary>
        /// 将SqlDataReader对象转换成User对象
        /// </summary>
        /// <param name="dr">SqlDataReader对象</param>
        /// <returns></returns>
        private User ToObject(SqlDataReader dr)
        {
            using (dr)
            {
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        User model = new User();
                        model.UserID = Convert.ToInt32(dr["UserID"]);
                        model.Name = dr["Name"].ToString();
                        model.Email = dr["Email"].ToString();
                        model.GroupID = Convert.ToInt32(dr["GroupID"]);
                        model.Salt = dr["Salt"].ToString();
                        model.Password = dr["Password"].ToString();
                        model.Status = Convert.ToByte(dr["Status"]);

                        return model;
                    }
                }
            }
            return null;
        }
Exemple #8
0
        /// <summary>
        /// 将SqlDataReader对象转换成User对象集合
        /// </summary>
        /// <param name="dr">SqlDataReader对象</param>
        /// <returns></returns>
        private List<User> ToList(SqlDataReader dr)
        {
            List<User> list = null;
            using (dr)
            {
                if (dr.HasRows)
                {
                    list = new List<User>();
                    while (dr.Read())
                    {
                        User model = new User();
                        model.UserID = Convert.ToInt32(dr["UserID"]);
                        model.Name = dr["Name"].ToString();
                        model.Email = dr["Email"].ToString();
                        model.GroupID = Convert.ToInt32(dr["GroupID"]);
                        model.Salt = dr["Salt"].ToString();
                        model.Password = dr["Password"].ToString();
                        model.Status = Convert.ToByte(dr["Status"]);

                        list.Add(model);
                    }
                }
            }
            return list;
        }
Exemple #9
0
        /// <summary>
        /// 更新一条新数据。
        /// </summary>
        /// <param name="User">需要更新的对象</param>
        /// <returns>影响行数</returns>
        public Int32 Update(User obj)
        {
            //将WHERE条件组合进SQL语句
            String sqlStr = String.Format(_SQL_UPDATE, "WHERE [UserID] = @UserID");
            //声明参数数组并赋值
            SqlParameter[] param = new SqlParameter[]{
                new SqlParameter("@UserID",obj.UserID),
                new SqlParameter("@Name",obj.Name),
                new SqlParameter("@Email",obj.Email),
                new SqlParameter("@GroupID",obj.GroupID),
                new SqlParameter("@Salt",obj.Salt),
                new SqlParameter("@Password",obj.Password),
                new SqlParameter("@Status",obj.Status)
            };

            return SqlHelper.ExecuteNonQuery(SqlHelper.connectionString, sqlStr, CommandType.Text, param);
        }