Beispiel #1
0
 private void butImport_Click(object sender, EventArgs e)
 {
     try {
         using (OpenFileDialog openDialog = ImportDialogSetup()) {
             if (openDialog.ShowDialog() != DialogResult.OK)
             {
                 return;                         //User cancelled out of OpenFileDialog
             }
             string fileContents          = File.ReadAllText(openDialog.FileName);
             TransferableAutoNotes import = JsonConvert.DeserializeObject <TransferableAutoNotes>(fileContents);
             AutoNoteControls.RemoveDuplicatesFromList(import.AutoNoteControls, import.AutoNotes);
             AutoNoteControls.InsertBatch(import.AutoNoteControls);
             AutoNotes.InsertBatch(import.AutoNotes);
             DataValid.SetInvalid(InvalidType.AutoNotes);
             AutoNoteL.FillListTree(treeNotes, _userOdCurPref);
             SecurityLogs.MakeLogEntry(Permissions.AutoNoteQuickNoteEdit, 0,
                                       $"Auto Note Import. {import.AutoNotes.Count} new Auto Notes, {import.AutoNoteControls.Count} new Prompts");
             MsgBox.Show(Lans.g(this, "Auto Notes successfully imported!") + "\r\n" + import.AutoNotes.Count + " " + Lans.g(this, "new Auto Notes")
                         + "\r\n" + import.AutoNoteControls.Count + " " + Lans.g(this, "new Prompts"));
         }
     }
     catch (Exception err) {
         FriendlyException.Show(Lans.g(this, "Auto Note(s) failed to import."), err);
     }
 }
		///<summary>Refreshes the email preview pane to show the web browser when viewing HTML and the editable text if not.</summary>
		public void RefreshView(bool isHtml,bool isRawHtml) {
			if(_hasMessageTextChanged && isHtml) {//only translate if attempting to see an HTML view. Regular text emails allowed to have 'invalid' characters
				try {
					if(isRawHtml) {
						HtmlText=textBodyText.Text;
					}
					else {
						HtmlText=MarkupEdit.TranslateToXhtml(textBodyText.Text,false,false,true);//do not aggregate for RAW HTML
					}
					_hasMessageTextChanged=false;
				}
				catch(Exception ex) {
					FriendlyException.Show("Error loading HTML.",ex);
				}
			}
			if(isHtml) {
				InitializeHtmlEmail();
			}
			else {
				//load the plain text
				webBrowser.Visible=false;
				textBodyText.Visible=true;
				textBodyText.BringToFront();
			}
		}
Beispiel #3
0
        private void butHideUnused_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Hide fee schedules that are not in use by insurance plans, patients, or providers?\r\n"
                             + "A backup of the database will be made first."))
            {
                return;
            }
            bool   hasChanged     = FeeScheds.Sync(_listFeeScheds, _listFeeSchedsOld);
            Action actionProgress = ODProgress.Show(ODEventType.HideUnusedFeeSchedules, startingMessage: Lans.g(this, "Backing up database..."));

            try {
                MiscData.MakeABackup();
            }
            catch (Exception ex) {
                actionProgress?.Invoke();
                FriendlyException.Show(Lans.g(this, "Unable to make a backup. No fee schedules have been altered."), ex);
                return;
            }
            ODEvent.Fire(ODEventType.HideUnusedFeeSchedules, Lans.g(this, "Hiding unused fee schedules..."));
            long countChanged = FeeScheds.HideUnusedScheds();

            if (hasChanged || countChanged > 0)
            {
                DataValid.SetInvalid(InvalidType.FeeScheds);
            }
            actionProgress?.Invoke();
            MessageBox.Show(countChanged.ToString() + " " + Lans.g(this, "unused fee schedules hidden."));
            _listFeeScheds    = FeeScheds.GetDeepCopy(_isSelectionMode);
            _listFeeSchedsOld = _listFeeScheds.Select(x => x.Copy()).ToList();
            FillGrid();
        }
Beispiel #4
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            _pagesPrinted = 0;
            PrintDocument pd = new PrintDocument();

            pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
            pd.DefaultPageSettings.Margins   = new Margins(25, 25, 40, 40);
            pd.DefaultPageSettings.Landscape = true;
            if (pd.DefaultPageSettings.PrintableArea.Height == 0)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
            }
            _headingPrinted = false;
            try {
#if DEBUG
                FormRpPrintPreview pView = new FormRpPrintPreview();
                pView.printPreviewControl2.Document = pd;
                pView.ShowDialog();
#else
                if (PrinterL.SetPrinter(pd, PrintSituation.Default, 0, "Incomplete Procedure Notes report printed"))
                {
                    pd.Print();
                }
#endif
            }
            catch (Exception ex) {
                FriendlyException.Show(Lan.g(this, "Printer not available"), ex);
            }
        }
