private void ControlReportLicenseGenerate_Load(object sender, EventArgs e)
        {
            lblHeading.Text             = Properties.Resources.REPORT_LICENSE_GENERATE;
            cboReportName.SelectedIndex = 0;
            try
            {
                using (TBL_SEASON_DATA_ACCESS sda = new TBL_SEASON_DATA_ACCESS())
                {
                    cboSeason.DataSource    = sda.ShowAllSeasonToComboBox();
                    cboSeason.DisplayMember = "SEASON_NAME";
                    cboSeason.ValueMember   = "SEASON_ID";
                }
                using (TBL_COMPANY_DATA_ACCESS cda = new TBL_COMPANY_DATA_ACCESS())
                {
                    var company = cda.ShowCompany();
                    foreach (var item in company)
                    {
                        COMPANY_NAME    = item.COMPANY_NAME;
                        COMPANY_ADDRESS = item.COMPANY_ADDRESS;
                    }
                }
                printer = new PrinterSettings();

                crxApp    = new CRAXDDRT.Application();
                crxReport = new CRAXDDRT.Report();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void ControlReport_Load(object sender, EventArgs e)
        {
            lblHeading.Text = Properties.Resources.REPORT_LICENSE_ACOUNT;
            using (TBL_COMPANY_DATA_ACCESS cda = new TBL_COMPANY_DATA_ACCESS())
            {
                var company = cda.ShowCompany();
                foreach (var item in company)
                {
                    COMPANY_NAME    = item.COMPANY_NAME;
                    COMPANY_ADDRESS = item.COMPANY_ADDRESS;
                }
            }
            try
            {
                printer = new PrinterSettings();

                crxApp    = new CRAXDDRT.Application();
                crxReport = new CRAXDDRT.Report();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                GC.Collect();
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime dt = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyy-MM" + "-01"));

            PrinterSettings printer   = new PrinterSettings();
            string          file_path = Application.StartupPath + @"\Report\ReportREFInvalidCustomer.rpt";

            CRAXDDRT.Application crxApp    = new CRAXDDRT.Application();
            CRAXDDRT.Report      crxReport = new CRAXDDRT.Report();
            crxReport = crxApp.OpenReport(file_path, null);
            foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
            {
                crxdt.SetLogOnInfo(@".\SQLEXPRESS", "EPower", "sa", "underadmin");
            }
            crxReport.SelectPrinter("", printer.PrinterName, "");
            crxReport.ParameterFields.GetItemByName("@COMPANY_NAME", Missing.Value).AddCurrentValue("អ៊ី-ផៅវើ E-Power");
            crxReport.ParameterFields.GetItemByName("@COMPANY_ADDRESS", Missing.Value).AddCurrentValue("ផ្ទះលេខ១៨ ផ្លូវលេខ ៦១៨​​ ខណ្ឌទួលគោក រាជធានីភ្នំពេញ");
            crxReport.ParameterFields.GetItemByName("@LOGIN_NAME", Missing.Value).AddCurrentValue("admin");
            crxReport.ParameterFields.GetItemByName("@DATA_MONTH", Missing.Value).AddCurrentValue(dt);
            crxReport.ParameterFields.GetItemByName("@CUSTOMER_GROUP_NAME", Missing.Value).AddCurrentValue(cboCustomerType.Text);
            crxReport.ParameterFields.GetItemByName("@CUSTOMER_CONNECTION_TYPE_NAME", Missing.Value).AddCurrentValue(cboConnectionType.Text);
            crxReport.ParameterFields.GetItemByName("@FILTER_POWER", Missing.Value).AddCurrentValue(cboPowerType.Text);
            crxReport.ParameterFields.GetItemByName("@CURRENCY_NAME", Missing.Value).AddCurrentValue(cboCurrency.Text);

            crxReport.ParameterFields.GetItemByName("@CUSTOMER_GROUP_ID", Missing.Value).AddCurrentValue(Convert.ToInt32(cboCustomerType.SelectedValue));
            crxReport.ParameterFields.GetItemByName("@CUSTOMER_CONNECTION_TYPE_ID", Missing.Value).AddCurrentValue(Convert.ToInt32(cboConnectionType.SelectedValue));
            crxReport.ParameterFields.GetItemByName("@CURRENCY_ID", Missing.Value).AddCurrentValue(Convert.ToInt32(cboCurrency.SelectedValue));
            if (cboPowerType.SelectedIndex == 0)
            {
                crxReport.ParameterFields.GetItemByName("@V1", Missing.Value).AddCurrentValue(0);
                crxReport.ParameterFields.GetItemByName("@V2", Missing.Value).AddCurrentValue(1000000);
            }
            else if (cboPowerType.SelectedIndex == 1)
            {
                //  MessageBox.Show("");
                crxReport.ParameterFields.GetItemByName("@V1", Missing.Value).AddCurrentValue(0);
                crxReport.ParameterFields.GetItemByName("@V2", Missing.Value).AddCurrentValue(10);
            }
            else if (cboPowerType.SelectedIndex == 2)
            {
                crxReport.ParameterFields.GetItemByName("@V1", Missing.Value).AddCurrentValue(1);
                crxReport.ParameterFields.GetItemByName("@V2", Missing.Value).AddCurrentValue(10);
            }
            else if (cboPowerType.SelectedIndex == 3)
            {
                crxReport.ParameterFields.GetItemByName("@V1", Missing.Value).AddCurrentValue(10);
                crxReport.ParameterFields.GetItemByName("@V2", Missing.Value).AddCurrentValue(1000000);
            }
            crxReport.PaperOrientation = CRAXDDRT.CRPaperOrientation.crPortrait;
            crxReport.PaperSize        = CRAXDDRT.CRPaperSize.crPaperA4;
            axCrystalActiveXReportViewer1.ReportSource = crxReport;
            axCrystalActiveXReportViewer1.ViewReport();
        }
Exemplo n.º 4
0
        public ViewReport(string titleReport, string rptFile, string querySql, string[] paramName, object[] paramValues, bool staticPrinter)
        {
            InitializeComponent();
            this.Text = titleReport;
            CRAXDDRT.Application crxApp = new CRAXDDRT.Application();
            CRAXDDRT.Report      report = new CRAXDDRT.Report();
            ADODB.Connection     conn   = new ADODB.Connection();
            ADODB.Recordset      rs     = new ADODB.Recordset();
            rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
            string connstr    = "Provider=SQLOLEDB;Data Source=" + SqlHelper.IPAddress + ";Initial Catalog=" + SqlHelper.DatabaseName + ";User Id=" + SqlHelper.UserID + ";Password="******";";
            string reportFile = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())) + "/Report/" + rptFile;

            try
            {
                conn.Open(connstr, null, null, 0);
                report = crxApp.OpenReport(reportFile, OpenReportMethod.OpenReportByDefault);
                report.DiscardSavedData();
                if (paramName != null)
                {
                    for (int i = 0; i < paramName.Length; i++)
                    {
                        report.ParameterFields.GetItemByName(paramName[i], null).AddCurrentValue(paramValues[i]);
                    }
                }
                rs.Open(
                    querySql,
                    // SQL statement / table,view name /
                    // stored procedure call / file name
                    conn,                                               // Connection / connection string
                    ADODB.CursorTypeEnum.adOpenForwardOnly,             // Cursor type. (forward-only cursor)
                    ADODB.LockTypeEnum.adLockOptimistic,                // Lock type. (locking records only
                    // when you call the Update method.
                    (int)ADODB.CommandTypeEnum.adCmdText);

                /* For Execute StoreProcedure */
                //    rs.Open(querySql, conn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                report.Database.SetDataSource(rs, 3, 1);
                if (staticPrinter)
                {
                    string printerName = Configurations.getPrinter();
                    report.SelectPrinter("", printerName, "");
                    //report.PrintOut(false, 1, true, 1, 200);
                }
                this.axCrystalActiveXReportViewer1.ReportSource = report;
                this.axCrystalActiveXReportViewer1.ViewReport();
            }
            catch (Exception ex)
            {
                //this.Dispose();
                //this.Close();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        public ViewReport
        (
            string titleReport,
            string rptFile,
            string procedureName,
            string procedureParam,
            string[] rptParamName,
            object[] rptParamValues,
            bool staticPrinter

        )
        {
            InitializeComponent();
            this.Text = titleReport;
            CRAXDDRT.Application crxApp = new CRAXDDRT.Application();
            CRAXDDRT.Report      report = new CRAXDDRT.Report();
            ADODB.Connection     conn   = new ADODB.Connection();

            ADODB.Recordset rs = new ADODB.Recordset();
            rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
            string connstr    = "Provider=SQLOLEDB;Data Source=" + SqlHelper.IPAddress + ";Initial Catalog=" + SqlHelper.DatabaseName + ";User Id=" + SqlHelper.UserID + ";Password="******";";
            string reportFile = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())) + "/Report/" + rptFile;

            try
            {
                conn.Open(connstr, null, null, 0);
                report = crxApp.OpenReport(reportFile, OpenReportMethod.OpenReportByDefault);
                report.DiscardSavedData();
                if (rptParamName != null)
                {
                    for (int i = 0; i < rptParamName.Length; i++)
                    {
                        report.ParameterFields.GetItemByName(rptParamName[i], null).AddCurrentValue(rptParamValues[i]);
                    }
                }

                rs.Open(procedureName, conn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);
                report.Database.SetDataSource(rs, 3, 1);
                if (staticPrinter)
                {
                    string printerName = Configurations.getPrinter();
                    report.SelectPrinter("", printerName, "");
                    //report.PrintOut(false, 1, true, 1, 200);
                }
                this.axCrystalActiveXReportViewer1.ReportSource = report;
                this.axCrystalActiveXReportViewer1.ViewReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void OpenReport()
        {
            PrinterSettings printer   = new PrinterSettings();
            string          file_path = Application.StartupPath + @"\Report\ReportLicenseAccount.rpt";

            CRAXDDRT.Application crxApp    = new CRAXDDRT.Application();
            CRAXDDRT.Report      crxReport = new CRAXDDRT.Report();
            crxReport = crxApp.OpenReport(file_path, null);
            foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
            {
                crxdt.SetLogOnInfo(@".", "EPOWERLICENSE", "sa", "underadmin");
            }
            crxReport.SelectPrinter("", printer.PrinterName, "");
            crxReport.ParameterFields.GetItemByName("COMPANY_NAME", Missing.Value).AddCurrentValue("អ៊ី-ផៅវើ E-Power");
            crxReport.ParameterFields.GetItemByName("COMPANY_ADDRESS", Missing.Value).AddCurrentValue("ផ្ទះលេខ១៨ ផ្លូវលេខ ៦១៨​​ ខណ្ឌទួលគោក រាជធានីភ្នំពេញ");
        }
Exemplo n.º 7
0
 private void btnLook_Click(object sender, EventArgs e)
 {
     try
     {
         string rpt_path = Application.StartupPath + @"\Report\ReportLicenseAvailable.rpt";
         crxReport = crxApp.OpenReport(rpt_path, null);
         foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
         {
             crxdt.SetLogOnInfo(Properties.Resources.INSTANCE_NAME, "EPOWERLICENSE", "sa", "underadmin");
         }
         crxReport.SelectPrinter("", printer.PrinterName, "");
         crxReport.ParameterFields.GetItemByName("@COMPANY_NAME", Missing.Value).AddCurrentValue(COMPANY_NAME);
         crxReport.ParameterFields.GetItemByName("@COMPANY_ADDRESS", Missing.Value).AddCurrentValue(COMPANY_ADDRESS);
         crxReport.ParameterFields.GetItemByName("@SEASON_ID", Missing.Value).AddCurrentValue(Convert.ToInt32(cboSeason.SelectedValue));
         crxReport.ParameterFields.GetItemByName("@SEASON_NAME", Missing.Value).AddCurrentValue(cboSeason.GetItemText(cboSeason.SelectedItem));
         axCrystalActiveXReportViewer1.ReportSource = crxReport;
         axCrystalActiveXReportViewer1.ViewReport();
         axCrystalActiveXReportViewer1.Zoom(100);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 private void btnLook_Click(object sender, EventArgs e)
 {
     try
     {
         string rpt_path = Application.StartupPath + @"\Report\ReportLicenseAccount.rpt";
         crxReport = crxApp.OpenReport(rpt_path, null);
         foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
         {
             crxdt.SetLogOnInfo(Properties.Resources.INSTANCE_NAME, "EPOWERLICENSE", "sa", "underadmin");
         }
         crxReport.SelectPrinter("", printer.PrinterName, "");
         crxReport.ParameterFields.GetItemByName("@COMPANY_NAME", Missing.Value).AddCurrentValue(COMPANY_NAME);
         crxReport.ParameterFields.GetItemByName("@COMPANY_ADDRESS", Missing.Value).AddCurrentValue(COMPANY_ADDRESS);
         crxReport.PaperOrientation = CRAXDDRT.CRPaperOrientation.crLandscape;
         axCrystalActiveXReportViewer1.Zoom(100);
         axCrystalActiveXReportViewer1.ReportSource = crxReport;
         axCrystalActiveXReportViewer1.ViewReport();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
     GC.Collect();
 }
        private void btnLook_Click(object sender, EventArgs e)
        {
            if (cboReportName.SelectedIndex == 0)
            {
                try
                {
                    DateTime dt       = Convert.ToDateTime(dateTimePicker.Value.ToString("yyy-MM-dd"));
                    string   rpt_path = Application.StartupPath + @"\Report\ReportLicenseGenerateDaily.rpt";
                    crxReport = crxApp.OpenReport(rpt_path, null);
                    foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
                    {
                        crxdt.SetLogOnInfo(Properties.Resources.INSTANCE_NAME, "EPOWERLICENSE", "sa", "underadmin");
                    }
                    crxReport.SelectPrinter("", printer.PrinterName, "");
                    crxReport.ParameterFields.GetItemByName("@COMPANY_NAME", Missing.Value).AddCurrentValue(COMPANY_NAME);
                    crxReport.ParameterFields.GetItemByName("@COMPANY_ADDRESS", Missing.Value).AddCurrentValue(COMPANY_ADDRESS);
                    crxReport.ParameterFields.GetItemByName("@SEASON_NAME", Missing.Value).AddCurrentValue(cboSeason.GetItemText(cboSeason.SelectedItem));
                    crxReport.ParameterFields.GetItemByName("@SEASON_ID", Missing.Value).AddCurrentValue(Convert.ToInt32(cboSeason.SelectedValue));
                    crxReport.ParameterFields.GetItemByName("@DATE", Missing.Value).AddCurrentValue(dt);
                    crxReport.PaperSize        = CRAXDDRT.CRPaperSize.crPaperA4;
                    crxReport.PaperOrientation = CRAXDDRT.CRPaperOrientation.crLandscape;
                    axCrystalActiveXReportViewer1.ReportSource = crxReport;
                    axCrystalActiveXReportViewer1.ViewReport();
                    axCrystalActiveXReportViewer1.Zoom(100);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            else if (cboReportName.SelectedIndex == 1)
            {
                try
                {
                    string rpt_path = Application.StartupPath + @"\Report\ReportLicenseGenerateMonthly.rpt";
                    crxReport = crxApp.OpenReport(rpt_path, null);
                    foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
                    {
                        crxdt.SetLogOnInfo(Properties.Resources.INSTANCE_NAME, "EPOWERLICENSE", "sa", "underadmin");
                    }
                    crxReport.SelectPrinter("", printer.PrinterName, "");
                    crxReport.ParameterFields.GetItemByName("@COMPANY_NAME", Missing.Value).AddCurrentValue(COMPANY_NAME);
                    crxReport.ParameterFields.GetItemByName("@COMPANY_ADDRESS", Missing.Value).AddCurrentValue(COMPANY_ADDRESS);
                    crxReport.ParameterFields.GetItemByName("@SEASON_NAME", Missing.Value).AddCurrentValue(cboSeason.GetItemText(cboSeason.SelectedItem));
                    crxReport.ParameterFields.GetItemByName("@SEASON_ID", Missing.Value).AddCurrentValue(Convert.ToInt32(cboSeason.SelectedValue));

                    crxReport.ParameterFields.GetItemByName("@MONTH", Missing.Value).AddCurrentValue(dateTimePicker.Value.Month);
                    crxReport.ParameterFields.GetItemByName("@YEAR", Missing.Value).AddCurrentValue(dateTimePicker.Value.Year);
                    crxReport.PaperSize        = CRAXDDRT.CRPaperSize.crPaperA4;
                    crxReport.PaperOrientation = CRAXDDRT.CRPaperOrientation.crLandscape;
                    axCrystalActiveXReportViewer1.ReportSource = crxReport;
                    axCrystalActiveXReportViewer1.ViewReport();
                    axCrystalActiveXReportViewer1.Zoom(100);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            else if (cboReportName.SelectedIndex == 2)
            {
                try
                {
                    string rpt_path = Application.StartupPath + @"\Report\ReportLicenseGenerateYearly.rpt";
                    crxReport = crxApp.OpenReport(rpt_path, null);
                    foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
                    {
                        crxdt.SetLogOnInfo(Properties.Resources.INSTANCE_NAME, "EPOWERLICENSE", "sa", "underadmin");
                    }
                    crxReport.SelectPrinter("", printer.PrinterName, "");
                    crxReport.ParameterFields.GetItemByName("@COMPANY_NAME", Missing.Value).AddCurrentValue(COMPANY_NAME);
                    crxReport.ParameterFields.GetItemByName("@COMPANY_ADDRESS", Missing.Value).AddCurrentValue(COMPANY_ADDRESS);
                    crxReport.ParameterFields.GetItemByName("@SEASON_NAME", Missing.Value).AddCurrentValue(cboSeason.GetItemText(cboSeason.SelectedItem));
                    crxReport.ParameterFields.GetItemByName("@SEASON_ID", Missing.Value).AddCurrentValue(Convert.ToInt32(cboSeason.SelectedValue));
                    crxReport.ParameterFields.GetItemByName("@YEAR", Missing.Value).AddCurrentValue(dateTimePicker.Value.Year);

                    axCrystalActiveXReportViewer1.ReportSource = crxReport;
                    axCrystalActiveXReportViewer1.ViewReport();
                    axCrystalActiveXReportViewer1.Zoom(100);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
        }