示例#1
0
    public void FillNotificationData(int SocietyID)
    {
        try
        {
            DataAccess dacess = new DataAccess();

            String DatalistQuery = "SELECT * FROM " + VIEW_NOTIFICATION + "  where SocietyID ='" + SocietyID + "' and EndDate  >= getDate() order by date desc";


            if (status == "Open")
            {
                DatalistQuery = "SELECT * FROM " + VIEW_NOTIFICATION + "  where SocietyID ='" + SocietyID + "' and  EndDate >= getDate() order by date desc";
            }
            else if (status == "Closed")
            {
                DatalistQuery = "Select * from " + VIEW_NOTIFICATION + " where SocietyID ='" + SocietyID + "' and  EndDate <= getDate() order by date desc ";
            }
            else if (status == "All")
            {
                DatalistQuery = " Select * from " + VIEW_NOTIFICATION + " Where SocietyID ='" + SocietyID + "'  order by date desc ";
            }

            DataSet ds = dacess.ReadData(DatalistQuery);

            if (ds == null)
            {
                drpNotifiFilter.Visible = false;
                lblEmptyTitle.Visible   = true;
                btnnext.Visible         = false;
                btnprevious.Visible     = false;
                showOpen.Visible        = false;
                showClose.Visible       = false;
                showAll.Visible         = false;
                // New_Notification.Visible = true;
                lblEmptyTitle.Text = "<h4>Notice Board is Empty Right Now!!</h4>";
            }

            else
            {
                DataTable dt = ds.Tables[0];

                if (ds.Tables.Count > 0)
                {
                    //DataNotifications.DataSource = ds;
                    //DataNotifications.DataBind();
                    DataNotifications.Visible = true;
                    lblEmptyTitle.Visible     = false;


                    adsource                     = new PagedDataSource();
                    adsource.DataSource          = ds.Tables[0].DefaultView;
                    adsource.PageSize            = 5;
                    adsource.AllowPaging         = true;
                    adsource.CurrentPageIndex    = pos;
                    DataNotifications.DataSource = adsource;
                    btnprevious.Visible          = !adsource.IsFirstPage;
                    btnnext.Visible              = !adsource.IsLastPage;
                    //dataListComplaint.DataSource = ds;
                    DataNotifications.DataBind();

                    lblPage.Text = "Page " + (adsource.CurrentPageIndex + 1) + " of " + adsource.PageCount;
                }
                else
                {
                }

                // showOpen.CssClass.Remove("Active");
                showOpen.Attributes["class"] = "Active";
                ClientScript.RegisterStartupScript(this.GetType(), "alert('')", " SetActiveClass('Open')", true);
            }
        }
        catch (Exception ex)
        {
        }
        // myModalNewNotficationPopup.Controls.Clear();
    }
示例#2
0
    protected void drpNotifiFilter_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataAccess dacess = new DataAccess();

        String Date       = drpNotifiFilter.SelectedItem.Text;
        String DateFilter = "";

        System.DateTime startDate = new DateTime();
        System.DateTime endDate   = new DateTime();


        if (Date == "All")
        {
            FillNotificationData(muser.currentResident.SocietyID);
            lblEmptyTitle.Visible = false;
        }

        else
        {
            if (Date == "This Month")
            {
                // System.DateTime date = System.DateTime.Now;
                DateTime date  = Utility.GetCurrentDateTimeinUTC();
                int      month = date.Month;
                int      year  = date.Year;
                int      days  = System.DateTime.DaysInMonth(year, month);
                startDate = new DateTime(year, month, 1);
                endDate   = new DateTime(year, month, days);
            }

            if (Date == "Last Month")
            {
                // System.DateTime date = System.DateTime.Now;

                DateTime date = Utility.GetCurrentDateTimeinUTC();

                System.DateTime prevDate = date.AddMonths(-1);

                int month = prevDate.Month;
                int year  = prevDate.Year;

                int days = System.DateTime.DaysInMonth(year, month);

                startDate = new DateTime(year, month, 1);
                endDate   = new DateTime(year, month, days);
            }

            if (Date == "This Year")
            {
                DateTime CurrentDate = Utility.GetCurrentDateTimeinUTC();

                int year = CurrentDate.Year;
                startDate = new DateTime(year, 1, 1);
                endDate   = new DateTime(year, 12, 31);
            }

            DateFilter = "Select * from " + VIEW_NOTIFICATION + " where Date between  '" + startDate + "' and '" + endDate + "' ";
            DataSet ds = dacess.ReadData(DateFilter);
            if (ds == null)
            {
                DataNotifications.Visible = false;
                lblEmptyTitle.Text        = "Selected Data is  not  Found.";
                lblEmptyTitle.Visible     = true;
            }

            else
            {
                DataNotifications.Visible = true;
                lblEmptyTitle.Text        = "";
                DataTable dta = ds.Tables[0];

                if (dta.Rows.Count != 0)
                {
                    DataNotifications.DataSource = ds;
                    DataNotifications.DataBind();
                }
            }
        }
    }