Beispiel #5
0
 private void FormFeeSchedules_FormClosing(object sender, FormClosingEventArgs e)
 {
     //When user rearranges while using Type filters _listFeeSched has not been sorted by item order yet, see FillGrid(...)
     _listFeeScheds.Sort(CompareItemOrder);
     //Renumber itemorder for the entire list before closing, this is defensive to prevent duplicate itemorder values
     //Changes in the form using Up and Down affect ListFeeScheds, so the order of the list is the order that the user made.
     for (int i = 0; i < _listFeeScheds.Count; i++)
     {
         if (_listFeeScheds[i].ItemOrder != i)
         {
             _listFeeScheds[i].ItemOrder = i;
         }
     }
     try {
         //Only send a signal if changes were made during the sync.  Changes can't be made if in selection mode.
         if (!_isSelectionMode && FeeScheds.Sync(_listFeeScheds, _listFeeSchedsOld))
         {
             DataValid.SetInvalid(InvalidType.FeeScheds);
         }
     }
     catch (Exception ex) {
         string errMsg = Lans.g(this, "Error saving fee schedules.");
         if (ex is System.Web.Services.Protocols.SoapException && RemotingClient.RemotingRole == RemotingRole.ClientWeb)
         {
             //Middle tier users can get this error when their payload is too large. This is done rare enough we can ask them to do a direct connect.
             errMsg += " " + Lans.g(this, "Try making a direct connection to the database and performing this action again.");
         }
         FriendlyException.Show(errMsg, ex);
     }
 }
 private void FillGrid()
 {
     ODProgress.ShowAction(
         () => {
         RefreshReport();
         gridMain.BeginUpdate();
         if (gridMain.ListGridColumns.Count == 0)
         {
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Patient"), _colWidthPatName, GridSortingStrategy.StringCompare));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Date"), _colWidthProcDate, HorizontalAlignment.Center, GridSortingStrategy.DateParse));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Code"), _colWidthProcCode, GridSortingStrategy.StringCompare));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Tth"), _colWidthProcTth, GridSortingStrategy.StringCompare));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Prov"), _colWidthProv, GridSortingStrategy.StringCompare));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Fee"), _colWidthFee, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Ins Paid"), _colWidthInsPay, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Write-off"), _colWidthWO, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Pt Paid"), _colWidthPtPaid, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Adjust"), _colWidthAdj, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
             gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Overpayment"), _colWidthOverpay, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
         }
         gridMain.ListGridRows.Clear();
         GridRow row;
         for (int i = 0; i < _myReport.ReportObjects.Count; i++)
         {
             if (_myReport.ReportObjects[i].ObjectType != ReportObjectType.QueryObject)
             {
                 continue;
             }
             QueryObject queryObj = (QueryObject)_myReport.ReportObjects[i];
             for (int j = 0; j < queryObj.ReportTable.Rows.Count; j++)
             {
                 DataRow rowCur = queryObj.ReportTable.Rows[j];
                 row            = new GridRow();
                 row.Cells.Add(rowCur["patientName"].ToString());
                 row.Cells.Add(PIn.Date(rowCur["ProcDate"].ToString()).ToShortDateString());
                 row.Cells.Add(PIn.String(rowCur["ProcCode"].ToString()));
                 row.Cells.Add(PIn.String(rowCur["ToothNum"].ToString()));
                 row.Cells.Add(PIn.String(rowCur["Abbr"].ToString()));
                 row.Cells.Add(PIn.Double(rowCur["fee"].ToString()).ToString("c"));
                 row.Cells.Add(PIn.Double(rowCur["insPaid"].ToString()).ToString("c"));
                 row.Cells.Add(PIn.Double(rowCur["wo"].ToString()).ToString("c"));
                 row.Cells.Add(PIn.Double(rowCur["ptPaid"].ToString()).ToString("c"));
                 row.Cells.Add(PIn.Double(rowCur["adjAmt"].ToString()).ToString("c"));
                 row.Cells.Add(PIn.Double(rowCur["overpay"].ToString()).ToString("c"));
                 row.Tag = rowCur;
                 gridMain.ListGridRows.Add(row);
             }
         }
         gridMain.EndUpdate();
     },
         startingMessage: "Refreshing Grid...",
         actionException: e => this.Invoke(() => {
         FriendlyException.Show(Lan.g(this, "Error filling the Procedures Overpaid grid."), e);
     })
         );
 }
        private void butEditTemplate_Click(object sender, System.EventArgs e)
        {
#if !DISABLE_MICROSOFT_OFFICE
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur    = ListForCat[listLetters.SelectedIndex];
            string      templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.TemplateName);
            string      dataFile     = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.DataFileName);
            if (!File.Exists(templateFile))
            {
                MessageBox.Show(Lan.g(this, "Template file does not exist:") + "  " + templateFile);
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            //Create an instance of Word.
            Word.Application WrdApp;
            try {
                WrdApp = LetterMerges.WordApp;
            }
            catch (Exception ex) {
                FriendlyException.Show(Lan.g(this, "Error. Is MS Word installed?"), ex);
                return;
            }
            //Open a document.
            Object oName = templateFile;
            wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdDoc.Select();
            //Attach the data file.
            wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            //At this point, Word remains open with just one new document.
            if (WrdApp.WindowState == Word.WdWindowState.wdWindowStateMinimize)
            {
                WrdApp.WindowState = Word.WdWindowState.wdWindowStateMaximize;
            }
            wrdDoc = null;
#else
            MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
#endif
        }
Beispiel #8
0
        private void DownloadAndStartMSI(string updateCode)
        {
            if (IsDynamicMode())
            {
                return;
            }
            string fileName = PrefC.GetString(PrefName.UpdateWebsitePath) + updateCode + "/OpenDental.msi";

            try {
                Process.Start(fileName);
            }
            catch (Exception ex) {
                FriendlyException.Show(Lan.g(this, "There was a problem launching") + " " + fileName, ex);
            }
        }
