Exemple #1
0
        public void LoadData(string PagesTextbox)
        {
            int  PagesIndex     = 0;
            bool boolCheckPages = true;

            if (PagesTextbox.Length > 0 && UltilFunc.IsNumeric(PagesTextbox.ToString()))
            {
                if (Convert.ToInt32(PagesTextbox) >= 1)
                {
                    PagesIndex = Convert.ToInt32(PagesTextbox) - 1;
                }
                else
                {
                    boolCheckPages = false;
                }
            }
            else
            {
                boolCheckPages = false;
            }
            string where = " 1=1 and Photo_Status=3 ";//AND Lang_ID IN (SELECT T_Nguoidung_NgonNgu.Ma_Ngonngu FROM T_Nguoidung_NgonNgu WHERE T_Nguoidung_NgonNgu.[Ma_Nguoidung] = " + _user.UserID + ")
            if (!String.IsNullOrEmpty(this.txtSearch_Cate.Text.Trim()))
            {
                where += " AND " + string.Format(" Photo_Name like N'%{0}%'", UltilFunc.SqlFormatText(this.txtSearch_Cate.Text.Trim()));
            }
            if (cboNgonNgu.SelectedIndex > 0)
            {
                where += " AND Lang_ID=" + cboNgonNgu.SelectedValue.ToString();
            }
            if (txt_FromDate.Text.Length > 0 && txt_ToDate.Text.Length == 0)
            {
                where += " and Date_Create>='" + txt_FromDate.Text + " 00:00:01'";
            }
            else if (txt_FromDate.Text.Length == 0 && txt_ToDate.Text.Length > 0)
            {
                where += " AND Date_Update < ='" + txt_ToDate.Text.Trim() + " 23:59:59'";
            }
            else if (txt_FromDate.Text.Length > 0 && txt_ToDate.Text.Length > 0)
            {
                where += " and Date_Update>='" + txt_FromDate.Text + " 00:00:01' and Date_Create<='" + txt_ToDate.Text + " 23:59:59'";
            }
            where         += " Order by Date_Update DESC";
            pages.PageSize = Global.MembersPerPage;
            HPCBusinessLogic.T_Photo_EventDAL _cateDAL = new HPCBusinessLogic.T_Photo_EventDAL();
            DataSet _ds;

            if (boolCheckPages)
            {
                _ds = _cateDAL.BindGridT_Photo_Events(PagesIndex, pages.PageSize, where);
            }
            else
            {
                _ds = _cateDAL.BindGridT_Photo_Events(pages.PageIndex, pages.PageSize, where);
            }
            int TotalRecords = Convert.ToInt32(_ds.Tables[1].Rows[0].ItemArray[0].ToString());
            int TotalRecord  = Convert.ToInt32(_ds.Tables[0].Rows.Count);

            if (TotalRecord == 0)
            {
                if (boolCheckPages)
                {
                    _ds = _cateDAL.BindGridT_Photo_Events(PagesIndex - 1, pages.PageSize, where);
                }
                else
                {
                    _ds = _cateDAL.BindGridT_Photo_Events(pages.PageIndex - 1, pages.PageSize, where);
                }
            }
            grdListCate.DataSource = _ds;
            grdListCate.DataBind();
            _ds.Clear();
            pages.TotalRecords     = curentPages.TotalRecords = TotalRecords;
            curentPages.TotalPages = pages.CalculateTotalPages();
            if (boolCheckPages)
            {
                curentPages.PageIndex = PagesIndex;
            }
            else
            {
                curentPages.PageIndex = pages.PageIndex;
            }
        }
        private void LoadData(int status)
        {
            string where = " 1=1 ";
            if (status == 5 || status == 7)
            {
                where += " and Creator=" + _userDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name).UserID + " AND Photo_Status = " + status + " AND Lang_ID IN (SELECT T_Nguoidung_NgonNgu.Ma_Ngonngu FROM T_Nguoidung_NgonNgu WHERE T_Nguoidung_NgonNgu.[Ma_Nguoidung] = " + _user.UserID + ")";
            }
            else
            {
                where += " and Photo_Status = " + status + " AND Lang_ID IN (SELECT DISTINCT(T_Nguoidung_NgonNgu.Ma_Ngonngu) FROM T_Nguoidung_NgonNgu WHERE T_Nguoidung_NgonNgu.[Ma_Nguoidung] = " + _user.UserID + ")";
            }
            where         += " Order by Date_Create DESC";
            pages.PageSize = 50;
            HPCBusinessLogic.T_Photo_EventDAL _untilDAL = new HPCBusinessLogic.T_Photo_EventDAL();
            DataSet _ds;

            _ds = _untilDAL.BindGridT_Photo_Events(pages.PageIndex, pages.PageSize, where);
            int TotalRecords = Convert.ToInt32(_ds.Tables[1].Rows[0].ItemArray[0].ToString());
            int TotalRecord  = Convert.ToInt32(_ds.Tables[0].Rows.Count);

            if (TotalRecord == 0)
            {
                _ds = _untilDAL.BindGridT_Photo_Events(pages.PageIndex - 1, pages.PageSize, where);
            }
            grdListCate.DataSource = _ds;
            grdListCate.DataBind(); _ds.Clear();
            if (TotalRecords == 0)
            {
                pages.Visible       = false;
                curentPages.Visible = false;
            }
            pages.TotalRecords     = curentPages.TotalRecords = TotalRecords;
            curentPages.TotalPages = pages.CalculateTotalPages();
            curentPages.PageIndex  = pages.PageIndex;
            if (grdListCate.Items.Count > 0)
            {
                int count = 0;
                foreach (DataGridItem m_Item in grdListCate.Items)
                {
                    T_Photo_EventDAL _DAL       = new T_Photo_EventDAL();
                    T_Photo_Event    _obj       = new T_Photo_Event();
                    ImageButton      btnModify  = m_Item.FindControl("btnModify") as ImageButton;
                    ImageButton      btnSave    = m_Item.FindControl("btnSave") as ImageButton;
                    ImageButton      btnBack    = m_Item.FindControl("btnBack") as ImageButton;
                    Label            lblNgonNgu = m_Item.FindControl("lblNgonNgu") as Label;
                    LinkButton       btnEdit    = m_Item.FindControl("btnEdit") as LinkButton;
                    Label            lblTacGia  = m_Item.FindControl("lblTacGia") as Label;
                    DropDownList     cboNgonNgu = m_Item.FindControl("cboNgonNgu") as DropDownList;
                    TextBox          txtTitle   = m_Item.FindControl("txtTitle") as TextBox;
                    TextBox          txtTacGia  = m_Item.FindControl("txt_tacgia") as TextBox;
                    //Image imgView = m_Item.FindControl("imgView") as Image;
                    //Image imgBrowse = m_Item.FindControl("imgBrowse") as Image;
                    if (txtTitle.Text.Trim().Length > 0)
                    {
                        btnSave.Visible    = false;
                        btnBack.Visible    = false;
                        btnModify.Visible  = true;
                        lblNgonNgu.Visible = true;
                        lblTacGia.Visible  = true;
                        btnEdit.Visible    = true;
                        cboNgonNgu.Visible = false;
                        txtTitle.Visible   = false;
                        txtTacGia.Visible  = false;
                        //imgView.Visible = true;
                        //imgBrowse.Visible = false;
                    }
                    else
                    {
                        btnSave.Visible    = true;
                        btnBack.Visible    = true;
                        btnModify.Visible  = false;
                        lblNgonNgu.Visible = false;
                        lblTacGia.Visible  = false;
                        btnEdit.Visible    = false;
                        cboNgonNgu.Visible = true;
                        txtTitle.Visible   = true;
                        txtTacGia.Visible  = true;
                        //imgView.Visible = false;
                        //imgBrowse.Visible = true;
                        if (count == 0)
                        {
                            txtTitle.Focus();
                        }
                        count++;
                    }
                }
            }
        }