private void sh() { int lastIndx = journalContainer.Controls.Count - 1; DateTime lastDate = DateTime.Now; DateTime initDate = DateTime.Now; DateTime startRecalculatedTime = DateTime.Now; int startRecalculateIndx = -1; double allWeight = 0.0; for (int i = lastIndx; i >= 0; i--) { JournalNoKAGControl jj = (JournalNoKAGControl)journalContainer.Controls[i]; if (i == lastIndx) { lastDate = jj.getJournalDateTime(); } if ((jj.isFreeze() || i == 0) && startRecalculateIndx < 0) { initDate = i == 0 ? jj.getJournalDateTime() : DateTime.Now; startRecalculatedTime = jj.getJournalDateTime(); startRecalculateIndx = i; } if (i == 0) { initDate = jj.getJournalDateTime(); } allWeight += ((DdtJournal)jj.getObject()).Weight; } DateTime finalTime = new DateTime(lastDate.Year, lastDate.Month, lastDate.Day, 8, 5, 0); if ((lastDate.Day > initDate.Day || initDate.Hour < 8) && lastDate > finalTime && startRecalculateIndx >= 0) { long ticksAllDay = finalTime.Ticks - startRecalculatedTime.Ticks; double minutesAllDay = ticksAllDay / 10000000 / 60; double minutesPerJ = minutesAllDay / (journalContainer.Controls.Count); DateTime lastRecalculated = new DateTime(startRecalculatedTime.Ticks); for (int i = startRecalculateIndx + 1; i < lastIndx; i++) { JournalNoKAGControl jCntrl = (JournalNoKAGControl)journalContainer.Controls[i]; //weight 100% = 240 minutes; DdtJournal journl = (DdtJournal)jCntrl.getObject(); DateTime re = lastRecalculated.AddMinutes(minutesPerJ * journl.Weight); jCntrl.initTime(re); lastRecalculated = new DateTime(re.Ticks); } JournalNoKAGControl lastJCntrl = (JournalNoKAGControl)journalContainer.Controls[lastIndx]; lastJCntrl.initTime(finalTime); } }
private void createDefferedJournalMenu_Click(object sender, EventArgs e) { JournalNoKAGControl goodJournalBefore = new JournalNoKAGControl(this, null, (int)DdtJournalDsiType.BeforeKag, hospitalitySession.CuringDoctor); if (journalContainer.Controls.Count > 0) { JournalNoKAGControl lastJournal = (JournalNoKAGControl)journalContainer.Controls[journalContainer.Controls.Count - 1]; goodJournalBefore.initTime(lastJournal.getJournalDateTime().AddHours(1)); goodJournalBefore.initDocName(lastJournal.getDocName()); goodJournalBefore.initRhytm(lastJournal.isGoodRhytm()); } journalContainer.Controls.Add(goodJournalBefore); JournalNoKAGControl badJournal = new JournalNoKAGControl(this, null, (int)DdtJournalDsiType.PendingJustification, hospitalitySession.CuringDoctor); badJournal.initTime(goodJournalBefore.getJournalDateTime().AddHours(1)); badJournal.initDocName(goodJournalBefore.getDocName()); badJournal.initRhytm(goodJournalBefore.isGoodRhytm()); journalContainer.Controls.Add(badJournal); JournalNoKAGControl goodJournal = new JournalNoKAGControl(this, null, (int)DdtJournalDsiType.AfterPending, hospitalitySession.CuringDoctor); goodJournal.initTime(badJournal.getJournalDateTime().AddMinutes(15)); goodJournal.initDocName(badJournal.getDocName()); goodJournal.initRhytm(badJournal.isGoodRhytm()); journalContainer.Controls.Add(goodJournal); sh(); }
private void createJournalMenu_Click(object sender, EventArgs e) { JournalNoKAGControl nextJournal = new JournalNoKAGControl(this, null, (int)DdtJournalDsiType.BeforeKag, hospitalitySession.CuringDoctor); if (journalContainer.Controls.Count > 0) { JournalNoKAGControl lastJournal = (JournalNoKAGControl)journalContainer.Controls[journalContainer.Controls.Count - 1]; nextJournal.initTime(lastJournal.getJournalDateTime().AddHours(4)); nextJournal.initDocName(lastJournal.getDocName()); nextJournal.initRhytm(lastJournal.isGoodRhytm()); } journalContainer.Controls.Add(nextJournal); sh(); }