public void Proceed() { int lasnumber = 0; DateTime transdate = DateTime.Now; TransQuery trans = new TransQuery("a"); trans.SelectAll(); trans.Where(trans.TransNumber >= txtTransNumber.Text.Trim()); trans.OrderBy(trans.TransNumber.Ascending,trans.BkuId.Ascending); TransCollection tC = new TransCollection(); if (tC.Load(trans)) { string autonumber = "201212-0438"; int count = 438; foreach (Trans t in tC) { Trans tt = new Trans(); if (tt.LoadByPrimaryKey((long)t.BkuId)) { string number = count.ToString().Trim(); if (number.Length == 3) number = "0" + number; tt.TransNumber = "201212-" + number; tt.Save(); count++; } } } }
protected void btnPreview_Click(object sender, EventArgs e) { if (dtpStartDate.SelectedDate > dtpEndDate.SelectedDate || dtpStartDate.SelectedDate > DateTime.Now) return; if (dtpEndDate.SelectedDate.ToString().Trim() == string.Empty) return; if ((dtpStartDate.SelectedDate.ToString().Trim() == string.Empty)) dtpStartDate.SelectedDate = dtpStartDate.MinDate; TransQuery tQ = new TransQuery(); tQ.Select(tQ.TransNumber, tQ.TransDate, tQ.Descript, tQ.DebitAmount, tQ.CreditAmount); tQ.Where(tQ.TransDate >= dtpStartDate.SelectedDate, tQ.TransDate <= dtpEndDate.SelectedDate); TransCollection tColl = new TransCollection(); tColl.Load(tQ); if (tColl.Count > 0) { RSCM_BKU_web.Report.LaporanKasBank report1 = new RSCM_BKU_web.Report.LaporanKasBank(); report1.ReportParameters[0].Value = "Toro"; report1.ReportParameters[1].Value = dtpStartDate.SelectedDate; report1.ReportParameters[2].Value = dtpEndDate.SelectedDate; report1.DataSource = tColl; LaporanKasBankWebViewer.Report = report1; LaporanKasBankWebViewer.RefreshReport(); } else return; }
protected void btnPreview_Click(object sender, EventArgs e) { if (dtpStartDate.SelectedDate > dtpEndDate.SelectedDate || dtpStartDate.SelectedDate > DateTime.Now) return; if (dtpEndDate.SelectedDate.ToString().Trim() == string.Empty) return; if ((dtpStartDate.SelectedDate.ToString().Trim() == string.Empty)) dtpStartDate.SelectedDate = dtpStartDate.MinDate; //Load All Valid Kas KasQuery kasQ = new KasQuery("a"); PeriodeAnggaranQuery paQ = new PeriodeAnggaranQuery("b"); kasQ.InnerJoin(paQ).On(kasQ.PeriodeId == paQ.Id); kasQ.Select(kasQ.KaCode, kasQ.KaName); paQ.Where(paQ.IsClosed == false); KasCollection kasC = new KasCollection(); kasC.Load(kasQ); ReportBook rb = new ReportBook(); foreach (Kas k in kasC) { TransQuery tQ = new TransQuery("c"); tQ.Select(tQ.TransNumber, tQ.TransDate, tQ.Descript, tQ.DebitAmount, tQ.CreditAmount); tQ.Where(tQ.TransDate >= dtpStartDate.SelectedDate, tQ.TransDate <= dtpEndDate.SelectedDate,tQ.KasId == k.KaCode); TransCollection tColl = new TransCollection(); tColl.Load(tQ); if (tColl.Count > 0) { RSCM_BKU_web.Report.LaporanKasBank report1 = new RSCM_BKU_web.Report.LaporanKasBank(); report1.ReportParameters[0].Value = k.KaName; report1.ReportParameters[1].Value = dtpStartDate.SelectedDate; report1.ReportParameters[2].Value = dtpEndDate.SelectedDate; report1.DataSource = tColl; rb.Reports.Add(report1); } } //ReportViewer1.Report = rb; //ReportViewer1.RefreshReport(); }
protected void cmdPreview_Click(object sender, EventArgs e) { if (dtfStartDate.IsEmpty) dtfStartDate.SelectedDate = new DateTime(2011, 01, 01); if (dtfEndDate.IsEmpty) dtfEndDate.SelectedDate = DateTime.Now; if (dtfStartDate.SelectedDate > dtfEndDate.SelectedDate) return; if (string.IsNullOrEmpty(cmbJenisKasBank.SelectedItem.Value)) { cmbJenisKasBank.SelectedIndex = 0; } //ini untuk saldo awal KasCollection saldoKas = new KasCollection(); saldoKas.Query.Select(saldoKas.Query.SaldoAwal); saldoKas.Query.Where(saldoKas.Query.KaCode == cmbJenisKasBank.SelectedItem.Value); saldoKas.Query.Load(); //hitung total kredit untuk semua transaksi sebelum tanggal awal TransCollection transtotalCreditCollection = new TransCollection(); transtotalCreditCollection.Query.Select(transtotalCreditCollection.Query.CreditAmount.Sum().Coalesce("0")); transtotalCreditCollection.Query.Where(transtotalCreditCollection.Query.TransDate < dtfStartDate.SelectedDate & transtotalCreditCollection.Query.KasId == cmbJenisKasBank.SelectedItem.Value); //transtotalCreditCollection.Query.OrderBy(transtotalCreditCollection.Query.TransNumber.Ascending, transtotalCreditCollection.Query.BkuId.Ascending); transtotalCreditCollection.Query.Load(); decimal totalCredit = 0; if (!transtotalCreditCollection[0].CreditAmount.HasValue) { totalCredit = 0; } else { totalCredit = (decimal)transtotalCreditCollection[0].CreditAmount.Value; } //hitung total debit untuk semua transaksi sebelum tanggal awal TransCollection transtotalDebitCollection = new TransCollection(); transtotalDebitCollection.Query.Select(transtotalDebitCollection.Query.DebitAmount.Sum().Coalesce("0")); transtotalDebitCollection.Query.Where(transtotalDebitCollection.Query.TransDate < dtfStartDate.SelectedDate & transtotalDebitCollection.Query.KasId == cmbJenisKasBank.SelectedItem.Value); transtotalDebitCollection.Query.Load(); decimal totalDebit = 0; if (transtotalDebitCollection[0].DebitAmount.HasValue == false) { totalDebit = 0; } else { totalDebit = (decimal)transtotalDebitCollection[0].DebitAmount.Value; } //so, Saldo Awal adalah ... decimal SaldoAwal = 0; foreach(Kas kkkk in saldoKas) { SaldoAwal = (decimal)kkkk.SaldoAwal + totalDebit - totalCredit; } //TransQuery transQ = new TransQuery(); string zero = "0"; string zeros = "0.0"; string sawal = "SALDO AWAL"; decimal nol = 0; DateTime skrg = DateTime.Now; DateTime startdate = dtfStartDate.SelectedDate; startdate = startdate.AddDays(-1); var trans = from t in db.Trans join k in db.KAs on t.KAS_ID equals k.KA_CODE where t.TRANS_DATE >= dtfStartDate.SelectedDate && t.TRANS_DATE <= dtfEndDate.SelectedDate && t.KAS_ID == cmbJenisKasBank.SelectedItem.Value select new { NUMBER = (string)t.TRANS_NUMBER, DATES = (DateTime)t.TRANS_DATE, DESCRIPTS = t.DESCRIPT, CREDIT = (decimal)t.CREDIT_AMOUNT, DEBIT = (decimal)t.DEBIT_AMOUNT, CODES = (String)k.KA_CODE, NAMES = (string)k.KA_NAME }; var Cash = from kas in db.KAs where kas.KA_CODE == cmbJenisKasBank.SelectedItem.Value select new { NUMBER = zero, DATES = startdate, DESCRIPTS = sawal, CREDIT = nol, DEBIT = SaldoAwal, CODES = zeros, NAMES = (string)kas.KA_NAME }; var Gab = trans.Union(Cash); DataTable Gabungan = AnonymousToDataTable.ToDataTable(Gab); Gabungan.Columns.Add("SALDO", typeof(decimal)); foreach (DataRow dr in Gabungan.Rows) { if (dr["DESCRIPTS"].ToString() == sawal) { dr["SALDO"] = SaldoAwal; continue; } SaldoAwal = SaldoAwal + (Convert.ToDecimal(dr["DEBIT"])) - (Convert.ToDecimal(dr["CREDIT"])); dr["SALDO"] = SaldoAwal; Gabungan.AcceptChanges(); } RSCM_BKU_web.Report.LaporanKasBank report1 = new RSCM_BKU_web.Report.LaporanKasBank(); report1.DataSource = Gabungan; ReportViewer1.Report = report1; ReportViewer1.RefreshReport(); }
protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); DateTime TransDateMonth = DateTime.Now; try { TransDateMonth = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate; } catch (Exception ex) { string error = ex.Message; } int transDateMonth = TransDateMonth.Month; //perubahan terakhir, autonumber mengikuti bulan transaksi, bukan bulan berjalan //string month = DateTime.Now.Month.ToString().Trim(); string month = transDateMonth.ToString().Trim(); string autonumber = ""; if (month.Length == 1) month = ('0' + month).Trim(); Trans Trans = new Trans(); //Auto Number AutoNumberingQuery anQ = new AutoNumberingQuery(); anQ.SelectAll(); anQ.Where(anQ.KaMonth == month, anQ.KaYear == DateTime.Now.Year.ToString().Trim()); AutoNumberingCollection anColl = new AutoNumberingCollection(); anColl.Load(anQ); //KelAnggaranQuery kaQ = new KelAnggaranQuery(); //kaQ.SelectAll(); //kaQ.Where(kaQ.KaCode == (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedValue.Trim()); //KelAnggaranCollection kaColl = new KelAnggaranCollection(); //kaColl.Load(kaQ); if (anColl.Count == 0) { AutoNumberingCollection anCollection = new AutoNumberingCollection(); AutoNumbering aN = new AutoNumbering(); aN = anCollection.AddNew(); aN.KaYear = DateTime.Now.Year.ToString().Trim(); aN.KaMonth = month; aN.LastNumber = 1; aN.PrefixNumber = "000"; //AutoNumbering an = new AutoNumbering { KaYear = DateTime.Now.Year.ToString().Trim(), KaMonth = month, LastNumber = 1, PrefixNumber = "000" }; autonumber = String.Format("{0}{1}{2}-0001", autonumber, DateTime.Now.Year.ToString().Trim(), month); //an.Save(); try { TransCollection transCollection = new TransCollection(); Trans = transCollection.AddNew(); //Trans.KaCode = (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedItem.Value; Trans.KaCode = (userControl.FindControl("HiddenField1") as HiddenField).Value; Trans.TransNumber = autonumber.ToUpper(); Trans.CekBgNumber = (userControl.FindControl("txtCek") as RadTextBox).Text; //Trans.Amount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value - (userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value); Trans.DebitAmount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value); Trans.CreditAmount = Convert.ToDecimal((userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value); Trans.Descript = (userControl.FindControl("txtDESC") as RadTextBox).Text; Trans.KasId = (userControl.FindControl("cmbKasID") as RadComboBox).SelectedValue.ToUpper(); Trans.TransDate = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate; Trans.UserInsert = "toro"; Trans.TglInsert = DateTime.Now; Trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; Trans.Isverified = false; Trans.IsClosed = false; using (esTransactionScope scope = new esTransactionScope()) { anCollection.Save(); transCollection.Save(); scope.Complete(); } } catch (Exception ex) { string es = ex.Message; } finally { RadGrid1.Rebind(); } } else foreach (AutoNumbering aa in anColl) { string i = (aa.LastNumber + 1).ToString().Trim(); if (i.Length == 1) autonumber = String.Format("{0}{1}{2}-000{3}", autonumber, aa.KaYear, aa.KaMonth, i); if (i.Length == 2) autonumber = String.Format("{0}{1}{2}-00{3}", autonumber, aa.KaYear, aa.KaMonth, i); if (i.Length == 3) autonumber = String.Format("{0}{1}{2}-0{3}", autonumber, aa.KaYear, aa.KaMonth, i); if (i.Length == 4) autonumber = String.Format("{0}{1}{2}-{3}", autonumber, aa.KaYear, aa.KaMonth, i); AutoNumbering anb = new AutoNumbering(); AutoNumberingCollection anCollection = new AutoNumberingCollection(); anb = anCollection.AddNew(); if (anb.LoadByPrimaryKey((long)aa.Id)) { anb.LastNumber = aa.LastNumber + 1; try { TransCollection transCollection = new TransCollection(); Trans = transCollection.AddNew(); Trans.KaCode = (userControl.FindControl("HiddenField1") as HiddenField).Value; Trans.TransNumber = autonumber.ToUpper(); Trans.CekBgNumber = (userControl.FindControl("txtCek") as RadTextBox).Text; Trans.DebitAmount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value); Trans.CreditAmount = Convert.ToDecimal((userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value); Trans.Descript = (userControl.FindControl("txtDESC") as RadTextBox).Text; Trans.KasId = (userControl.FindControl("cmbKasID") as RadComboBox).SelectedValue.ToUpper(); Trans.TransDate = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate; Trans.UserInsert = "toro"; Trans.TglInsert = DateTime.Now; Trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; Trans.Isverified = false; Trans.IsClosed = false; anb.LastNumber = aa.LastNumber + 1; using (esTransactionScope scope = new esTransactionScope()) { transCollection.Save(); scope.Complete(); } anb.Save(); } catch (Exception ex) { string es = ex.Message; } finally { RadGrid1.Rebind(); } } } }
virtual public void Combine(TransCollection collection) { base.Combine(collection); }
protected void cmdSave_Click(object sender, EventArgs e) { //ADD Trans trans = new Trans(); string Descript = txtDescription.Text; string CreditAmoun = txtCreditAmount.Text; if (Request.QueryString["BKU_ID"] == null) { int TransDateMonth = ((DateTime)dtpTransDate.SelectedDate).Month; string month = TransDateMonth.ToString().Trim(); string autonumber = ""; if (month.Length == 1) month = ('0' + month).Trim(); //Trans Trans = new Trans(); //Auto Number AutoNumberingQuery anQ = new AutoNumberingQuery(); anQ.SelectAll(); anQ.Where(anQ.KaMonth == month, anQ.KaYear == DateTime.Now.Year.ToString().Trim()); AutoNumberingCollection anColl = new AutoNumberingCollection(); anColl.Load(anQ); //New month, new autonumber if (anColl.Count == 0) { AutoNumberingCollection anCollection = new AutoNumberingCollection(); AutoNumbering aN = new AutoNumbering(); aN = anCollection.AddNew(); aN.KaYear = DateTime.Now.Year.ToString().Trim(); aN.KaMonth = month; aN.LastNumber = 1; aN.PrefixNumber = "000"; autonumber = String.Format("{0}{1}{2}-0001", autonumber, DateTime.Now.Year.ToString().Trim(), month); try { Decimal DebitAmount = 0; Decimal CreditAmount = 0; TransCollection transColl = new TransCollection(); trans = transColl.AddNew(); trans.TransNumber = autonumber.ToUpper(); trans.KaCode = cmbTransCode.SelectedValue; trans.TransDate = dtpTransDate.SelectedDate; trans.KasId = cmbKasID.SelectedValue; trans.Descript = txtDescription.Text; trans.CekBgNumber = txtCekBG.Text; if (Decimal.TryParse(txtDebitAmount.Text, out DebitAmount)) trans.DebitAmount = DebitAmount; else trans.DebitAmount = 0; if (Decimal.TryParse(txtCreditAmount.Text, out CreditAmount)) trans.CreditAmount = CreditAmount; else trans.CreditAmount = 0; trans.UserInsert = HttpContext.Current.Session["UserId"].ToString(); trans.TglInsert = DateTime.Now; trans.Isverified = false; trans.IsClosed = false; trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; using (esTransactionScope scope = new esTransactionScope()) { anCollection.Save(); transColl.Save(); scope.Complete(); } } catch (Exception ex) { string es = ex.Message; } } // If month already exist, increment autonumber else { foreach (AutoNumbering aa in anColl) { string i = (aa.LastNumber + 1).ToString().Trim(); if (i.Length == 1) autonumber = String.Format("{0}{1}{2}-000{3}", autonumber, aa.KaYear, aa.KaMonth, i); if (i.Length == 2) autonumber = String.Format("{0}{1}{2}-00{3}", autonumber, aa.KaYear, aa.KaMonth, i); if (i.Length == 3) autonumber = String.Format("{0}{1}{2}-0{3}", autonumber, aa.KaYear, aa.KaMonth, i); if (i.Length == 4) autonumber = String.Format("{0}{1}{2}-{3}", autonumber, aa.KaYear, aa.KaMonth, i); AutoNumbering anb = new AutoNumbering(); AutoNumberingCollection anCollection = new AutoNumberingCollection(); anb = anCollection.AddNew(); if (anb.LoadByPrimaryKey((long)aa.Id)) { anb.LastNumber = aa.LastNumber + 1; try { Decimal DebitAmount = 0; Decimal CreditAmount = 0; TransCollection transColl = new TransCollection(); trans = transColl.AddNew(); trans.TransNumber = autonumber.ToUpper(); trans.KaCode = cmbTransCode.SelectedValue; trans.TransDate = dtpTransDate.SelectedDate; trans.KasId = cmbKasID.SelectedValue; trans.CekBgNumber = txtCekBG.Text; trans.KasId = cmbKasID.SelectedValue; trans.Descript = txtDescription.Text; if (Decimal.TryParse(txtDebitAmount.Text, out DebitAmount)) trans.DebitAmount = DebitAmount; else trans.DebitAmount = 0; if (Decimal.TryParse(txtCreditAmount.Text, out CreditAmount)) trans.CreditAmount = CreditAmount; else trans.CreditAmount = 0; trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"]; trans.Isverified = false; trans.IsClosed = false; trans.UserInsert = HttpContext.Current.Session["UserId"].ToString(); trans.TglInsert = DateTime.Now; anb.LastNumber = aa.LastNumber + 1; using (esTransactionScope scope = new esTransactionScope()) { transColl.Save(); anb.Save(); scope.Complete(); } //anb.Save(); } catch (Exception ex) { string es = ex.Message; } } } } } //EDIT else { long bkuID = 0; Decimal DebitAmount = 0; Decimal CreditAmount = 0; try { if (long.TryParse(txtTransID.Text, out bkuID)) { if (trans.LoadByPrimaryKey(bkuID)) { trans.TransDate = dtpTransDate.SelectedDate; trans.KaCode = cmbTransCode.SelectedItem.Value; trans.KasId = cmbKasID.SelectedItem.Value; trans.Descript = Descript; trans.CekBgNumber = txtCekBG.Text; if (Decimal.TryParse(txtDebitAmount.Text, out DebitAmount)) trans.DebitAmount = DebitAmount; else trans.DebitAmount = 0; if (Decimal.TryParse(txtCreditAmount.Text, out CreditAmount)) trans.CreditAmount = CreditAmount; else trans.CreditAmount = 0; trans.UserUpdate = HttpContext.Current.Session["UserId"].ToString(); trans.TglUpdate = DateTime.Now; trans.Save(); } } } catch (Exception ex) { string es = ex.Message; } } if (Request.QueryString["BKU_ID"] != null) { ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind('navigateAndRebind');", true); HttpContext.Current.Session["CUDMode"] = "1"; // EDIT } else { ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true); HttpContext.Current.Session["CUDMode"] = "0"; //ADD } }
protected void cmdPeview_Click(object sender, EventArgs e) { if (dtfStartDate.IsEmpty) dtfStartDate.SelectedDate = new DateTime(2010, 01, 01); if (dtfEndDate.IsEmpty) dtfEndDate.SelectedDate = DateTime.Now; if (dtfStartDate.SelectedDate > dtfEndDate.SelectedDate) return; TransaksiBKUQuery transBkuQ = new TransaksiBKUQuery(); //KelAnggaranQuery kelAnggaranQuery = new KelAnggaranQuery(); SaldoAwalCollection saCol = new SaldoAwalCollection(); saCol.LoadAll(); //hitung total kredit untuk semua transaksi sebelum tanggal awal TransCollection transtotalCreditCollection = new TransCollection(); transtotalCreditCollection.Query.Select(transtotalCreditCollection.Query.CreditAmount.Sum().Coalesce("0")); transtotalCreditCollection.Query.Where(transtotalCreditCollection.Query.TransDate < dtfStartDate.SelectedDate); transtotalCreditCollection.Query.Load(); decimal totalCredit = 0; if (!transtotalCreditCollection[0].CreditAmount.HasValue) { totalCredit = 0; } else { totalCredit = (decimal)transtotalCreditCollection[0].CreditAmount.Value; } //hitung total debit untuk semua transaksi sebelum tanggal awal TransCollection transtotalDebitCollection = new TransCollection(); transtotalDebitCollection.Query.Select(transtotalDebitCollection.Query.DebitAmount.Sum().Coalesce("0")); transtotalDebitCollection.Query.Where(transtotalDebitCollection.Query.TransDate < dtfStartDate.SelectedDate); transtotalDebitCollection.Query.Load(); decimal totalDebit = 0; if (transtotalDebitCollection[0].DebitAmount.HasValue == false) { totalDebit = 0; } else { totalDebit = (decimal)transtotalDebitCollection[0].DebitAmount.Value; } transBkuQ.SelectAll(); //transBkuQ.Select(transBkuQ.TransNumber,transBkuQ.TransDate,kelAnggaranQuery.GtCode,transBkuQ.Descript,transBkuQ.KaName,transBkuQ.CekBgNumber); transBkuQ.OrderBy(transBkuQ.TransNumber.Ascending); transBkuQ.Where(transBkuQ.TransDate >= dtfStartDate.SelectedDate & transBkuQ.TransDate <= dtfEndDate.SelectedDate); //transBkuQ.InnerJoin(kelAnggaranQuery).On(transBkuQ.KaCode == kelAnggaranQuery.KaCode); TransaksiBKUCollection transBkuCol = new TransaksiBKUCollection(); transBkuCol.Load(transBkuQ); if (transBkuCol.Count > 0) { dt = transBkuQ.LoadDataTable(); dt.Columns.Add("Saldo", typeof(decimal)); DataTable dtCopy = dt.Clone(); foreach (RSCM_BKU_Web.BusinessObjects.SaldoAwal sa in saCol) { dtCopy.Rows.Add("0", null, "SALDO AWAL TOTAL", "0", "Saldo Awal Total", "", (sa.SaldoAwal + totalDebit - totalCredit), 0, false, false, true, "", (sa.SaldoAwal + totalDebit - totalCredit)); SaldoAwal = Convert.ToDecimal((sa.SaldoAwal + totalDebit - totalCredit)); } foreach (DataColumn dc in dt.Columns) { titles += dc.ColumnName; this.Title = titles; } foreach (DataRow dr in dt.Rows) { SaldoAwal = SaldoAwal + (Convert.ToDecimal(dr["DEBIT_AMOUNT"]) - Convert.ToDecimal(dr["CREDIT_AMOUNT"])); dr["Saldo"] = SaldoAwal; dt.AcceptChanges(); dtCopy.Rows.Add(dr["TRANS_NUMBER"], dr["TRANS_DATE"], dr["DESCRIPT"], dr["KA_CODE"], dr["KA_NAME"], dr["GT_CODE"], dr["DEBIT_AMOUNT"], dr["CREDIT_AMOUNT"], dr["IS_CLOSED"], dr["ISVERIFIED"], dr["IS_ACTIVE"], dr["CEK_BG_NUMBER"], dr["Saldo"]); } RSCM_BKU_web.Report.LaporanBKU report1 = new LaporanBKU(); OfficerCollection ofc = new OfficerCollection(); ofc.LoadAll(); foreach (Officer o in ofc) { if (o.Jabatan == "kaunit") { report1.ReportParameters[2].Value = o.NamaLengkap; report1.ReportParameters[4].Value = o.Nip; } else { report1.ReportParameters[3].Value = o.NamaLengkap; report1.ReportParameters[5].Value = o.Nip; } } CultureInfo ci = new CultureInfo("id-ID"); report1.ReportParameters[0].Value = dtfStartDate.SelectedDate.ToString("d",ci); report1.ReportParameters[1].Value = dtfEndDate.SelectedDate.ToString("d",ci); report1.ReportParameters[6].Value = SaldoAwal.ToString(); report1.ReportParameters[6].Value = string.Format("{0:N2}", SaldoAwal); report1.DataSource = dtCopy; ReportViewer1.Report = report1; ReportViewer1.RefreshReport(); ReportViewer1.RefreshReport(); } else return; }
protected void viewReport(object sender, DirectEventArgs e) { if (dtfStartDate.IsEmpty) dtfStartDate.SelectedDate = new DateTime(2010, 01, 01); if (dtfEndDate.IsEmpty) dtfEndDate.SelectedDate = DateTime.Now; if (dtfStartDate.SelectedDate > dtfEndDate.SelectedDate) return; //ini untuk saldo awal TransaksiBKUQuery transBkuQ = new TransaksiBKUQuery(); SaldoAwalCollection saCol = new SaldoAwalCollection(); saCol.LoadAll(); //hitung total kredit untuk semua transaksi sebelum tanggal awal TransCollection transtotalCreditCollection = new TransCollection(); transtotalCreditCollection.Query.Select(transtotalCreditCollection.Query.CreditAmount.Sum().Coalesce("0")); transtotalCreditCollection.Query.Where(transtotalCreditCollection.Query.TransDate < dtfStartDate.SelectedDate); transtotalCreditCollection.Query.Load(); decimal totalCredit = transtotalCreditCollection[0].CreditAmount.Value; //hitung total debit untuk semua transaksi sebelum tanggal awal TransCollection transtotalDebitCollection = new TransCollection(); transtotalDebitCollection.Query.Select(transtotalDebitCollection.Query.DebitAmount.Sum().Coalesce("0")); transtotalDebitCollection.Query.Where(transtotalDebitCollection.Query.TransDate < dtfStartDate.SelectedDate); transtotalDebitCollection.Query.Load(); decimal totalDebit = transtotalCreditCollection[0].DebitAmount.Value; transBkuQ.SelectAll(); transBkuQ.Where(transBkuQ.TransDate >= dtfStartDate.SelectedDate, transBkuQ.TransDate <= dtfEndDate.SelectedDate); //transBkuQ.OrderBy(("TransNumber")); transBkuQ.OrderBy(transBkuQ.TransNumber.Descending); TransaksiBKUCollection transBkuCol = new TransaksiBKUCollection(); transBkuCol.Load(transBkuQ); if (transBkuCol.Count > 0) { dt = transBkuQ.LoadDataTable(); dt.Columns.Add("Saldo", typeof(decimal)); DataTable dtCopy = dt.Clone(); foreach (RSCM_BKU_Web.BusinessObjects.SaldoAwal sa in saCol) { dt.Rows.Add("0", null, "Saldo Awal Total", "0", "SALDO AWAL", "0", "", 0, 0, false, false, true, sa.SaldoAwal + totalDebit - totalCredit); dtCopy.Rows.Add("0", null, "Saldo Awal Total", "0", "SALDO AWAL", "0", 0, 0, false, false, true, sa.SaldoAwal + totalDebit - totalCredit); SaldoAwal = Convert.ToDecimal((sa.SaldoAwal + totalDebit - totalCredit)); } foreach (DataColumn dc in dt.Columns) { titles += dc.ColumnName; this.Title = titles; } foreach (DataRow dr in dt.Rows) { SaldoAwal = SaldoAwal + (Convert.ToDecimal(dr["DEBIT_AMOUNT"]) - Convert.ToDecimal(dr["CREDIT_AMOUNT"])); dr["Saldo"] = SaldoAwal; dt.AcceptChanges(); dtCopy.Rows.Add(dr["TRANS_NUMBER"], dr["TRANS_DATE"], dr["DESCRIPT"], dr["KA_CODE"], dr["KA_NAME"], dr["GT_CODE"], dr["CEK_BG_NUMBER"], dr["DEBIT_AMOUNT"], dr["CREDIT_AMOUNT"], dr["IS_CLOSED"], dr["ISVERIFIED"], dr["IS_ACTIVE"], dr["Saldo"]); } RSCM_BKU_web.Report.LaporanBKU report1 = new LaporanBKU(); report1.ReportParameters[0].Value = dtfStartDate.SelectedDate; report1.ReportParameters[1].Value = dtfEndDate.SelectedDate; report1.DataSource = dtCopy; ReportViewer1.Report = report1; ReportViewer1.RefreshReport(); ReportViewer1.RefreshReport(); } else return; }