示例#1
0
        private void ValidPhone_TextChanged(object sender, System.EventArgs e)
        {
            if (sender.GetType() != typeof(ValidPhone))
            {
                return;
            }
            if (!IsFormattingEnabled)
            {
                return;
            }
            ValidPhone textPhone     = (ValidPhone)sender;
            string     formattedText = TelephoneNumbers.AutoFormat(textPhone.Text);

            if (textPhone.Text == formattedText)
            {
                return;
            }
            //If there are characters that get removed from calling AutoFormat (i.e. spaces) and the cursor was at the start (which happens if/when the
            //ValidPhone control initially gets filled with a value) the calculated new selection start index would be an invalid value, so Max with 0.
            //Move cursor forward the difference in text length, i.e. if this adds a '(' character, move the cursor ahead one index.
            int newSelectionStartPosition = Math.Max(textPhone.SelectionStart + formattedText.Length - textPhone.Text.Length, 0);

            //remove this event handler from the TextChanged event so that setting the text here doesn't cause this to run again
            textPhone.TextChanged -= ValidPhone_TextChanged;
            textPhone.Text         = formattedText;
            //add this event handler back to the TextChanged event
            textPhone.TextChanged   += ValidPhone_TextChanged;
            textPhone.SelectionStart = newSelectionStartPosition;
        }
示例#2
0
        private void textPhone_TextChanged(object sender, System.EventArgs e)
        {
            int cursor = textPhone.SelectionStart;
            int length = textPhone.Text.Length;

            textPhone.Text = TelephoneNumbers.AutoFormat(textPhone.Text);
            if (textPhone.Text.Length > length)
            {
                cursor++;
            }
            textPhone.SelectionStart = cursor;
        }
        private void textAnyPhone_TextChanged(object sender, System.EventArgs e)
        {
            if (sender.GetType() != typeof(TextBox))
            {
                return;
            }
            TextBox textPhone         = (TextBox)sender;
            int     phoneTextPosition = textPhone.SelectionStart;
            int     textLength        = textPhone.Text.Length;

            textPhone.Text = TelephoneNumbers.AutoFormat(textPhone.Text);
            int diff = textPhone.Text.Length - textLength;

            textPhone.SelectionStart = phoneTextPosition + diff;
        }
示例#4
0
        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.
        }
示例#5
0
        ///<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 listOther_DoubleClick(object sender, EventArgs e)
        {
            int index = listOther.SelectedIndex;

            if (index == -1)
            {
                return;
            }
            InputBox input = new InputBox("Phone Number");

            input.textResult.Text = otherList[index].PhoneNumberVal;
            input.ShowDialog();
            if (input.DialogResult != DialogResult.OK)
            {
                return;
            }
            otherList[index].PhoneNumberVal = TelephoneNumbers.AutoFormat(input.textResult.Text);
            PhoneNumbers.Update(otherList[index]);
            FillList();
        }
示例#7
0
        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;
                        }
                    }
                }
            }
        }