private void FormReportExporter_Load(object sender, EventArgs e)
        {
            //PasswordForm frm = new PasswordForm();
            //if (frm.ShowDialog() != DialogResult.OK)
            //{
            //    // The user canceled.
            //    this.Close();
            //}

            btnExportPDF.Enabled   = false;
            btnexportEXCEL.Enabled = false;
            btnexportEXCEL.Click  += btnexportEXCEL_Click;
            btnExportPDF.Click    += btnExportPDF_Click;
            exp_Factory            = new ExporterFactory(true);

            if (exp_Factory.BisLocked)
            {
                this.Text          = exp_Factory.ProgTittle;
                txtReportName.Text = exp_Factory.ReportName;

                comboBoxDBs.Items.Add(exp_Factory.GetCatalog());
                foreach (var item in exp_Factory.GetSpName())
                {
                    comboBoxSPs.Items.Add(item);
                }

                comboBoxDBs.SelectedIndex = 0;
                comboBoxSPs.SelectedIndex = 0;
                comboBoxDBs.Enabled       = false;
                comboBoxSPs.Enabled       = true;
                comboBoxDBs.Visible       = false;
                comboBoxSPs.Visible       = true;
                labelSPs.Visible          = true;
                labelDBNames.Visible      = false;
            }
            else
            {
                comboBoxDBs.DataSource = GetDBNames();
            }

            //exp_Factory.setDate(DateTime.Now.AddDays(-1), DateTime.Now);
            //DataTable dt = exp_Factory.GetData();
            //dataGridView.DataSource = dt;
            //string fileName = exp_Factory.ExportToPDF(dt);
            //exp_Factory.SendEmail(fileName);
            // Display the password form.
        }
Exemple #2
0
        private static void Main(string[] args)
        {
            // MessageBox.Show(args[0]);
            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FormReportExporter());
            }
            else if (args[0].ToLower().Equals("day"))
            {
                //MessageBox.Show("This was Day");
                //This takes the current day and send it as an argunment to the SQL stored procedure
                ExporterFactory exp_Factory = new ExporterFactory(false);
                exp_Factory.setDate(DateTime.Now.AddDays(-1).Date, DateTime.Now.AddDays(-1).Date);
                DataTable dt = exp_Factory.GetData();
                exp_Factory.periodeName = "Day";
                string fileName = exp_Factory.ExportToPDF(dt);
                exp_Factory.SendEmail(fileName);
            }
            else if (args[0].ToLower().Equals("week"))
            {
                //This takes the current day and send it as an argunment to the SQL stored procedure
                ExporterFactory exp_Factory = new ExporterFactory(false);
                exp_Factory.setDate(DateTime.Now.AddDays(-8).Date, DateTime.Now.AddDays(-1).Date);

                DataTable dt = exp_Factory.GetData();
                exp_Factory.periodeName = "Week";
                string fileName = exp_Factory.ExportToPDF(dt);
                exp_Factory.SendEmail(fileName);
            }
            else if ((args[0].ToLower().Equals("month")))
            {
                ExporterFactory exp_Factory = new ExporterFactory(false);
                exp_Factory.setDate(DateTime.Now.AddMonths(-1).Date, DateTime.Now.AddDays(-1).Date);

                DataTable dt = exp_Factory.GetData();
                exp_Factory.periodeName = "Month";
                string fileName = exp_Factory.ExportToPDF(dt);
                exp_Factory.SendEmail(fileName);
            }
        }