Beispiel #9
0
 private void butArchive_Click(object sender, EventArgs e)
 {
     #region Validation
     if (checkArchiveDoBackupFirst.Checked)              //We only need to validate the backup settings if the user wants to make a backup first
     {
         if (!MsgBox.Show(MsgBoxButtons.YesNo, "To make a backup of the database, ensure no other machines are currently using OpenDental. Proceed?"))
         {
             return;
         }
         //Validation
         if (string.IsNullOrWhiteSpace(textArchiveServerName.Text))
         {
             MsgBox.Show(this, "Please specify a Server Name.");
             return;
         }
         if (string.IsNullOrWhiteSpace(textArchiveUser.Text))
         {
             MsgBox.Show(this, "Please enter a User.");
             return;
         }
         if (string.IsNullOrWhiteSpace(PrefC.GetString(PrefName.ArchiveKey)))                 //If archive key isn't set, generate a new one.
         {
             string archiveKey = MiscUtils.CreateRandomAlphaNumericString(10);
             Prefs.UpdateString(PrefName.ArchiveKey, archiveKey);
         }
     }
     #endregion
     //Create an ODProgress
     ODProgress.ShowAction(() => {
         //Make a backup if needed
         if (checkArchiveDoBackupFirst.Checked)
         {
             try {
                 MiscData.MakeABackup(textArchiveServerName.Text, textArchiveUser.Text, textArchivePass.Text, doVerify: true);
             }
             catch (Exception ex) {
                 FriendlyException.Show("An error occurred backing up the old database. Old data was not removed from the database. " +
                                        "Ensure no other machines are currently using OpenDental and try again.", ex);
                 return;
             }
         }
         //Delete the unnecessary data
         SecurityLogs.DeleteBeforeDateInclusive(dateTimeArchive.Value);
         SecurityLogs.MakeLogEntry(Permissions.Backup, 0, $"SecurityLog and SecurityLogHashes on/before {dateTimeArchive.Value} deleted.");
     },
                           eventType: typeof(MiscDataEvent),
                           odEventType: ODEventType.MiscData);
 }
 ///<summary>Refreshes the email preview pane to show the web browser when viewing HTML and the editable text if not.</summary>
 public void ChangeView(bool isHtml)
 {
     if (_hasTextChanged)
     {
         //plain text box changed, grab the new plain text string and translate into html, regardless of if this is currently an html message or not.
         try {
             string htmlText = "";
             if (_isRaw)
             {
                 htmlText      = textBodyText.Text;
                 _htmlDocument = htmlText;
             }
             else
             {
                 //handle aggregation of the full document text with the template ourselves so we can display properly but only save the html string.
                 htmlText      = MarkupEdit.TranslateToXhtml(textBodyText.Text, false, false, true, false);
                 _htmlDocument = PrefC.GetString(PrefName.EmailMasterTemplate).Replace("@@@body@@@", htmlText);
             }
             _hasTextChanged = false;
         }
         catch (Exception ex) {
             FriendlyException.Show("Error loading HTML.", ex);
         }
     }
     if (isHtml || _isRaw)
     {
         try {
             textBodyText.Visible        = false;
             webBrowserHtml.Visible      = true;
             webBrowserHtml.Location     = textBodyText.Location;
             webBrowserHtml.Size         = textBodyText.Size;
             webBrowserHtml.Anchor       = textBodyText.Anchor;
             webBrowserHtml.DocumentText = _htmlDocument;
             webBrowserHtml.BringToFront();
         }
         catch (Exception ex) {
             ex.DoNothing();
             //invalid preview
         }
     }
     else
     {
         //load the plain text
         webBrowserHtml.Visible = false;
         textBodyText.Visible   = true;
         textBodyText.BringToFront();
     }
 }
Beispiel #11
0
 private void butNew_Click(object sender, System.EventArgs e)
 {
                 #if DISABLE_MICROSOFT_OFFICE
     MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
     return;
                 #endif
     if (!Directory.Exists(PrefC.GetString(PrefName.LetterMergePath)))
     {
         MsgBox.Show(this, "Letter merge path invalid");
         return;
     }
     if (textTemplateName.Text == "")
     {
         MsgBox.Show(this, "Please enter a template file name first.");
         return;
     }
     string templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), textTemplateName.Text);
     if (File.Exists(templateFile))
     {
         MsgBox.Show(this, "A file with that name already exists.  Choose a different name, or close this window to edit the template.");
         return;
     }
     Object oMissing = System.Reflection.Missing.Value;
     Object oFalse   = false;
     //Create an instance of Word.
     Word.Application WrdApp;
     try{
         WrdApp = LetterMerges.WordApp;
     }
     catch (Exception ex) {
         FriendlyException.Show(Lan.g(this, "Error. Is MS Word installed?"), ex);
         return;
     }
     //Create a new document.
     Object         oName = templateFile;
     Word._Document wrdDoc;
     wrdDoc = WrdApp.Documents.Add(ref oMissing, ref oMissing, ref oMissing,
                                   ref oMissing);
     wrdDoc.SaveAs(ref oName, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                   ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                   ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
     wrdDoc.Saved = true;
     wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
     WrdApp.WindowState = Word.WdWindowState.wdWindowStateMinimize;
     wrdDoc             = null;
     MsgBox.Show(this, "Done. You can edit the new template after closing this window.");
 }
Beispiel #12
0
 private void checkDomainLoginEnabled_MouseUp(object sender, MouseEventArgs e)
 {
     if (checkDomainLoginEnabled.Checked && string.IsNullOrWhiteSpace(textDomainLoginPath.Text))
     {
         if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Would you like to use your current domain as the domain login path?"))
         {
             try {
                 DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE");
                 string         defaultNamingContext = rootDSE.Properties["defaultNamingContext"].Value.ToString();
                 textDomainLoginPath.Text = "LDAP://" + defaultNamingContext;
             }
             catch (Exception ex) {
                 FriendlyException.Show(Lan.g(this, "Unable to bind to the current domain."), ex);
             }
         }
     }
 }
Beispiel #13
0
 ///<summary>Returns true when the ImageStore was able to find or create a patient folder for the selected patient.  Sets patFolder to the corresponding folder name.
 ///Otherwise, displays an error message to the user (with additional details regarding what went wrong) and returns false.
 ///Optionally set isFormClosedOnError false if the DialogResult should not be set to Abort and the current window closed.</summary>
 private bool TryGetPatientFolder(out string patFolder, bool isFormClosedOnError = true)
 {
     patFolder = "";
     try {
         patFolder = ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath());
     }
     catch (Exception ex) {
         FriendlyException.Show(ex.Message, ex);
         if (isFormClosedOnError)
         {
             this.DialogResult = DialogResult.Abort;
             this.Close();
         }
         return(false);
     }
     return(true);
 }
        ///<summary></summary>
        private void TransferUnallocatedToUnearned()
        {
            List <PaySplit> listSplitsForPats = PaySplits.GetForPats(_listFamilyPatNums);

            if (listSplitsForPats.IsNullOrEmpty())
            {
                return;
            }
            //Pass in an invalid payNum of 0 which will get set correctly later if there are in fact splits to transfer.
            PaymentEdit.IncomeTransferData unallocatedTransfers = PaymentEdit.TransferUnallocatedSplitToUnearned(listSplitsForPats, 0);
            if (unallocatedTransfers.ListSplitsCur.Count == 0)
            {
                return;
            }
            if (!unallocatedTransfers.ListSplitsCur.Sum(x => x.SplitAmt).IsZero())
            {
                //Display the UnearnedType and the SplitAmt for each split in the list.
                string splitInfo = string.Join("\r\n  ", unallocatedTransfers.ListSplitsCur
                                               .Select(x => $"SplitAmt: {x.SplitAmt}"));
                //Show the sum of all splits first and then give a breakdown of each individual split.
                string details = $"Sum of unallocatedTransfers.ListSplitsCur: {unallocatedTransfers.ListSplitsCur.Sum(x => x.SplitAmt)}\r\n"
                                 + $"Individual Split Info:\r\n  {splitInfo}";
                FriendlyException.Show("Error transferring unallocated paysplits.  Please call support.", new ApplicationException(details), "Close");
                //Close the window and do not let the user create transfers because something is wrong.
                DialogResult = DialogResult.Cancel;
                Close();
                return;
            }
            //There are unallocated paysplits that need to be transferred to unearned.
            _unallocatedPayNum = PaymentEdit.CreateAndInsertUnallocatedPayment(_patCur);
            foreach (PaySplit split in unallocatedTransfers.ListSplitsCur)
            {
                split.PayNum = _unallocatedPayNum;              //Set the PayNum because it was purposefully set to 0 above to save queries.
                PaySplits.Insert(split);
            }
            foreach (PaySplits.PaySplitAssociated splitAssociated in unallocatedTransfers.ListSplitsAssociated)
            {
                if (splitAssociated.PaySplitLinked != null && splitAssociated.PaySplitOrig != null)
                {
                    PaySplits.UpdateFSplitNum(splitAssociated.PaySplitOrig.SplitNum, splitAssociated.PaySplitLinked.SplitNum);
                }
            }
            SecurityLogs.MakeLogEntry(Permissions.PaymentCreate, _patCur.PatNum
                                      , $"Unallocated splits automatically transferred to unearned for payment {_unallocatedPayNum}.");
        }
        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();
        }
