Пример #1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (this.textDescription.Text == "")
     {
         MessageBox.Show(Lan.g(this, "Please enter a description."));
         return;
     }
     if (this.textEclaimCode.Text == "")
     {
         MessageBox.Show(Lan.g(this, "Please enter an electronic claim code."));
         return;
     }
     if (comboGroup.GetSelectedDefNum() == 0)
     {
         MsgBox.Show(this, "Please select a group.");
         return;
     }
     SaveFilingCode();
     DialogResult = DialogResult.OK;
 }
Пример #2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDescription.Text == "")
            {
                MsgBox.Show(this, "Please enter a description");
                return;
            }
            if (this.textDataFileName.Text == "" ||
                this.textTemplateName.Text == "")
            {
                MsgBox.Show(this, "Filenames cannot be left blank.");
                return;
            }
            if (comboCategory.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a category");
                return;
            }
            if (listPatSelect.SelectedIndices.Count == 0 &&
                listReferral.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "Please select at least one field.");
                return;
            }
            Cursor.Current              = Cursors.WaitCursor;
            LetterMergeCur.Description  = textDescription.Text;
            LetterMergeCur.TemplateName = textTemplateName.Text;
            LetterMergeCur.DataFileName = textDataFileName.Text;
            LetterMergeCur.Category     = _listLetterMergeCatDefs[comboCategory.SelectedIndex].DefNum;
            LetterMergeCur.ImageFolder  = comboImageFolder.GetSelectedDefNum();
            if (IsNew)
            {
                LetterMerges.Insert(LetterMergeCur);
            }
            else
            {
                LetterMerges.Update(LetterMergeCur);
            }
            LetterMergeFields.DeleteForLetter(LetterMergeCur.LetterMergeNum);
            LetterMergeField field;

            for (int i = 0; i < listPatSelect.SelectedItems.Count; i++)
            {
                field = new LetterMergeField();
                field.LetterMergeNum = LetterMergeCur.LetterMergeNum;
                field.FieldName      = (string)listPatSelect.SelectedItems[i];
                //(string)listPatSelect.Items[listPatSelect.SelectedIndices[i]];
                LetterMergeFields.Insert(field);
            }
            for (int i = 0; i < listReferral.SelectedItems.Count; i++)
            {
                field = new LetterMergeField();
                field.LetterMergeNum = LetterMergeCur.LetterMergeNum;
                field.FieldName      = "referral." + (string)listReferral.SelectedItems[i];
                LetterMergeFields.Insert(field);
            }
            for (int i = 0; i < listOther.SelectedItems.Count; i++)
            {
                field = new LetterMergeField();
                field.LetterMergeNum = LetterMergeCur.LetterMergeNum;
                field.FieldName      = (string)listOther.SelectedItems[i];
                LetterMergeFields.Insert(field);
            }
            Cursor.Current = Cursors.Default;
            DialogResult   = DialogResult.OK;
        }
Пример #3
0
        private void butPrint_Click(object sender, System.EventArgs e)          //TODO: Implement ODprintout pattern
        {
#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.GetSelectedDefNum();
            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 (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();
            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;
        }