private void CashTransaction(int counterNo) { List<Sale> sales = new List<Sale>(); decimal GiftVoucherTotal = 0; decimal CashTotal = 0; decimal Total = 0; int TotalQuantity = 0; sales = SaleService.GetSalesByCounterNumber(counterNo); foreach (var sale in sales) { GiftVoucherTotal += (decimal)sale.GiftVoucherAmount; CashTotal += (decimal)sale.CashAmount; Total += (decimal)sale.SaleTotal; TotalQuantity += (int)sale.SaleTotalQuantity; } frmReports ReportForm = new frmReports(); ReportDataSource rdsSales = new ReportDataSource("Sales", sales); ReportParameter rpGiftVoucherTotal = new ReportParameter(); if(GiftVoucherTotal > 0) rpGiftVoucherTotal = new ReportParameter("GiftVoucherTotal", GiftVoucherTotal.ToString("#,##")); else rpGiftVoucherTotal = new ReportParameter("GiftVoucherTotal", "0.00"); ReportParameter rpCashTotal = new ReportParameter("CashTotal", CashTotal.ToString("#,##")); ReportParameter rpTotal = new ReportParameter("Total", Total.ToString("#,##")); ReportParameter rpTotalQuantity = new ReportParameter("TotalQuantity", TotalQuantity.ToString("#,##")); ReportForm.rptViewer.RefreshReport(); ReportForm.rptViewer.Reset(); ReportForm.rptViewer.ProcessingMode = ProcessingMode.Local; ReportForm.rptViewer.LocalReport.ReportPath = "Reports\\rptCashTransaction.rdlc"; ReportForm.rptViewer.LocalReport.DataSources.Clear(); ReportForm.rptViewer.LocalReport.DataSources.Add(rdsSales); ReportForm.rptViewer.LocalReport.SetParameters(new ReportParameter[] { rpGiftVoucherTotal }); ReportForm.rptViewer.LocalReport.SetParameters(new ReportParameter[] { rpCashTotal }); ReportForm.rptViewer.LocalReport.SetParameters(new ReportParameter[] { rpTotal }); ReportForm.rptViewer.LocalReport.SetParameters(new ReportParameter[] { rpTotalQuantity }); ReportForm.rptViewer.LocalReport.Refresh(); ReportForm.rptViewer.RefreshReport(); ReportForm.ShowDialog(); this.Close(); }
private void SaleProduct(int counterNo) { List<SaleProductSupport> saleProductSupports = new List<SaleProductSupport>(); int totalQuantity = 0; decimal totalCost = 0; saleProductSupports = SaleService.GetSaleProductListSupportByCounter(counterNo); foreach (var saleProductSupport in saleProductSupports) { totalQuantity += saleProductSupport.Quantity; totalCost += saleProductSupport.TotalCost; } ReportParameter CounterID = new ReportParameter("CounterNo", counterNo.ToString()); ReportParameter TotalQuantity = new ReportParameter("TotalQuantity", totalQuantity.ToString()); ReportParameter TotalCost = new ReportParameter("TotalCost", totalCost.ToString()); frmReports ReportForm = new frmReports(); ReportDataSource rdsSales = new ReportDataSource("SaleProductSupport", saleProductSupports); ReportForm.rptViewer.RefreshReport(); ReportForm.rptViewer.Reset(); ReportForm.rptViewer.ProcessingMode = ProcessingMode.Local; ReportForm.rptViewer.LocalReport.ReportPath = "Reports\\rptSaleProductReport.rdlc"; ReportForm.rptViewer.LocalReport.DataSources.Clear(); ReportForm.rptViewer.LocalReport.SetParameters(new ReportParameter[] { CounterID }); ReportForm.rptViewer.LocalReport.SetParameters(new ReportParameter[] { TotalQuantity }); ReportForm.rptViewer.LocalReport.SetParameters(new ReportParameter[] { TotalCost }); ReportForm.rptViewer.LocalReport.DataSources.Add(rdsSales); ReportForm.rptViewer.LocalReport.Refresh(); ReportForm.rptViewer.RefreshReport(); ReportForm.ShowDialog(); this.Close(); }