private void butPrintClassic() { if(StmtCur.DocNum!=0 && checkIsSent.Checked && !StmtCur.IsInvoice)//Invoices are always recreated on the fly in order to show "Copy" when needed. { //launch existing archive pdf. User can click print from within Acrobat. Cursor=Cursors.WaitCursor; Patient pat=Patients.GetPat(StmtCur.PatNum); string patFolder=ImageStore.GetPatientFolder(pat,ImageStore.GetPreferredAtoZpath()); Process.Start(ImageStore.GetFilePath(Documents.GetByNum(StmtCur.DocNum),patFolder)); Cursor=Cursors.Default; } else {//was not initially sent, or else user has unchecked the sent box if(initiallySent && checkIsSent.Checked && StmtCur.DocNum==0 && !StmtCur.IsInvoice)//for invoice, we don't notify user that it's a recreation { MsgBox.Show(this,"There was no archived image of this statement. The printout will be based on current data."); } //So create an archive if(listMode.SelectedIndex==(int)StatementMode.Email) { listMode.SelectedIndex=(int)StatementMode.InPerson; } checkIsSent.Checked=true; Cursor=Cursors.WaitCursor; if(!SaveToDb()) { Cursor=Cursors.Default; return; } FormRpStatement FormST=new FormRpStatement(); Family fam=Patients.GetFamily(StmtCur.PatNum); Patient pat=fam.GetPatient(StmtCur.PatNum); DataSet dataSet=AccountModules.GetStatementDataSet(StmtCur); FormST.CreateStatementPdfClassic(StmtCur,pat,fam,dataSet); #if DEBUG FormST.PrintStatement(StmtCur,true,dataSet,fam,pat); FormST.ShowDialog(); #else FormST.PrintStatement(StmtCur,false,dataSet,fam,pat); #endif if(StmtCur.IsInvoice && checkIsInvoiceCopy.Visible) {//for foreign countries StmtCur.IsInvoiceCopy=true; Statements.Update(StmtCur); } Cursor=Cursors.Default; } DialogResult=DialogResult.OK; }
private void butPreviewClassic() { if(StmtCur.DocNum!=0 && checkIsSent.Checked) {//initiallySent && checkIsSent.Checked){ //launch existing archive pdf Cursor=Cursors.WaitCursor; Patient pat=Patients.GetPat(StmtCur.PatNum); string patFolder=ImageStore.GetPatientFolder(pat,ImageStore.GetPreferredAtoZpath()); //Currently unable to load Statements stored in database even though they get saved into the database. if(!File.Exists(ImageStore.GetFilePath(Documents.GetByNum(StmtCur.DocNum),patFolder))) { Cursor=Cursors.Default; MsgBox.Show(this,"File not found: " + Documents.GetByNum(StmtCur.DocNum).FileName); return; } Process.Start(ImageStore.GetFilePath(Documents.GetByNum(StmtCur.DocNum),patFolder)); Cursor=Cursors.Default; } else{//was not initially sent, or else user has unchecked the sent box //No archive to use, so just preview on the fly if(initiallySent && checkIsSent.Checked && StmtCur.DocNum==0){ MsgBox.Show(this,"There was no archived image of this statement. The preview will be based on current data."); } Cursor=Cursors.WaitCursor; if(!SaveToDb()){ Cursor=Cursors.Default; return; } FormRpStatement FormST=new FormRpStatement(); Family fam=Patients.GetFamily(StmtCur.PatNum); Patient pat=fam.GetPatient(StmtCur.PatNum); DataSet dataSet=AccountModules.GetStatementDataSet(StmtCur); //Would throw exception if no printer is installed. try { FormST.PrintStatement(StmtCur,true,dataSet,fam,pat); } catch { MsgBox.Show(this,"No printers installed."); Cursor=Cursors.Default; return; } FormST.ShowDialog(); Cursor=Cursors.Default; } }
private void butPrint_Click(object sender,EventArgs e) { if(StmtCur.DocNum!=0 && checkIsSent.Checked){ //launch existing archive pdf. User can click print from within Acrobat. Cursor=Cursors.WaitCursor; Patient pat=Patients.GetPat(StmtCur.PatNum); string patFolder=ImageStore.GetPatientFolder(pat,ImageStore.GetPreferredAtoZpath()); Process.Start(ImageStore.GetFilePath(Documents.GetByNum(StmtCur.DocNum),patFolder)); Cursor=Cursors.Default; } else{//was not initially sent, or else user has unchecked the sent box if(initiallySent && checkIsSent.Checked && StmtCur.DocNum==0){ MsgBox.Show(this,"There was no archived image of this statement. The printout will be based on current data."); } //So create an archive if(listMode.SelectedIndex==(int)StatementMode.Email){ listMode.SelectedIndex=(int)StatementMode.InPerson; } checkIsSent.Checked=true; Cursor=Cursors.WaitCursor; if(!SaveToDb()){ Cursor=Cursors.Default; return; } FormRpStatement FormST=new FormRpStatement(); Family fam=Patients.GetFamily(StmtCur.PatNum); Patient pat=fam.GetPatient(StmtCur.PatNum); DataSet dataSet=AccountModules.GetStatementDataSet(StmtCur); FormST.CreateStatementPdf(StmtCur,pat,fam,dataSet); #if DEBUG FormST.PrintStatement(StmtCur,true,dataSet,fam,pat); FormST.ShowDialog(); #else FormST.PrintStatement(StmtCur,false,dataSet,fam,pat); #endif Cursor=Cursors.Default; } DialogResult=DialogResult.OK; }
private void butPreview_Click(object sender,EventArgs e) { if(StmtCur.DocNum!=0 && checkIsSent.Checked){//initiallySent && checkIsSent.Checked){ //launch existing archive pdf Cursor=Cursors.WaitCursor; Patient pat=Patients.GetPat(StmtCur.PatNum); string patFolder=ImageStore.GetPatientFolder(pat,ImageStore.GetPreferredAtoZpath()); Process.Start(ImageStore.GetFilePath(Documents.GetByNum(StmtCur.DocNum),patFolder)); Cursor=Cursors.Default; } else{//was not initially sent, or else user has unchecked the sent box //No archive to use, so just preview on the fly if(initiallySent && checkIsSent.Checked && StmtCur.DocNum==0){ MsgBox.Show(this,"There was no archived image of this statement. The preview will be based on current data."); } Cursor=Cursors.WaitCursor; if(!SaveToDb()){ Cursor=Cursors.Default; return; } FormRpStatement FormST=new FormRpStatement(); Family fam=Patients.GetFamily(StmtCur.PatNum); Patient pat=fam.GetPatient(StmtCur.PatNum); DataSet dataSet=AccountModules.GetStatementDataSet(StmtCur); FormST.PrintStatement(StmtCur,true,dataSet,fam,pat); FormST.ShowDialog(); Cursor=Cursors.Default; } }
/// <summary>Saves the statement. Attaches a pdf to it by creating a doc object. Prints it or emails it. </summary> private void PrintStatement(Statement stmt) { Cursor=Cursors.WaitCursor; Statements.Insert(stmt); FormRpStatement FormST=new FormRpStatement(); DataSet dataSet=AccountModules.GetStatementDataSet(stmt); FormST.CreateStatementPdf(stmt,PatCur,FamCur,dataSet); //if(ImageStore.UpdatePatient == null){ // ImageStore.UpdatePatient = new FileStore.UpdatePatientDelegate(Patients.Update); //} Patient guar=Patients.GetPat(stmt.PatNum); string guarFolder=ImageStore.GetPatientFolder(guar,ImageStore.GetPreferredAtoZpath()); //OpenDental.Imaging.ImageStoreBase imageStore = OpenDental.Imaging.ImageStore.GetImageStore(guar); if(stmt.Mode_==StatementMode.Email) { string attachPath=EmailMessages.GetEmailAttachPath(); Random rnd=new Random(); string fileName=DateTime.Now.ToString("yyyyMMdd")+"_"+DateTime.Now.TimeOfDay.Ticks.ToString()+rnd.Next(1000).ToString()+".pdf"; string filePathAndName=ODFileUtils.CombinePaths(attachPath,fileName); File.Copy(ImageStore.GetFilePath(Documents.GetByNum(stmt.DocNum),guarFolder),filePathAndName); //Process.Start(filePathAndName); EmailMessage message=Statements.GetEmailMessageForStatement(stmt,guar); EmailAttach attach=new EmailAttach(); attach.DisplayedFileName="Statement.pdf"; attach.ActualFileName=fileName; message.Attachments.Add(attach); FormEmailMessageEdit FormE=new FormEmailMessageEdit(message); FormE.IsNew=true; FormE.ShowDialog(); //If user clicked delete or cancel, delete pdf and statement if(FormE.DialogResult==DialogResult.Cancel) { Patient pat; string patFolder; if(stmt.DocNum!=0) { //delete the pdf pat=Patients.GetPat(stmt.PatNum); patFolder=ImageStore.GetPatientFolder(pat,ImageStore.GetPreferredAtoZpath()); List<Document> listdocs=new List<Document>(); listdocs.Add(Documents.GetByNum(stmt.DocNum)); try { ImageStore.DeleteDocuments(listdocs,patFolder); } catch { //Image could not be deleted, in use. //This should never get hit because the file was created by this user within this method. //If the doc cannot be deleted, then we will not stop them, they will have to manually delete it from the images module. } } //delete statement Procedures.DetachFromInvoice(stmt.StatementNum); Adjustments.DetachFromInvoice(stmt.StatementNum); Statements.DeleteObject(stmt); } } else {//not email #if DEBUG //don't bother to check valid path because it's just debug. string imgPath=ImageStore.GetFilePath(Documents.GetByNum(stmt.DocNum),guarFolder); DateTime now=DateTime.Now; while(DateTime.Now<now.AddSeconds(5) && !File.Exists(imgPath)) {//wait up to 5 seconds. Application.DoEvents(); } Process.Start(imgPath); #else FormST.PrintStatement(stmt,false,dataSet,FamCur,PatCur); #endif } Cursor=Cursors.Default; }
/// <summary>Saves the statement. Attaches a pdf to it by creating a doc object. Prints it or emails it. </summary> private void PrintStatement(Statement stmt) { Cursor=Cursors.WaitCursor; Statements.Insert(stmt); FormRpStatement FormST=new FormRpStatement(); DataSet dataSet=AccountModules.GetStatementDataSet(stmt); FormST.CreateStatementPdf(stmt,PatCur,FamCur,dataSet); //if(ImageStore.UpdatePatient == null){ // ImageStore.UpdatePatient = new FileStore.UpdatePatientDelegate(Patients.Update); //} Patient guar=Patients.GetPat(stmt.PatNum); string guarFolder=ImageStore.GetPatientFolder(guar,ImageStore.GetPreferredAtoZpath()); //OpenDental.Imaging.ImageStoreBase imageStore = OpenDental.Imaging.ImageStore.GetImageStore(guar); if(stmt.Mode_==StatementMode.Email){ string attachPath=FormEmailMessageEdit.GetAttachPath(); Random rnd=new Random(); string fileName=DateTime.Now.ToString("yyyyMMdd")+"_"+DateTime.Now.TimeOfDay.Ticks.ToString()+rnd.Next(1000).ToString()+".pdf"; string filePathAndName=ODFileUtils.CombinePaths(attachPath,fileName); File.Copy(ImageStore.GetFilePath(Documents.GetByNum(stmt.DocNum),guarFolder),filePathAndName); //Process.Start(filePathAndName); EmailMessage message=new EmailMessage(); message.PatNum=guar.PatNum; message.ToAddress=guar.Email; message.FromAddress=PrefC.GetString(PrefName.EmailSenderAddress); string str; str=PrefC.GetString(PrefName.BillingEmailSubject); str=str.Replace("[nameF]",guar.GetNameFirst()); str=str.Replace("[nameFL]",guar.GetNameFL()); str=str.Replace("[namePref]",guar.Preferred); str=str.Replace("[PatNum]",guar.PatNum.ToString()); message.Subject=str; str=PrefC.GetString(PrefName.BillingEmailBodyText); str=str.Replace("[nameF]",guar.GetNameFirst()); str=str.Replace("[nameFL]",guar.GetNameFL()); str=str.Replace("[namePref]",guar.Preferred); str=str.Replace("[PatNum]",guar.PatNum.ToString()); message.BodyText=str; EmailAttach attach=new EmailAttach(); attach.DisplayedFileName="Statement.pdf"; attach.ActualFileName=fileName; message.Attachments.Add(attach); FormEmailMessageEdit FormE=new FormEmailMessageEdit(message); FormE.IsNew=true; FormE.ShowDialog(); } else{ #if DEBUG //don't bother to check valid path because it's just debug. string imgPath=ImageStore.GetFilePath(Documents.GetByNum(stmt.DocNum),guarFolder); DateTime now=DateTime.Now; while(DateTime.Now<now.AddSeconds(5) && !File.Exists(imgPath)) {//wait up to 5 seconds. Application.DoEvents(); } Process.Start(imgPath); #else FormST.PrintStatement(stmt,false,dataSet,FamCur,PatCur); #endif } Cursor=Cursors.Default; }