Exemplo n.º 1
0
        private void PrintDealerSummary(ReportViewer rptViewer)
        {
            DateTime   ldRunDate;
            String     lsRunDate  = "";
            IACDataSet ReportData = new IACDataSet();

            IACDataSetTableAdapters.ClosedDealerSummaryTableAdapter ClosedDealerSummaryTableAdapter = new IACDataSetTableAdapters.ClosedDealerSummaryTableAdapter();


            lsRunDate = comboBoxRunMonth.SelectedValue.ToString() + "/31/" + textBoxRunYear.Text;
            DateTime.TryParse(lsRunDate, out ldRunDate);
            if (ldRunDate == DateTime.MinValue)
            {
                lsRunDate = comboBoxRunMonth.SelectedValue.ToString() + "/30/" + textBoxRunYear.Text;
                DateTime.TryParse(lsRunDate, out ldRunDate);
                if (ldRunDate == DateTime.MinValue)
                {
                    lsRunDate = comboBoxRunMonth.SelectedValue.ToString() + "/28/" + textBoxRunYear.Text;
                    DateTime.TryParse(lsRunDate, out ldRunDate);
                    if (ldRunDate == DateTime.MinValue)
                    {
                        lsRunDate = comboBoxRunMonth.SelectedValue.ToString() + "/27/" + textBoxRunYear.Text;   // Must be a leap year with February run date
                        DateTime.TryParse(lsRunDate, out ldRunDate);
                    }
                }
            }

            ClosedDealerSummaryTableAdapter.Fill(ReportData.ClosedDealerSummary, ldRunDate.Month, ldRunDate.Year);

            if (ReportData.ClosedDealerSummary.Rows.Count == 0)
            {
                MessageBox.Show("*** Sorry there are no DEALHIST records for the RUN MONTH AND YEAR you entered!!! ***");
            }
            else
            {
                ClosedDealerSummary myReportObject = new ClosedDealerSummary();
                myReportObject.SetDataSource(ReportData);
                myReportObject.SetParameterValue("gdCutOffDate", ldRunDate);
                myReportObject.SetParameterValue("gsUserID", Program.gsUserID);
                myReportObject.SetParameterValue("gsUserName", Program.gsUserName);
                rptViewer.crystalReportViewer.ReportSource = myReportObject;
                rptViewer.crystalReportViewer.Refresh();
                rptViewer.Show();
            }
        }
Exemplo n.º 2
0
        private void buttonExcel_Click(object sender, EventArgs e)
        {
            SQLBackupandRestore SQLBR = new SQLBackupandRestore();
            TrialBalancePretty  TBP   = new TrialBalancePretty();

            String lsDealerNum = comboBoxDealer.Text.TrimEnd().TrimStart() + "%", lsState;

            lsState = (comboBoxState.SelectedValue != null) ? comboBoxState.SelectedValue.ToString().TrimStart().TrimEnd() + "%" : "%";

            IACDataSetTableAdapters.CUSTOMERTableAdapter                CUSTOMERTableAdapter                = new IACDataSetTableAdapters.CUSTOMERTableAdapter();
            IACDataSetTableAdapters.ClosedDealerSummaryTableAdapter     ClosedDealerSummaryTableAdapter     = new IACDataSetTableAdapters.ClosedDealerSummaryTableAdapter();
            IACDataSetTableAdapters.WS_DEALER_TRIAL_BALANCETableAdapter WS_DEALER_TRIAL_BALANCETableAdapter = new IACDataSetTableAdapters.WS_DEALER_TRIAL_BALANCETableAdapter();
            // Moses Newman 05/3/2014 Get rid of SQL Pass Through!
            CUSTOMERTableAdapter.FillByStateDealer(iACDataSet.CUSTOMER, lsState, lsDealerNum);
            ClosedDealerSummaryTableAdapter.Fill(iACDataSet.ClosedDealerSummary, DateTime.Now.Month, DateTime.Now.Year);
            WS_DEALER_TRIAL_BALANCETableAdapter.FillByStateDealer(iACDataSet.WS_DEALER_TRIAL_BALANCE, lsState, lsDealerNum);
            Int32 elapsed = 0;

            if (SQLBR.RunJob("TrialBalance", "Export Trial Balance To EXCEL", false))
            {
                TBP.IACType            = "C";
                TBP.CustDealerCount    = iACDataSet.CUSTOMER.Rows.Count;
                TBP.DealerCount        = iACDataSet.WS_DEALER_TRIAL_BALANCE.Rows.Count;
                TBP.DealerSummaryCount = iACDataSet.ClosedDealerSummary.Rows.Count;
                TBP.FullSourcePath     = @"\\Dc-iac\public\AccStuff\mfdata\comp1000\ClosedTrialBalance.xlsx";
                Thread.Sleep(5000);
                var fi1 = new FileInfo(TBP.FullSourcePath);

                while (TBP.IsFileLocked(fi1) && elapsed < 500000)
                {
                    Thread.Sleep(1000);
                    elapsed += 1000;
                }
                TBP.TBPRetty();
            }
        }