private void menuVoiceMailsRightClick_Popup(object sender, EventArgs e) { if (gridVoiceMails.SelectedCell.Y == -1 || (gridVoiceMails.ListGridColumns[gridVoiceMails.SelectedCell.X].Tag ?? "").ToString() == nameof(VoiceMail.Note)) { gridVoiceMails.ContextMenu = menuVoiceMailsRightClick; return; } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[gridVoiceMails.SelectedCell.Y].Tag; if (voiceMailCur.PatNum == 0) { menuGoToChart.Visible = false; } else { menuGoToChart.Visible = true; } if (voiceMailCur.PhoneNumber == "") { menuGoogleNum.Visible = false; } else { menuGoogleNum.Visible = true; } }
///<summary>Inserts one VoiceMail into the database. Returns the new priKey.</summary> public static long Insert(VoiceMail voiceMail) { if (DataConnection.DBtype == DatabaseType.Oracle) { voiceMail.VoiceMailNum = DbHelper.GetNextOracleKey("voicemail", "VoiceMailNum"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(voiceMail, true)); } catch (Oracle.ManagedDataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { voiceMail.VoiceMailNum++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(voiceMail, false)); } }
public static void RegenerateExtensionFiles(string extensionNumber, Domain domain) { if (!IsDomainDeployed(domain.Name)) { Log.Trace("Creating domain " + domain.Name + " to produce an extension"); RegenerateDomainFile(domain); } Extension ext = Extension.Load(extensionNumber, domain); if (ext == null) { Lock(); List <sDeployedExtension> exts = extensions; for (int x = 0; x < exts.Count; x++) { if ((exts[x].Number == extensionNumber) || (exts[x].DomainName == domain.Name)) { exts.RemoveAt(x); break; } } extensions = exts; UnLock(); _deployer.DestroyExtension(domain.Name, extensionNumber); EventController.TriggerEvent(new ExtensionDestroyedEvent(extensionNumber, domain.Name)); } else { sDeployedExtension sext = new sDeployedExtension(ext); Lock(); List <sDeployedExtension> exts = extensions; bool add = true; for (int x = 0; x < exts.Count; x++) { if ((exts[x].Number == extensionNumber) && (exts[x].DomainName == domain.Name)) { exts[x] = sext; add = false; break; } } if (add) { exts.Add(sext); } extensions = exts; UnLock(); _deployer.DeployExtension(sext); EventController.TriggerEvent(new ExtensionDeploymentEvent(sext)); Log.Trace("Config file for extension " + extensionNumber + " has been successfully created"); Extension ex = Extension.Load(extensionNumber, domain); VoiceMail vm = VoiceMail.Load(ex.Number, ex.Context); if ((vm != null) && vm.ResetVMPassword) { vm.ResetVMPassword = false; vm.Update(); } } }
///<summary>Goes to the chart module of the patient of the selected voicemail.</summary> private void GoToChart() { if (gridVoiceMails.SelectedCell.Y == -1 || gridVoiceMails.ListGridRows.Count <= gridVoiceMails.SelectedCell.Y || !Security.IsAuthorized(Permissions.ChartModule)) { return; } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[gridVoiceMails.SelectedCell.Y].Tag; GotoModule.GotoChart(voiceMailCur.PatNum); }
public sDeployedVoicemail(VoiceMail vm, string number, string domain) { _password = vm.Password; _maxMessages = vm.MaxMessage; _copyTo = null; if (vm.CopyTo != null) { _copyTo = vm.CopyTo.Number + "@" + vm.CopyTo.Domain.Name; } _email = vm.Email; _attachToEmail = vm.AttachToEmail; _number = number; _domain = domain; }
///<summary>Inserts one VoiceMail into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(VoiceMail voiceMail) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(voiceMail, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { voiceMail.VoiceMailNum = DbHelper.GetNextOracleKey("voicemail", "VoiceMailNum"); //Cacheless method } return(InsertNoCache(voiceMail, true)); } }
///<summary>Updates one VoiceMail in the database.</summary> public static void Update(VoiceMail voiceMail) { string command = "UPDATE voicemail SET " + "UserNum = " + POut.Long(voiceMail.UserNum) + ", " + "PatNum = " + POut.Long(voiceMail.PatNum) + ", " + "DateCreated = " + POut.DateT(voiceMail.DateCreated) + ", " + "Duration = " + POut.Int(voiceMail.Duration) + ", " + "FileName = '" + POut.String(voiceMail.FileName) + "', " + "PhoneNumber = '" + POut.String(voiceMail.PhoneNumber) + "', " + "StatusVM = " + POut.Int((int)voiceMail.StatusVM) + ", " + "Note = '" + POut.String(voiceMail.Note) + "', " + "DateClaimed = " + POut.DateT(voiceMail.DateClaimed) + " " + "WHERE VoiceMailNum = " + POut.Long(voiceMail.VoiceMailNum); Db.NonQ(command); }
public sDeployedExtension(Extension ext) { _domainName = ext.Domain.Name; _number = ext.Number; _password = ext.Password; _vm = null; _context = ext.Context.Name; _internalCallerID = ext.InternalCallerID; _internalCallerIDName = ext.InternalCallerIDName; _externalCallerID = ext.ExternalCallerID; _externalCallerIDName = ext.ExternalCallerIDName; _voicemailTimeout = ext.VoicemailTimeout; if (ext.HasVoicemail) { _vm = new sDeployedVoicemail(VoiceMail.Load(ext.Number, ext.Context), Number, DomainName); } }
private void CreateTask() { if (gridVoiceMails.SelectedCell.Y == -1 || gridVoiceMails.Rows.Count <= gridVoiceMails.SelectedCell.Y) { MsgBox.Show(this, "No voice mail selected"); return; } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.Rows[gridVoiceMails.SelectedCell.Y].Tag; VoiceMail voiceMailOld = voiceMailCur.Copy(); if (voiceMailCur.PatNum == 0) //Multiple patients had a match for the phone number { FormPatientSelect FormPS = new FormPatientSelect(new Patient { HmPhone = voiceMailCur.PhoneNumber }); if (FormPS.ShowDialog() != DialogResult.OK) { return; } voiceMailCur.PatNum = FormPS.SelectedPatNum; VoiceMails.Update(voiceMailCur, voiceMailOld); FillGrid(); } Task task = new Task() { TaskListNum = -1 }; //don't show it in any list yet. Tasks.Insert(task); Task taskOld = task.Copy(); task.UserNum = Security.CurUser.UserNum; task.TaskListNum = Tasks.TriageTaskListNum; task.DateTimeEntry = voiceMailCur.DateCreated; task.PriorityDefNum = Tasks.TriageBlueNum; task.ObjectType = TaskObjectType.Patient; task.KeyNum = voiceMailCur.PatNum; task.Descript = "VM " + TelephoneNumbers.AutoFormat(voiceMailCur.PhoneNumber) + " "; FormTaskEdit FormTE = new FormTaskEdit(task, taskOld); FormTE.IsNew = true; FormTE.Show(); //non-modal FormTE.BringToFront(); //The reason the below line didn't work is because popups would appear behind the task. //FormTE.TopMost=true;//For some techs, when they open a task from this window, it goes behind all the other windows. This is an attempted fix. }
///<summary>Returns true if the VM was successfully sent to self.</summary> private bool SendToMe() { if (gridVoiceMails.SelectedCell.Y == -1 || gridVoiceMails.ListGridRows.Count <= gridVoiceMails.SelectedCell.Y) { return(false); } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[gridVoiceMails.SelectedCell.Y].Tag; VoiceMail voiceMailOld = voiceMailCur.Copy(); if (voiceMailCur.UserNum == Security.CurUser.UserNum) //Trying to send a VM to themselves that is already theirs { return(true); //Save a couple trips to the database } VoiceMail voiceMailUpdated = VoiceMails.GetOne(voiceMailCur.VoiceMailNum); if (voiceMailUpdated == null || voiceMailCur.StatusVM == VoiceMailStatus.Deleted) { MsgBox.Show(this, "This voice mail has been deleted."); FillGrid(); return(false); } DateTime dateTimeNow = MiscData.GetNowDateTime(); if ((voiceMailCur.UserNum == 0 && //The tech is trying to send an unclaimed VM to themselves. voiceMailUpdated.UserNum != 0) || //Someone else has already claimed it. voiceMailUpdated.DateClaimed > dateTimeNow.AddSeconds(-8)) //Someone has claimed it in the last 8 seconds { MsgBox.Show(this, "This voice mail has just been claimed by someone else."); FillGrid(); return(false); } if (voiceMailUpdated.UserNum != 0 && !MsgBox.Show(this, MsgBoxButtons.YesNo, "This voice mail has been claimed by someone else. Are you sure you want to send it to yourself?")) { return(false); } voiceMailCur.UserNum = Security.CurUser.UserNum; voiceMailCur.DateClaimed = dateTimeNow; VoiceMails.Update(voiceMailCur, voiceMailOld); Signalods.Insert(new Signalod { IType = InvalidType.VoiceMails }); FillGrid(); return(true); }
///<summary>Returns true if a task was inserted into the DB, when true formTaskEdit is set. Otherwise null.</summary> private bool TryCreateTaskAndForm(out FormTaskEdit formTaskEdit) { formTaskEdit = null; if (gridVoiceMails.SelectedCell.Y == -1 || gridVoiceMails.ListGridRows.Count <= gridVoiceMails.SelectedCell.Y) { MsgBox.Show(this, "No voice mail selected"); return(false); } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[gridVoiceMails.SelectedCell.Y].Tag; VoiceMail voiceMailOld = voiceMailCur.Copy(); if (voiceMailCur.PatNum == 0) //Multiple patients had a match for the phone number { FormPatientSelect FormPS = new FormPatientSelect(new Patient { HmPhone = voiceMailCur.PhoneNumber }); if (FormPS.ShowDialog() != DialogResult.OK) { return(false); } voiceMailCur.PatNum = FormPS.SelectedPatNum; VoiceMails.Update(voiceMailCur, voiceMailOld); FillGrid(); } Task task = new Task() { TaskListNum = -1 }; //don't show it in any list yet. Tasks.Insert(task); Task taskOld = task.Copy(); task.UserNum = Security.CurUser.UserNum; task.TaskListNum = Tasks.TriageTaskListNum; task.DateTimeEntry = voiceMailCur.DateCreated; task.PriorityDefNum = Tasks.TriageBlueNum; task.ObjectType = TaskObjectType.Patient; task.KeyNum = voiceMailCur.PatNum; task.Descript = "VM " + TelephoneNumbers.AutoFormat(voiceMailCur.PhoneNumber) + " "; FormTaskEdit FormTE = new FormTaskEdit(task, taskOld); FormTE.IsNew = true; formTaskEdit = FormTE; return(true); }
private void gridVoiceMails_CellLeave(object sender, ODGridClickEventArgs e) { if (gridVoiceMails.ListGridColumns[e.Col].Tag.ToString() != nameof(VoiceMail.Note)) { return; } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[e.Row].Tag; VoiceMail voiceMailOld = voiceMailCur.Copy(); voiceMailCur.Note = gridVoiceMails.GetText(e.Row, e.Col); VoiceMails.Update(voiceMailCur, voiceMailOld); if (voiceMailCur.Note != voiceMailOld.Note) { Signalods.Insert(new Signalod { IType = InvalidType.VoiceMails }); } }
public override string ToString() { v = (VoiceMail)base.Tag; Binding myBinding = new Binding("boxnumber"); myBinding.Mode = BindingMode.TwoWay; myBinding.Source = v; txtbox.SetBinding(TextBox.TextProperty, myBinding); Binding myBinding2 = new Binding("context"); myBinding2.Mode = BindingMode.TwoWay; myBinding2.Source = v; txtcontext.SetBinding(TextBox.TextProperty, myBinding2); Binding myBinding3 = new Binding("flags"); myBinding3.Mode = BindingMode.TwoWay; myBinding3.Source = v; txtflags.SetBinding(TextBox.TextProperty, myBinding3); return base.ToString(); }
///<summary>Returns true if Update(VoiceMail,VoiceMail) would make changes to the database. ///Does not make any changes to the database and can be called before remoting role is checked.</summary> public static bool UpdateComparison(VoiceMail voiceMail, VoiceMail oldVoiceMail) { if (voiceMail.UserNum != oldVoiceMail.UserNum) { return(true); } if (voiceMail.PatNum != oldVoiceMail.PatNum) { return(true); } if (voiceMail.DateCreated != oldVoiceMail.DateCreated) { return(true); } if (voiceMail.Duration != oldVoiceMail.Duration) { return(true); } if (voiceMail.FileName != oldVoiceMail.FileName) { return(true); } if (voiceMail.PhoneNumber != oldVoiceMail.PhoneNumber) { return(true); } if (voiceMail.StatusVM != oldVoiceMail.StatusVM) { return(true); } if (voiceMail.Note != oldVoiceMail.Note) { return(true); } if (voiceMail.DateClaimed != oldVoiceMail.DateClaimed) { return(true); } return(false); }
private void gridVoiceMails_CellClick(object sender, ODGridClickEventArgs e) { if (e.Row == -1 || gridVoiceMails.ListGridRows.Count <= e.Row) { return; } labelError.Visible = false; VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[e.Row].Tag; labelDuration.Text = Lan.g(this, "Duration:"); if (voiceMailCur.Duration >= 60) //At least one minute long { labelDuration.Text += " " + voiceMailCur.Duration / 60 + " " + Lan.g(this, "min"); } if (voiceMailCur.Duration >= 0) { labelDuration.Text += " " + voiceMailCur.Duration % 60 + " " + Lan.g(this, "sec"); } try { if (PrefC.GetBool(PrefName.VoiceMailSMB2Enabled)) { string remoteName = Path.GetDirectoryName(voiceMailCur.FileName); using (new ODNetworkConnection(remoteName, PrefC.VoiceMailNetworkCredentialsSMB2)) { PlayVM(voiceMailCur.FileName); } } else { PlayVM(voiceMailCur.FileName); } } catch (ODException ex) { labelError.Text = ex.Message + " - Error Code: " + ex.ErrorCode; labelError.Visible = true; } catch (Exception ex) { labelError.Text = ex.Message; labelError.Visible = true; } }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <VoiceMail> TableToList(DataTable table) { List <VoiceMail> retVal = new List <VoiceMail>(); VoiceMail voiceMail; foreach (DataRow row in table.Rows) { voiceMail = new VoiceMail(); voiceMail.VoiceMailNum = PIn.Long(row["VoiceMailNum"].ToString()); voiceMail.UserNum = PIn.Long(row["UserNum"].ToString()); voiceMail.PatNum = PIn.Long(row["PatNum"].ToString()); voiceMail.DateCreated = PIn.DateT(row["DateCreated"].ToString()); voiceMail.Duration = PIn.Int(row["Duration"].ToString()); voiceMail.FileName = PIn.String(row["FileName"].ToString()); voiceMail.PhoneNumber = PIn.String(row["PhoneNumber"].ToString()); voiceMail.StatusVM = (OpenDentBusiness.VoiceMailStatus)PIn.Int(row["StatusVM"].ToString()); voiceMail.Note = PIn.String(row["Note"].ToString()); voiceMail.DateClaimed = PIn.DateT(row["DateClaimed"].ToString()); retVal.Add(voiceMail); } return(retVal); }
///<summary>Inserts one VoiceMail into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(VoiceMail voiceMail, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO voicemail ("; if (!useExistingPK && isRandomKeys) { voiceMail.VoiceMailNum = ReplicationServers.GetKeyNoCache("voicemail", "VoiceMailNum"); } if (isRandomKeys || useExistingPK) { command += "VoiceMailNum,"; } command += "UserNum,PatNum,DateCreated,Duration,FileName,PhoneNumber,StatusVM,Note,DateClaimed) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(voiceMail.VoiceMailNum) + ","; } command += POut.Long(voiceMail.UserNum) + "," + POut.Long(voiceMail.PatNum) + "," + POut.DateT(voiceMail.DateCreated) + "," + POut.Int(voiceMail.Duration) + "," + "'" + POut.String(voiceMail.FileName) + "'," + "'" + POut.String(voiceMail.PhoneNumber) + "'," + POut.Int((int)voiceMail.StatusVM) + "," + "'" + POut.String(voiceMail.Note) + "'," + POut.DateT(voiceMail.DateClaimed) + ")"; if (useExistingPK || isRandomKeys) { Db.NonQ(command); } else { voiceMail.VoiceMailNum = Db.NonQ(command, true, "VoiceMailNum", "voiceMail"); } return(voiceMail.VoiceMailNum); }
private void butDelete_Click(object sender, EventArgs e) { if (gridVoiceMails.SelectedCell.Y == -1 || gridVoiceMails.ListGridRows.Count <= gridVoiceMails.SelectedCell.Y) { MsgBox.Show(this, "No voice mail selected"); return; } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[gridVoiceMails.SelectedCell.Y].Tag; if (voiceMailCur.StatusVM == VoiceMailStatus.Deleted) { MsgBox.Show(this, "Voice mail is already deleted."); return; } //Check if the voice mail has been altered by another user before we delete it. VoiceMail voiceMailDb = VoiceMails.GetOne(voiceMailCur.VoiceMailNum); if (voiceMailCur.UserNum != voiceMailDb.UserNum || voiceMailCur.PatNum != voiceMailDb.PatNum || voiceMailCur.StatusVM != voiceMailDb.StatusVM || voiceMailCur.FileName != voiceMailDb.FileName) { MsgBox.Show(this, "Another user has modified this voice mail."); FillGrid(); return; } try { VoiceMails.Archive(voiceMailCur); } catch (Exception ex) { MessageBox.Show(Lan.g(this, "Unable to archive deleted voice mail:") + "\r\n" + ex.Message); return; } axWindowsMediaPlayer.close(); //No need to keep playing a deleted message. FillGrid(); }
private void menuGoogleNum_Click(object sender, EventArgs e) { if (gridVoiceMails.SelectedCell.Y == -1 || gridVoiceMails.ListGridRows.Count <= gridVoiceMails.SelectedCell.Y) { return; } VoiceMail voiceMailCur = (VoiceMail)gridVoiceMails.ListGridRows[gridVoiceMails.SelectedCell.Y].Tag; string number = voiceMailCur.PhoneNumber; //The numbers are often represented with a leading 1, ex: 15033635432. Google searches generally yield better results without the leading 1. //If the number is a standard length (11 digits) and it starts with a 1, strip the leading 1. if (number.Length == 11 && number[0] == '1') { number = number.Right(10); } string url = @"https://www.google.com/search?q=" + number; try { Process.Start(url); } catch (Exception ex) { ex.DoNothing(); } }
public override string ToString() { v = (VoiceMail)base.Tag; Binding myBinding = new Binding("boxnumber"); myBinding.Mode = BindingMode.TwoWay; myBinding.Source = v; txtbox.SetBinding(TextBox.TextProperty, myBinding); Binding myBinding2 = new Binding("context"); myBinding2.Mode = BindingMode.TwoWay; myBinding2.Source = v; txtcontext.SetBinding(TextBox.TextProperty, myBinding2); Binding myBinding3 = new Binding("flags"); myBinding3.Mode = BindingMode.TwoWay; myBinding3.Source = v; txtflags.SetBinding(TextBox.TextProperty, myBinding3); return(base.ToString()); }
///<summary>Updates one VoiceMail in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(VoiceMail voiceMail, VoiceMail oldVoiceMail) { string command = ""; if (voiceMail.UserNum != oldVoiceMail.UserNum) { if (command != "") { command += ","; } command += "UserNum = " + POut.Long(voiceMail.UserNum) + ""; } if (voiceMail.PatNum != oldVoiceMail.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(voiceMail.PatNum) + ""; } if (voiceMail.DateCreated != oldVoiceMail.DateCreated) { if (command != "") { command += ","; } command += "DateCreated = " + POut.DateT(voiceMail.DateCreated) + ""; } if (voiceMail.Duration != oldVoiceMail.Duration) { if (command != "") { command += ","; } command += "Duration = " + POut.Int(voiceMail.Duration) + ""; } if (voiceMail.FileName != oldVoiceMail.FileName) { if (command != "") { command += ","; } command += "FileName = '" + POut.String(voiceMail.FileName) + "'"; } if (voiceMail.PhoneNumber != oldVoiceMail.PhoneNumber) { if (command != "") { command += ","; } command += "PhoneNumber = '" + POut.String(voiceMail.PhoneNumber) + "'"; } if (voiceMail.StatusVM != oldVoiceMail.StatusVM) { if (command != "") { command += ","; } command += "StatusVM = " + POut.Int((int)voiceMail.StatusVM) + ""; } if (voiceMail.Note != oldVoiceMail.Note) { if (command != "") { command += ","; } command += "Note = '" + POut.String(voiceMail.Note) + "'"; } if (voiceMail.DateClaimed != oldVoiceMail.DateClaimed) { if (command != "") { command += ","; } command += "DateClaimed = " + POut.DateT(voiceMail.DateClaimed) + ""; } if (command == "") { return(false); } command = "UPDATE voicemail SET " + command + " WHERE VoiceMailNum = " + POut.Long(voiceMail.VoiceMailNum); Db.NonQ(command); return(true); }
///<summary>Inserts one VoiceMail into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(VoiceMail voiceMail) { return(InsertNoCache(voiceMail, false)); }
public VoipPhone UpdateSettings(string numberId, string greeting, string holdUp, string wait, VoiceMail voiceMail, WorkingHours workingHours, bool?allowOutgoingCalls, bool?record, string alias) { if (!CRMSecurity.IsAdmin) { throw CRMSecurity.CreateSecurityException(); } var dao = DaoFactory.GetVoipDao(); var number = dao.GetNumber(numberId).NotFoundIfNull(); number.Alias = Update.IfNotEmptyAndNotEquals(number.Alias, alias); number.Settings.GreetingAudio = Update.IfNotEmptyAndNotEquals(number.Settings.GreetingAudio, greeting); number.Settings.HoldAudio = Update.IfNotEmptyAndNotEquals(number.Settings.HoldAudio, holdUp); number.Settings.VoiceMail = Update.IfNotEmptyAndNotEquals(number.Settings.VoiceMail, voiceMail); number.Settings.WorkingHours = Update.IfNotEmptyAndNotEquals(number.Settings.WorkingHours, workingHours); if (!string.IsNullOrEmpty(wait)) { number.Settings.Queue.WaitUrl = wait; } if (allowOutgoingCalls.HasValue) { number.Settings.AllowOutgoingCalls = allowOutgoingCalls.Value; if (!number.Settings.AllowOutgoingCalls) { number.Settings.Operators.ForEach(r => r.AllowOutgoingCalls = false); } } if (record.HasValue) { number.Settings.Record = record.Value; if (!number.Settings.Record) { number.Settings.Operators.ForEach(r => r.Record = false); } } dao.SaveOrUpdateNumber(number); return(number); }
private void FillGrid() { labelError.Visible = false; List <VoiceMail> listVoiceMails = VoiceMails.GetAll(includeDeleted: checkShowDeleted.Checked).OrderBy(x => x.UserNum > 0) //Show unclaimed VMs first .ThenBy(x => x.DateCreated).ToList(); //Show oldest VMs on top VoiceMail voiceMailSelected = null; int selectedCellX = gridVoiceMails.SelectedCell.X; string changedNoteText = null; //If this value is null, then the note has not been changed by the user. if (gridVoiceMails.SelectedCell.Y > -1) { voiceMailSelected = (VoiceMail)gridVoiceMails.ListGridRows[gridVoiceMails.SelectedCell.Y].Tag; changedNoteText = gridVoiceMails.GetText(gridVoiceMails.SelectedCell.Y, gridVoiceMails.ListGridColumns.GetIndex(Lan.g(this, "Note"))); if (changedNoteText == voiceMailSelected.Note) { changedNoteText = null; //To indicate that it has not been changed. } } gridVoiceMails.BeginUpdate(); gridVoiceMails.ListGridColumns.Clear(); GridColumn col; col = new GridColumn(Lan.g(this, "Date Time"), 120); gridVoiceMails.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Phone #"), 105); gridVoiceMails.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "Patient"), 200); gridVoiceMails.ListGridColumns.Add(col); col = new GridColumn(Lan.g(this, "User"), 90); gridVoiceMails.ListGridColumns.Add(col); if (checkShowDeleted.Checked) { col = new GridColumn(Lan.g(this, "Deleted"), 60, HorizontalAlignment.Center); gridVoiceMails.ListGridColumns.Add(col); } col = new GridColumn(Lan.g(this, "Note"), 200, true); col.Tag = nameof(VoiceMail.Note); gridVoiceMails.ListGridColumns.Add(col); gridVoiceMails.ListGridRows.Clear(); GridRow row; foreach (VoiceMail voiceMail in listVoiceMails) { row = new GridRow(); row.Cells.Add(voiceMail.DateCreated.ToShortDateString() + " " + voiceMail.DateCreated.ToShortTimeString()); string phoneField = TelephoneNumbers.AutoFormat(voiceMail.PhoneNumber); if (string.IsNullOrEmpty(phoneField)) { phoneField = Lan.g(this, "Unknown"); } row.Cells.Add(phoneField); row.Cells.Add(voiceMail.PatientName); row.Cells.Add(voiceMail.UserName); if (checkShowDeleted.Checked) { row.Cells.Add(voiceMail.StatusVM == VoiceMailStatus.Deleted ? "X" : ""); } row.Cells.Add(voiceMail.Note); row.Tag = voiceMail; gridVoiceMails.ListGridRows.Add(row); } gridVoiceMails.EndUpdate(); //Reselect the selected row if necessary if (voiceMailSelected != null) { for (int i = 0; i < gridVoiceMails.ListGridRows.Count; i++) { if (((VoiceMail)gridVoiceMails.ListGridRows[i].Tag).VoiceMailNum == voiceMailSelected.VoiceMailNum) { gridVoiceMails.SetSelected(new Point(selectedCellX, i)); if (changedNoteText != null) //The user has changed the note. { gridVoiceMails.ListGridRows[i].Cells[gridVoiceMails.ListGridColumns.GetIndex(Lan.g(this, "Note"))].Text = changedNoteText; } } } } }