private void UpdateValue()
 {
     try
     {
         if (String.IsNullOrEmpty(lbIDUserEdit.Text))
         {
             _ErrorPost =
                 LibAlert.Alert.AlertError("Bạn không được phép thay đổi bài viết trên dòng thời gian của " +
                                           Session["FullName1"]);
         }
         else
         {
             var obj = new DTOWall
             {
                 Wall_ID      = int.Parse(lbWallID.Text),
                 AccountID1   = int.Parse(lbIDUserEdit.Text),
                 Wall_Titile  = txtTitilePostEdit.Value,
                 Wall_Content = txtContentPostEdit.Value,
                 Wall_Img     = null
             };
             BllWall.Update(obj);
             _ErrorPostEdit = LibAlert.Alert.AlertSucess("Thay đổi trạng thái thành công !");
             GetWall(Request.Params["username"], int.Parse(WebConfigurationManager.AppSettings["pageSizeWall"]));
         }
     }
     catch (Exception ex)
     {
         _ErrorPostEdit = LibAlert.Alert.AlertError("Có lỗi xảy ra trong quá trình đăng bài !<br/>" + ex.Message);
     }
 }
        private void GetWallEdit(int Wall_ID)
        {
            var _clsGetWall    = new BllWall();
            var _dtGetWallEdit = _clsGetWall.GetWallEdit(Wall_ID, int.Parse(lbIDUser.Text));

            if (_dtGetWallEdit != null && _dtGetWallEdit.Rows.Count > 0)
            {
                lbWallID.Text            = _dtGetWallEdit.Rows[0]["Wall_ID"].ToString();
                lbWallIDDel.Text         = _dtGetWallEdit.Rows[0]["Wall_ID"].ToString();
                txtTitilePostEdit.Value  = _dtGetWallEdit.Rows[0]["Wall_Titile"].ToString();
                txtContentPostEdit.Value = _dtGetWallEdit.Rows[0]["Wall_Content"].ToString();
            }
        }
Esempio n. 3
0
        private void GetDetail(int Wall_ID)
        {
            var _clsGetWallDetail = new BllWall();
            var _dtGetWallDetail  = _clsGetWallDetail.GetViewAllDetail(Wall_ID);

            if (_dtGetWallDetail != null && _dtGetWallDetail.Rows.Count > 0)
            {
                lb_lst_Wall_ID_ViewDetailNoImg.Text = _dtGetWallDetail.Rows[0]["Wall_ID"].ToString();
                _htmlLinkProfice   = _dtGetWallDetail.Rows[0]["UserName"].ToString();
                imgAvatarNoImg.Src = _dtGetWallDetail.Rows[0]["User_Image"].ToString();
                lb_lst_UserName_ViewDetailNoImg.Text = _dtGetWallDetail.Rows[0]["FullName"].ToString();
                lb_lst_datetime_NoImages.Text        = String.Format("{0:dd-MM}", _dtGetWallDetail.Rows[0]["DateBegin"]) + " lúc " +
                                                       String.Format("{0:hh:mm}", _dtGetWallDetail.Rows[0]["DateBegin"]);
                lb_lst_titile_ViewDetailNoImg.Text  = _dtGetWallDetail.Rows[0]["Wall_Titile"].ToString();
                lb_lst_content_ViewDetailNoImg.Text = _dtGetWallDetail.Rows[0]["Wall_Content"].ToString();
            }
        }
 private void Delete()
 {
     try
     {
         var obj = new DTOWall {
             AccountID1 = int.Parse(lbUserIDDel.Text), Wall_ID = int.Parse(lbWallIDDel.Text)
         };
         BllWall.Delete(obj);
         lbMsgDel.Text = string.Empty;
         GetWall(Request.Params["username"], int.Parse(WebConfigurationManager.AppSettings["pageSizeWall"]));
         LibWindowUI.Window.CloseWindows(Page, GetType(), "#myModalDel");
     }
     catch (Exception ex)
     {
         lbMsgDel.Text = "Có lỗi xảy ra trong quá trình xoá bài viết.<br/>" + ex.Message;
     }
 }
        private bool CheckUnlike(int Wall_ID, int AccountID1)
        {
            var check     = false;
            var _clsCheck = new BllWall();
            var dtCheck   = _clsCheck.GetLikeWall();

            if (dtCheck != null && dtCheck.Rows.Count > 0)
            {
                foreach (DataRow dr in dtCheck.Rows)
                {
                    if (Wall_ID == int.Parse(dr["Wall_ID"].ToString()) && AccountID1 == int.Parse(dr["AccountID1"].ToString()))
                    {
                        check = true;
                    }
                }
            }
            return(check);
        }