Beispiel #16
0
        private void butStartListenerService_Click(object sender, EventArgs e)
        {
            //No setup permission check here so that anyone can hopefully get the service back up and running.
            //Check to see if the service started up on its own while we were in this window.
            if (FillTextListenerServiceStatus() == eServiceSignalSeverity.Working)
            {
                //Use a slightly different message than below so that we can easily tell which part of this method customers reached.
                MsgBox.Show(this, "Listener Service already started.  Please call us for support if eServices are still not working.");
                return;
            }
            //Check to see if the listener service is installed on this computer.
            List <ServiceController> listEConnectorServices;

            try {
                listEConnectorServices = ServicesHelper.GetServicesByRegistryImagePath("OpenDentalEConnector.exe");
            }
            catch (Exception ex) {
                string error = Lan.g(this, "There was an problem starting eConnector Services.  Try running eConnector in administrator "
                                     + "mode or manually start the services.");
                FriendlyException.Show(error, ex);
                return;
            }
            if (listEConnectorServices.Count == 0)
            {
                MsgBox.Show(this, "eConnector Service not found on this computer.  The service can only be started from the computer that is hosting eServices.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            string serviceErrors = ServicesHelper.StartServices(listEConnectorServices);

            Cursor = Cursors.Default;
            if (!string.IsNullOrEmpty(serviceErrors))
            {
                string error = Lan.g(this, "There was a problem starting eConnector Services.  Please go manually start the following eConnector Services")
                               + ":\r\n" + serviceErrors;
                MessageBox.Show(error);
            }
            else
            {
                MsgBox.Show(this, "eConnector Services Started.");
            }
            FillTextListenerServiceStatus();
            FillGridListenerService();
        }
 private void FormPrinterSetup_Load(object sender, System.EventArgs e)
 {
     PrinterSettings.StringCollection installedPrinters = null;
     try {
         installedPrinters = PrinterSettings.InstalledPrinters;
     }
     catch (Exception ex) {           //do not let the window open if printers cannot be accessed
         FriendlyException.Show(Lan.g(this, "Unable to access installed printers."), ex);
         DialogResult = DialogResult.Cancel;
         return;
     }
     checkSimple.Checked = PrefC.GetBool(PrefName.EasyHidePrinters);
     SetSimple();
     SetControls(this, installedPrinters);
     if (Clinics.IsMedicalPracticeOrClinic(Clinics.ClinicNum))
     {
         labelTPandPerio.Text = Lan.g(this, "Treatment Plans");
     }
 }
 private void TransferClaimsPayAsTotal()
 {
     ClaimProcs.FixClaimsNoProcedures(_listFamilyPatNums);
     if (!ProcedureCodes.GetContainsKey("ZZZFIX"))
     {
         Cache.Refresh(InvalidType.ProcCodes);                //Refresh local cache only because middle tier has already inserted the signal.
     }
     try {
         _claimTransferResult = ClaimProcs.TransferClaimsAsTotalToProcedures(_listFamilyPatNums);
     }
     catch (ApplicationException ex) {
         FriendlyException.Show(ex.Message, ex);
         return;
     }
     if (_claimTransferResult != null && _claimTransferResult.ListInsertedClaimProcs.Count > 0)           //valid and items were created
     {
         SecurityLogs.MakeLogEntry(Permissions.ClaimProcReceivedEdit, _patCur.PatNum, "Automatic transfer of claims pay as total from income transfer.");
     }
 }
Beispiel #19
0
 private void FormCreditRecurringDateChoose_Load(object sender, EventArgs e)
 {
     try {
         if (FillComboBoxMonthSelect())
         {
             return;                    //We are using the comboBox instead of two buttons.
         }
         //We are using the This Month/Last Month buttons instead of the comboBox.
         DateTime thisMonth = GetValidPayDate(DateTime.Today);
         DateTime lastMonth = GetValidPayDate(DateTime.Today.AddMonths(-1));
         if (PrefC.GetBool(PrefName.RecurringChargesUseTransDate))
         {
             //Labels set here, buttons set in respective button methods butLastMonth_Click/butThisMonth_Click
             labelLastMonth.Text = Lan.g(this, "Recurring charge date will be:") + " " + lastMonth.ToShortDateString();
             labelThisMonth.Text = Lan.g(this, "Recurring charge date will be:") + " " + thisMonth.ToShortDateString();
         }
         else
         {
             labelLastMonth.Text += " " + lastMonth.ToShortDateString();
             labelThisMonth.Text += " " + thisMonth.ToShortDateString();
         }
         //If the recurring pay date is in the future do not let them choose that option.
         if (thisMonth > DateTime.Now)
         {
             butThisMonth.Enabled = false;
             labelThisMonth.Text  = Lan.g(this, "Cannot make payment for future date:") + " " + thisMonth.ToShortDateString();
         }
         if (lastMonth < _creditCardCur.DateStart)
         {
             labelLastMonth.Text  = Lan.g(this, "Cannot make payment before start date:") + " " + _creditCardCur.DateStart;
             butLastMonth.Enabled = false;
         }
         if (thisMonth < _creditCardCur.DateStart)
         {
             labelThisMonth.Text  = Lan.g(this, "Cannot make payment before start date:") + " " + _creditCardCur.DateStart;
             butThisMonth.Enabled = false;
         }
     }
     catch (Exception ex) {
         FriendlyException.Show(ex.Message, ex);
         Close();
     }
 }
Beispiel #20
0
 ///<summary>Validation for the domain login path provided.
 ///Accepted formats are those listed here: https://msdn.microsoft.com/en-us/library/aa746384(v=vs.85).aspx, excluding plain "LDAP:"
 ///Does not check if there are users on the domain object, only that the domain object exists and can be searched.</summary>
 private void textDomainLoginPath_Leave(object sender, EventArgs e)
 {
     if (checkDomainLoginEnabled.Checked)
     {
         if (string.IsNullOrWhiteSpace(textDomainLoginPath.Text))
         {
             MsgBox.Show(this, "Warning. Domain Login is enabled, but no path has been entered. If you do not provide a domain path,"
                         + "you will not be able to assign domain logins to users.");
         }
         else
         {
             try {
                 DirectoryEntry         testEntry   = new DirectoryEntry(textDomainLoginPath.Text);
                 DirectorySearcher      search      = new DirectorySearcher(testEntry);
                 SearchResultCollection testResults = search.FindAll();                         //Just do a generic search to verify the object might have users on it
             }
             catch (Exception ex) {
                 FriendlyException.Show(Lan.g(this, "An error occurred while attempting to access the provided Domain Login Path."), ex);
             }
         }
     }
 }
 ///<summary>Allows users to paste an image from their clipboard. Throws if the content on the clipboard is not a supported image format.</summary>
 private void ButPasteImage_Click(object sender, EventArgs e)
 {
     try{
         Image imageClipboard = Clipboard.GetImage();
         if (imageClipboard == null)
         {
             //Either an image doesn't exist on the clipboard, or
             // an image exists on the clipboard that cannot be converted to a bitmap, in which case imageClipboard will also be null.
             throw new ODException(Lan.g(this, "Could not find a valid image on the clipboard."));
         }
         ShowImageAttachmentItemEdit(imageClipboard);
     }
     catch (ODException ode) {
         MsgBox.Show(this, ode.Message);
     }
     catch (ExternalException ee) {
         FriendlyException.Show(Lan.g(this, "The clipboard could not be accessed. This typically occurs when the clipboard is being used by another process."), ee);
     }
     catch (Exception ex) {
         FriendlyException.Show(Lan.g(this, "An error occurred while accessing the clipboard. Please call support if the issue persists."), ex);
     }
 }
Beispiel #22
0
        private void Image_Click()
        {
            //Store the images in their own a-z folder and retrieve them from there.
            string emailFolder = "";

            try {
                emailFolder = ImageStore.GetEmailImagePath();              //will create the folder if it doesn't exist already.
            }
            catch (Exception ex) {
                FriendlyException.Show(Lans.g(this, "Unable to find Email Images folder"), ex);
                return;
            }
            FormImagePicker FormIP = new FormImagePicker(emailFolder);

            FormIP.ShowDialog();
            if (FormIP.DialogResult != DialogResult.OK)
            {
                return;
            }
            textContentEmail.SelectionLength = 0;
            textContentEmail.SelectedText    = "[[img:" + FormIP.SelectedImageName + "]]";
        }
 private void WebhookHelper(string username, string key, long clinicNum)
 {
     if (username == "" || key == "")
     {
         return;
     }
     try {
         Cursor = Cursors.WaitCursor;
         List <PaySimple.ApiWebhookResponse> listWebhooks = PaySimple.GetAchWebhooks(clinicNum);
         List <string> listHooksNeeded = new List <string>();
         if (listWebhooks.SelectMany(x => x.WebhookTypes.FindAll(y => y == "payment_failed")).Count() == 0)
         {
             //no payment_failed webhook exists, created one.
             listHooksNeeded.Add("payment_failed");
         }
         if (listWebhooks.SelectMany(x => x.WebhookTypes.FindAll(y => y == "payment_returned")).Count() == 0)
         {
             //no payment_returned webhook exists, created one.
             listHooksNeeded.Add("payment_returned");
         }
         if (listWebhooks.SelectMany(x => x.WebhookTypes.FindAll(y => y == "payment_settled")).Count() == 0)
         {
             //no payment_settled webhook exists, created one.
             listHooksNeeded.Add("payment_settled");
         }
         if (listHooksNeeded.Count > 0)
         {
             string url = WebServiceMainHQProxy.GetWebServiceMainHQInstance().GetPaySimpleWebHookUrl();
             PaySimple.PostWebhook(clinicNum, listHooksNeeded.ToArray(), url);
         }
     }
     catch (Exception ex) {
         FriendlyException.Show("Unable to register for payment responses from PaySimple.", ex);
     }
     finally {
         Cursor = Cursors.Default;
     }
 }
        private void buttonAddImage_Click(object sender, EventArgs e)
        {
            string         patFolder  = ImageStore.GetPatientFolder(_claimPat, ImageStore.GetPreferredAtoZpath());
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Multiselect      = false;
            fileDialog.InitialDirectory = patFolder;
            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            //The filename property is the entire path of the file.
            string selectedFile = fileDialog.FileName;

            if (selectedFile.EndsWith(".pdf"))
            {
                MessageBox.Show(this, "DentalXChange does not support PDF attachments.");
                return;
            }
            //There is purposely no validation that the user selected an image as that will be handled on Dentalxchange's end.
            Image image;

            try {
                image = Image.FromFile(selectedFile);
                ShowImageAttachmentItemEdit(image);
            }
            catch (System.IO.FileNotFoundException ex) {
                FriendlyException.Show(Lan.g(this, "The selected file at: " + selectedFile + " could not be found"), ex);
            }
            catch (System.OutOfMemoryException ex) {
                //Image.FromFile() will throw an OOM exception when the image format is invalid or not supported.
                //See MSDN if you have trust issues:  https://msdn.microsoft.com/en-us/library/stf701f5(v=vs.110).aspx
                FriendlyException.Show(Lan.g(this, "The file does not have a valid image format. Please try again or call support." + "\r\n" + ex.Message), ex);
            }
            catch (Exception ex) {
                FriendlyException.Show(Lan.g(this, "An error occurred. Please try again or call support.") + "\r\n" + ex.Message, ex);
            }
        }
        private void butExport_Click(object sender, System.EventArgs e)
        {
            List <AutoNote> listCheckedAutoNotes = GetCheckedAutoNotes(treeNotes.Nodes);

            if (listCheckedAutoNotes.Count == 0)
            {
                MsgBox.Show(this, "You must select at least one Auto Note to export.");
                return;
            }
            try {
                string fileName;
                if (ODBuild.IsWeb())
                {
                    //file download dialog will come up later, after file is created.
                    fileName = "autonotes.json";
                }
                else
                {
                    using (SaveFileDialog saveDialog = ExportDialogSetup()) {
                        if (saveDialog.ShowDialog() != DialogResult.OK)
                        {
                            return;                            //user canceled out of SaveFileDialog
                        }
                        fileName = saveDialog.FileName;
                    }
                }
                List <SerializableAutoNote>        serializableAutoNotes        = AutoNotes.GetSerializableAutoNotes(listCheckedAutoNotes);
                List <AutoNoteControl>             listAutoNoteControls         = AutoNoteControls.GetListByParsingAutoNoteText(serializableAutoNotes);
                List <SerializableAutoNoteControl> serializableAutoNoteControls = AutoNoteControls.GetSerializableAutoNoteControls(listAutoNoteControls);
                AutoNotes.WriteAutoNotesToJson(serializableAutoNotes, serializableAutoNoteControls, fileName);
                SecurityLogs.MakeLogEntry(Permissions.AutoNoteQuickNoteEdit, 0, "Auto Note Export");
                MsgBox.Show(this, "Auto Note(s) successfully exported.");
            }
            catch (Exception err) {
                FriendlyException.Show("AutoNote(s) failed to export.", err);
            }
        }
Beispiel #26
0
        private void butCheckForUpdates_Click(object sender, EventArgs e)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                MsgBox.Show(this, "Updates are only allowed from the web server");
                return;
            }
            if (PrefC.GetString(PrefName.WebServiceServerName) != "" &&       //using web service
                !ODEnvironment.IdIsThisComputer(PrefC.GetString(PrefName.WebServiceServerName).ToLower()))                  //and not on web server
            {
                MessageBox.Show(Lan.g(this, "Updates are only allowed from the web server") + ": " + PrefC.GetString(PrefName.WebServiceServerName));
                return;
            }
            if (ReplicationServers.ServerIsBlocked())
            {
                MsgBox.Show(this, "Updates are not allowed on this replication server");
                return;
            }
            Cursor                     = Cursors.WaitCursor;
            groupBuild.Visible         = false;
            groupStable.Visible        = false;
            groupBeta.Visible          = false;
            groupAlpha.Visible         = false;
            textConnectionMessage.Text = Lan.g(this, "Attempting to connect to web service......");
            Application.DoEvents();
            string result = "";

            try {
                result = CustomerUpdatesProxy.SendAndReceiveUpdateRequestXml();
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                string friendlyMessage = Lan.g(this, "Error checking for updates.");
                FriendlyException.Show(friendlyMessage, ex);
                textConnectionMessage.Text = friendlyMessage;
                return;
            }
            textConnectionMessage.Text = Lan.g(this, "Connection successful.");
            Cursor = Cursors.Default;
            try {
                ParseXml(result);
            }
            catch (Exception ex) {
                string friendlyMessage = Lan.g(this, "Error checking for updates.");
                FriendlyException.Show(friendlyMessage, ex);
                textConnectionMessage.Text = friendlyMessage;
                return;
            }
            if (!string.IsNullOrEmpty(_buildAvailableDisplay))
            {
                groupBuild.Visible = true;
                textBuild.Text     = _buildAvailableDisplay;
            }
            if (!string.IsNullOrEmpty(_stableAvailableDisplay))
            {
                groupStable.Visible = true;
                textStable.Text     = _stableAvailableDisplay;
            }
            if (!string.IsNullOrEmpty(_betaAvailableDisplay))
            {
                groupBeta.Visible = true;
                textBeta.Text     = _betaAvailableDisplay;
            }
            if (!string.IsNullOrEmpty(_alphaAvailableDisplay))
            {
                groupAlpha.Visible = true;
                textAlpha.Text     = _alphaAvailableDisplay;
            }
            if (string.IsNullOrEmpty(_betaAvailable) &&
                string.IsNullOrEmpty(_stableAvailable) &&
                string.IsNullOrEmpty(_buildAvailable) &&
                string.IsNullOrEmpty(_alphaAvailable))
            {
                textConnectionMessage.Text += Lan.g(this, "  There are no downloads available.");
            }
            else
            {
                textConnectionMessage.Text += Lan.g(this, "  The following downloads are available.\r\n"
                                                    + "Be sure to stop the program on all other computers in the office before installing.");
            }
        }
