Exemplo n.º 1
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            if (_receipt != null)
            {
                string reportPath = @".\Reports\Receipt.rdlc";
                List <Model.ReceiptForPrinting> receipts = new ReceiptsLogic().GetReceiptForPrinting(_receipt);

                DeductImproveCostComfirmBox confirmBox = new DeductImproveCostComfirmBox();
                confirmBox.WindowStartupLocation = WindowStartupLocation.Manual;
                confirmBox.Top  = Mouse.GetPosition(null).Y - 200;
                confirmBox.Left = Mouse.GetPosition(null).X;
                if (confirmBox.ShowDialog() == false)
                {
                    reportPath = @".\Reports\ReceiptDeductImproveCost.rdlc";
                    foreach (var r in receipts)
                    {
                        r.GrandTotalText = ThaiBahtTextUtil.ThaiBahtText(Convert.ToDecimal(r.GrandTotal) - r.ImproveCost);
                    }
                }

                ReportPreviewer rp = new ReportPreviewer();
                rp.SetDataSet("ReceiptDataSet", receipts);
                rp.SetReportPath(reportPath);
                rp.ShowDialog();
            }
        }
Exemplo n.º 2
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool     deductImproveCost = false;
                int      reportMonth       = cbbMonth.SelectedIndex + 1;
                int      reportYear        = int.Parse(cbbYear.SelectedItem.ToString());
                DateTime fromDate          = new DateTime(reportYear - 543, reportMonth, 1);
                DateTime toDate            = fromDate.AddMonths(1).AddDays(-1);
                List <Model.ReceiptForPrinting> printReceipts = new List <Model.ReceiptForPrinting>();
                ReportPreviewer rp = new ReportPreviewer();

                string reportPath = @".\Reports\Receipt.rdlc";

                Receipt.DeductImproveCostComfirmBox confirmBox = new Receipt.DeductImproveCostComfirmBox();
                confirmBox.WindowStartupLocation = WindowStartupLocation.Manual;
                confirmBox.Top  = Mouse.GetPosition(null).Y;
                confirmBox.Left = Mouse.GetPosition(null).X;
                if (confirmBox.ShowDialog() == false)
                {
                    reportPath        = @".\Reports\ReceiptDeductImproveCost.rdlc";
                    deductImproveCost = true;
                }

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (o, ea) =>
                {
                    List <Model.Receipt> receipts = new ReceiptsLogic().GetReceipts(fromDate, toDate, Global.CurrentApartment.ApartmentId);
                    foreach (var r in receipts)
                    {
                        List <Model.ReceiptForPrinting> printedReceipt = new ReceiptsLogic().GetReceiptForPrinting(r);
                        if (deductImproveCost)
                        {
                            foreach (var pr in printedReceipt)
                            {
                                pr.GrandTotalText = ThaiBahtTextUtil.ThaiBahtText(Convert.ToDecimal(pr.GrandTotal) - pr.ImproveCost);
                            }
                        }
                        printReceipts.AddRange(printedReceipt);
                    }
                };

                worker.RunWorkerCompleted += (o, ea) =>
                {
                    rp.SetDataSet("ReceiptDataSet", printReceipts);
                    rp.SetReportPath(reportPath);
                    rp.ShowDialog();
                    loadingPanel.IsBusy = false;
                };

                loadingPanel.IsBusy = true;

                worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 3
