private void fillGUI(DateTime date) { if (date.Ticks >= DateTimeTools.GetWorkWeekStartAndEnd(DateTime.Parse(_baseData["beginn"]))[0].Ticks) { if (_baseData.Count != 0) { this.Text = "Digitaler Ausbildungsbericht - " + date.ToShortDateString(); lblActWeek.Text = DateTimeTools.GetWeekOfYear(date).ToString(); string ausbwoche = string.Empty; DateTime beginnDate = DateTime.Parse(DataManager.LoadBaseData()["beginn"]); DateTime[] dta = DateTimeTools.GetWorkWeekStartAndEnd(date); if (dta[0].Month < beginnDate.Month) { ausbwoche = "1"; } else { ausbwoche = DateTimeTools.GetActAppWeek(DateTime.Parse(_baseData["beginn"]), date).ToString(); } lblWorkWeek.Text = ausbwoche; int year = DateTimeTools.GetActAppYear(DateTime.Parse(_baseData["beginn"]), date); if (year == 0) { year = 1; } lblWorkYear.Text = year.ToString(); panelReport.Enabled = ((_settings["ReportType"] == "dayly" && date.DayOfWeek == DayOfWeek.Saturday) || date.DayOfWeek == DayOfWeek.Sunday) ? false : true; lblWeekStart.Text = DateTimeTools.GetWorkWeekStartAndEnd(date)[0].ToShortDateString(); lblWeekEnd.Text = DateTimeTools.GetWorkWeekStartAndEnd(date)[1].ToShortDateString(); } else { InternalSetup.setupAssist(1, ref _settings); } } else { panelReport.Enabled = false; } }
void StartProgram() { try { Padding = new System.Windows.Forms.Padding(0, 0, 0, 5); AddDayPicker(); LoadBlocks(); lblLocalVersionShortCut.Text = "Deine Version: " + Application.ProductVersion; //Updater herunterladen if (File.Exists(DataManager.GetWorkingDirectory() + "\\Updater.exe")) { File.Delete(DataManager.GetWorkingDirectory() + "\\Updater.exe"); } if (MiscTools.CheckFilesystem()) { InternalSetup.setupAssist(0, ref _settings); } _settings = DataManager.LoadSettings(); InternalSetup.setupAssist(int.Parse(_settings["lastUndoneSetupStep"]), ref _settings); foreach (RatingItem ri in icRatings.SubItems) { if (_settings.ContainsKey(ri.Name)) { ri.RatingValue = int.Parse(_settings[ri.Name]); } } if (!_settings.ContainsKey("FileNames")) { _settings.Add("FileNames", "Bericht {AW} von {WS} - {WE}"); } DataManager.SaveSettings(_settings); cbxAutoUpdate.Checked = _settings["AutoUpdate"] == "1" ? true : false; loadBaseData(); if (_settings["ReportType"] == "dayly" || _settings["ReportType"] == "dayly+sa") { _actReport = DataManager.GetReportOfDate(DateTime.Now); if (_actReport == null) { _actReport = new Report(null, DateTime.Now.ToShortDateString(), "", "", "", "", "", "", "0", null, null); } DaylyReport dr = new DaylyReport(daypicker); btnSave.Click += new System.EventHandler(dr.SaveAsPDF); btnSpellcheck.Click += new EventHandler(dr.SetSpellCheckEnabled); dr.Dock = DockStyle.Fill; panelReport.Controls.Add(dr); dr.fillReportedDays(); ReportElement = dr; } else if (_settings["ReportType"] == "weekly") { _actReport = DataManager.GetReportOfWeek(DateTimeTools.GetActAppWeek(DateTime.Parse(DataManager.LoadBaseData()["beginn"]), DateTime.Now)); if (_actReport == null) { _actReport = new Report(null, DateTimeTools.GetWeekOfYear(DateTime.Now).ToString(), DateTimeTools.GetWeekOfYear(DateTime.Now).ToString(), DateTime.Now.Year.ToString(), "", "", "", ""); } WeeklyReport wr = new WeeklyReport(_actReport, daypicker, _baseData); btnSave.Click += new System.EventHandler(wr.SaveAsPDF); btnSpellcheck.Click += new EventHandler(wr.SetSpellCheckEnabled); wr.Dock = DockStyle.Fill; panelReport.Controls.Add(wr); wr.fillReportedDays(); ReportElement = wr; } else { InternalSetup.setupAssist(2, ref _settings); } fillGUI(daypicker.SelectedDate); addEvents(); Thread start = new Thread(SendStats.SendStart); start.Start(); Thread checkv = new Thread(checkVersion); checkv.Start(); } catch (Exception exception) { MessageBox.Show(exception.ToString()); Environment.Exit(0); } }