Beispiel #27
0
        private void butPreview_Click(object sender, System.EventArgs e)
        {
#if !DISABLE_MICROSOFT_OFFICE
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur = ListForCat[listLetters.SelectedIndex];
            letterCur.ImageFolder = comboImageCategory.SelectedTag <Def>().DefNum;
            string templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.TemplateName);
            string dataFile     = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.DataFileName);
            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp;
            try{
                WrdApp = LetterMerges.WordApp;
            }
            catch {
                MsgBox.Show(this, "Error. Is Word installed?");
                return;
            }
            string errorMessage = "";
            //Open a document.
            try {
                Object oName = templateFile;
                wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing,
                                               ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                               ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
                wrdDoc.Select();
            }
            catch (Exception ex) {
                errorMessage = Lan.g(this, "Error opening document:") + "\r\n" + ex.Message;
                MessageBox.Show(errorMessage);
                return;
            }
            //Attach the data file.
            try {
                wrdMailMerge = wrdDoc.MailMerge;
                wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
                wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
                wrdMailMerge.Execute(ref oFalse);
            }
            catch (Exception ex) {
                errorMessage = Lan.g(this, "Error attaching data file:") + "\r\n" + ex.Message;
                MessageBox.Show(errorMessage);
                return;
            }
            if (letterCur.ImageFolder != 0)           //if image folder exist for this letter, save to AtoZ folder
            //Open document from the atoz folder.
            {
                try {
                    WrdApp.Activate();
                    string tempFilePath = ODFileUtils.CreateRandomFile(Path.GetTempPath(), GetFileExtensionForWordDoc(templateFile));
                    Object oFileName    = tempFilePath;
                    WrdApp.ActiveDocument.SaveAs(oFileName);                    //save the document to temp location
                    Document doc       = SaveToImageFolder(tempFilePath, letterCur);
                    string   patFolder = ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath());
                    string   fileName  = ImageStore.GetFilePath(doc, patFolder);
                    if (!FileAtoZ.Exists(fileName))
                    {
                        throw new ApplicationException(Lans.g("LetterMerge", "Error opening document" + " " + doc.FileName));
                    }
                    FileAtoZ.StartProcess(fileName);
                    WrdApp.ActiveDocument.Close();                    //Necessary since we created an extra document
                    try {
                        File.Delete(tempFilePath);                    //Clean up the temp file
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                    }
                }
                catch (Exception ex) {
                    FriendlyException.Show(Lan.g(this, "Error saving file to the Image module:") + "\r\n" + ex.Message, ex);
                }
            }
            //Close the original form document since just one record.
            try {
                wrdDoc.Saved = true;
                wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
            }
            catch (Exception ex) {
                errorMessage = Lan.g(this, "Error closing document:") + "\r\n" + ex.Message;
                MessageBox.Show(errorMessage);
                return;
            }
            //At this point, Word remains open with just one new document.
            try {
                WrdApp.Activate();
                if (WrdApp.WindowState == Word.WdWindowState.wdWindowStateMinimize)
                {
                    WrdApp.WindowState = Word.WdWindowState.wdWindowStateMaximize;
                }
            }
            catch (Exception ex) {
                errorMessage = Lan.g(this, "Error showing Microsoft Word:") + "\r\n" + ex.Message;
                MessageBox.Show(errorMessage);
                return;
            }
            wrdMailMerge = null;
            wrdDoc       = null;
            Commlog CommlogCur = new Commlog();
            CommlogCur.CommDateTime   = DateTime.Now;
            CommlogCur.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            CommlogCur.UserNum        = Security.CurUser.UserNum;
            Commlogs.Insert(CommlogCur);
