コード例 #1
0
 protected void LnkExportExcel_Click(object sender, EventArgs e)
 {
     Response.Clear();
     Response.AddHeader("content-disposition", "attachment; filename = FerdiSikayetler.xls");
     Response.ContentType = "application/vnd.xls";
     StringWriter stringWrite = new StringWriter();
     HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
     GrdIndividualComplaints.Columns[GrdIndividualComplaints.Columns.Count - 1].Visible = false;
     GrdIndividualComplaints.Columns[GrdIndividualComplaints.Columns.Count - 2].Visible = false;
     GrdIndividualComplaints.RenderControl(htmlWrite);
     Response.Write(stringWrite.ToString());
     Response.End();
     GrdIndividualComplaints.Columns[GrdIndividualComplaints.Columns.Count - 1].Visible = false;
     GrdIndividualComplaints.Columns[GrdIndividualComplaints.Columns.Count - 2].Visible = false;
 }
コード例 #2
0
    void BindGrid()
    {

        if (Session[_FilterSessionName] != null)
        {
            var DictionarySession = (Dictionary<string, object>)Session[_FilterSessionName];
            if (DictionarySession.Count != 0)
            {
                TxtRowIndexFilter.Text = DictionarySession["RowIndex"]._ToString();
                TxtNumbersFilter.Text = DictionarySession["Numbers"]._ToString();
                DListComplaintTypeFilter.SelectedValue = DictionarySession["ComplaintTypeID"]._ToString();
                DlistExecutiveUsersFilter.SelectedValue = DictionarySession["ExecutiveUsersID"]._ToString();
                TxtApplicantsFullnameFilter.Text = DictionarySession["ApplicantsFullname"]._ToString();
                DListApplicantsGenderTypeFilter.SelectedValue = DictionarySession["GenderTypeID"]._ToString();
                DListApplicantsSocialStatusFilter.SelectedValue = DictionarySession["SocialStatusID"]._ToString();
                TxtVictimsFullnameFilter.Text = DictionarySession["VictimsFullname"]._ToString();
                TxtComplaintInstitutionFilter.Text = DictionarySession["ComplaintInstitution"]._ToString();
                DListComplaintResultTypeFilter.SelectedValue = DictionarySession["ComplaintResultTypeID"]._ToString();
                TxtResultsFilter.Text = DictionarySession["Results"]._ToString();
                TxtEnterOrganizationsStartDtFilter.Text = DictionarySession["StartEnterOrganizations_Dt"]._ToString();
                TxtEnterOrganizationsEndDtFilter.Text = DictionarySession["EndEnterOrganizations_Dt"]._ToString();
                TxtEnterSectorStartDtFilter.Text = DictionarySession["StartEnterSector_Dt"]._ToString();
                TxtEnterSectorEndDtFilter.Text = DictionarySession["EndEnterSector_Dt"]._ToString();
                DListDatePriority.SelectedValue = DictionarySession["DatePriority"]._ToString();
                DListPageSize.SelectedValue = DictionarySession["PageSize"]._ToString();
            }
        }

        #region BetweenDateFromat

        string OrganizationsDate = "";

        string Dt1 = "19000101";
        string Dt2 = DateTime.Now.ToString("yyyyMMdd");

        object DateFilter1 = Config.DateTimeFormat(TxtEnterOrganizationsStartDtFilter.Text.Trim());
        object DateFilter2 = Config.DateTimeFormat(TxtEnterOrganizationsEndDtFilter.Text.Trim());

        if (DateFilter1 == null && DateFilter2 == null)
        {
            OrganizationsDate = "";
        }
        else
        {
            if (DateFilter1 != null)
            {
                Dt1 = ((DateTime)DateFilter1).ToString("yyyyMMdd");
            }

            if (DateFilter2 != null)
            {
                Dt2 = ((DateTime)DateFilter2).ToString("yyyyMMdd");
            }

            OrganizationsDate = Dt1 + "&" + Dt2;
        }


        string SectorDate = "";

        Dt1 = "19000101";
        Dt2 = DateTime.Now.ToString("yyyyMMdd");

        DateFilter1 = Config.DateTimeFormat(TxtEnterSectorStartDtFilter.Text.Trim());
        DateFilter2 = Config.DateTimeFormat(TxtEnterSectorEndDtFilter.Text.Trim());

        if (DateFilter1 == null && DateFilter2 == null)
        {
            SectorDate = "";
        }
        else
        {
            if (DateFilter1 != null)
            {
                Dt1 = ((DateTime)DateFilter1).ToString("yyyyMMdd");
            }

            if (DateFilter2 != null)
            {
                Dt2 = ((DateTime)DateFilter2).ToString("yyyyMMdd");
            }

            SectorDate = Dt1 + "&" + Dt2;

        }
        #endregion

        var Dictionary = new Dictionary<string, object>()
        {
            {"Numbers",TxtNumbersFilter.Text},
            {"ComplaintTypeID",int.Parse(DListComplaintTypeFilter.SelectedValue)},
            {"ExecutiveUsersID",int.Parse(DlistExecutiveUsersFilter.SelectedValue) },
            {"GenderTypeID",int.Parse(DListApplicantsGenderTypeFilter.SelectedValue) },
            {"SocialStatusID",int.Parse(DListApplicantsSocialStatusFilter.SelectedValue) },
            {"(LIKE)ApplicantsFullname",TxtApplicantsFullnameFilter.Text},
            {"(LIKE)VictimsFullname",TxtVictimsFullnameFilter.Text},
            {"ComplaintInstitution", TxtComplaintInstitutionFilter.Text},
            {"ComplaintResultTypeID", DListComplaintResultTypeFilter.SelectedValue},
            {"(LIKE)Results", TxtResultsFilter.Text},
            {"EnterOrganizations_Dt(BETWEEN)", OrganizationsDate},
            {"EnterSector_Dt(BETWEEN)", SectorDate}
        };

        //Sira sayina gore filteri elave olaraq gonderirik
        int RowIndex = -1;
        if (!int.TryParse(TxtRowIndexFilter.Text, out RowIndex))
        {
            RowIndex = -1;
        }


        int PageNum;
        int RowNumber = 30;

        if (DListPageSize.SelectedValue == "20")
        {
            RowNumber = 10000;
        }

        string OrderByType = "desc";

        if (DListDatePriority.SelectedValue == "20")
        {
            OrderByType = "asc";
        }

        if (!int.TryParse(Config._GetQueryString("p"), out PageNum))
        {
            PageNum = 1;
        }

        // Axirinci sehifeni secmedikce Cache temizlemirik herdefe count almasin deye
        if (PageNum >= (Cache[_CountCacheName]._ToInt32() / RowNumber))
        {
            Cache.Remove(_CountCacheName);
        }

        HdnPageNumber.Value = PageNum.ToString();

        DALC.DataTableResult ApplicationsList = DALC.GetIndividualComplaints(Dictionary, PageNum, RowNumber, new object[] { RowIndex }, OrderByType);

        if (ApplicationsList.Count == -1)
        {
            return;
        }

        if (ApplicationsList.Dt.Rows.Count < 1 && PageNum > 1)
        {
            Config.RedirectURL(string.Format("/tools/IndividualComplaints/?p={0}", PageNum - 1));
        }

        int Total_Count = ApplicationsList.Count % RowNumber > 0 ? (ApplicationsList.Count / RowNumber) + 1 : ApplicationsList.Count / RowNumber;
        HdnTotalCount.Value = Total_Count.ToString();

        PnlPager.Visible = ApplicationsList.Count > RowNumber;

        GrdIndividualComplaints.DataSource = ApplicationsList.Dt;
        GrdIndividualComplaints.DataBind();

        LblCountInfo.Text = string.Format("Axtarış üzrə nəticə: {0}", ApplicationsList.Count);

    }