Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user_data"] == null)
                Response.Redirect("default.aspx");

            mUserData = (User_Data)Session["user_data"];
        }
Exemplo n.º 2
0
        protected void ExitLB_Click(object sender, EventArgs e)
        {
            Session["user_data"] = null;
            mUser_Data = new User_Data();

            TouristP.Visible = true;
            UserAreaP.Visible = false ;
        }
Exemplo n.º 3
0
        protected void ensureAdd_Click(object sender, EventArgs e)
        {
            if (Session["user_data"] != null)
                mUser_Data = (User_Data)Session["user_data"];
            else
                mUser_Data.userName = "******";

            long userId = Convert.ToInt64(Request.QueryString["userId"]);
            mComment.AddUserComment(userId,userCommentTB.Text.ToString(),mUser_Data.userName);
            Response.Redirect("Home.aspx?userId=" + Convert.ToString(Request.QueryString["userId"]), true);
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user_data"] == null || Request.QueryString["albumId"] == null)
            {
                Response.Redirect("Default.aspx",true);
                return;
            }

            mUserData = (User_Data)Session["user_data"];
            long albumId = Convert.ToInt64(Request.QueryString["albumId"]);
            mAlbum.GetAlbumByAlbumId(albumId, ref mAlbumData);
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user_data"] == null)
                Response.Redirect("default.aspx");

            mUserData = (User_Data)Session["user_data"];

            if (!Page.IsPostBack)
            {
                userNameTB.Text = mUserData.userName;
                EmailTB.Text = mUserData.email;
                MSNTB.Text = mUserData.MSN;
                descriptionTB.Text = mUserData.descriptions;
            }
        }
Exemplo n.º 6
0
 //根据信息插入新的users列
 public void InsertUser(ref User_Data userData)
 {
     try
     {
         Conn.Open();
         string sql = "insert into Users (userLoginName,userName,userPassword,sex,birth,MSN,email,logoUrl,question1,answer1,question2,answer2,question3,answer3,descriptions)"
                 +" values (@userLoginName,@userName,@userPassword,@sex,@birth,@MSN,@email,@logoUrl,@question1,@answer1,@question2,@answer2,@question3,@answer3,@descriptions)";
         //添加用户信息进用户列表
         SqlParameter[] parm = this.ConvertUser_DataToParams(ref userData);
         ExecuteNonQuery(sql, parm);
         Conn.Close();
     }
     catch (Exception e)
     {
         Conn.Close();
         throw e;
     }
 }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user_data"] == null || Request.QueryString["imageId"] == null)
            {
                Response.Redirect("default.aspx");
            }

            mUserData = (User_Data)Session["user_data"];

            long imageId = Convert.ToInt64(Request.QueryString["imageId"]);
            mImage.GetImageByImageId(imageId, ref mImageData);
            mAlbum.GetAlbumByAlbumId(mImageData.albumId, ref mAlbumData);

            if(mUserData.userId!=mAlbumData.userId)
                Response.Redirect("default.aspx");

            if (!Page.IsPostBack)
            {
                descriptionsTB.Text = mImageData.descriptions;
                imageTypeDDL.Text = mImageData.imageType;
            }
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user_data"] == null || Request.QueryString["albumId"] == null)
            {
                Response.Redirect("Default.aspx",true);
                return;
            }

            mUserData = (User_Data)Session["user_data"];
            albumId = Convert.ToInt64(Request.QueryString["albumId"]);
            mAlbum.GetAlbumByAlbumId(albumId, ref mAlbumData);

            if (mAlbumData.userId != mUserData.userId)
            {
                Response.Redirect("Default.aspx",true);
            }

            if (!Page.IsPostBack)
            {
                descriptionTB.Text = mAlbumData.descriptions;
                permissionTB.Text = mAlbumData.permission;
            }
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["imageId"] == null)
            {
                Response.Redirect("default.aspx", true);
            }

            imageId = Convert.ToInt64(Request.QueryString["imageId"]);
            mImage.GetImageByImageId(imageId, ref image_data);
            imageI.ImageUrl = image_data.imageUrl;
            ImageNameL.Text = image_data.imageName;
            ImageDescriptionL.Text = image_data.descriptions;
            ImageTypeL.Text = image_data.imageType;

            mAlbum.GetAlbumByAlbumId(image_data.albumId, ref album_data);
            mUser.GetUserDataByUserId(album_data.userId, ref userOfThisPage);

            UserLogoI.ImageUrl = userOfThisPage.logoUrl;
            UserNameL.Text = userOfThisPage.userName;
            UserSexL.Text = userOfThisPage.sex;
            UserDescriptionsL.Text = userOfThisPage.descriptions;

            if (Session["user_data"] == null)
            {
                UserAreaP.Visible = false;
            }
            else
                user_data = (User_Data)Session["user_data"];

            if (user_data.userId != album_data.userId)
            {
                UserAreaP.Visible = false;
            }
            else
            {
                UserAreaNameL.Text = user_data.userName;
            }

            commentList = mComment.ViewImageCommentByImageId(image_data.imageId);
            if (!Page.IsPostBack)
            {
                GridView3.DataSource = commentList;
                GridView3.DataBind();
            }
        }
