Пример #1
0
        public void btnSearch_Click()
        {
            DateTime dtFrom = DateTime.Now;
            DateTime dtTo = DateTime.Now;
            if (dfFrom.IsEmpty)
                dtFrom = new DateTime(2000, 12, 31);
            else
                dtFrom = dfFrom.SelectedDate;
            if (dfTo.IsEmpty)
                dtTo = DateTime.Now;
            else
                dtTo = dfTo.SelectedDate;
            if (dtFrom > dtTo)
            {
                X.Msg.Alert("Error", "From Date must smaller than End Date").Show();
                return;
            }

            SuratkeluarQuery skQ = new SuratkeluarQuery();
            skQ.SelectAll();
            if (dtFrom == dtTo)
            {
                skQ.Where(skQ.Tanggal == dtFrom && skQ.Judul.Like("%" + txtJudul.Text.Trim() + "%")
                    && skQ.Keterangan.Like("%" + txtKeterangan.Text.Trim() + "%") && skQ.Nomor.Like("%" + txtNomorSurat.Text.Trim() +
                    "%") && skQ.Kepada.Like("%" + txtPenerima.Text.Trim() + "%"));
            }
            else
            {
                skQ.Where(skQ.Tanggal.Between(dtFrom,dtTo) && skQ.Judul.Like("%" + txtJudul.Text.Trim() + "%")
                    && skQ.Keterangan.Like("%" + txtKeterangan.Text.Trim() + "%") && skQ.Nomor.Like("%" + txtNomorSurat.Text.Trim() +
                    "%") && skQ.Kepada.Like("%" + txtPenerima.Text.Trim() + "%"));
            }

            DataTable dt = skQ.LoadDataTable();
            this.storeOutbox.DataSource = dt;
            this.storeOutbox.DataBind();
        }
        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();
                }
            }
        }