protected void Page_Load(object sender, EventArgs e) { if (!X.IsAjaxRequest) { SuratkeluarQuery skQ = new SuratkeluarQuery("a"); NomorQuery nQ = new NomorQuery("b"); skQ.Select(nQ.Keterangan, skQ.Nomorid, skQ.Nomor.Count().As("jumlahsurat")); skQ.InnerJoin(nQ).On(skQ.Nomorid == nQ.Format); skQ.GroupBy(skQ.Nomorid); SuratkeluarCollection skC = new SuratkeluarCollection(); skC.Load(skQ); rptChartInboxMonthly rptChart = new rptChartInboxMonthly(); rptChart.DataSource = skC; //foreach (Suratkeluar sk in skC) //{ // string jumlahSurat = sk.GetColumn("jumlahsurat").ToString(); // string keterangan = sk.GetColumn(NomorMetadata.ColumnNames.Keterangan, "kosong").ToString(); // double JumlahSurat = 0; // if (!double.TryParse(jumlahSurat, out JumlahSurat)) // JumlahSurat = 0; // ChartSeries cs = new ChartSeries(); // cs.Name = "Surat Keluar"; // cs.Type = ChartSeriesType.Bar; // cs.AddItem(JumlahSurat, sk.Nomorid); //} Telerik.Reporting.InstanceReportSource inst = new Telerik.Reporting.InstanceReportSource(); inst.ReportDocument = rptChart; this.ReportViewer1.ReportSource = inst; this.ReportViewer1.RefreshReport(); this.ReportViewer1.Update(); } }
private void rptChartInboxMonthly_NeedDataSource(object sender, EventArgs e) { //Get Month and Year of all surat masuk //SuratkeluarQuery skq = new SuratkeluarQuery(); //skq.Select(skq.Tanggal); //skq.es.Distinct = true; SuratkeluarQuery skQ = new SuratkeluarQuery("a"); NomorQuery nQ = new NomorQuery("b"); skQ.Select(nQ.Keterangan,skQ.Nomorid, skQ.Nomor.Count().As("jumlahsurat")); skQ.InnerJoin(nQ).On(skQ.Nomorid == nQ.Format); skQ.GroupBy(skQ.Nomorid); SuratkeluarCollection skC = new SuratkeluarCollection(); skC.Load(skQ); if (skC.Count > 0) { foreach (Suratkeluar sk in skC) { try { string jumlahSurat = sk.GetColumn("jumlahsurat").ToString(); //string Keterangan = sk.GetColumn(NomorMetadata.ColumnNames.Keterangan).ToString(); double JumlahSurat = 0; if (!double.TryParse(jumlahSurat, out JumlahSurat)) JumlahSurat = 0; ChartSeries cs = new ChartSeries(); cs.Name = "Surat Keluar"; cs.Type = ChartSeriesType.Bar; cs.AddItem(JumlahSurat, sk.Nomorid); this.chartSuratMasuk.Series.Add(cs); } catch (Exception ex) { Ext.Net.X.Msg.Alert("error",ex.Message).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(); } } }