private void btnBasicInventoryReport_Click(object sender, EventArgs e)
        {
            ReportViewerForm form = new ReportViewerForm();

            form.rptviewer.LocalReport.ReportPath = "BasicInventory.rdlc";
            form.SetInventoryReportDataSource();
            form.rptviewer.Show();
            form.Show();
            form.rptviewer.RefreshReport();
            form.rptviewer.LocalReport.Refresh();
        }
Exemple #2
0
        private void btnPrintReport_Click(object sender, EventArgs e)
        {
            using (DealershipManagerEntities context = new DealershipManagerEntities())
            {
                try
                {
                    context.ExecuteStoreCommand("DELETE FROM tmpCalculation");
                }
                catch
                {
                }
                finally
                {
                    context.SaveChanges();
                }

                int id = 0;
                foreach (DataGridViewRow row in dgvLeaseInfo.Rows)
                {
                    try
                    {
                        TmpCalculation tmp = new TmpCalculation();

                        tmp.id = id;
                        id++;
                        Double balance = 0;
                        Double.TryParse(row.Cells["Balance"].Value.ToString().Replace("$", ""), out balance);
                        tmp.Balance = balance;

                        double cost = 0;
                        Double.TryParse(txtCapitalizedCost.Text, out cost);
                        tmp.Cost = cost;

                        Double gst = 0;
                        Double.TryParse(row.Cells["GST"].Value.ToString().Replace("$", ""), out gst);
                        tmp.GST = gst;

                        Double interest = 0;
                        Double.TryParse(row.Cells["Interest"].Value.ToString().Replace("$", ""), out interest);
                        tmp.Interest = interest;

                        Double interestrate = 0;
                        Double.TryParse(txtInterestRate.Text, out interestrate);
                        tmp.InterestRate = interestrate;

                        int numberofmonths = 0;
                        int.TryParse(txtNumberOfMonths.Text, out numberofmonths);
                        tmp.Months = numberofmonths;

                        Double paymentAmount = 0;
                        Double.TryParse(row.Cells["Payment"].Value.ToString().Replace("$", ""), out paymentAmount);
                        tmp.PaymentAmount = paymentAmount;

                        int paymentno = 0;
                        int.TryParse(row.Cells["Payment No."].Value.ToString().Replace("$", ""), out paymentno);
                        tmp.PmtNo = paymentno;

                        Double principle = 0;
                        Double.TryParse(row.Cells["Principle"].Value.ToString().Replace("$", ""), out principle);
                        tmp.Principle = principle;

                        context.TmpCalculations.AddObject(tmp);
                    }
                    catch (Exception ex)
                    {
                        string test = ex.Message;
                    }
                    finally
                    {
                        context.SaveChanges();
                    }
                }
            }

            ReportViewerForm form = new ReportViewerForm();

            form.rptviewer.LocalReport.ReportPath = "TempCalculationReport.rdlc";
            form.SetTempCalcReportDataSource();
            form.rptviewer.Show();
            form.Show();
            form.rptviewer.RefreshReport();
            form.rptviewer.LocalReport.Refresh();


            //ReportViewerForm rptv = new ReportViewerForm();
            //rptv.MdiParent = this.MdiParent;
            //rptv.Show();
            //rptv.rptviewer.LocalReport.Refresh();
            //rptv.rptviewer.Refresh();
            //rptv.rptviewer.RefreshReport();
            //rptv.rptviewer.Visible = true;
        }
        private void btnCustomerCompleteFinanceReport_Click(object sender, EventArgs e)
        {
            using (DealershipManagerEntities context = new DealershipManagerEntities())
            {
                IQueryable <Customer> customerQuery = (from customer in context.Customers
                                                       join sale in context.Sales on customer.Id equals sale.CustomerId
                                                       where customer.BandName != "" && sale.current == true
                                                       orderby customer.LastName, customer.FirstName
                                                       select customer).Distinct().OrderBy(x => x.LastName).ThenBy(y => y.FirstName);



                List <FinanceReportRow> rows      = new List <FinanceReportRow>();
                List <Customer>         customers = customerQuery.ToList();
                foreach (Customer c in customerQuery)
                {
                    FinanceReportRow frr = new FinanceReportRow();
                    frr.First_Name = c.FirstName;
                    frr.Last_Name  = c.LastName;
                    frr.Notes      = "";

                    Finance financeQuery = (from finance in context.Finances
                                            join sale in context.Sales on finance.saleId equals sale.id
                                            join customer in customerQuery on sale.CustomerId equals customer.Id
                                            where sale.CurrentBalance > 0 && sale.current == true && customer.Id == c.Id
                                            orderby finance.DatePaid descending
                                            select finance).FirstOrDefault();
                    if (financeQuery != null)
                    {
                        frr.Current_Balance = financeQuery.Balance ?? 0;
                        frr.Payment_Due     = financeQuery.Payment ?? 0;
                        rows.Add(frr);
                    }
                }

                ReportViewerForm form = new ReportViewerForm();
                form.rptviewer.LocalReport.ReportPath           = "CompleteFinanceReport.rdlc";
                form.rptviewer.LocalReport.DataSources[0].Value = rows;
                form.rptviewer.LocalReport.DataSources[0].Name  = "FinanceRows";
                form.rptviewer.Show();
                form.Show();
                form.rptviewer.RefreshReport();
                form.rptviewer.LocalReport.Refresh();

                //dgvReport.Columns.Add("Last_Name", "Last Name");
                //dgvReport.Columns["Last_Name"].DataPropertyName = "Last_Name";
                //dgvReport.Columns.Add("First_Name", "First Name");
                //dgvReport.Columns["First_Name"].DataPropertyName = "First_Name";
                //dgvReport.Columns.Add("Current_Balance", "Current Balance");
                //dgvReport.Columns["Current_Balance"].DataPropertyName = "Current_Balance";
                //dgvReport.Columns["Current_Balance"].DefaultCellStyle.Format = "C";
                //dgvReport.Columns.Add("Payment_Due", "Payment Due");
                //dgvReport.Columns["Payment_Due"].DataPropertyName = "Payment_Due";
                //dgvReport.Columns["Payment_Due"].DefaultCellStyle.Format = "C";
                //dgvReport.Columns.Add("Notes", "Notes");
                //dgvReport.Columns["Notes"].DataPropertyName = "Notes";

                //// Initialize the DataGridView.
                //dgvReport.AutoGenerateColumns = false;
                //dgvReport.AutoSize = true;

                //dgvReport.DataSource = rows;
                //dgvReport.Refresh();

                //PrintPreviewDialog objPPdialog = new PrintPreviewDialog();

                //printDocument1.DocumentName = "Payment Information";
                //objPPdialog.Document = printDocument1;
                //objPPdialog.ShowDialog();
            }
        }