Exemplo n.º 10
0
        //转换dataTabel的首行数据至User_Data结构
        private void ConvertDataTableToUser_Data(DataTable dt, ref User_Data user_data)
        {
            if (dt.Rows.Count < 1)
                return;

            user_data.userId = Convert.ToInt64(dt.Rows[0]["userId"]);
            user_data.userName = dt.Rows[0]["userName"].ToString();
            user_data.userPassword = dt.Rows[0]["userPassword"].ToString();
            user_data.userLoginName = dt.Rows[0]["userLoginName"].ToString();
            user_data.question1 = dt.Rows[0]["question1"].ToString();
            user_data.answer1 = dt.Rows[0]["answer1"].ToString();
            user_data.question2 = dt.Rows[0]["question2"].ToString();
            user_data.answer2 = dt.Rows[0]["answer2"].ToString();
            user_data.question3 = dt.Rows[0]["question3"].ToString();
            user_data.answer3 = dt.Rows[0]["answer3"].ToString();
            user_data.birth = dt.Rows[0]["birth"].ToString();
            user_data.email = dt.Rows[0]["email"].ToString();
            user_data.MSN = dt.Rows[0]["MSN"].ToString();
            user_data.descriptions = dt.Rows[0]["descriptions"].ToString();
            user_data.logoUrl = dt.Rows[0]["logoUrl"].ToString();
            user_data.sex = dt.Rows[0]["sex"].ToString();
        }
Exemplo n.º 11
0
 //用户更新
 public void UpdateUser(ref User_Data userData, FileUpload userLogoFU)
 {
     string exname;
     if (userLogoFU.FileName.Length > 0)
     {
         exname = userLogoFU.FileName.Split('.')[1];
         if (exname.ToLower() == "jpg" || exname.ToLower() == "gif" || exname.ToLower() == "png")
         {
             userLogoFU.SaveAs(MAP_PATH + "\\" + userData.logoUrl);
         }
     }
     mUserDB.UpdateUser(ref userData);
 }
Exemplo n.º 12
0
 //用户更新
 public void UpdateUser(ref User_Data userData)
 {
     mUserDB.UpdateUser(ref userData);
 }
Exemplo n.º 13
0
        //添加用户,参数absoluteUrl:用户文件夹的绝对路径,用用户登录名作为文件夹名字
        public void RegisterUser(ref User_Data userData, FileUpload fileUpload)
        {
            string filePath = MAP_PATH + "\\" + BASE_PATH + "\\" + USER_FILE_PREFIX + userData.userLoginName;
            userData.logoUrl = BASE_PATH + "\\" + USER_FILE_PREFIX + userData.userLoginName + "\\" + USER_LOGO_PREFIX + userData.userLoginName;

            if (fileUpload.FileName.Length > 0)
            {
                string exname = fileUpload.FileName.Split('.')[1];
                if (exname.ToLower() == "jpg" || exname.ToLower() == "gif" || exname.ToLower() == "png")
                {
                    userData.logoUrl += "." + exname;
                    CreateUserFile(filePath);
                    fileUpload.SaveAs(MAP_PATH + "\\" + userData.logoUrl);
                    mUserDB.InsertUser(ref userData);
                }
            }
        }
Exemplo n.º 14
0
 //用户登录,返回用户登录名和密码是否匹配
 public bool Login(string LoginName, string password, ref User_Data user_data)
 {
     DataTable dt = mUserDB.SelectedUserByName(LoginName);
     if (dt.Rows.Count == 0)
         return false;
     if (!(dt.Rows[0]["UserPassword"].ToString() == password))
         return false;
     this.ConvertDataTableToUser_Data(dt, ref user_data);
     return true;
 }