#else
            MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
#endif
            //this window now closes regardless of whether the user saved the comm item.
            DialogResult = DialogResult.OK;
        }
Beispiel #28
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
#if DISABLE_MICROSOFT_OFFICE
            MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
            return;
#endif
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur = ListForCat[listLetters.SelectedIndex];
            letterCur.ImageFolder = comboImageCategory.SelectedTag <Def>().DefNum;
            string templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.TemplateName);
            string dataFile     = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.DataFileName);
            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            PrintDocument pd = new PrintDocument();
            if (!PrinterL.SetPrinter(pd, PrintSituation.Default, PatCur.PatNum, "Letter merge " + letterCur.Description + " printed"))
            {
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp;
            try {
                WrdApp = LetterMerges.WordApp;
            }
            catch {
                MsgBox.Show(this, "Error.  Is MS Word installed?");
                return;
            }
            //Open a document.
            Object oName = templateFile;
            wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdDoc.Select();
            wrdMailMerge = wrdDoc.MailMerge;
            //Attach the data file.
            wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter;
            //WrdApp.ActivePrinter=pd.PrinterSettings.PrinterName;
            //replaced with following 4 lines due to MS bug that changes computer default printer
            object   oWBasic   = WrdApp.WordBasic;
            object[] oWBValues = new object[] { pd.PrinterSettings.PrinterName, 1 };
            String[] sWBNames  = new String[] { "Printer", "DoNotSetAsSysDefault" };
            oWBasic.GetType().InvokeMember("FilePrintSetup", BindingFlags.InvokeMethod, null, oWBasic, oWBValues, null, null, sWBNames);
            wrdMailMerge.Execute(ref oFalse);
            if (letterCur.ImageFolder != 0)           //if image folder exist for this letter, save to AtoZ folder
            {
                try {
                    wrdDoc.Select();
                    wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
                    wrdMailMerge.Execute(ref oFalse);
                    WrdApp.Activate();
                    string tempFilePath = ODFileUtils.CreateRandomFile(Path.GetTempPath(), GetFileExtensionForWordDoc(templateFile));
                    Object oFileName    = tempFilePath;
                    WrdApp.ActiveDocument.SaveAs(oFileName);                    //save the document
                    WrdApp.ActiveDocument.Close();
                    SaveToImageFolder(tempFilePath, letterCur);
                }
                catch (Exception ex) {
                    FriendlyException.Show(Lan.g(this, "Error saving file to the Image module:") + "\r\n" + ex.Message, ex);
                }
            }
            //Close the original form document since just one record.
            wrdDoc.Saved = true;
            wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
            //At this point, Word remains open with no documents.
            WrdApp.WindowState = Word.WdWindowState.wdWindowStateMinimize;
            wrdMailMerge       = null;
            wrdDoc             = null;
            Commlog CommlogCur = new Commlog();
            CommlogCur.CommDateTime   = DateTime.Now;
            CommlogCur.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            CommlogCur.UserNum        = Security.CurUser.UserNum;
            Commlogs.Insert(CommlogCur);
            DialogResult = DialogResult.OK;
        }
