private void butPrint_Click(object sender, EventArgs e) { linesPrinted = 0; pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd.OriginAtMargins = true; if (pd.DefaultPageSettings.PaperSize.Height == 0) { pd.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100); } #if DEBUG printPreview = new PrintPreview(PrintSituation.Default, pd, 1); printPreview.ShowDialog(); #else try { if (Printers.SetPrinter(pd, PrintSituation.Default)) { pd.Print(); } } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } #endif }
///<summary>Preview is only used for debugging.</summary> public void PrintReport(bool justPreview) { pd2 = new PrintDocument(); pd2.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage); pd2.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd2.OriginAtMargins = true; if (pd2.DefaultPageSettings.PaperSize.Height == 0) { pd2.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100); } headingPrinted = false; //isPrinting=true; //FillGrid(); try { if (justPreview) { FormRpPrintPreview pView = new FormRpPrintPreview(); pView.printPreviewControl2.Document = pd2; pView.ShowDialog(); } else { if (Printers.SetPrinter(pd2, PrintSituation.Default)) { pd2.Print(); } } } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } //isPrinting=false; }
private void OnLabels_Click() { if (gridMain.SelectedIndices.Length == 0) { MessageBox.Show(Lan.g(this, "Please select an item first.")); return; } PrintDocument pd = new PrintDocument(); //only used to pass printerName if (!Printers.SetPrinter(pd, PrintSituation.LabelSingle)) { return; } Carrier carrier; Claim claim; InsPlan plan; for (int i = 0; i < gridMain.SelectedIndices.Length; i++) { claim = Claims.GetClaim(listQueue[gridMain.SelectedIndices[i]].ClaimNum); plan = InsPlans.GetPlan(claim.PlanNum, new InsPlan[] {}); carrier = Carriers.GetCarrier(plan.CarrierNum); LabelSingle label = new LabelSingle(); if (!label.PrintIns(carrier, pd.PrinterSettings.PrinterName)) { return; } } }
///<summary></summary> public void PrintReport() { pd2 = new PrintDocument(); pd2.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage); pd2.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd2.OriginAtMargins = true; if (!PrefB.GetBool("RxOrientVert")) { pd2.DefaultPageSettings.Landscape = true; } #if DEBUG pd2.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100); pView.printPreviewControl2.Document = pd2; pView.ShowDialog(); #else if (!Printers.SetPrinter(pd2, PrintSituation.Rx)) { return; } try{ pd2.Print(); } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } #endif }
/*private void butSave_Click(object sender, System.EventArgs e) { * if( textDateStart.errorProvider1.GetError(textDateStart)!="" || textDateEnd.errorProvider1.GetError(textDateEnd)!="") || { || MessageBox.Show(Lan.g(this,"Please fix data entry errors first.")); || return; || } || int daysPast=((TimeSpan)(DateTime.Today-PIn.PDate(textDateStart.Text))).Days;//can be neg || int daysFuture=((TimeSpan)(PIn.PDate(textDateEnd.Text)-DateTime.Today)).Days;//can be neg || if(Prefs.UpdateBool("RecallGroupByFamily",checkGroupFamilies.Checked) | Prefs.UpdateInt("RecallDaysPast",daysPast) | Prefs.UpdateInt("RecallDaysFuture",daysFuture)) | { | DataValid.SetInvalid(InvalidTypes.Prefs); | } | }*/ private void butPrint_Click(object sender, EventArgs e) { pagesPrinted = 0; pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); pd.DefaultPageSettings.Margins = new Margins(25, 25, 40, 40); //pd.OriginAtMargins=true; if (pd.DefaultPageSettings.PaperSize.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 (Printers.SetPrinter(pd, PrintSituation.Default)) { pd.Print(); } #endif } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } }
private void OnBlank_Click() { PrintDocument pd = new PrintDocument(); if (!Printers.SetPrinter(pd, PrintSituation.Claim)) { return; } FormClaimPrint FormCP = new FormClaimPrint(); FormCP.PrintBlank = true; FormCP.PrintImmediate(pd.PrinterSettings.PrinterName, pd.PrinterSettings.Copies); }
///<summary></summary> public void PrintReport(bool justPreview) { pd2 = new PrintDocument(); pd2.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage); // pd2.DefaultPageSettings.Margins= new Margins(10,40,40,60); try { if (justPreview) { printPreviewControl2.Document = pd2; } else if (Printers.SetPrinter(pd2, PrintSituation.Default)) { pd2.Print(); } } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } }
///<summary></summary> public void PrintPat(Patient pat) { Pat = pat.Copy(); pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintPagePat); pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd.OriginAtMargins = true; pd.DefaultPageSettings.Landscape = false; if (!Printers.SetPrinter(pd, PrintSituation.LabelSingle)) { return; } try{ pd.Print(); } catch { MessageBox.Show(Lan.g("Label", "Printer not available")); } }
private void Print_Click(){ PrintDocument pd=new PrintDocument(); pd.DocumentName=viewer.SourceFile; pd.PrinterSettings.FromPage=1; pd.PrinterSettings.ToPage=viewer.PageCount; pd.PrinterSettings.MaximumPage=viewer.PageCount; pd.PrinterSettings.MinimumPage=1; pd.DefaultPageSettings.Landscape=viewer.PageWidth>viewer.PageHeight; try{ if(Printers.SetPrinter(pd,PrintSituation.Default)){ if(pd.PrinterSettings.PrintRange==PrintRange.Selection) { pd.PrinterSettings.FromPage=viewer.PageCurrent; } viewer.Print(pd); } } catch{ MessageBox.Show(Lan.g(this,"Printer not available")); } }
private void OnPrint_Click() { FormClaimPrint FormCP = new FormClaimPrint(); if (gridMain.SelectedIndices.Length == 0) { for (int i = 0; i < listQueue.Length; i++) { if ((listQueue[i].ClaimStatus == "W" || listQueue[i].ClaimStatus == "P") && listQueue[i].NoSendElect) { gridMain.SetSelected(i, true); } } if (MessageBox.Show(Lan.g(this, "No items were selected. Print all selected paper claims?"), "" , MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } PrintDocument pd = new PrintDocument(); if (!Printers.SetPrinter(pd, PrintSituation.Claim)) { return; } for (int i = 0; i < gridMain.SelectedIndices.Length; i++) { FormCP.ThisPatNum = listQueue[gridMain.SelectedIndices[i]].PatNum; FormCP.ThisClaimNum = listQueue[gridMain.SelectedIndices[i]].ClaimNum; if (!FormCP.PrintImmediate(pd.PrinterSettings.PrinterName, 1)) { return; } Etranss.SetClaimSentOrPrinted(listQueue[gridMain.SelectedIndices[i]].ClaimNum, listQueue[gridMain.SelectedIndices[i]].PatNum, 0, EtransType.ClaimPrinted); } FillGrid(); FillHistory(); }
private void butPrint_Click(object sender, System.EventArgs e) { if (textBody.Text == "") { MsgBox.Show(this, "Letter not allowed to be blank."); return; } pd2 = new PrintDocument(); pd2.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage); pd2.OriginAtMargins = true; if (!Printers.SetPrinter(pd2, PrintSituation.Default)) { return; } try{ pd2.Print(); } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } Commlog CommlogCur = new Commlog(); CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType = CommItemType.Misc; CommlogCur.PatNum = PatCur.PatNum; CommlogCur.Note = "Letter sent"; if (LetterCur != null) { CommlogCur.Note += ": " + LetterCur.Description + ". "; } FormCommItem FormCI = new FormCommItem(CommlogCur); FormCI.IsNew = true; FormCI.ShowDialog(); //this window now closes regardless of whether the user saved the comm item. DialogResult = DialogResult.OK; }
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; }