Exemplo n.º 15
0
 protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.ToString().Equals("delete"))
     {
         mUser_Data = (User_Data)Session["user_data"];
         long i = Convert.ToInt64(e.CommandArgument);
         mComment.DeleteUserCommentByCommentId(i);
         Response.Redirect("Home.aspx?userId=" + Convert.ToString(Request.QueryString["userId"]), true);
     }
 }
Exemplo n.º 16
0
 protected void MyHomeLB_Click(object sender, EventArgs e)
 {
     mUser_Data = (User_Data)Session["user_data"];
     string url = "Home.aspx?userId=" + Convert.ToString(mUser_Data.userId);
     Response.Redirect(url, true);
 }
Exemplo n.º 17
0
 public void UpdateUser(ref User_Data userData)
 {
     try
     {
         Conn.Open();
         string sql = "update Users set userName = @userName,birth = @birth,MSN = @MSN,email = @email,descriptions = @descriptions"
                +" where userId = @userId";
         //添加用户信息进用户列表
         SqlParameter[] parm = this.ConvertUser_DataToParams(ref userData);
         ExecuteNonQuery(sql, parm);
         Conn.Close();
     }
     catch (Exception e)
     {
         Conn.Close();
         throw e;
     }
 }
Exemplo n.º 18
0
 //将userData结构中的数据转换到sqlparameter中
 //辅助方法
 private SqlParameter[] ConvertUser_DataToParams(ref User_Data userData)
 {
     SqlParameter[] parm = new SqlParameter[]
     {
         new SqlParameter ("@userId",userData.userId),
         new SqlParameter ("@userLoginName",userData.userLoginName),
         new SqlParameter ("@userName",userData.userName),
         new SqlParameter ("@userPassword",userData.userPassword),
         new SqlParameter ("@sex",userData.sex),
         new SqlParameter ("@birth",userData.birth),
         new SqlParameter ("@MSN",userData.MSN),
         new SqlParameter ("@email",userData.email),
         new SqlParameter ("@logoUrl",userData.logoUrl),
         new SqlParameter ("@question1",userData.question1),
         new SqlParameter ("@answer1",userData.answer1),
         new SqlParameter ("@question2",userData.question2),
         new SqlParameter ("@answer2",userData.answer2),
         new SqlParameter ("@question3",userData.question3),
         new SqlParameter ("@answer3",userData.answer3),
         new SqlParameter ("@descriptions",userData.descriptions)
     };
     return parm;
 }
Exemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["albumId"] == null)
            {
                Response.Redirect("Default.aspx",true);
                return;
            }

            albumId = Convert.ToInt64(Request.QueryString["albumId"]);
            mAlbum.GetAlbumByAlbumId(albumId, ref album_data);

            AlbumNameL.Text = album_data.albumName;
            AlbumLogoI.ImageUrl = album_data.logoUrl;
            AlbumDescriptionsL.Text = album_data.descriptions;

            mUser.GetUserDataByUserId(album_data.userId, ref userOfThisPage);
            UserLogoI.ImageUrl = userOfThisPage.logoUrl;
            UserNameL.Text = userOfThisPage.userName;
            UserSexL.Text = userOfThisPage.sex;
            UserDescriptionsL.Text = userOfThisPage.descriptions;

            if (Session["user_data"] == null)
            {
                UserAreaP.Visible = false;
            }
            else
                user_data = (User_Data)Session["user_data"];

            if (user_data.userId != album_data.userId)
            {
                UserAreaP.Visible = false;
            }

            imageList = mImage.ViewImageListByAlbumId(album_data.albumId);
            commentList = mComment.ViewAlbumCommentByAlbumId(album_data.albumId);

            if (!Page.IsPostBack)
            {
                GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
                GridView3.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");

                GridView3.DataSource = commentList;
                GridView3.DataBind();

                GridView1.DataSource = imageList;
                GridView1.DataBind();
            }
        }
Exemplo n.º 20
0
 public void GetUserDataByUserId(long id, ref User_Data user_data)
 {
     DataTable dt = mUserDB.SelectedUserByUserId(id);
     ConvertDataTableToUser_Data(dt, ref user_data);
 }