private void butPickPresenter_Click(object sender, EventArgs e) { FormUserPick FormUP = new FormUserPick(); List <Userod> listUsers = Userods.GetWhere(x => x.ClinicIsRestricted == false || x.ClinicNum == Clinics.ClinicNum, true); FormUP.ListUserodsFiltered = listUsers; if (_presenterCur != null) { FormUP.SuggestedUserNum = _presenterCur.UserNum; } FormUP.IsPickNoneAllowed = true; FormUP.ShowDialog(); if (FormUP.DialogResult != DialogResult.OK) { return; } _presenterCur = Userods.GetUser(FormUP.SelectedUserNum); //can be null if (_presenterCur != null) { textPresenter.Text = _presenterCur.UserName; } else { textPresenter.Text = ""; } }
private void FormPopupDisplay_Load(object sender, EventArgs e) { textDescription.Text = PopupCur.Description.Replace("\r\n", "\n").Replace("\n", "\r\n"); if (PopupCur.UserNum != 0) { textUser.Text = Userods.GetUser(PopupCur.UserNum).UserName; } textCreateDate.Text = ""; if (PopupCur.DateTimeEntry.Year > 1880) { textCreateDate.Text = PopupCur.DateTimeEntry.ToShortDateString() + " " + PopupCur.DateTimeEntry.ToShortTimeString(); } DateTime dateT = Popups.GetLastEditDateTimeForPopup(PopupCur.PopupNum); textEditDate.Text = ""; if (dateT.Year > 1880) { textEditDate.Text = dateT.ToShortDateString() + " " + dateT.ToShortTimeString(); //Sets the Edit date to the entry date of the last popup change that was archived for this popup. } for (int i = 1; i <= 4; i++) { comboMinutes.Items.Add(i.ToString()); } for (int i = 1; i <= 11; i++) { comboMinutes.Items.Add((i * 5).ToString()); } comboMinutes.Text = "10"; for (int i = 1; i <= 12; i++) { comboHours.Items.Add(i.ToString()); } comboHours.Text = "1"; MinutesDisabled = 0; }
private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e) { Userod user = Userods.GetUser(ListUser[e.Row].UserNum); FormUserEdit FormU = new FormUserEdit(user); FormU.ShowDialog(); if (FormU.DialogResult == DialogResult.Cancel) { return; } if (Security.CurUser.UserNum == user.UserNum) { Security.CurUser = FormU.UserCur; //if user changed their own password, this keeps the CurUser synched. Needed for eCW bridge. } FillUsers(); for (int i = 0; i < ListUser.Count; i++) { if (ListUser[i].UserNum == FormU.UserCur.UserNum) { gridMain.SetSelected(i, true); SelectedGroupNum = FormU.UserCur.UserGroupNum; } } FillTreePerm(); changed = true; }
private void FillGrid() { SecurityLog[] logList = SecurityLogs.Refresh(PatNum, PermTypes, FKey); grid.BeginUpdate(); grid.Columns.Clear(); ODGridColumn col; col = new ODGridColumn(Lan.g("TableAudit", "Date Time"), 120); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "User"), 70); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Permission"), 110); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Log Text"), 569); grid.Columns.Add(col); grid.Rows.Clear(); ODGridRow row; for (int i = 0; i < logList.Length; i++) { row = new ODGridRow(); row.Cells.Add(logList[i].LogDateTime.ToShortDateString() + " " + logList[i].LogDateTime.ToShortTimeString()); row.Cells.Add(Userods.GetUser(logList[i].UserNum).UserName); row.Cells.Add(logList[i].PermType.ToString()); row.Cells.Add(logList[i].LogText); grid.Rows.Add(row); } grid.EndUpdate(); grid.ScrollToEnd(); }
private void FillGridMain() { gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); GridColumn col; col = new GridColumn(Lan.g("TableOrthoAudit", "Date Time"), 120); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableOrthoAudit", "User"), 70); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableOrthoAudit", "Permission"), 110); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableOrthoAudit", "Log Text"), 569); gridMain.ListGridColumns.Add(col); gridMain.ListGridRows.Clear(); GridRow row; Userod user; //First Selected Ortho Chart Logs foreach (int iDate in gridHist.SelectedIndices) { DateTime dateRow = (DateTime)gridHist.ListGridRows[iDate].Tag; if (!DictDateOrthoLogs.ContainsKey(dateRow)) { continue; } for (int i = 0; i < DictDateOrthoLogs[dateRow].Count; i++) { row = new GridRow(); row.Cells.Add(DictDateOrthoLogs[dateRow][i].LogDateTime.ToShortDateString() + " " + DictDateOrthoLogs[dateRow][i].LogDateTime.ToShortTimeString()); user = Userods.GetUser(DictDateOrthoLogs[dateRow][i].UserNum); if (user == null) //Will be null for audit trails made by outside entities that do not require users to be logged in. E.g. Web Sched. { row.Cells.Add("unknown"); } else { row.Cells.Add(user.UserName); } row.Cells.Add(DictDateOrthoLogs[dateRow][i].PermType.ToString()); row.Cells.Add(DictDateOrthoLogs[dateRow][i].LogText); gridMain.ListGridRows.Add(row); } } //Then any applicable patient field logs. for (int i = 0; i < PatientFieldLogs.Count; i++) { row = new GridRow(); row.Cells.Add(PatientFieldLogs[i].LogDateTime.ToShortDateString() + " " + PatientFieldLogs[i].LogDateTime.ToShortTimeString()); row.Cells.Add(Userods.GetUser(PatientFieldLogs[i].UserNum).UserName); row.Cells.Add(PatientFieldLogs[i].PermType.ToString()); row.Cells.Add(PatientFieldLogs[i].LogText); gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); gridMain.ScrollToEnd(); }
private void FillGrid() { try { LogList = SecurityLogs.Refresh(PatNum, PermTypes, FKey); } catch (Exception ex) { FriendlyException.Show(Lan.g(this, "There was a problem refreshing the Audit Trail with the current filters."), ex); LogList = new SecurityLog[0]; } grid.BeginUpdate(); grid.ListGridColumns.Clear(); GridColumn col; col = new GridColumn(Lan.g("TableAudit", "Date Time"), 120); grid.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableAudit", "User"), 70); grid.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableAudit", "Permission"), 170); grid.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableAudit", "Log Text"), 510); grid.ListGridColumns.Add(col); grid.ListGridRows.Clear(); GridRow row; Userod user; foreach (SecurityLog logCur in LogList) { row = new GridRow(); row.Cells.Add(logCur.LogDateTime.ToShortDateString() + " " + logCur.LogDateTime.ToShortTimeString()); user = Userods.GetUser(logCur.UserNum); if (user == null) //Will be null for audit trails made by outside entities that do not require users to be logged in. E.g. Web Sched. { row.Cells.Add("unknown"); } else { row.Cells.Add(user.UserName); } row.Cells.Add(logCur.PermType.ToString()); row.Cells.Add(logCur.LogText); grid.ListGridRows.Add(row); } grid.EndUpdate(); grid.ScrollToEnd(); }
private void FormEmailAddress_Load(object sender, System.EventArgs e) { if (_emailAddressCur != null) { textSMTPserver.Text = _emailAddressCur.SMTPserver; textUsername.Text = _emailAddressCur.EmailUsername; if (!String.IsNullOrEmpty(_emailAddressCur.EmailPassword)) //can happen if creating a new user email. { textPassword.Text = MiscUtils.Decrypt(_emailAddressCur.EmailPassword); } textPort.Text = _emailAddressCur.ServerPort.ToString(); checkSSL.Checked = _emailAddressCur.UseSSL; textSender.Text = _emailAddressCur.SenderAddress; textSMTPserverIncoming.Text = _emailAddressCur.Pop3ServerIncoming; textPortIncoming.Text = _emailAddressCur.ServerPortIncoming.ToString(); //Both EmailNotifyAddressNum and EmailDefaultAddressNum could be 0 (unset), in which case we still may want to display the user. List <long> listDefaultAddressNums = new List <long>() { PrefC.GetLong(PrefName.EmailNotifyAddressNum), PrefC.GetLong(PrefName.EmailDefaultAddressNum) }; if (_isNew || !_emailAddressCur.EmailAddressNum.In(listDefaultAddressNums)) { Userod user = Userods.GetUser(_emailAddressCur.UserNum); textUserod.Tag = user; textUserod.Text = user?.UserName; } else { groupUserod.Visible = false; } textAccessToken.Text = _emailAddressCur.AccessToken; textRefreshToken.Text = _emailAddressCur.RefreshToken; } groupGoogleAuth.Visible = !textAccessToken.Text.IsNullOrEmpty(); if (groupGoogleAuth.Visible) { groupAuthentication.Location = new Point(_groupAuthLocationXAuthorized, groupAuthentication.Location.Y); } else { groupAuthentication.Location = new Point(_groupAuthLocationXNotAuthorized, groupAuthentication.Location.Y); } }
private void FillGrid() { SecurityLog[] logList = SecurityLogs.Refresh(PatNum, PermTypes); grid.BeginUpdate(); grid.Rows.Clear(); ODGridRow row; for (int i = 0; i < logList.Length; i++) { row = new ODGridRow(); row.Cells.Add(logList[i].LogDateTime.ToShortDateString() + " " + logList[i].LogDateTime.ToShortTimeString()); row.Cells.Add(Userods.GetUser(logList[i].UserNum).UserName); row.Cells.Add(logList[i].PermType.ToString()); row.Cells.Add(logList[i].LogText); grid.Rows.Add(row); } grid.EndUpdate(); grid.ScrollToEnd(); }
private void FillGrid() { //Fill the log if it wasn't filled outside of this window. if (LogList == null) { LogList = SecurityLogs.Refresh(PatNum, PermTypes, FKey, checkIncludeArchived.Checked); } grid.BeginUpdate(); grid.Columns.Clear(); ODGridColumn col; col = new ODGridColumn(Lan.g("TableAudit", "Date Time"), 120); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "User"), 70); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Permission"), 170); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Log Text"), 510); grid.Columns.Add(col); grid.Rows.Clear(); ODGridRow row; Userod user; for (int i = 0; i < LogList.Length; i++) { row = new ODGridRow(); row.Cells.Add(LogList[i].LogDateTime.ToShortDateString() + " " + LogList[i].LogDateTime.ToShortTimeString()); user = Userods.GetUser(LogList[i].UserNum); if (user == null) //Will be null for audit trails made by outside entities that do not require users to be logged in. E.g. Web Sched. { row.Cells.Add("unknown"); } else { row.Cells.Add(user.UserName); } row.Cells.Add(LogList[i].PermType.ToString()); row.Cells.Add(LogList[i].LogText); grid.Rows.Add(row); } grid.EndUpdate(); grid.ScrollToEnd(); }
private void FormPopupDisplay_Load(object sender, EventArgs e) { //This homogenizes the display because sometimes popups are stored with "\n" and sometimes they are saved with "\r\n" textDescription.Text = PopupCur.Description.Replace("\r\n", "\n").Replace("\n", "\r\n"); if (PopupCur.UserNum != 0) { //Display last user to edit PopupCur, or "Unknown(5)" if user not found. textUser.Text = Userods.GetUser(PopupCur.UserNum)?.UserName ?? (Lan.g(this, "Unknown") + $"({POut.Long(PopupCur.UserNum)})"); } textCreateDate.Text = ""; if (PopupCur.DateTimeEntry.Year > 1880) { textCreateDate.Text = PopupCur.DateTimeEntry.ToShortDateString() + " " + PopupCur.DateTimeEntry.ToShortTimeString(); } DateTime dateT = Popups.GetLastEditDateTimeForPopup(PopupCur.PopupNum); textEditDate.Text = ""; if (dateT.Year > 1880) { textEditDate.Text = dateT.ToShortDateString() + " " + dateT.ToShortTimeString(); //Sets the Edit date to the entry date of the last popup change that was archived for this popup. } for (int i = 1; i <= 4; i++) { comboMinutes.Items.Add(i.ToString()); } for (int i = 1; i <= 11; i++) { comboMinutes.Items.Add((i * 5).ToString()); } comboMinutes.Text = "10"; for (int i = 1; i <= 12; i++) { comboHours.Items.Add(i.ToString()); } comboHours.Text = "1"; MinutesDisabled = 0; if (PopupCur.UserNum != Security.CurUser.UserNum && !Security.IsAuthorized(Permissions.PopupEdit, true)) { textDescription.ReadOnly = true; } }
private void butPickUserod_Click(object sender, EventArgs e) { FormUserPick formUserPick = new FormUserPick(); formUserPick.SuggestedUserNum = ((Userod)textUserod.Tag)?.UserNum ?? 0; //Preselect current selection. if (formUserPick.ShowDialog() == DialogResult.OK) { Userod user = Userods.GetUser(formUserPick.SelectedUserNum); if (user.UserNum == (((Userod)textUserod.Tag)?.UserNum ?? 0)) { return; //No change. } EmailAddress emailUserExisting = EmailAddresses.GetForUser(user.UserNum); if (emailUserExisting != null) { MsgBox.Show(this, "User email already exists for " + user.UserName); return; } textUserod.Tag = user; textUserod.Text = user.UserName; } }
private void butCalculate_Click(object sender, EventArgs e) { _listTopJobs.Clear(); listEngNoJobs.Items.Clear(); List <long> listEngNums = listEngineers.SelectedTags <Employee>().Select(x => x.EmployeeNum).ToList(); List <long> listUserNums = listEngNums.Select(x => Userods.GetUserByEmployeeNum(x).UserNum).ToList(); //Get 6 months of scheduled engineering time. Arbitrary because there should be no way we have a 6 month release cycle. List <Schedule> listSchedules = Schedules.RefreshPeriodForEmps(DateTime.Today, DateTime.Today.AddMonths(6), listEngNums); //Get all the jobs according to the selected criteria. //No need to fill currently, but I may want to add reviews into this to improve accuracy for unfinished jobs List <Job> listJobs = _listJobsAll.Where(x => x.Priority.In(listPriorities.SelectedTags <Def>().Select(y => y.DefNum)) && x.PhaseCur.In(listPhases.SelectedTags <JobPhase>()) && x.Category.In(listCategories.SelectedTags <JobCategory>())).ToList(); double totalJobHours = 0; DateTime releaseDate = DateTime.Today; double avgJobHours = _avgJobHours; double jobTimePercent = _jobTimePercent; double avgBreakHours = _avgBreakHours; Double.TryParse(textAvgJobHours.Text, out avgJobHours); Double.TryParse(textEngJobPercent.Text, out jobTimePercent); Double.TryParse(textBreakHours.Text, out avgBreakHours); gridCalculatedJobs.BeginUpdate(); gridCalculatedJobs.Columns.Clear(); gridCalculatedJobs.Columns.Add(new ODGridColumn("EstHrs", 0) { TextAlign = HorizontalAlignment.Center }); gridCalculatedJobs.Columns.Add(new ODGridColumn("ActHrs", 0) { TextAlign = HorizontalAlignment.Center }); gridCalculatedJobs.Columns.Add(new ODGridColumn("", 200)); gridCalculatedJobs.Rows.Clear(); foreach (Job job in listJobs) { if (job.UserNumEngineer == 0 && listUserNums.Contains(job.UserNumExpert)) { listUserNums.Remove(job.UserNumExpert); } if (job.UserNumEngineer != 0 && listUserNums.Contains(job.UserNumEngineer)) { listUserNums.Remove(job.UserNumEngineer); } //If hrsEst is 0 then use the avgJobHours as a base. double hrsEst = job.TimeEstimate.TotalHours == 0?avgJobHours:job.TimeEstimate.TotalHours; //Remove the actual hours spent on the job currently //If negative then just use 0 (We aren't in a dimension where negative time estimates can be used for other jobs) double hrsCalculated = (hrsEst - job.HoursActual) < 0?0:hrsEst - job.HoursActual; totalJobHours += hrsCalculated; if (job.PhaseCur == JobPhase.Development) { _listTopJobs.Add(new Tuple <long, double>(job.JobNum, hrsCalculated)); } gridCalculatedJobs.Rows.Add( new ODGridRow( new ODGridCell(job.TimeEstimate.TotalHours == 0?"0(" + _avgJobHours + ")":job.TimeEstimate.TotalHours.ToString()), new ODGridCell(job.HoursActual.ToString()), new ODGridCell(job.Title) ) { Tag = job } ); } gridCalculatedJobs.EndUpdate(); foreach (long engNum in listUserNums) { Userod eng = Userods.GetUser(engNum); listEngNoJobs.Items.Add(new ODBoxItem <Userod>(eng.UserName, eng)); } try { _listTopJobs = _listTopJobs.OrderByDescending(x => x.Item2).Take(3).ToList(); butJob1.Text = "#" + _listTopJobs[0].Item1.ToString() + "-" + Math.Round(_listTopJobs[0].Item2).ToString() + " hours"; butJob2.Text = "#" + _listTopJobs[1].Item1.ToString() + "-" + Math.Round(_listTopJobs[1].Item2).ToString() + " hours"; butJob3.Text = "#" + _listTopJobs[2].Item1.ToString() + "-" + Math.Round(_listTopJobs[2].Item2).ToString() + " hours"; } catch { panelExtra.Visible = false; } labelJobHours.Text = Math.Round(totalJobHours).ToString(); labelJobNumber.Text = listJobs.Count.ToString(); double schedHoursTotal = 0; double schedHoursBreaksTotal = 0; double schedHoursPercentTotal = 0; foreach (Schedule sched in listSchedules) { //Calculate actual scheduled time double schedHours = (sched.StopTime - sched.StartTime).TotalHours; schedHoursTotal += schedHours; //Remove average break time schedHours -= avgBreakHours; schedHoursBreaksTotal += schedHours; //Multiply the scheduled time by the percentage of coding time for the jobs we care about schedHours = schedHours * jobTimePercent; schedHoursPercentTotal += schedHours; //Remove the scheduled hours from the total job hours totalJobHours -= schedHours; if (totalJobHours < 0) { releaseDate = sched.SchedDate; //Add a week as a buffer break; } } labelEngHours.Text = Math.Round(schedHoursTotal).ToString(); labelAfterBreak.Text = Math.Round(schedHoursBreaksTotal).ToString(); labelRatioHours.Text = Math.Round(schedHoursPercentTotal).ToString(); labelReleaseDate.Text = releaseDate.ToShortDateString() + " - " + releaseDate.AddDays(7).ToShortDateString(); labelReleaseDate.Visible = true; panelExtra.Visible = true; }
private void FillGrid() { gridTaskHist.BeginUpdate(); gridTaskHist.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableTaskAudit", "Create Date"), 140); gridTaskHist.Columns.Add(col); col = new ODGridColumn(Lan.g("TableTaskAudit", "Edit Date"), 140); gridTaskHist.Columns.Add(col); col = new ODGridColumn(Lan.g("TableTaskAudit", "Editing User"), 80); gridTaskHist.Columns.Add(col); col = new ODGridColumn(Lan.g("TableTaskAudit", "Changes"), 100); gridTaskHist.Columns.Add(col); gridTaskHist.Rows.Clear(); ODGridRow row; //Row describes difference between current row and the Next row. Last row will be the last TaskHist compared to the current Task. for (int i = 1; i < _listTaskAudit.Count; i++) { TaskHist taskHistCur = _listTaskAudit[i - 1]; TaskHist taskHistNext = _listTaskAudit[i]; row = new ODGridRow(); if (taskHistCur.DateTimeEntry == DateTime.MinValue) { row.Cells.Add(_listTaskAudit[i].DateTimeEntry.ToString()); } else { row.Cells.Add(taskHistCur.DateTimeEntry.ToString()); } row.Cells.Add(taskHistCur.DateTStamp.ToString()); long usernum = taskHistCur.UserNumHist; if (usernum == 0) { usernum = taskHistCur.UserNum; } row.Cells.Add(Userods.GetUser(usernum).UserName); row.Cells.Add(TaskHists.GetChangesDescription(taskHistCur, taskHistNext)); gridTaskHist.Rows.Add(row); } //Compare the current task with the last hist entry (Add the "current revision" of the task if necessary.) if (_listTaskAudit.Count > 0) { TaskHist taskHistCur = _listTaskAudit[_listTaskAudit.Count - 1]; Task task = Tasks.GetOne(TaskNumCur); if (task != null) { TaskHist taskHistNext = new TaskHist(task); row = new ODGridRow(); if (taskHistCur.DateTimeEntry == DateTime.MinValue) { row.Cells.Add(taskHistNext.DateTimeEntry.ToString()); } else { row.Cells.Add(taskHistCur.DateTimeEntry.ToString()); } row.Cells.Add(taskHistCur.DateTStamp.ToString()); long usernum = taskHistCur.UserNumHist; if (usernum == 0) { usernum = taskHistCur.UserNum; } row.Cells.Add(Userods.GetUser(usernum).UserName); row.Cells.Add(TaskHists.GetChangesDescription(taskHistCur, taskHistNext)); gridTaskHist.Rows.Add(row); } } gridTaskHist.EndUpdate(); }
private void FillGrid() { long userNum = 0; if (comboUser.SelectedIndex > 0) { userNum = UserodC.Listt[comboUser.SelectedIndex - 1].UserNum; } SecurityLog[] logList = null; if (comboPermission.SelectedIndex == 0) { logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text), Permissions.None, PatNum, userNum); } else { logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text), (Permissions)Enum.Parse(typeof(Permissions), comboPermission.SelectedItem.ToString()), PatNum, userNum); } grid.BeginUpdate(); grid.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableAudit", "Date"), 70); col.SortingStrategy = GridSortingStrategy.DateParse; grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Time"), 60); col.SortingStrategy = GridSortingStrategy.DateParse; grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Patient"), 100); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "User"), 70); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Permission"), 110); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Computer"), 70); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Log Text"), 560); grid.Columns.Add(col); grid.Rows.Clear(); ODGridRow row; Userod user; for (int i = 0; i < logList.Length; i++) { row = new ODGridRow(); row.Cells.Add(logList[i].LogDateTime.ToShortDateString()); row.Cells.Add(logList[i].LogDateTime.ToShortTimeString()); row.Cells.Add(logList[i].PatientName); user = Userods.GetUser(logList[i].UserNum); //user might be null due to old bugs. if (user == null) { row.Cells.Add("unknown"); } else { row.Cells.Add(Userods.GetUser(logList[i].UserNum).UserName); } if (logList[i].PermType == Permissions.ChartModule) { row.Cells.Add("ChartModuleViewed"); } else if (logList[i].PermType == Permissions.FamilyModule) { row.Cells.Add("FamilyModuleViewed"); } else if (logList[i].PermType == Permissions.AccountModule) { row.Cells.Add("AccountModuleViewed"); } else if (logList[i].PermType == Permissions.ImagesModule) { row.Cells.Add("ImagesModuleViewed"); } else if (logList[i].PermType == Permissions.TPModule) { row.Cells.Add("TreatmentPlanModuleViewed"); } else { row.Cells.Add(logList[i].PermType.ToString()); } row.Cells.Add(logList[i].CompName); row.Cells.Add(logList[i].LogText); //Get the hash for the audit log entry from the database and rehash to compare string newHash = SecurityLogHashes.GetHashString(logList[i]); if (logList[i].LogHash != newHash) { row.ColorText = Color.Red; //Bad hash or no hash entry at all. This prevents users from deleting the entire hash table to make the audit trail look valid and encrypted. //historical entries will show as red. } grid.Rows.Add(row); } grid.EndUpdate(); grid.ScrollToEnd(); }
private void FillGrid() { long userNum = 0; if (comboUser.SelectedIndex > 0) { userNum = UserodC.Listt[comboUser.SelectedIndex - 1].UserNum; } SecurityLog[] logList = null; if (comboPermission.SelectedIndex == 0) { logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text), Permissions.None, PatNum, userNum); } else { logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text), (Permissions)Enum.Parse(typeof(Permissions), comboPermission.SelectedItem.ToString()), PatNum, userNum); } grid.BeginUpdate(); grid.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableAudit", "Date"), 70); col.SortingStrategy = GridSortingStrategy.DateParse; grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Time"), 60); col.SortingStrategy = GridSortingStrategy.DateParse; grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Patient"), 100); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "User"), 70); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Permission"), 110); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Computer"), 70); grid.Columns.Add(col); col = new ODGridColumn(Lan.g("TableAudit", "Log Text"), 560); grid.Columns.Add(col); grid.Rows.Clear(); ODGridRow row; Userod user; for (int i = 0; i < logList.Length; i++) { row = new ODGridRow(); row.Cells.Add(logList[i].LogDateTime.ToShortDateString()); row.Cells.Add(logList[i].LogDateTime.ToShortTimeString()); row.Cells.Add(logList[i].PatientName); user = Userods.GetUser(logList[i].UserNum); //user might be null due to old bugs. if (user == null) { row.Cells.Add("unknown"); } else { row.Cells.Add(Userods.GetUser(logList[i].UserNum).UserName); } if (logList[i].PermType == Permissions.ChartModule) { row.Cells.Add("ChartModuleViewed"); } else { row.Cells.Add(logList[i].PermType.ToString()); } row.Cells.Add(logList[i].CompName); row.Cells.Add(logList[i].LogText); grid.Rows.Add(row); } grid.EndUpdate(); grid.ScrollToEnd(); }
private void FormPopupEdit_Load(object sender, EventArgs e) { Pat = Patients.GetPat(PopupCur.PatNum); textPatient.Text = Pat.GetNameLF(); if (PopupCur.IsNew) //If popup is new User is the logged-in user and create date is now. { butAudit.Visible = false; textUser.Text = Security.CurUser.UserName; textCreateDate.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); } else { if (PopupCur.UserNum != 0) //This check is so that any old popups without a user will still display correctly. { textUser.Text = Userods.GetUser(PopupCur.UserNum).UserName; } if (PopupAudit != null) //This checks if this window opened from FormPopupAudit { textCreateDate.Text = ""; if (PopupAudit.DateTimeEntry.Year > 1880) { textCreateDate.Text = PopupAudit.DateTimeEntry.ToShortDateString() + " " + PopupAudit.DateTimeEntry.ToShortTimeString(); //Sets the original creation date. } textEditDate.Text = ""; if (DateLastEdit.Year > 1880) { textEditDate.Text = DateLastEdit.ToShortDateString() + " " + DateLastEdit.ToShortTimeString(); } } else { textCreateDate.Text = ""; if (PopupCur.DateTimeEntry.Year > 1880) { textCreateDate.Text = PopupCur.DateTimeEntry.ToShortDateString() + " " + PopupCur.DateTimeEntry.ToShortTimeString(); //Sets the original creation date. } DateTime dateT = Popups.GetLastEditDateTimeForPopup(PopupCur.PopupNum); textEditDate.Text = ""; if (dateT.Year > 1880) { textEditDate.Text = dateT.ToShortDateString() + " " + dateT.ToShortTimeString(); //Sets the Edit date to the entry date of the last popup change that was archived for this popup. } } } comboPopupLevel.Items.Add(Lan.g("enumEnumPopupFamily", Enum.GetNames(typeof(EnumPopupLevel))[0])); //Patient comboPopupLevel.Items.Add(Lan.g("enumEnumPopupFamily", Enum.GetNames(typeof(EnumPopupLevel))[1])); //Family if (Pat.SuperFamily != 0) { comboPopupLevel.Items.Add(Lan.g("enumEnumPopupFamily", Enum.GetNames(typeof(EnumPopupLevel))[2])); //SuperFamily } comboPopupLevel.SelectedIndex = (int)PopupCur.PopupLevel; checkIsDisabled.Checked = PopupCur.IsDisabled; textDescription.Text = PopupCur.Description; if (PopupCur.IsArchived) { butDelete.Enabled = false; butOK.Enabled = false; comboPopupLevel.Enabled = false; checkIsDisabled.Enabled = false; textDescription.ReadOnly = true; textPatient.ReadOnly = true; } if (PopupCur.PopupNumArchive != 0) { butAudit.Visible = false; } }
private void FormTreatPlanEdit_Load(object sender, System.EventArgs e) { //this window never comes up for new TP. Always saved ahead of time. if (!Security.IsAuthorized(Permissions.TreatPlanEdit, PlanCur.DateTP)) { butOK.Enabled = false; butDelete.Enabled = false; butPickResponsParty.Enabled = false; butClearResponsParty.Enabled = false; butSigClear.Enabled = false; butDocumentDetach.Enabled = false; textHeading.ReadOnly = true; textDateTP.ReadOnly = true; textNote.ReadOnly = true; if (Security.IsAuthorized(Permissions.TreatPlanSign, PlanCur.DateTP)) //User has permission to edit the heading field. { textHeading.ReadOnly = false; butOK.Enabled = true; } } if (!Security.IsAuthorized(Permissions.TreatPlanPresenterEdit, true)) { butPickPresenter.Visible = false; } if (PlanCur.UserNumPresenter > 0) { _presenterCur = Userods.GetUser(PlanCur.UserNumPresenter); _presenterOld = _presenterCur.Copy(); textPresenter.Text = _presenterCur.UserName; } textUserEntry.Text = Userods.GetName(PlanCur.SecUserNumEntry); textDateTP.Text = PlanCur.DateTP.ToShortDateString(); textHeading.Text = PlanCur.Heading; textNote.Text = PlanCur.Note; if (PrefC.GetBool(PrefName.EasyHidePublicHealth)) { labelResponsParty.Visible = false; textResponsParty.Visible = false; butPickResponsParty.Visible = false; butClearResponsParty.Visible = false; } if (PlanCur.ResponsParty != 0) { textResponsParty.Text = Patients.GetLim(PlanCur.ResponsParty).GetNameLF(); } if (PlanCur.Signature != "") //Per Nathan 01 OCT 2015: In addition to invalidating signature (old behavior) we will also block editing signed TPs. { butOK.Enabled = false; textHeading.ReadOnly = true; textDateTP.ReadOnly = true; textNote.ReadOnly = true; butClearResponsParty.Enabled = false; butPickResponsParty.Enabled = false; butSigClear.Visible = true; butDocumentDetach.Enabled = false; } else { butSigClear.Visible = false; butSigClear.Enabled = false; } if (PlanCur.DocNum > 0) //Was set at some point in the past. { Document doc = Documents.GetByNum(PlanCur.DocNum); if (doc.DocNum == 0) { textDocument.Text = "(" + Lan.g(this, "Missing Document") + ")"; //Invalid Fkey to document.DocNum butDocumentView.Enabled = false; } else { textDocument.Text = doc.Description; if (!Documents.DocExists(doc.DocNum)) { textDocument.Text += " (" + Lan.g(this, "Unreachable File") + ")"; //Document points to unreachable file butDocumentView.Enabled = false; } } } else //hide document controls because there is no attached document { labelDocument.Visible = false; textDocument.Visible = false; butDocumentView.Visible = false; butDocumentDetach.Visible = false; } }
private void FormVaccinePatEdit_Load(object sender, EventArgs e) { Patient pat = Patients.GetLim(VaccinePatCur.PatNum); if (pat.Age != 0 && pat.Age < 3) { labelDocument.Text = "Document reason not given below. Reason can include a contraindication due to a specific allergy, adverse effect, intollerance, or specific disease."; //less leeway with reasons for kids. } _listVaccineDefs = VaccineDefs.GetDeepCopy(); comboVaccine.Items.Clear(); for (int i = 0; i < _listVaccineDefs.Count; i++) { comboVaccine.Items.Add(_listVaccineDefs[i].CVXCode + " - " + _listVaccineDefs[i].VaccineName); if (_listVaccineDefs[i].VaccineDefNum == VaccinePatCur.VaccineDefNum) { comboVaccine.SelectedIndex = i; } } if (!IsNew && VaccinePatCur.VaccineDefNum != 0) { VaccineDef vaccineDef = VaccineDefs.GetOne(VaccinePatCur.VaccineDefNum); //Need vaccine to get manufacturer. DrugManufacturer manufacturer = DrugManufacturers.GetOne(vaccineDef.DrugManufacturerNum); textManufacturer.Text = manufacturer.ManufacturerCode + " - " + manufacturer.ManufacturerName; } if (VaccinePatCur.DateTimeStart.Year > 1880) { textDateTimeStart.Text = VaccinePatCur.DateTimeStart.ToString(); } if (VaccinePatCur.DateTimeEnd.Year > 1880) { textDateTimeStop.Text = VaccinePatCur.DateTimeEnd.ToString(); } if (VaccinePatCur.AdministeredAmt != 0) { textAmount.Text = VaccinePatCur.AdministeredAmt.ToString(); } _listDrugUnits = DrugUnits.GetDeepCopy(); comboUnits.Items.Clear(); comboUnits.Items.Add("none"); comboUnits.SelectedIndex = 0; for (int i = 0; i < _listDrugUnits.Count; i++) { comboUnits.Items.Add(_listDrugUnits[i].UnitIdentifier); if (_listDrugUnits[i].DrugUnitNum == VaccinePatCur.DrugUnitNum) { comboUnits.SelectedIndex = i + 1; } } textLotNum.Text = VaccinePatCur.LotNumber; if (VaccinePatCur.DateExpire.Year > 1880) { textDateExpiration.Text = VaccinePatCur.DateExpire.ToShortDateString(); } listRefusalReason.Items.Clear(); string[] arrayVaccineRefusalReasons = Enum.GetNames(typeof(VaccineRefusalReason)); for (int i = 0; i < arrayVaccineRefusalReasons.Length; i++) { listRefusalReason.Items.Add(arrayVaccineRefusalReasons[i]); VaccineRefusalReason refusalReason = (VaccineRefusalReason)i; if (refusalReason == VaccinePatCur.RefusalReason) { listRefusalReason.SelectedIndex = i; } } listCompletionStatus.Items.Clear(); string[] arrayCompletionStatuses = Enum.GetNames(typeof(VaccineCompletionStatus)); for (int i = 0; i < arrayCompletionStatuses.Length; i++) { listCompletionStatus.Items.Add(arrayCompletionStatuses[i]); VaccineCompletionStatus completionStatus = (VaccineCompletionStatus)i; if (completionStatus == VaccinePatCur.CompletionStatus) { listCompletionStatus.SelectedIndex = i; } } textNote.Text = VaccinePatCur.Note; if (IsNew) { if (pat.ClinicNum == 0) { VaccinePatCur.FilledCity = PrefC.GetString(PrefName.PracticeCity); VaccinePatCur.FilledST = PrefC.GetString(PrefName.PracticeST); } else { Clinic clinic = Clinics.GetClinic(pat.ClinicNum); VaccinePatCur.FilledCity = clinic.City; VaccinePatCur.FilledST = clinic.State; } } textFilledCity.Text = VaccinePatCur.FilledCity; textFilledSt.Text = VaccinePatCur.FilledST; if (IsNew) { VaccinePatCur.UserNum = Security.CurUser.UserNum; } Userod user = Userods.GetUser(VaccinePatCur.UserNum); if (user != null) //Will be null for vaccines entered in older versions, before the UserNum column was created. { textUser.Text = user.UserName; } _provNumSelectedOrdering = VaccinePatCur.ProvNumOrdering; comboProvNumOrdering.Items.Clear(); _listProviders = Providers.GetDeepCopy(true); for (int i = 0; i < _listProviders.Count; i++) { comboProvNumOrdering.Items.Add(_listProviders[i].GetLongDesc()); //Only visible provs added to combobox. if (_listProviders[i].ProvNum == VaccinePatCur.ProvNumOrdering) { comboProvNumOrdering.SelectedIndex = i; //Sets combo text too. } } if (comboProvNumOrdering.SelectedIndex == -1) //The provider exists but is hidden { comboProvNumOrdering.Text = Providers.GetLongDesc(_provNumSelectedOrdering); //Appends "(hidden)" to the end of the long description. } _provNumSelectedAdministering = VaccinePatCur.ProvNumAdminister; comboProvNumAdministering.Items.Clear(); for (int i = 0; i < _listProviders.Count; i++) { comboProvNumAdministering.Items.Add(_listProviders[i].GetLongDesc()); //Only visible provs added to combobox. if (_listProviders[i].ProvNum == VaccinePatCur.ProvNumAdminister) { comboProvNumAdministering.SelectedIndex = i; //Sets combo text too. } } if (comboProvNumAdministering.SelectedIndex == -1) //The provider exists but is hidden { comboProvNumAdministering.Text = Providers.GetLongDesc(_provNumSelectedAdministering); //Appends "(hidden)" to the end of the long description. } comboAdministrationRoute.Items.Clear(); string[] arrayVaccineAdministrationRoutes = Enum.GetNames(typeof(VaccineAdministrationRoute)); for (int i = 0; i < arrayVaccineAdministrationRoutes.Length; i++) { comboAdministrationRoute.Items.Add(arrayVaccineAdministrationRoutes[i]); VaccineAdministrationRoute administrationRoute = (VaccineAdministrationRoute)i; if (administrationRoute == VaccinePatCur.AdministrationRoute) { comboAdministrationRoute.SelectedIndex = i; } } comboAdministrationSite.Items.Clear(); string[] arrayVaccineAdministrationSites = Enum.GetNames(typeof(VaccineAdministrationSite)); for (int i = 0; i < arrayVaccineAdministrationSites.Length; i++) { comboAdministrationSite.Items.Add(arrayVaccineAdministrationSites[i]); VaccineAdministrationSite administrationSite = (VaccineAdministrationSite)i; if (administrationSite == VaccinePatCur.AdministrationSite) { comboAdministrationSite.SelectedIndex = i; } } listAdministrationNote.Items.Clear(); string[] arrayAdministrationNotes = Enum.GetNames(typeof(VaccineAdministrationNote)); for (int i = 0; i < arrayAdministrationNotes.Length; i++) { listAdministrationNote.Items.Add(arrayAdministrationNotes[i]); VaccineAdministrationNote administrationNote = (VaccineAdministrationNote)i; if (administrationNote == VaccinePatCur.AdministrationNoteCode) { listAdministrationNote.SelectedIndex = i; } } listAction.Items.Clear(); string[] arrayVaccineActions = Enum.GetNames(typeof(VaccineAction)); for (int i = 0; i < arrayVaccineActions.Length; i++) { listAction.Items.Add(arrayVaccineActions[i]); VaccineAction action = (VaccineAction)i; if (action == VaccinePatCur.ActionCode) { listAction.SelectedIndex = i; } } _listVaccineObservations = VaccineObses.GetForVaccine(VaccinePatCur.VaccinePatNum); FillObservations(); }
private void FillGrid() { if (textRows.errorProvider1.GetError(textRows) != "") { MsgBox.Show(this, "Please fix data entry errors first."); return; } long userNum = 0; if (comboUser.SelectedIndex > 0) { userNum = _listUserods[comboUser.SelectedIndex - 1].UserNum; } SecurityLog[] logList = null; DateTime datePreviousFrom = PIn.Date(textDateEditedFrom.Text); DateTime datePreviousTo = DateTime.Today; if (textDateEditedTo.Text != "") { datePreviousTo = PIn.Date(textDateEditedTo.Text); } try { if (comboPermission.SelectedIndex == 0) { logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text), Permissions.None, PatNum, userNum, datePreviousFrom, datePreviousTo, checkIncludeArchived.Checked, PIn.Int(textRows.Text)); } else { logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text), (Permissions)Enum.Parse(typeof(Permissions), comboPermission.SelectedItem.ToString()), PatNum, userNum, datePreviousFrom, datePreviousTo, checkIncludeArchived.Checked, PIn.Int(textRows.Text)); } } catch (Exception ex) { FriendlyException.Show(Lan.g(this, "There was a problem refreshing the Audit Trail with the current filters."), ex); logList = new SecurityLog[0]; } grid.BeginUpdate(); grid.Columns.Clear(); grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Date"), 70, GridSortingStrategy.DateParse)); grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Time"), 60, GridSortingStrategy.DateParse)); grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Patient"), 100)); grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "User"), 70)); grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Permission"), 190)); grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Computer"), 70)); grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Log Text"), 279)); grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Last Edit"), 100)); grid.Rows.Clear(); ODGridRow row; foreach (SecurityLog logCur in logList) { row = new ODGridRow(); row.Cells.Add(logCur.LogDateTime.ToShortDateString()); row.Cells.Add(logCur.LogDateTime.ToShortTimeString()); row.Cells.Add(logCur.PatientName); //user might be null due to old bugs. row.Cells.Add(Userods.GetUser(logCur.UserNum)?.UserName ?? "unknown"); if (logCur.PermType == Permissions.ChartModule) { row.Cells.Add("ChartModuleViewed"); } else if (logCur.PermType == Permissions.FamilyModule) { row.Cells.Add("FamilyModuleViewed"); } else if (logCur.PermType == Permissions.AccountModule) { row.Cells.Add("AccountModuleViewed"); } else if (logCur.PermType == Permissions.ImagesModule) { row.Cells.Add("ImagesModuleViewed"); } else if (logCur.PermType == Permissions.TPModule) { row.Cells.Add("TreatmentPlanModuleViewed"); } else { row.Cells.Add(logCur.PermType.ToString()); } row.Cells.Add(logCur.CompName); if (logCur.PermType != Permissions.UserQuery) { row.Cells.Add(logCur.LogText); } else { //Only display the first snipet of very long queries. User can double click to view. row.Cells.Add(logCur.LogText.Left(200, true)); row.Tag = (Action)(() => { MsgBoxCopyPaste formText = new MsgBoxCopyPaste(logCur.LogText); formText.NormalizeContent(); formText.Show(); }); } if (logCur.DateTPrevious.Year < 1880) { row.Cells.Add(""); } else { row.Cells.Add(logCur.DateTPrevious.ToString()); } //Get the hash for the audit log entry from the database and rehash to compare if (logCur.LogHash != SecurityLogHashes.GetHashString(logCur)) { row.ColorText = Color.Red; //Bad hash or no hash entry at all. This prevents users from deleting the entire hash table to make the audit trail look valid and encrypted. //historical entries will show as red. } grid.Rows.Add(row); } grid.EndUpdate(); grid.ScrollToEnd(); }
private void FormPopupEdit_Load(object sender, EventArgs e) { Pat = Patients.GetPat(PopupCur.PatNum); textPatient.Text = Pat.GetNameLF(); if (PopupCur.IsNew) //If popup is new User is the logged-in user and create date is now. { butAudit.Visible = false; textUser.Text = Security.CurUser.UserName; textCreateDate.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); } else { if (PopupCur.UserNum != 0) //This check is so that any old popups without a user will still display correctly. //Display last user to edit PopupCur, or "Unknown(5)" if user not found. { textUser.Text = Userods.GetUser(PopupCur.UserNum)?.UserName ?? (Lan.g(this, "Unknown") + $"({POut.Long(PopupCur.UserNum)})"); } if (PopupAudit != null) //This checks if this window opened from FormPopupAudit { textCreateDate.Text = ""; if (PopupAudit.DateTimeEntry.Year > 1880) { textCreateDate.Text = PopupAudit.DateTimeEntry.ToShortDateString() + " " + PopupAudit.DateTimeEntry.ToShortTimeString(); //Sets the original creation date. } textEditDate.Text = ""; if (DateLastEdit.Year > 1880) { textEditDate.Text = DateLastEdit.ToShortDateString() + " " + DateLastEdit.ToShortTimeString(); } } else { textCreateDate.Text = ""; if (PopupCur.DateTimeEntry.Year > 1880) { textCreateDate.Text = PopupCur.DateTimeEntry.ToShortDateString() + " " + PopupCur.DateTimeEntry.ToShortTimeString(); //Sets the original creation date. } DateTime dateT = Popups.GetLastEditDateTimeForPopup(PopupCur.PopupNum); textEditDate.Text = ""; if (dateT.Year > 1880) { textEditDate.Text = dateT.ToShortDateString() + " " + dateT.ToShortTimeString(); //Sets the Edit date to the entry date of the last popup change that was archived for this popup. } } } comboPopupLevel.Items.Add(Lan.g("enumEnumPopupFamily", Enum.GetNames(typeof(EnumPopupLevel))[0])); //Patient comboPopupLevel.Items.Add(Lan.g("enumEnumPopupFamily", Enum.GetNames(typeof(EnumPopupLevel))[1])); //Family if (Pat.SuperFamily != 0 || PopupCur.PopupLevel == EnumPopupLevel.SuperFamily) { //Previously if a superfamily head was moved out to their own family the associated superfamily popups were incorrectly copied. //This would cause the comboPopupLevel selection logic below to error. comboPopupLevel.Items.Add(Lan.g("enumEnumPopupFamily", Enum.GetNames(typeof(EnumPopupLevel))[2])); //SuperFamily } comboPopupLevel.SelectedIndex = (int)PopupCur.PopupLevel; checkIsDisabled.Checked = PopupCur.IsDisabled; textDescription.Text = PopupCur.Description; if (!PopupCur.IsNew && PopupCur.UserNum != Security.CurUser.UserNum && !Security.IsAuthorized(Permissions.PopupEdit, true)) { butDelete.Enabled = false; comboPopupLevel.Enabled = false; textDescription.ReadOnly = true; textPatient.ReadOnly = true; labelNoPerms.Visible = true; } if (PopupCur.IsArchived) { butDelete.Enabled = false; butOK.Enabled = false; comboPopupLevel.Enabled = false; checkIsDisabled.Enabled = false; textDescription.ReadOnly = true; textPatient.ReadOnly = true; } if (PopupCur.PopupNumArchive != 0) { butAudit.Visible = false; } }