Beispiel #29
0
        static void Main(string[] args)
        {
            //Application.EnableVisualStyles() uses version 6 of comctl32.dll instead of version 5. See https://support.microsoft.com/en-us/kb/2892345
            //See also http://stackoverflow.com/questions/8335983/accessviolationexception-on-tooltip-that-faults-comctl32-dll-net-4-0
            Application.EnableVisualStyles();            //This line fixes rare AccessViolationExceptions for ToolTips on our ValidDate boxes, ValidDouble boxes, etc...
            //Register an EventHandler which handles unhandled exceptions.
            //AppDomain.CurrentDomain.UnhandledException+=new UnhandledExceptionEventHandler(OnUnhandeledExceptionPolicy);
            bool isSecondInstance = false;           //or more.

            Process[] processes = Process.GetProcesses();
            for (int i = 0; i < processes.Length; i++)
            {
                if (processes[i].Id == Process.GetCurrentProcess().Id)
                {
                    continue;
                }
                //we have to do it this way because during debugging, the name has vshost tacked onto the end.
                if (processes[i].ProcessName.StartsWith("OpenDental"))
                {
                    isSecondInstance = true;
                    break;
                }
            }

            /*
             * if(args.Length>0) {//if any command line args, then we will attempt to reuse an existing OD window.
             *      if(isSecondInstance){
             *              FormCommandLinePassOff formCommandLine=new FormCommandLinePassOff();
             *              formCommandLine.CommandLineArgs=new string[args.Length];
             *              args.CopyTo(formCommandLine.CommandLineArgs,0);
             *              Application.Run(formCommandLine);
             *              return;
             *      }
             * }*/
            Application.SetCompatibleTextRenderingDefault(false); //designer uses new text rendering.  This makes the exe use matching text rendering.  Before this was added, it was common for labels to be longer in the running program than they were in the designer.
            Application.EnableVisualStyles();                     //changes appearance to XP
            Application.DoEvents();
            string[] cla = new string[args.Length];
            args.CopyTo(cla, 0);
            FormOpenDental             formOD      = new FormOpenDental(cla);
            Action <Exception, string> onUnhandled = new Action <Exception, string>((e, threadName) => {
                //Try to automatically submit a bug report to HQ.  Default to "None" just in case the submission fails.
                BugSubmissionResult subResult = BugSubmissionResult.None;
                try {
                    subResult = BugSubmissions.SubmitException(e, threadName, FormOpenDental.CurPatNum, formOD.GetSelectedModuleName());
                }
                catch (Exception ex) {
                    ex.DoNothing();
                }
                FriendlyException.Show("Critical Error: " + e.Message, e, "Quit");
                formOD.ProcessKillCommand();
            });

            CodeBase.ODThread.RegisterForUnhandledExceptions(formOD, onUnhandled);
            formOD.IsSecondInstance = isSecondInstance;
            Application.AddMessageFilter(new ODGlobalUserActiveHandler());
            Application.ThreadException += new ThreadExceptionEventHandler((object s, ThreadExceptionEventArgs e) => {
                onUnhandled(e.Exception, "ProgramEntry");
            });
            Application.Run(formOD);
        }
