Beispiel #1
0
        public SettingUserControl(MysqlMethod mysql, Form1 form1)
        {
            InitializeComponent();
            XtraReportSetting = InitialMethod.InitialXtraReportLoad();
            Form1             = form1;
            MysqlMethod       = mysql;
            GatewayConfigs    = MysqlMethod.Search_GatewayConfig();
            foreach (var Gatewayitem in GatewayConfigs)
            {
                var configs = MysqlMethod.Search_ElectricConfig(Gatewayitem.GatewayIndex);
                foreach (var Configitem in configs)
                {
                    ElectricConfigs.Add(Configitem);
                }
            }
            ReportConfigs = MysqlMethod.Search_ReportConfig();
            ReportTitleSetting reportTitle = InitialMethod.InitialReportTitleSetting();

            ContractNoTextEdit.Text = reportTitle.ContractNo;
            ElectNoTextEdit.Text    = reportTitle.ElectNo;
            FileFormatSetting fileFormat = InitialMethod.InitialFileFormatSetting();

            OutputFormatComboBoxEdit.SelectedIndex = fileFormat.FileFormat;
            AutotoggleSwitch.IsOn = XtraReportSetting.AutoExport;       //自動匯出開關
            PathtextEdit.Text     = XtraReportSetting.Path;             //儲存路徑
            DaycomboBoxEdit.Text  = XtraReportSetting.Day.ToString();   //匯出時間

            int Index = 0;

            foreach (var ReportConfigitem in ReportConfigs)
            {
                var electricconfig = ElectricConfigs.Where(g => g.GatewayIndex == ReportConfigitem.GatewayIndex & g.DeviceIndex == ReportConfigitem.DeviceIndex).ToList()[0];
                ExportElectricSettingUserControl control = new ExportElectricSettingUserControl(ReportConfigitem, electricconfig, MysqlMethod)
                {
                    Location = new Point(5 + 420 * Index, 5)
                };
                ReportviewpanelControl.Controls.Add(control);
                exportElectricSettingUserControls.Add(control);
                Index++;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 自動發送功能
        /// </summary>
        public override void TextChange()
        {
            XtraReportSetting = InitialMethod.InitialXtraReportLoad();
            ReportTitleSetting reportTitle = InitialMethod.InitialReportTitleSetting();
            FileFormatSetting  fileFormat  = InitialMethod.InitialFileFormatSetting();

            if (XtraReportSetting.AutoExport && DateTime.Now.Day == XtraReportSetting.Day)
            {
                if (!ExportFlag)
                {
                    string ttime = string.Empty;
                    if (XtraReportSetting.Day.ToString().Length == 2)
                    {
                        ttime = DateTime.Now.ToString("yyyy/MM/") + $"{XtraReportSetting.Day} 00:00:00";
                    }
                    else
                    {
                        ttime = DateTime.Now.ToString("yyyy/MM/") + $"0{XtraReportSetting.Day} 00:00:00";
                    }
                    AnalysisXtraReport analysisXtraReport = new AnalysisXtraReport();
                    analysisXtraReport.create_XtraReport(MysqlMethod, ttime, reportTitle);
                    analysisXtraReport.CreateDocument();
                    if (Directory.Exists($"{XtraReportSetting.Path}"))
                    {
                        FileFormatTypeEnum fileFormatType = (FileFormatTypeEnum)fileFormat.FileFormat;
                        switch (fileFormatType)
                        {
                        case FileFormatTypeEnum.PDF:
                        {
                            string path = XtraReportSetting.Path + $"\\Production Report(F1&F2)_{DateTime.Now.ToString("yyyyMMdd")}.pdf";
                            analysisXtraReport.ExportToPdf(path);
                            break;
                        }

                        case FileFormatTypeEnum.DOCX:
                        {
                            string            path    = XtraReportSetting.Path + $"\\Production Report(F1&F2)_{DateTime.Now.ToString("yyyyMMdd")}.docx";
                            DocxExportOptions options = new DocxExportOptions()
                            {
                                TableLayout = true
                            };
                            analysisXtraReport.ExportToDocx(path, options);
                            break;
                        }

                        case FileFormatTypeEnum.XLSX:
                        {
                            string path = XtraReportSetting.Path + $"\\Production Report(F1&F2)_{DateTime.Now.ToString("yyyyMMdd")}.xlsx";
                            analysisXtraReport.ExportToXlsx(path);
                            break;
                        }
                        }
                    }
                    ExportFlag = true;
                }
            }
            else
            {
                ExportFlag = false;
            }
        }