private void Reload(bool forced = false) { try { if (forced) { ClearHash(); selgerkodeList.Clear(); comboDBselgerkode.Items.Clear(); listBoxSk.Items.Clear(); listBox_GraphSelgere.Items.Clear(); _graphInitialized = false; } if (EmptyDatabase()) { Log.n("Databasen er tom. Importer transaksjoner fra Elguide!"); labelRankingLastDateBig.ForeColor = SystemColors.ControlText; labelRankingLastDateBig.Text = "(tom)"; labelRankingLastDate.ForeColor = SystemColors.ControlText; labelRankingLastDate.Text = ""; labelGraphLastDateBig.ForeColor = SystemColors.ControlText; labelGraphLastDateBig.Text = "(tom)"; labelGraphLastDate.ForeColor = SystemColors.ControlText; labelGraphLastDate.Text = ""; webRanking.Navigate(htmlImport); ShowHideGui_EmptyRanking(false); buttonOppdater.BackColor = SystemColors.ControlLight; buttonOppdater.ForeColor = SystemColors.ControlText; DataTable DT = (DataTable)dataGridTransaksjoner.DataSource; if (DT != null) DT.Clear(); selgerkodeList.Clear(); } else { labelRankingLastDateBig.Text = appConfig.dbTo.ToString("dddd", norway); labelRankingLastDate.Text = appConfig.dbTo.ToString("d. MMM", norway); labelGraphLastDateBig.Text = appConfig.dbTo.ToString("dddd", norway); labelGraphLastDate.Text = appConfig.dbTo.ToString("d. MMM", norway); if ((DateTime.Now - appConfig.dbTo).Days >= 3) { labelRankingLastDateBig.ForeColor = Color.Red; labelRankingLastDate.ForeColor = Color.Red; labelGraphLastDateBig.ForeColor = Color.Red; labelGraphLastDate.ForeColor = Color.Red; } else { labelRankingLastDateBig.ForeColor = SystemColors.ControlText; labelRankingLastDate.ForeColor = SystemColors.ControlText; labelGraphLastDateBig.ForeColor = SystemColors.ControlText; labelGraphLastDate.ForeColor = SystemColors.ControlText; } ShowHideGui_EmptyRanking(true); if (!autoMode) UpdateRank(); highlightDate = appConfig.dbTo; moveDate(0, true); InitDB(); topgraph = new TopGraph(this); salesCodes = new SalesCodes(this, true); transInitialized = false; } } catch (Exception ex) { FormError errorMsg = new FormError("Kritisk feil ved initialisering av databasen.\nInstaller programmet på nytt hvis problemet vedvarer.", ex); errorMsg.ShowDialog(this); } }
private void InitializeMyComponents() { database = new Database(this); vinnprodukt = new Vinnprodukt(this); openXml = new OpenXML(this); processing = new FormProcessing(this); salesCodes = new SalesCodes(this); tools = new KgsaTools(this); worker = new BackgroundWorker(); webService.ObjectForScripting = new ScriptInterface(); UpdateServicePage.OnBrowseServicePage += UpdateServicePage_OnRun; Log.LogAdded += new EventHandler(LogMessage_LogAdded); timerAutoRanking.Tick += timer_Tick; timerAutoQuick.Tick += timer_TickQuick; timerAutoService.Tick += timerService_Tick; timerAutoStore.Tick += timerStore_Tick; timerMsgClear.Tick += timer; bwSendEmail.DoWork += new DoWorkEventHandler(bwSendEmail_DoWork); bwSendEmail.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwSendEmail_RunWorkerCompleted); bwPopulateSk.DoWork += new DoWorkEventHandler(bwPopulateSk_DoWork); bwPopulateSk.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwPopulateSk_Completed); bwImport.DoWork += new DoWorkEventHandler(bwImport_DoWork); bwImport.ProgressChanged += new ProgressChangedEventHandler(bwProgressReport_ProgressChanged); bwImport.WorkerReportsProgress = true; bwImport.WorkerSupportsCancellation = true; bwImport.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwImport_Completed); bwImportObsolete.DoWork += new DoWorkEventHandler(bwImportObsolete_DoWork); bwImportObsolete.ProgressChanged += new ProgressChangedEventHandler(bwProgressReport_ProgressChanged); bwImportObsolete.WorkerReportsProgress = true; bwImportObsolete.WorkerSupportsCancellation = true; bwImportObsolete.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwImportObsolete_Completed); bwPDF.DoWork += new DoWorkEventHandler(bwPDF_DoWork); bwPDF.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwPDF.WorkerReportsProgress = true; bwPDF.WorkerSupportsCancellation = true; bwPDF.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwPDF_Completed); bwBudgetPDF.DoWork += new DoWorkEventHandler(bwBudgetPDF_DoWork); bwBudgetPDF.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwBudgetPDF.WorkerReportsProgress = true; bwBudgetPDF.WorkerSupportsCancellation = true; bwBudgetPDF.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwPDF_Completed); bwOpenPDF.DoWork += new DoWorkEventHandler(bwOpenPDF_DoWork); bwOpenPDF.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwOpenPDF.WorkerReportsProgress = true; bwOpenPDF.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwOpenPDF_Completed); bwAutoRanking.DoWork += new DoWorkEventHandler(bwAutoRanking_DoWork); bwAutoRanking.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwAutoRanking.WorkerReportsProgress = true; bwAutoRanking.WorkerSupportsCancellation = true; bwAutoRanking.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwAutoRanking_Completed); bwMacroRanking.DoWork += new DoWorkEventHandler(bwMacroRanking_DoWork); bwMacroRanking.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwMacroRanking.WorkerReportsProgress = true; bwMacroRanking.WorkerSupportsCancellation = true; bwMacroRanking.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwMacroRanking_Completed); bwAutoStore.DoWork += new DoWorkEventHandler(bwAutoStore_DoWork); bwAutoStore.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwAutoStore.WorkerReportsProgress = true; bwAutoStore.WorkerSupportsCancellation = true; bwAutoStore.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwAutoStore_Completed); bwRanking.DoWork += new DoWorkEventHandler(bwRanking_DoWork); bwRanking.ProgressChanged += new ProgressChangedEventHandler(bwProgressReport_ProgressChanged); bwRanking.WorkerReportsProgress = true; bwRanking.WorkerSupportsCancellation = true; bwRanking.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwRanking_Completed); bwVinnSelger.DoWork += new DoWorkEventHandler(bwVinnSelger_DoWork); bwVinnSelger.ProgressChanged += new ProgressChangedEventHandler(bwProgressReport_ProgressChanged); bwVinnSelger.WorkerReportsProgress = true; bwVinnSelger.WorkerSupportsCancellation = true; bwVinnSelger.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwRanking_Completed); bwBudget.DoWork += new DoWorkEventHandler(bwBudget_DoWork); bwBudget.ProgressChanged += new ProgressChangedEventHandler(bwProgressReport_ProgressChanged); bwBudget.WorkerReportsProgress = true; bwBudget.WorkerSupportsCancellation = true; bwBudget.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBudget_Completed); bwStore.DoWork += new DoWorkEventHandler(bwStore_DoWork); bwStore.ProgressChanged += new ProgressChangedEventHandler(bwProgressReport_ProgressChanged); bwStore.WorkerReportsProgress = true; bwStore.WorkerSupportsCancellation = true; bwStore.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwStore_Completed); bwReport.DoWork += new DoWorkEventHandler(bwReport_DoWork); bwReport.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwReport.WorkerReportsProgress = true; bwReport.WorkerSupportsCancellation = true; bwReport.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwReport_Completed); bwQuickAuto.DoWork += new DoWorkEventHandler(bwQuickAuto_DoWork); bwQuickAuto.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwQuickAuto.WorkerReportsProgress = true; bwQuickAuto.WorkerSupportsCancellation = true; bwQuickAuto.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwQuickAuto_Completed); bwAutoImportService.DoWork += new DoWorkEventHandler(bwAutoImportService_DoWork); bwAutoImportService.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwAutoImportService.WorkerReportsProgress = true; bwAutoImportService.WorkerSupportsCancellation = true; bwAutoImportService.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwAutoImportService_Completed); bwImportService.DoWork += new DoWorkEventHandler(bwImportService_DoWork); bwImportService.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwImportService.WorkerReportsProgress = true; bwImportService.WorkerSupportsCancellation = true; bwImportService.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwImportService_Completed); bwGraph.DoWork += new DoWorkEventHandler(bwGraph_DoWork); bwGraph.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwGraph.WorkerReportsProgress = true; bwGraph.WorkerSupportsCancellation = true; bwGraph.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwGraph_Completed); bwService.DoWork += new DoWorkEventHandler(bwService_DoWork); bwService.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwServiceGraph_Completed); bwServiceReport.DoWork += new DoWorkEventHandler(bwServiceReport_DoWork); bwServiceReport.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwServiceReport_Completed); bwUpdateTopGraph.DoWork += new DoWorkEventHandler(bwUpdateTopGraph_DoWork); bwUpdateTopGraph.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwUpdateTopGraph_Completed); bwUpdateBigGraph.DoWork += new DoWorkEventHandler(bwUpdateBigGraph_DoWork); bwUpdateBigGraph.ProgressChanged += new ProgressChangedEventHandler(bwProgressCustom_ProgressChanged); bwUpdateBigGraph.WorkerSupportsCancellation = true; bwUpdateBigGraph.WorkerReportsProgress = true; bwUpdateBigGraph.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwUpdateBigGraph_Completed); bwCreateHtml.DoWork += new DoWorkEventHandler(bwCreateHtml_DoWork); bwCreateHtml.ProgressChanged += new ProgressChangedEventHandler(bwProgressReport_ProgressChanged); bwCreateHtml.WorkerReportsProgress = true; bwCreateHtml.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwCreateHtml_Completed); bwHentAvdelinger.DoWork += new DoWorkEventHandler(bwHentAvdelinger_DoWork); bwHentAvdelinger.WorkerSupportsCancellation = true; bwHentAvdelinger.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwHentAvdelinger_Completed); }