Beispiel #30
0
 private void FormPayConnect_Load(object sender, EventArgs e)
 {
     _progCur = Programs.GetCur(ProgramName.PayConnect);
     if (_progCur == null)
     {
         MsgBox.Show(this, "PayConnect does not exist in the database.");
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, "TerminalProcessingEnabled", _clinicNum)))
     {
         try {
             //If the config file for the DentalXChange credit card processing .dll doesn't exist, construct it from the included resource.
             if (!File.Exists("DpsPos.dll.config"))
             {
                 File.WriteAllText("DpsPos.dll.config", Properties.Resources.DpsPos_dll_config);
             }
         }
         catch (Exception ex) {
             FriendlyException.Show("Unable to create the config file for the terminal. Trying running the program as an administrator.", ex);
             //We will still allow them to run the transaction. Probably the worse that will happen is the timeout variable will be less than desired.
         }
     }
     if (!PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, "TerminalProcessingEnabled", _clinicNum)) ||
         _isAddingCard)                    //When adding a card, the web service must be used.
     {
         groupProcessMethod.Visible = false;
         Height -= 55;              //All the controls except for the Transaction Type group box should be anchored to the bottom, so they will move themselves up.
     }
     else
     {
         string procMethod = ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum,
                                                                            PayConnect.ProgramProperties.DefaultProcessingMethod, _clinicNum);
         if (procMethod == "0")
         {
             radioWebService.Checked = true;
         }
         else if (procMethod == "1")
         {
             radioTerminal.Checked = true;
         }
     }
     textAmount.Text = POut.Decimal(_amountInit);
     if (_patCur == null)           //Prepaid card
     {
         radioAuthorization.Enabled = false;
         radioVoid.Enabled          = false;
         radioReturn.Enabled        = false;
         textZipCode.ReadOnly       = true;
         textNameOnCard.ReadOnly    = true;
         checkSaveToken.Enabled     = false;
         sigBoxWrapper.Enabled      = false;
     }
     else              //Other cards
     {
         textZipCode.Text       = _patCur.Zip;
         textNameOnCard.Text    = _patCur.GetNameFL();
         checkSaveToken.Checked = PrefC.GetBool(PrefName.StoreCCtokens);
         if (PrefC.GetBool(PrefName.StoreCCnumbers))
         {
             labelStoreCCNumWarning.Visible = true;
         }
         FillFieldsFromCard();
     }
     if (_isAddingCard)             //We will run a 0.01 authorization so we will not allow the user to change the transaction type or the amount.
     {
         radioAuthorization.Checked = true;
         _trantype = PayConnectService.transType.AUTH;
         groupTransType.Enabled      = false;
         labelAmount.Visible         = false;
         textAmount.Visible          = false;
         checkSaveToken.Checked      = true;
         checkSaveToken.Enabled      = false;
         checkForceDuplicate.Checked = true;
         checkForceDuplicate.Enabled = false;
     }
     if (PIn.Bool(ProgramProperties.GetPropVal(_progCur.ProgramNum, PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, _clinicNum)))
     {
         textCardNumber.ReadOnly = true;
     }
 }