Esempio n. 6
0
 private void GetNewStatus()
 {
     if (Session["login"] != null && Session["AccountID"] != null)
     {
         var _clsGetNewStatus = new BllWall();
         var _dtGetNewstatus  = _clsGetNewStatus.GetStatusLike(int.Parse(Session["AccountID"].ToString()));
         if (_dtGetNewstatus != null && _dtGetNewstatus.Rows.Count > 0)
         {
             ListViewNewsStatus.DataSource = _dtGetNewstatus;
             ListViewNewsStatus.DataBind();
             ListViewNewsStatus.Visible = true;
             ddlNewStatus.Visible       = true;
         }
         else
         {
             ListViewNewsStatus.Visible = false;
             ddlNewStatus.Visible       = false;
         }
     }
 }
        private bool CheckInsert(int Wall_ID, int AccountID1, string sMsg)
        {
            var check     = false;
            var _clsCheck = new BllWall();
            var dtCheck   = _clsCheck.GetLikeWall();

            if (dtCheck != null && dtCheck.Rows.Count > 0)
            {
                foreach (DataRow dr in dtCheck.Rows)
                {
                    if (Wall_ID == int.Parse(dr["Wall_ID"].ToString()) && AccountID1 == int.Parse(dr["AccountID1"].ToString()))
                    {
                        check      = true;
                        lbMsg.Text = sMsg;
                        LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                    }
                }
            }
            return(check);
        }
        protected void ListViewWallFollwer_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            var ListViewSubWallFollower = (ListView)e.Item.FindControl("ListViewSubWallFollower");

            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                var lbFollower  = ((Label)e.Item.FindControl("lbFollower"));
                var _clsGetWall = new BllWall();
                var _dtGetWall  = _clsGetWall.GetWallFollower(int.Parse(lbFollower.Text), 10);
                if (_dtGetWall != null && _dtGetWall.Rows.Count > 0)
                {
                    ListViewSubWallFollower.DataSource = _dtGetWall;
                    ListViewSubWallFollower.DataBind();
                    ListViewSubWallFollower.Visible = true;
                }
                else
                {
                    ListViewSubWallFollower.Visible = false;
                }
            }
        }
        private void GetWall(string UserName, int pageSize)
        {
            var _clsGetWall     = new BllWall();
            var _dtGetWallCount = _clsGetWall.GetWallCount(UserName);
            var _dtGetWall      = _clsGetWall.GetWall(UserName, pageSize);

            if (_dtGetWall != null && _dtGetWall.Rows.Count > 0)
            {
                lbIDUser.Text          = _dtGetWall.Rows[0]["AccountID"].ToString();
                lbUserMain.Text        = _dtGetWall.Rows[0]["AccountID"].ToString();
                ListViewAll.DataSource = _dtGetWall;
                ListViewAll.DataBind();
                ListViewAll.Visible = true;
                lbTotal.Text        = _dtGetWall.Rows.Count.ToString();
                if (_dtGetWallCount != null && _dtGetWallCount.Rows.Count > 0)
                {
                    if (int.Parse(lbTotal.Text) < int.Parse(WebConfigurationManager.AppSettings["pageSizeWall"]))
                    {
                        btnViewMore.Visible = false;
                    }
                    else if (int.Parse(lbTotal.Text) == int.Parse(_dtGetWallCount.Rows[0]["Total"].ToString()))
                    {
                        btnViewMore.Visible = false;
                    }
                    else
                    {
                        btnViewMore.Visible = true;
                    }
                }
            }
            else
            {
                ListViewAll.Visible = false;
                btnViewMore.Visible = false;
            }
        }
        protected void ListViewSubWallFollower_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            try
            {
                var SenderId          = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value;
                var lb_lst_account_ID = ((Label)e.Item.FindControl("lb_lst_account_ID"));
                if (Session["login"] != null &&
                    Session["AccountID"] != null)
                {
                    #region [Like]
                    //-------Like----------
                    var lb_lst_like = ((Label)e.Item.FindControl("lb_lst_like"));
                    if (e.CommandName == "Like_lst")
                    {
                        if (Session["login"] != null &&
                            Session["AccountID"] != null)
                        {
                            if (
                                !CheckInsert(int.Parse(SenderId), int.Parse(Session["AccountID"].ToString()),
                                             "Bạn không thể Like hai lần trên cùng một mẫu tin !"))
                            {
                                var obj = new DTOWall
                                {
                                    Wall_ID    = int.Parse(SenderId),
                                    LikeCount  = int.Parse(lb_lst_like.Text) + 1,
                                    AccountID1 = int.Parse(Session["AccountID"].ToString()),
                                    AccountID2 = int.Parse(lb_lst_account_ID.Text),
                                };
                                BllWall.Like(obj);
                                GetUserFollowerList();
                            }
                        }
                    }
                    #endregion

                    #region [Unlike]
                    if (e.CommandName == "Unlike_lst")
                    {
                        if (int.Parse(lb_lst_like.Text) == 0)
                        {
                            lbMsg.Text = "Số lượt thích hiện tại là 0.Bạn không thể bỏ thích";
                            LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                        }
                        else
                        {
                            if (CheckUnlike(int.Parse(SenderId), int.Parse(Session["AccountID"].ToString())))
                            {
                                var obj = new DTOWall
                                {
                                    Wall_ID    = int.Parse(SenderId),
                                    LikeCount  = int.Parse(lb_lst_like.Text) - 1,
                                    AccountID1 = int.Parse(Session["AccountID"].ToString()),
                                };
                                BllWall.UnLike(obj);
                                GetUserFollowerList();
                            }
                            else
                            {
                                lbMsg.Text = "Bạn không thể bỏ Like hai lần trên cùng một mẫu tin !";
                                LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                            }
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                _Error = LibAlert.Alert.AlertError(ex.Message);
            }
        }
        protected void ListViewAll_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            try
            {
                if (Session["login"] != null &&
                    Session["AccountID"] != null)
                {
                    #region [Edit]
                    //--------Edit-------
                    var txtWallComment    = (TextBox)e.Item.FindControl("txtWallComment");
                    var SenderId          = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value;
                    var lb_lst_account_ID = ((Label)e.Item.FindControl("lb_lst_account_ID"));
                    if (e.CommandName == "_EditPost")
                    {
                        if (lb_lst_account_ID.Text == Session["AccountID"].ToString())
                        {
                            GetWallEdit(int.Parse(SenderId));
                            LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModalStatusEdit");
                        }
                        else
                        {
                            lbMsg.Text = "Bạn không được phép thay đổi trạng thái của người khác !";
                            LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                        }
                    }
                    #endregion

                    #region [DelPost]
                    if (e.CommandName == "_DelPost")
                    {
                        _flag = true;
                        btnDelStatus.InnerText = "Xoá bài viết";
                        if (lb_lst_account_ID.Text == Session["AccountID"].ToString())
                        {
                            GetWallEdit(int.Parse(SenderId));
                            lbMsgDel.Text = "Bạn có chắc chắn muốn xóa tin này không ?";
                            LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModalDel");
                        }
                        else
                        {
                            lbMsg.Text = "Bạn không được phép xoá trạng thái của người khác !";
                            LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                        }
                    }
                    #endregion

                    #region [Like]
                    //-------Like----------
                    var lb_lst_like = ((Label)e.Item.FindControl("lb_lst_like"));
                    if (e.CommandName == "Like_lst")
                    {
                        if (Session["login"] != null &&
                            Session["AccountID"] != null)
                        {
                            if (
                                !CheckInsert(int.Parse(SenderId), int.Parse(Session["AccountID"].ToString()),
                                             "Bạn không thể Like hai lần trên cùng một mẫu tin !"))
                            {
                                var obj = new DTOWall
                                {
                                    Wall_ID    = int.Parse(SenderId),
                                    LikeCount  = int.Parse(lb_lst_like.Text) + 1,
                                    AccountID1 = int.Parse(Session["AccountID"].ToString()),
                                    AccountID2 = int.Parse(lb_lst_account_ID.Text),
                                };
                                BllWall.Like(obj);
                                if (Request.Params["username"] != null)
                                {
                                    GetWall(Request.Params["username"], int.Parse(WebConfigurationManager.AppSettings["pageSizeWall"]));
                                }
                            }
                        }
                    }
                    #endregion

                    #region [Unlike]
                    if (e.CommandName == "Unlike_lst")
                    {
                        if (int.Parse(lb_lst_like.Text) == 0)
                        {
                            lbMsg.Text = "Số lượt thích hiện tại là 0.Bạn không thể bỏ thích";
                            LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                        }
                        else
                        {
                            if (CheckUnlike(int.Parse(SenderId), int.Parse(Session["AccountID"].ToString())))
                            {
                                var obj = new DTOWall
                                {
                                    Wall_ID    = int.Parse(SenderId),
                                    LikeCount  = int.Parse(lb_lst_like.Text) - 1,
                                    AccountID1 = int.Parse(Session["AccountID"].ToString()),
                                };
                                BllWall.UnLike(obj);
                                if (Request.Params["username"] != null)
                                {
                                    GetWall(Request.Params["username"], int.Parse(WebConfigurationManager.AppSettings["pageSizeWall"]));
                                }
                            }
                            else
                            {
                                lbMsg.Text = "Bạn không thể bỏ Like hai lần trên cùng một mẫu tin !";
                                LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                            }
                        }
                    }
                    #endregion

                    #region [PostComment]
                    if (e.CommandName == "_btnInsert")
                    {
                        if (String.IsNullOrEmpty(txtWallComment.Text))
                        {
                            lbMsg.Text = "Vui lòng điền vào nội dung Comment !";
                            LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                        }
                        else
                        {
                            InsertValueComment(int.Parse(SenderId), txtWallComment.Text);
                            txtWallComment.Text = string.Empty;
                        }
                        //--------Get-Data---------
                        var PanelComment       = ((HtmlGenericControl)e.Item.FindControl("PanelComment"));
                        var ListViewComment    = (ListView)e.Item.FindControl("ListViewComment");
                        var lbTotalComment     = (Label)e.Item.FindControl("lbTotalComment");
                        var btnViewMoreComment = (Button)e.Item.FindControl("btnViewMoreComment");
                        var _clsGetComment     = new BllWallComment();
                        var _dtGetWallCount    = _clsGetComment.GetWallCommentCount(int.Parse(SenderId));
                        var _dtGetComment      = _clsGetComment.GetWallComment(int.Parse(SenderId), int.Parse(WebConfigurationManager.AppSettings["pageSizeWallComment"]));
                        if (_dtGetComment != null && _dtGetComment.Rows.Count > 0)
                        {
                            ListViewComment.DataSource = _dtGetComment;
                            ListViewComment.DataBind();
                            ListViewComment.Visible = true;
                            PanelComment.Visible    = true;
                            lbTotalComment.Text     = _dtGetComment.Rows.Count.ToString();
                            if (_dtGetWallCount != null && _dtGetWallCount.Rows.Count > 0)
                            {
                                if (int.Parse(lbTotalComment.Text) < int.Parse(WebConfigurationManager.AppSettings["pageSizeWallComment"]))
                                {
                                    btnViewMoreComment.Visible = false;
                                }
                                else if (int.Parse(lbTotalComment.Text) == int.Parse(_dtGetWallCount.Rows[0]["Total"].ToString()))
                                {
                                    btnViewMoreComment.Visible = false;
                                }
                                else
                                {
                                    btnViewMoreComment.Visible = true;
                                }
                            }
                        }
                        else
                        {
                            PanelComment.Visible       = false;
                            ListViewComment.Visible    = false;
                            btnViewMoreComment.Visible = false;
                        }
                    }
                    #endregion

                    #region [ViewMore]
                    //------ViewMore---
                    if (e.CommandName == "_btnViewMoreComment")
                    {
                        //--------Get-Data---------
                        var PanelComment       = ((HtmlGenericControl)e.Item.FindControl("PanelComment"));
                        var ListViewComment    = (ListView)e.Item.FindControl("ListViewComment");
                        var lbTotalComment     = (Label)e.Item.FindControl("lbTotalComment");
                        var btnViewMoreComment = (Button)e.Item.FindControl("btnViewMoreComment");
                        var _clsGetComment     = new BllWallComment();
                        var _dtGetWallCount    = _clsGetComment.GetWallCommentCount(int.Parse(SenderId));
                        var _dtGetComment      = _clsGetComment.GetWallComment(int.Parse(SenderId), int.Parse(lbTotalComment.Text) + 10);
                        if (_dtGetComment != null && _dtGetComment.Rows.Count > 0)
                        {
                            ListViewComment.DataSource = _dtGetComment;
                            ListViewComment.DataBind();
                            ListViewComment.Visible = true;
                            PanelComment.Visible    = true;
                            lbTotalComment.Text     = _dtGetComment.Rows.Count.ToString();
                            if (_dtGetWallCount != null && _dtGetWallCount.Rows.Count > 0)
                            {
                                if (int.Parse(lbTotalComment.Text) < int.Parse(WebConfigurationManager.AppSettings["pageSizeWallComment"]))
                                {
                                    btnViewMoreComment.Visible = false;
                                }
                                else if (int.Parse(lbTotalComment.Text) == int.Parse(_dtGetWallCount.Rows[0]["Total"].ToString()))
                                {
                                    btnViewMoreComment.Visible = false;
                                }
                                else
                                {
                                    btnViewMoreComment.Visible = true;
                                }
                            }
                        }
                        else
                        {
                            PanelComment.Visible       = false;
                            ListViewComment.Visible    = false;
                            btnViewMoreComment.Visible = false;
                        }
                    }
                    #endregion
                }
                else
                {
                    lbMsg.Text = "<b>Chương trình bị ngắt quãng vì lý do an toàn</b><br/>Vui lòng thoát ra và đăng nhập lại !";
                    LibWindowUI.Window.OpenWindows(Page, GetType(), "#myModal");
                }
            }
            catch (Exception ex)
            {
                _Error = LibAlert.Alert.AlertError(ex.Message);
            }
        }