protected void Page_Load(object sender, EventArgs e) { int fromDate = 0; int fromMonth = 0; int fromYear = 0; int toDate = 0; int toMonth = 0; int toYear = 0; DateTime fromDateQuery = new DateTime(); DateTime toDateQuery = new DateTime(); if (!X.IsAjaxRequest) { if (Request.QueryString.Count == 0) Response.Redirect("Default.aspx"); if (Request.QueryString["fromDay"] != null) fromDate = Convert.ToInt32(Request.QueryString["fromDay"].ToString()); if (Request.QueryString["fromMonth"] != null) fromMonth = Convert.ToInt32(Request.QueryString["fromMonth"].ToString()); if (Request.QueryString["fromYear"] != null) fromYear = Convert.ToInt32(Request.QueryString["fromYear"].ToString()); if (Request.QueryString["toDay"] != null) toDate = Convert.ToInt32(Request.QueryString["toDay"].ToString()); if (Request.QueryString["toMonth"] != null) toMonth = Convert.ToInt32(Request.QueryString["toMonth"].ToString()); if (Request.QueryString["toYear"] != null) toYear = Convert.ToInt32(Request.QueryString["toYear"].ToString()); fromDateQuery = new DateTime(fromYear, fromMonth, fromDate); toDateQuery = new DateTime(toYear, toMonth, toDate); SuratmasukQuery smQ = new SuratmasukQuery("a"); smQ.Select(smQ.Nomor, smQ.Judul, smQ.Tanggal, smQ.Dari.As("Sender_Receiver"), smQ.Keterangan); smQ.Where(smQ.Tanggal.Between(fromDateQuery, toDateQuery)); smQ.OrderBy(smQ.Tanggal.Ascending, smQ.Nomor.Ascending); SuratmasukCollection smC = new SuratmasukCollection(); smC.Load(smQ); if (smC.Count > 0) { rptInboxOutbox rptInOut = new rptInboxOutbox(); rptInOut.DataSource = smC; Telerik.Reporting.InstanceReportSource inst = new Telerik.Reporting.InstanceReportSource(); inst.ReportDocument = rptInOut; this.ReportViewer1.ReportSource = inst; this.ReportViewer1.RefreshReport(); this.ReportViewer1.Update(); } else X.Msg.Alert("Error", "No Data").Show(); } }
public void btnSearch_Click() { DateTime from; DateTime to; bool isInbox = false; bool isOutbox = false; if (chkInbox.Checked) isInbox = true; if (chkOutbox.Checked) isOutbox = true; if (dfTo.IsEmpty) { X.Msg.Alert("error", "To Date must be FILLED").Show(); return; } if (dfFrom.SelectedDate > dfTo.SelectedDate) { X.Msg.Alert("error", "From Date can not BIGGER than To Date").Show(); return; } if (dfFrom.IsEmpty) from = new DateTime(1453, 12, 31); else from = dfFrom.SelectedDate; this.ReportViewer1.Visible = true; to = dfTo.SelectedDate; if (isInbox & !isOutbox) { SuratmasukQuery smQ = new SuratmasukQuery("a"); smQ.Select(smQ.Nomor, smQ.Judul, smQ.Tanggal, smQ.Dari.As("Sender_Receiver"), smQ.Keterangan); smQ.Where(smQ.Tanggal.Between(from, to)); smQ.OrderBy(smQ.Tanggal.Ascending, smQ.Nomor.Ascending); SuratmasukCollection smC = new SuratmasukCollection(); smC.Load(smQ); if (smC.Count > 0) { rptInboxOutbox rptInOut = new rptInboxOutbox(); rptInOut.DataSource = smC; Telerik.Reporting.InstanceReportSource inst = new Telerik.Reporting.InstanceReportSource(); inst.ReportDocument = rptInOut; this.ReportViewer1.ReportSource = inst; this.ReportViewer1.RefreshReport(); this.ReportViewer1.Update(); } } if (!isInbox & isOutbox) { SuratkeluarQuery skQ = new SuratkeluarQuery("b"); skQ.Select(skQ.Nomor, skQ.Judul, skQ.Tanggal, skQ.Kepada.As("Sender_Receiver"), skQ.Keterangan); skQ.Where(skQ.Tanggal.Between(from, to)); skQ.OrderBy(skQ.Tanggal.Ascending, skQ.Nomor.Ascending); SuratkeluarCollection skC = new SuratkeluarCollection(); skC.Load(skQ); if (skC.Count > 0) { rptInboxOutbox rptInOut = new rptInboxOutbox(); rptInOut.DataSource = skC; Telerik.Reporting.InstanceReportSource inst = new Telerik.Reporting.InstanceReportSource(); inst.ReportDocument = rptInOut; this.ReportViewer1.ReportSource = inst; this.ReportViewer1.RefreshReport(); this.ReportViewer1.Update(); } } if (isInbox & isOutbox) { SuratkeluarQuery skQ = new SuratkeluarQuery("a"); skQ.Select(skQ.Nomor, skQ.Judul, skQ.Tanggal, skQ.Kepada.As("Sender_Receiver"), skQ.Keterangan); skQ.Where(skQ.Tanggal.Between(from, to)); SuratmasukQuery smQ = new SuratmasukQuery("b"); smQ.Select(smQ.Nomor, smQ.Judul, smQ.Tanggal, smQ.Dari.As("Sender_Receiver"), smQ.Keterangan); smQ.Where(smQ.Tanggal.Between(from, to)); skQ.Union(smQ); skQ.OrderBy(skQ.Tanggal.Ascending, skQ.Tanggal.Ascending); SuratkeluarCollection skC = new SuratkeluarCollection(); skC.Load(skQ); if (skC.Count > 0) { rptInboxOutbox rptInOut = new rptInboxOutbox(); rptInOut.DataSource = skC; Telerik.Reporting.InstanceReportSource inst = new Telerik.Reporting.InstanceReportSource(); inst.ReportDocument = rptInOut; this.ReportViewer1.ReportSource = inst; this.ReportViewer1.RefreshReport(); this.ReportViewer1.Update(); } } }