0
 private void btnPrint_Click(object sender, RoutedEventArgs e)
 {
     if (_invoice != null)
     {
         ReportPreviewer rp = new ReportPreviewer();
         rp.SetDataSet("InvoiceDataSet", new InvoicesLogic().GetInvoiceForPrinting(_invoice));
         rp.SetReportPath(@".\Reports\Invoice.rdlc");
         rp.ShowDialog();
     }
 }
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string reportMonth   = cbbMonth.SelectedItem.ToString();
                string reportYear    = cbbYear.SelectedItem.ToString();
                int    reportMonthNo = cbbMonth.SelectedIndex + 1;
                int    reportYearNo  = int.Parse(reportYear) - 543;
                List <ReportParameter> parameters = new List <ReportParameter>();
                parameters.Add(new ReportParameter("ApartmentName", Global.CurrentApartment.ApartmentName));
                parameters.Add(new ReportParameter("ApartmentAddress", Global.CurrentApartment.Address));
                parameters.Add(new ReportParameter("ReportYear", reportYear));
                parameters.Add(new ReportParameter("ReportMonth", reportMonth));
                parameters.Add(cbDeductImproveCost.IsChecked == true ? new ReportParameter("DeductImproveCost", "True") : new ReportParameter("DeductImproveCost", "False"));
                ReportPreviewer rp = new ReportPreviewer();

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (o, ea) =>
                {
                    rp.SetDataSet("IncomeSummaryDataSet", new ReceiptsLogic().GetIncomeSummaryRecords(reportMonthNo, reportYearNo, Global.CurrentApartment.ApartmentId));
                };

                worker.RunWorkerCompleted += (o, ea) =>
                {
                    rp.SetReportPath(@".\Reports\IncomeSummary.rdlc");
                    rp.SetParameters(parameters);
                    rp.ShowDialog();
                    loadingPanel.IsBusy = false;
                };

                loadingPanel.IsBusy = true;

                worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 5
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int      reportMonth = cbbMonth.SelectedIndex + 1;
                int      reportYear  = int.Parse(cbbYear.SelectedItem.ToString());
                DateTime fromDate    = new DateTime(reportYear - 543, reportMonth, 1);
                DateTime toDate      = fromDate.AddMonths(1).AddDays(-1);
                List <Model.InvoiceForPrinting> printInvoices = new List <Model.InvoiceForPrinting>();
                ReportPreviewer rp = new ReportPreviewer();

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (o, ea) =>
                {
                    List <Model.Invoice> invoices = new InvoicesLogic().GetInvoices(fromDate, toDate, Global.CurrentApartment.ApartmentId);

                    foreach (var inv in invoices)
                    {
                        printInvoices.AddRange(new InvoicesLogic().GetInvoiceForPrinting(inv));
                    }
                };

                worker.RunWorkerCompleted += (o, ea) =>
                {
                    rp.SetDataSet("InvoiceDataSet", printInvoices);
                    rp.SetReportPath(@".\Reports\Invoice.rdlc");
                    rp.ShowDialog();
                    loadingPanel.IsBusy = false;
                };

                loadingPanel.IsBusy = true;

                worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 6
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string reportMonth = cbbMonth.SelectedItem.ToString();
                string reportYear  = cbbYear.SelectedItem.ToString();
                List <Model.IncomeReportRecord> reportDataSet = new List <Model.IncomeReportRecord>();
                DateTime        fromDate            = new DateTime(int.Parse(reportYear) - 543, cbbMonth.SelectedIndex + 1, 1);
                DateTime        toDate              = fromDate.AddMonths(1).AddDays(-1);
                bool            isDeductImproveCost = Convert.ToBoolean(cbDeductImproveCost.IsChecked);
                ReportPreviewer rp = new ReportPreviewer();

                List <ReportParameter> parameters = new List <ReportParameter>();
                parameters.Add(new ReportParameter("ReportYear", reportYear));
                parameters.Add(new ReportParameter("ReportMonth", reportMonth));

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (o, ea) =>
                {
                    List <Model.Invoice> invoices = new InvoicesLogic().GetInvoices(fromDate, toDate, Global.CurrentApartment.ApartmentId);
                    foreach (var invoice in invoices)
                    {
                        Decimal electricCost = invoice.EUsedUnit * invoice.EUnit;
                        Decimal waterCost    = invoice.WUsedUnit * invoice.WUnit;
                        Decimal total        = electricCost + waterCost + invoice.TelCost + invoice.Room.MonthCost + invoice.ImproveCost;

                        Model.IncomeReportRecord rec = new Model.IncomeReportRecord()
                        {
                            RoomNo        = invoice.Room.RoomNo,
                            ContactName   = invoice.Room.Customer.ContactName,
                            MonthName     = reportYear,
                            ElectricCost  = electricCost,
                            WaterCost     = waterCost,
                            TelephoneCost = invoice.TelCost,
                            MonthCost     = invoice.Room.MonthCost,
                            ImproveCost   = isDeductImproveCost ? 0 : invoice.ImproveCost,
                            Total         = isDeductImproveCost ? (total - invoice.ImproveCost) : total
                        };

                        reportDataSet.Add(rec);
                    }
                    rp.SetDataSet("IncomeReportDataSet", reportDataSet);
                };

                worker.RunWorkerCompleted += (o, ea) =>
                {
                    rp.SetReportPath(@".\Reports\IncomeReport.rdlc");
                    rp.SetParameters(parameters);
                    rp.ShowDialog();
                    loadingPanel.IsBusy = false;
                };

                loadingPanel.IsBusy = true;

                worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }