コード例 #1
0
        ///<summary>Returns true if the commlog was able to save to the database.  Otherwise returns false.
        ///Set showMsg to true to show a meaningful message when the commlog cannot be saved.</summary>
        public bool SaveCommItem(bool showMsg)
        {
            Commlog commlog;

            if (!_view.TryGetCommItem(showMsg, out commlog))
            {
                return(false);
            }
            if (IsNew || IsPersistent)
            {
                _view.SetCommlogNum(Commlogs.Insert(commlog));
                SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert");
                //Post insert persistent user preferences.
                if (IsPersistent)
                {
                    if (_userOdPrefClearNote == null || PIn.Bool(_userOdPrefClearNote.ValueString))
                    {
                        _view.ClearNote();
                    }
                    if (_userOdPrefEndDate == null || PIn.Bool(_userOdPrefEndDate.ValueString))
                    {
                        _view.ClearDateTimeEnd();
                    }
                    ODException.SwallowAnyException(() => {
                        FormOpenDental.S_RefreshCurrentModule();
                    });
                }
            }
            else
            {
                Commlogs.Update(commlog);
                SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "");
            }
            return(true);
        }
コード例 #2
0
        ///<summary>Sends text message to callfire.  If patNum=0 will not create commlog entry.</summary>
        private bool SendCallFire(long patNum, string wirelessPhone, string message)
        {
            string key = ProgramProperties.GetPropVal(ProgramName.CallFire, "Key From CallFire");
            string msg = wirelessPhone + "," + message.Replace(",", "");     //ph#,msg Commas in msg cause error.

            try {
                CallFireService.SMSService callFire = new CallFireService.SMSService();
                callFire.sendSMSCampaign(
                    key,
                    new string[] { msg },
                    "Open Dental");
            }
            catch (Exception ex) {
                MsgBox.Show(this, "Error sending text message.\r\n\r\n" + ex.Message);
                return(false);
            }
            if (patNum == 0)             //No patient selected, do not make commlog.
            {
                return(true);
            }
            Commlog commlog = new Commlog();

            commlog.CommDateTime   = DateTime.Now;
            commlog.DateTStamp     = DateTime.Now;
            commlog.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.TEXT);
            commlog.Mode_          = CommItemMode.Text;
            commlog.Note           = msg;//phone,note
            commlog.PatNum         = patNum;
            commlog.SentOrReceived = CommSentOrReceived.Sent;
            commlog.UserNum        = Security.CurUser.UserNum;
            commlog.DateTimeEnd    = DateTime.Now;
            Commlogs.Insert(commlog);
            SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert Text Message");
            return(true);
        }
コード例 #3
0
        /*
         * ///<summary>This button won't even be visible unless there is an email to view.</summary>
         * private void butEmail_Click(object sender, System.EventArgs e) {
         *      EmailMessage message=EmailMessages.Refresh(CommlogCur.EmailMessageNum);
         *      //If a date is entered, user will not be able to click Send
         *      FormEmailMessageEdit FormE=new FormEmailMessageEdit(message);
         *      FormE.ShowDialog();
         *      CommlogCur=Commlogs.GetOne(CommlogCur.CommlogNum);
         * }*/

        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDateTime.Text == ""
                //|| textAmount.errorProvider1.GetError(textAmount)!=""
                )
            {
                MessageBox.Show(Lan.g(this, "Please enter a date first."));
                return;
            }
            try{
                DateTime.Parse(textDateTime.Text);
            }
            catch {
                MessageBox.Show(Lan.g(this, "Date and time invalid."));
                return;
            }
            CommlogCur.CommDateTime = PIn.PDateT(textDateTime.Text);
            //there will always be a commtype selected.
            CommlogCur.CommType       = (CommItemType)(listType.SelectedIndex + 1);
            CommlogCur.Mode_          = (CommItemMode)listMode.SelectedIndex;
            CommlogCur.SentOrReceived = (CommSentOrReceived)listSentOrReceived.SelectedIndex;
            CommlogCur.Note           = textNote.Text;
            if (IsNew)
            {
                Commlogs.Insert(CommlogCur);
            }
            else
            {
                Commlogs.Update(CommlogCur);
                //SecurityLogs.MakeLogEntry("Adjustment Edit",Adjustments.cmd.CommandText);
            }
            DialogResult = DialogResult.OK;
        }
コード例 #4
0
ファイル: FormCommItem.cs プロジェクト: nampn/ODental
 private void butOK_Click(object sender, System.EventArgs e)
 {
     //button not enabled if no permission
     if (textDateTime.Text == "")
     {
         MsgBox.Show(this, "Please enter a date first.");
         return;
     }
     try{
         DateTime.Parse(textDateTime.Text);
     }
     catch {
         MsgBox.Show(this, "Date / Time invalid.");
         return;
     }
     if (textDateTimeEnd.Text != "")
     {
         try {
             DateTime.Parse(textDateTimeEnd.Text);
         }
         catch {
             MsgBox.Show(this, "End date and time invalid.");
             return;
         }
         CommlogCur.DateTimeEnd = PIn.DateT(textDateTimeEnd.Text);
     }
     CommlogCur.CommDateTime = PIn.DateT(textDateTime.Text);
     //there may not be a commtype selected.
     if (listType.SelectedIndex == -1)
     {
         CommlogCur.CommType = 0;
     }
     else
     {
         CommlogCur.CommType = DefC.Short[(int)DefCat.CommLogTypes][listType.SelectedIndex].DefNum;
     }
     CommlogCur.Mode_          = (CommItemMode)listMode.SelectedIndex;
     CommlogCur.SentOrReceived = (CommSentOrReceived)listSentOrReceived.SelectedIndex;
     CommlogCur.Note           = textNote.Text;
     try {
         SaveSignature();
     }
     catch (Exception ex) {
         MessageBox.Show(Lan.g(this, "Error saving signature.") + "\r\n" + ex.Message);
         return;
     }
     if (IsNew)
     {
         Commlogs.Insert(CommlogCur);
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, CommlogCur.PatNum, "Insert");
     }
     else
     {
         Commlogs.Update(CommlogCur);
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, CommlogCur.PatNum, "");
     }
     DialogResult = DialogResult.OK;
 }
コード例 #5
0
ファイル: FormTxtMsgEdit.cs プロジェクト: steev90/opendental
        /// <summary>May be called from other parts of the program without showing this form. You must still create an instance of this form though. Checks CallFire bridge, if it is OK to send a text, etc. (Buttons to load this form are usually  disabled if it is not OK, but this is needed for Confirmations, Recalls, etc.) </summary>
        public void SendText(long patNum, string wirelessPhone, string message, YN txtMsgOk)
        {
            if (Plugins.HookMethod(this, "FormTxtMsgEdit.SendText_Start", patNum, wirelessPhone, message, txtMsgOk))
            {
                return;
            }
            if (wirelessPhone == "")
            {
                MsgBox.Show(this, "Please enter a phone number.");
                return;
            }
            if (!Programs.IsEnabled(ProgramName.CallFire))
            {
                MsgBox.Show(this, "CallFire Program Link must be enabled.");
                return;
            }
            if (txtMsgOk == YN.Unknown && PrefC.GetBool(PrefName.TextMsgOkStatusTreatAsNo))
            {
                MsgBox.Show(this, "It is not OK to text this patient.");
                return;
            }
            if (txtMsgOk == YN.No)
            {
                MsgBox.Show(this, "It is not OK to text this patient.");
                return;
            }
            string key = ProgramProperties.GetPropVal(ProgramName.CallFire, "Key From CallFire");
            string msg = wirelessPhone + "," + message.Replace(",", "");     //ph#,msg Commas in msg cause error.

            try {
                CallFireService.SMSService callFire = new CallFireService.SMSService();
                callFire.sendSMSCampaign(
                    key,
                    new string[] { msg },
                    "Open Dental");
            }
            catch (Exception ex) {
                MsgBox.Show(this, "Error sending text message.\r\n\r\n" + ex.Message);
                return;
            }
            Commlog commlog = new Commlog();

            commlog.CommDateTime   = DateTime.Now;
            commlog.DateTStamp     = DateTime.Now;
            commlog.CommType       = DefC.Short[(int)DefCat.CommLogTypes][0].DefNum; //The first one in the list.  We can enhance later.
            commlog.Mode_          = CommItemMode.Text;
            commlog.Note           = msg;                                            //phone,note
            commlog.PatNum         = patNum;
            commlog.SentOrReceived = CommSentOrReceived.Sent;
            commlog.UserNum        = Security.CurUser.UserNum;
            commlog.DateTimeEnd    = DateTime.Now;
            Commlogs.Insert(commlog);
            SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert Text Message");
        }
コード例 #6
0
 public void AutoSaveCommItem(Commlog commlog)
 {
     if (IsNew)
     {
         //Insert
         _view.SetCommlogNum(Commlogs.Insert(commlog));
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Autosave Insert");
         IsNew = false;
     }
     else
     {
         //Update
         Commlogs.Update(commlog);
     }
 }
コード例 #7
0
 private void AutoSaveCommItem()
 {
     if (_commlogOld.IsNew)
     {
         //Insert
         Commlogs.Insert(_commlogCur);
         textCommlogNum.Text = this._commlogCur.CommlogNum.ToString();
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, _commlogCur.PatNum, "Autosave Insert");
         _commlogCur.IsNew = false;
     }
     else
     {
         //Update
         Commlogs.Update(_commlogCur);
     }
     _commlogOld = _commlogCur.Copy();
 }
コード例 #8
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateTime.Text == ""
         //|| textAmount.errorProvider1.GetError(textAmount)!=""
         )
     {
         MessageBox.Show(Lan.g(this, "Please enter a date first."));
         return;
     }
     try{
         DateTime.Parse(textDateTime.Text);
     }
     catch {
         MessageBox.Show(Lan.g(this, "Date and time invalid."));
         return;
     }
     if (!checkIsStatementSent.Checked && listType.SelectedIndex == -1)
     {
         MsgBox.Show(this, "Please select a type.");
         return;
     }
     CommlogCur.CommDateTime = PIn.PDateT(textDateTime.Text);
     //there may not be a commtype selected.
     if (listType.SelectedIndex == -1)
     {
         CommlogCur.CommType = 0;
     }
     else
     {
         CommlogCur.CommType = DefB.Short[(int)DefCat.CommLogTypes][listType.SelectedIndex].DefNum;
     }
     CommlogCur.Mode_           = (CommItemMode)listMode.SelectedIndex;
     CommlogCur.SentOrReceived  = (CommSentOrReceived)listSentOrReceived.SelectedIndex;
     CommlogCur.Note            = textNote.Text;
     CommlogCur.IsStatementSent = checkIsStatementSent.Checked;
     if (IsNew)
     {
         Commlogs.Insert(CommlogCur);
     }
     else
     {
         Commlogs.Update(CommlogCur);
         //SecurityLogs.MakeLogEntry("Adjustment Edit",Adjustments.cmd.CommandText);
     }
     DialogResult = DialogResult.OK;
 }
コード例 #9
0
 private void butStationary_Click(object sender, EventArgs e)
 {
     if (PrefB.GetString("StationaryDocument") == "")
     {
         MsgBox.Show(this, "You must setup your stationary document and word processor path in Setup | Misc");
         return;
     }
     Cursor = Cursors.AppStarting;
     PtLetter_ToClipboard();
     try {
         this.Cursor = Cursors.AppStarting;
         string patFolder = ODFileUtils.CombinePaths(
             FormPath.GetPreferredImagePath(),
             PatCur.ImageFolder.Substring(0, 1),
             PatCur.ImageFolder);
         //string ProgName = @"C:\Program Files\OpenOffice.org 2.0\program\swriter.exe";
         //string ProgName = PrefB.GetString("WordProcessorPath");
         string TheFile = ODFileUtils.CombinePaths(patFolder, "Letter_" + DateTime.Now.ToFileTime() + ".doc");
         try{
             File.Copy(
                 ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), PrefB.GetString("StationaryDocument")),
                 TheFile);
             DialogResult = DialogResult.OK;
         }
         catch {
         }
         try {
             Process.Start(TheFile);
         }
         catch {
         }
         this.Cursor = Cursors.Default;
         Commlog CommlogCur = new Commlog();
         CommlogCur.CommDateTime = DateTime.Now;
         CommlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
         CommlogCur.PatNum       = PatCur.PatNum;
         CommlogCur.Note         = Lan.g(this, "Letter sent: See Images for this date.");
         Commlogs.Insert(CommlogCur);
     }
     catch {
         Cursor = Cursors.Default;
         MsgBox.Show(this, "Cannot find stationary document. Or another problem exists.");
     }
 }
コード例 #10
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
            if (gridBill.SelectedIndices.Length == 0)
            {
                MessageBox.Show(Lan.g(this, "Please select items first."));
                return;
            }
            if (!MsgBox.Show(this, true, "Please be prepared to wait up to ten minutes while all the bills get processed.  Continue?"))
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            int[] guarNums = new int[gridBill.SelectedIndices.Length];
            for (int i = 0; i < gridBill.SelectedIndices.Length; i++)
            {
                guarNums[i] = AgingList[gridBill.SelectedIndices[i]].PatNum;
            }
            FormRpStatement FormS = new FormRpStatement();

            FormS.LoadAndPrint(guarNums, GeneralNote);
            Cursor = Cursors.Default;
                        #if DEBUG
            FormS.ShowDialog();
                        #endif
            if (MsgBox.Show(this, true, "Printing Statements Complete.  OK to make Commlog entries?"))
            {
                Commlog commlog;
                for (int i = 0; i < guarNums.Length; i++)
                {
                    commlog = new Commlog();
                    commlog.CommDateTime    = DateTime.Now;
                    commlog.CommType        = 0;
                    commlog.SentOrReceived  = CommSentOrReceived.Sent;
                    commlog.Mode_           = CommItemMode.Mail;
                    commlog.IsStatementSent = true;
                    commlog.PatNum          = guarNums[i];         //uaually the guarantor
                    Commlogs.Insert(commlog);
                }
            }
            DialogResult = DialogResult.OK;
        }
コード例 #11
0
 ///<summary>Returns true if the commlog was able to save to the database.  Otherwise returns false.
 ///Set showMsg to true to show a meaningful message when the commlog cannot be saved.</summary>
 private bool SaveCommItem(bool showMsg)
 {
     if (!SyncCommlogWithUI(showMsg))
     {
         return(false);
     }
     if (_isPersistent && string.IsNullOrWhiteSpace(_commlogCur.Note))              //in persistent mode, we don't want to save empty commlogs
     {
         return(false);
     }
     if (_commlogOld.IsNew || _isPersistent)
     {
         Commlogs.Insert(_commlogCur);
         _commlogCur.IsNew   = false;
         _commlogOld         = _commlogCur.Copy();
         textCommlogNum.Text = _commlogCur.CommlogNum.ToString();
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, _commlogCur.PatNum, "Insert");
         //Post insert persistent user preferences.
         if (_isPersistent)
         {
             if (_userOdPrefClearNote == null || PIn.Bool(_userOdPrefClearNote.ValueString))
             {
                 ClearNote();
             }
             if (_userOdPrefEndDate == null || PIn.Bool(_userOdPrefEndDate.ValueString))
             {
                 ClearDateTimeEnd();
             }
             ODException.SwallowAnyException(() => {
                 FormOpenDental.S_RefreshCurrentModule();
             });
         }
     }
     else
     {
         Commlogs.Update(_commlogCur);
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, _commlogCur.PatNum, "");
     }
     return(true);
 }
コード例 #12
0
        ///<summary>Go through the transaction dictionary created in CreateProcedureLogs() to edit repeat charges as needed.
        ///Returns the note for the newly generated repeat charge.</summary>
        private void ZeroOutRepeatingCharge(ProcedureCode procCur, List <AvaTax.TransQtyAmt> listCurTrans)
        {
            Commlog prepaymentCommlog = new Commlog();

            prepaymentCommlog.PatNum         = _patCur.PatNum;
            prepaymentCommlog.SentOrReceived = CommSentOrReceived.Received;
            prepaymentCommlog.CommDateTime   = DateTime.Now;
            prepaymentCommlog.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.FIN);
            prepaymentCommlog.Mode_          = CommItemMode.None;
            prepaymentCommlog.Note           = "";//Appended to below.
            prepaymentCommlog.UserNum        = Security.CurUser.UserNum;
            string note = "From PrepaymentTool: \r\n";
            bool   hasBeenBilledThisMonth = (DateTimeOD.Today.Day >= _patCur.BillingCycleDay);
            //Get all applicable repeat charges.
            List <RepeatCharge> listRcForProc = _listRcForPat.FindAll(x => x.ProcCode == procCur.ProcCode && x.IsEnabled);
            //Get number of months new repeat charge will be for.
            int numMonths = listCurTrans.Sum(x => x.qty);
            //Create repeat charge, taken from ContrAccount.cs
            RepeatCharge rcNew = new RepeatCharge();

            rcNew.PatNum         = _patCur.PatNum;
            rcNew.ProcCode       = procCur.ProcCode;
            rcNew.ChargeAmt      = 0;
            rcNew.IsEnabled      = true;
            rcNew.CopyNoteToProc = true;
            //Build dates using billing day so the patient doesn't have gaps in their repeat charges.
            DateTime dateBillThisMonth = DateTimeOD.GetMostRecentValidDate(DateTime.Today.Year, DateTime.Today.Month, _patCur.BillingCycleDay);

            if (hasBeenBilledThisMonth)
            {
                //Current month has been billed, push new repeat charge out a month.
                rcNew.DateStart = dateBillThisMonth.AddMonths(1);
                rcNew.DateStop  = dateBillThisMonth.AddMonths(numMonths);
            }
            else
            {
                //Current month has not been billed yet, include on this repeat charge.
                rcNew.DateStart = dateBillThisMonth;
                rcNew.DateStop  = dateBillThisMonth.AddMonths(numMonths - 1);
            }
            //Use the stop date to update the Note as requested by Accounting.
            DatePrepaidThrough = rcNew.DateStop.AddMonths(1).AddDays(-1);
            rcNew.Note         = _prepaidThroughNote;
            //Edit exisiting repeat charge start/stop dates.
            foreach (RepeatCharge rcExisting in listRcForProc)
            {
                if (rcExisting.DateStop.Year > 1880 && rcExisting.DateStop < DateTimeOD.Today)
                {
                    continue;                    //The charge has a stop date in the past (has been disabled).
                }
                if (rcExisting.DateStop.Year > 1880 && rcExisting.DateStop <= DateTimeOD.Today.AddMonths(numMonths))
                {
                    rcExisting.DateStop  = DateTimeOD.Today;
                    rcExisting.IsEnabled = false;
                    //This repeat charge will never be used again due to the prepayment we are creating right now.  Disable and add note to commlog for history.
                    note += "Disabled repeat charge with Rate: " + POut.Double(rcExisting.ChargeAmt) + " for Code: " + POut.String(rcExisting.ProcCode)
                            + " Start Date: " + POut.Date(rcExisting.DateStart) + " Stop Date: " + POut.Date(rcExisting.DateStop) + "\r\n";
                    RepeatCharges.Update(rcExisting);
                    continue;
                }
                //Need to push start date of existing repeat charge forward one month past the new repeat charge (if charge months overlap).
                DateTime dateNext = rcNew.DateStop.AddMonths(1);
                if (dateNext > rcExisting.DateStart)                 //Only change if needed.
                {
                    note += "Edited Start Date for repeat charge from: " + POut.Date(rcExisting.DateStart) + " to: " + POut.Date(dateNext) +
                            " Code: " + POut.String(rcExisting.ProcCode) + " Rate: " + POut.Double(rcExisting.ChargeAmt) + "\r\n";
                    //Change to billing day to make sure it matches other repeat charges.
                    rcExisting.DateStart = dateNext;
                    RepeatCharges.Update(rcExisting);
                }
            }
            //Insert the new repeat charge.
            prepaymentCommlog.Note = note;
            Commlogs.Insert(prepaymentCommlog);
            RepeatCharges.Insert(rcNew);
        }
コード例 #13
0
ファイル: FormLetterMerges.cs プロジェクト: royedwards/DRDNet
        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;
        }
コード例 #14
0
ファイル: FormLetterMerges.cs プロジェクト: royedwards/DRDNet
        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;
        }
コード例 #15
0
ファイル: FormUnsched.cs プロジェクト: ChemBrain/OpenDental
        private void Delete_Click()
        {
            if (!Security.IsAuthorized(Permissions.AppointmentEdit))
            {
                return;
            }
            if (grid.SelectedIndices.Length > 1)
            {
                if (!MsgBox.Show(MsgBoxButtons.OKCancel, "Delete all selected appointments permanently?"))
                {
                    return;
                }
            }
            List <Appointment> listApptsWithNote   = new List <Appointment>();
            List <long>        listSelectedAptNums = new List <long>();

            foreach (int i in grid.SelectedIndices)
            {
                listSelectedAptNums.Add(_listUnschedApt[i].AptNum);
                if (!string.IsNullOrEmpty(_listUnschedApt[i].Note))
                {
                    listApptsWithNote.Add(_listUnschedApt[i]);
                }
            }
            if (listApptsWithNote.Count > 0)           //There were notes in the appointment(s) we are about to delete and we must ask if they want to save them in a commlog.
            {
                string commlogMsg = "";
                if (grid.SelectedIndices.Length == 1)
                {
                    commlogMsg = Commlogs.GetDeleteApptCommlogMessage(listApptsWithNote[0].Note, listApptsWithNote[0].AptStatus);
                }
                else
                {
                    commlogMsg = "One or more appointments have notes.  Save appointment notes in CommLogs?";
                }
                DialogResult result = MessageBox.Show(commlogMsg, "Question...", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                else if (result == DialogResult.Yes)
                {
                    foreach (Appointment apptCur in listApptsWithNote)
                    {
                        Commlog commlogCur = new Commlog();
                        commlogCur.PatNum       = apptCur.PatNum;
                        commlogCur.CommDateTime = DateTime.Now;
                        commlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT);
                        commlogCur.Note         = Lan.g(this, "Deleted Appt. & saved note") + ": ";
                        if (apptCur.ProcDescript != "")
                        {
                            commlogCur.Note += apptCur.ProcDescript + ": ";
                        }
                        commlogCur.Note   += apptCur.Note;
                        commlogCur.UserNum = Security.CurUser.UserNum;
                        //there is no dialog here because it is just a simple entry
                        Commlogs.Insert(commlogCur);
                    }
                }
            }
            Appointments.Delete(listSelectedAptNums);
            foreach (int i in grid.SelectedIndices)
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, _listUnschedApt[i].PatNum,
                                          Lan.g(this, "Appointment deleted from the Unscheduled list."), _listUnschedApt[i].AptNum, _listUnschedApt[i].DateTStamp);
            }
            FillGrid();
        }
コード例 #16
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];
            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;
            }
            //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.wdSendToNewDocument;
            wrdMailMerge.Execute(ref oFalse);
            //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 just one new document.
            WrdApp.Activate();
            if (WrdApp.WindowState == Word.WdWindowState.wdWindowStateMinimize)
            {
                WrdApp.WindowState = Word.WdWindowState.wdWindowStateMaximize;
            }
            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;
        }
コード例 #17
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur    = ListForCat[listLetters.SelectedIndex];
            string      templateFile = PrefB.GetString("LetterMergePath") + letterCur.TemplateName;
            string      dataFile     = PrefB.GetString("LetterMergePath") + letterCur.DataFileName;

            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            PrintDocument pd = new PrintDocument();

            if (!Printers.SetPrinter(pd, PrintSituation.Default))
            {
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp = LetterMerges.WordApp;
            //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;
            wrdMailMerge.Execute(ref oFalse);
            //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       = CommItemType.Misc;
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            Commlogs.Insert(CommlogCur);
            DialogResult = DialogResult.OK;
        }