protected void LnkExportExcel_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment; filename = GelenZengler.xls"); Response.ContentType = "application/vnd.xls"; StringWriter stringWrite = new StringWriter(); HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); GrdCallCenter.Columns[GrdCallCenter.Columns.Count - 1].Visible = false; GrdCallCenter.Columns[GrdCallCenter.Columns.Count - 2].Visible = false; GrdCallCenter.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); GrdCallCenter.Columns[GrdCallCenter.Columns.Count - 1].Visible = false; GrdCallCenter.Columns[GrdCallCenter.Columns.Count - 2].Visible = false; }
void BindGrid() { if (Session[_FilterSessionName] != null) { var DictionarySession = (Dictionary <string, object>)Session[_FilterSessionName]; if (DictionarySession.Count != 0) { TxtRowIndexFilter.Text = DictionarySession["RowIndex"]._ToString(); //DlistCallCenterTypeFilter.SelectedValue = DictionarySession["CallCenterTypeID"]._ToString(); DListComplaintTypeFilter.SelectedValue = DictionarySession["ComplaintTypeID"]._ToString(); TxtApplicantFullnameFilter.Text = DictionarySession["ApplicantFullname"]._ToString(); DListApplicantGenderTypeFilter.SelectedValue = DictionarySession["GenderTypeID"]._ToString(); DListApplicantSocialStatusFilter.SelectedValue = DictionarySession["SocialStatusID"]._ToString(); TxtPhoneNumberFilter.Text = DictionarySession["PhoneNumber"]._ToString(); TxtVictimsFullnameFilter.Text = DictionarySession["VictimsFullname"]._ToString(); DListComplaintResultTypeFilter.SelectedValue = DictionarySession["ComplaintResultTypeID"]._ToString(); TxtResultsFilter.Text = DictionarySession["Results"]._ToString(); TxtCallDtStartFilter.Text = DictionarySession["StartCall_Dt"]._ToString(); TxtCallDtEndFilter.Text = DictionarySession["EndCall_Dt"]._ToString(); TxtStartPunishmentPeriodFilter.Text = DictionarySession["StartPunishmentPeriod"]._ToString(); TxtEndPunishmentPeriodFilter.Text = DictionarySession["EndPunishmentPeriod"]._ToString(); DListDatePriority.SelectedValue = DictionarySession["DatePriority"]._ToString(); DListPageSize.SelectedValue = DictionarySession["PageSize"]._ToString(); } } #region BetweenDateFromat string DatePunishmentPeriod = ""; string DatePunishmentPeriod1 = "19000101"; string DatePunishmentPeriod2 = DateTime.Now.ToString("yyyyMMdd"); object DtStartPunishmentPeriod = Config.DateTimeFormat(TxtStartPunishmentPeriodFilter.Text.Trim()); object DtEndPunishmentPeriod = Config.DateTimeFormat(TxtEndPunishmentPeriodFilter.Text.Trim()); if (DtStartPunishmentPeriod == null && DtEndPunishmentPeriod == null) { DatePunishmentPeriod = ""; } else { if (DtStartPunishmentPeriod != null) { DatePunishmentPeriod1 = ((DateTime)DtStartPunishmentPeriod).ToString("yyyyMMdd"); } if (DtEndPunishmentPeriod != null) { DatePunishmentPeriod2 = ((DateTime)DtEndPunishmentPeriod).ToString("yyyyMMdd"); } DatePunishmentPeriod = DatePunishmentPeriod1 + "&" + DatePunishmentPeriod2; } string Date = ""; string Dt1 = "19000101"; string Dt2 = DateTime.Now.ToString("yyyyMMdd"); object DateFilter1 = Config.DateTimeFormat(TxtCallDtStartFilter.Text.Trim()); object DateFilter2 = Config.DateTimeFormat(TxtCallDtEndFilter.Text.Trim()); if (DateFilter1 == null && DateFilter2 == null) { Date = ""; } else { if (DateFilter1 != null) { Dt1 = ((DateTime)DateFilter1).ToString("yyyyMMdd"); } if (DateFilter2 != null) { Dt2 = ((DateTime)DateFilter2).ToString("yyyyMMdd"); } Date = Dt1 + "&" + Dt2; } #endregion var Dictionary = new Dictionary <string, object>() { // {"CallCenterTypeID",int.Parse(DlistCallCenterTypeFilter.SelectedValue)}, { "ComplaintTypeID", int.Parse(DListComplaintTypeFilter.SelectedValue) }, { "(LIKE)ApplicantFullname", TxtApplicantFullnameFilter.Text }, { "GenderTypeID", int.Parse(DListApplicantGenderTypeFilter.SelectedValue) }, { "SocialStatusID", int.Parse(DListApplicantSocialStatusFilter.SelectedValue) }, { "PhoneNumber", TxtPhoneNumberFilter.Text }, { "VictimsFullname", TxtVictimsFullnameFilter.Text }, { "ComplaintResultTypeID", DListComplaintResultTypeFilter.SelectedValue }, { "(LIKE)Results", TxtResultsFilter.Text }, { "Call_Dt(BETWEEN)", Date }, { "StartPunishmentPeriod(BETWEEN)", DatePunishmentPeriod }, { "EndPunishmentPeriod(BETWEEN)", DatePunishmentPeriod } }; //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.GetCallCenter(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/CallCenter/?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; GrdCallCenter.DataSource = ApplicationsList.Dt; GrdCallCenter.DataBind(); LblCountInfo.Text = string.Format("Axtarış üzrə nəticə: {0}", ApplicationsList.Count); }