Example #1
0
		private void butLabels_Click(object sender, System.EventArgs e) {
			if(Table.Rows.Count==0){
        MessageBox.Show(Lan.g(this,"There are no appointments in the list.  Must have at least one to print."));    
        return;
      }
			if(grid.SelectedIndices.Length==0){
				for(int i=0;i<Table.Rows.Count;i++){
					grid.SetSelected(i,true);
				}
			}
			List<long> aptNums=new List<long>();
			for(int i=0;i<grid.SelectedIndices.Length;i++) {
        aptNums.Add(PIn.Long(Table.Rows[grid.SelectedIndices[i]]["AptNum"].ToString()));
      }
			AddrTable=Appointments.GetAddrTable(aptNums);
			pagesPrinted=0;
			patientsPrinted=0;
			pd=new PrintDocument();
			pd.PrintPage+=new PrintPageEventHandler(this.pdLabels_PrintPage);
			pd.OriginAtMargins=true;
			pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			printPreview=new FormPrintPreview(PrintSituation.LabelSheet
				,pd,(int)Math.Ceiling((double)AddrTable.Rows.Count/30),0,"Confirmation list labels printed");
			printPreview.ShowDialog();
		}
Example #2
0
		private void but3A_Click(object sender,EventArgs e) {
			if(!DateIsValid()) {
				return;
			}
			Cursor.Current=Cursors.WaitCursor;
			PrintDocument pd=new PrintDocument();
			pd.PrintPage+=new PrintPageEventHandler(this.pdAgeGender_PrintPage);
			FormPrintPreview printPreview=new FormPrintPreview(PrintSituation.Default,pd,1,0,"UDS reporting 3A-AgeGender printed");
			printPreview.ShowDialog();
		}
Example #3
0
        private void butPostcards_Click(object sender, EventArgs e)
        {
            if (!validDateFrom.IsValid || !validDateTo.IsValid)
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            DateTime dateFrom = PIn.Date(validDateFrom.Text);
            DateTime dateTo   = PIn.Date(validDateTo.Text);

            if (dateTo < dateFrom)
            {
                MsgBox.Show(this, "To date cannot be before From date.");
                return;
            }
            if (dateFrom.AddYears(1) <= dateTo)
            {
                MsgBox.Show(this, "Date range must not exceed 1 year.");
                return;
            }
            BirthdayTable = RpBirthday.GetBirthdayTable(dateFrom, dateTo);
            if (BirthdayTable.Rows.Count == 0)
            {
                MsgBox.Show(this, "No postcards to preview.");
                return;
            }
            pagesPrinted    = 0;
            patientsPrinted = 0;
            pd                             = new PrintDocument();
            pd.PrintPage                  += new PrintPageEventHandler(this.pdCards_PrintPage);
            pd.OriginAtMargins             = true;
            pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
            if (PrefC.GetLong(PrefName.RecallPostcardsPerSheet) == 1)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 400, 600);
                pd.DefaultPageSettings.Landscape = true;
            }
            else if (PrefC.GetLong(PrefName.RecallPostcardsPerSheet) == 3)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 850, 1100);
            }
            else              //4
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 850, 1100);
                pd.DefaultPageSettings.Landscape = true;
            }
            printPreview = new FormPrintPreview(PrintSituation.Postcard, pd,
                                                (int)Math.Ceiling((double)BirthdayTable.Rows.Count / (double)PrefC.GetLong(PrefName.RecallPostcardsPerSheet)), 0, "Birthday report postcards printed");
            printPreview.ShowDialog();
        }
Example #4
0
        private void butPostcards_Click(object sender, EventArgs e)
        {
            if (errorProvider1.GetError(textDateFrom) != "" ||
                errorProvider1.GetError(textDateTo) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            DateTime dateFrom = DateTime.ParseExact(textDateFrom.Text, cultureDateFormat, CultureInfo.CurrentCulture);
            DateTime dateTo   = DateTime.ParseExact(textDateTo.Text, cultureDateFormat, CultureInfo.CurrentCulture);

            //DateTime dateFrom=PIn.PDate(textDateFrom.Text);
            //DateTime dateTo=PIn.PDate(textDateTo.Text);
            if (dateTo < dateFrom)
            {
                MsgBox.Show(this, "To date cannot be before From date.");
                return;
            }
            BirthdayTable = Patients.GetBirthdayList(dateFrom, dateTo);
            if (BirthdayTable.Rows.Count == 0)
            {
                MsgBox.Show(this, "No postcards to preview.");
                return;
            }
            pagesPrinted    = 0;
            patientsPrinted = 0;
            pd                             = new PrintDocument();
            pd.PrintPage                  += new PrintPageEventHandler(this.pdCards_PrintPage);
            pd.OriginAtMargins             = true;
            pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
            if (PrefC.GetLong(PrefName.RecallPostcardsPerSheet) == 1)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 400, 600);
                pd.DefaultPageSettings.Landscape = true;
            }
            else if (PrefC.GetLong(PrefName.RecallPostcardsPerSheet) == 3)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 850, 1100);
            }
            else              //4
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 850, 1100);
                pd.DefaultPageSettings.Landscape = true;
            }
            printPreview = new FormPrintPreview(PrintSituation.Postcard, pd,
                                                (int)Math.Ceiling((double)BirthdayTable.Rows.Count / (double)PrefC.GetLong(PrefName.RecallPostcardsPerSheet)), 0, "Birthday report postcards printed");
            printPreview.ShowDialog();
        }
		///<summary>Surround with try/catch.</summary>
		public static void PrintBatch(List<Sheet> sheetBatch){
			//currently no validation for parameters in a batch because of the way it was created.
			//could validate field names here later.
			SheetList=sheetBatch;
			sheetsPrinted=0;
			PrintDocument pd=new PrintDocument();
			pd.OriginAtMargins=true;
			pd.PrintPage+=new PrintPageEventHandler(pd_PrintPage);
			if(sheetBatch[0].Width>0 && sheetBatch[0].Height>0){
				pd.DefaultPageSettings.PaperSize=new PaperSize("Default",sheetBatch[0].Width,sheetBatch[0].Height);
			}
			PrintSituation sit=PrintSituation.Default;
			pd.DefaultPageSettings.Landscape=sheetBatch[0].IsLandscape;
			switch(sheetBatch[0].SheetType){
				case SheetTypeEnum.LabelPatient:
				case SheetTypeEnum.LabelCarrier:
				case SheetTypeEnum.LabelReferral:
					sit=PrintSituation.LabelSingle;
					break;
				case SheetTypeEnum.ReferralSlip:
					sit=PrintSituation.Default;
					break;
			}
			//later: add a check here for print preview.
			#if DEBUG
				pd.DefaultPageSettings.Margins=new Margins(20,20,0,0);
				FormPrintPreview printPreview=new FormPrintPreview(sit,pd,SheetList.Count,0,"Batch of "+sheetBatch[0].Description+" printed");
				printPreview.ShowDialog();
			#else
				try {
					if(!PrinterL.SetPrinter(pd,sit,0,"Batch of "+sheetBatch[0].Description+" printed")) {
						return;
					}
					pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
					pd.Print();
				}
				catch(Exception ex){
					throw ex;
					//MessageBox.Show(Lan.g("Sheet","Printer not available"));
				}
			#endif
		}
Example #6
0
		///<summary>Changes made to printing confirmation postcards need to be made in FormRecallList.butPostcards_Click() as well.</summary>
		private void butPostcards_Click(object sender,System.EventArgs e) {
			if(Table.Rows.Count==0) {
				MessageBox.Show(Lan.g(this,"There are no appointments in the list.  Must have at least one to print."));
				return;
			}
			if(grid.SelectedIndices.Length==0) {
				ContactMethod cmeth;
				for(int i=0;i<Table.Rows.Count;i++) {
					cmeth=(ContactMethod)PIn.Long(Table.Rows[i]["PreferConfirmMethod"].ToString());
					if(cmeth!=ContactMethod.Mail && cmeth!=ContactMethod.None) {
						continue;
					}
					grid.SetSelected(i,true);
				}
			}
			List<long> aptNums=new List<long>();
			for(int i=0;i<grid.SelectedIndices.Length;i++) {
				aptNums.Add(PIn.Long(Table.Rows[grid.SelectedIndices[i]]["AptNum"].ToString()));
			}
			AddrTable=Appointments.GetAddrTable(aptNums);
			pagesPrinted=0;
			patientsPrinted=0;
			pd=new PrintDocument();
			pd.PrintPage+=new PrintPageEventHandler(this.pdCards_PrintPage);
			pd.OriginAtMargins=true;
			pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			if(PrefC.GetLong(PrefName.RecallPostcardsPerSheet)==1) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",500,700);
				pd.DefaultPageSettings.Landscape=true;
			}
			else if(PrefC.GetLong(PrefName.RecallPostcardsPerSheet)==3) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",850,1100);
			}
			else {//4
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",850,1100);
				pd.DefaultPageSettings.Landscape=true;
			}
			printPreview=new FormPrintPreview(PrintSituation.Postcard,pd,
				(int)Math.Ceiling((double)AddrTable.Rows.Count/(double)PrefC.GetLong(PrefName.RecallPostcardsPerSheet)),0,"Confirmation list postcards printed");
			printPreview.ShowDialog();
		}
		///<summary>Changes made to printing recall postcards need to be made in FormConfirmList.butPostcards_Click() as well.</summary>
		private void butPostcards_Click(object sender,System.EventArgs e) {
			if(gridMain.Rows.Count < 1) {
				MessageBox.Show(Lan.g(this,"There are no Patients in the Recall table.  Must have at least one to print."));
				return;
			}
			if(PrefC.GetLong(PrefName.RecallStatusMailed)==0) {
				MsgBox.Show(this,"You need to set a status first in the Recall Setup window.");
				return;
			}
			if(gridMain.SelectedIndices.Length==0) {
				ContactMethod cmeth;
				for(int i=0;i<table.Rows.Count;i++) {
					//if(table.Rows[i]["status"].ToString()!=""){//we only want rows without a status
					//	continue;
					//}
					cmeth=(ContactMethod)PIn.Long(table.Rows[i]["PreferRecallMethod"].ToString());
					if(cmeth!=ContactMethod.Mail && cmeth!=ContactMethod.None) {
						continue;
					}
					gridMain.SetSelected(i,true);
				}
				if(gridMain.SelectedIndices.Length==0) {
					MsgBox.Show(this,"No patients of mail type.");
					return;
				}
				if(!MsgBox.Show(this,MsgBoxButtons.OKCancel,"Preview postcards for all of the selected patients?")) {
					return;
				}
			}
			List<long> recallNums=new List<long>();
			for(int i=0;i<gridMain.SelectedIndices.Length;i++) {
				recallNums.Add(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["RecallNum"].ToString()));
			}
			RecallListSort sortBy=(RecallListSort)comboSort.SelectedIndex;
			addrTable=Recalls.GetAddrTable(recallNums,checkGroupFamilies.Checked,sortBy);
			pagesPrinted=0;
			patientsPrinted=0;
			pd=new PrintDocument();
			pd.PrintPage+=new PrintPageEventHandler(this.pdCards_PrintPage);
			pd.OriginAtMargins=true;
			pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			if(PrefC.GetLong(PrefName.RecallPostcardsPerSheet)==1) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",500,700);
				pd.DefaultPageSettings.Landscape=true;
			}
			else if(PrefC.GetLong(PrefName.RecallPostcardsPerSheet)==3) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",850,1100);
			}
			else {//4
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",850,1100);
				pd.DefaultPageSettings.Landscape=true;
			}
			int totalPages=(int)Math.Ceiling((double)addrTable.Rows.Count/(double)PrefC.GetLong(PrefName.RecallPostcardsPerSheet));
			printPreview=new FormPrintPreview(PrintSituation.Postcard,pd,totalPages,0,"Recall list postcards printed");
			printPreview.ShowDialog();
			if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Did all the postcards finish printing correctly?  Statuses will be changed and commlog entries made for all of the selected patients.  Click Yes only if postcards printed successfully.")) {
				Cursor=Cursors.WaitCursor;
				for(int i=0;i<gridMain.SelectedIndices.Length;i++) {
					//make commlog entries for each patient
					Commlogs.InsertForRecall(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PatNum"].ToString()),CommItemMode.Mail,
						PIn.Int(table.Rows[gridMain.SelectedIndices[i]]["numberOfReminders"].ToString()),PrefC.GetLong(PrefName.RecallStatusMailed));
				}
				for(int i=0;i<gridMain.SelectedIndices.Length;i++) {
					Recalls.UpdateStatus(
						PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["RecallNum"].ToString()),PrefC.GetLong(PrefName.RecallStatusMailed));
				}
			}
			FillMain(null);
			Cursor=Cursors.Default;
		}
		private void butLabels_Click(object sender, System.EventArgs e) {
			if(gridMain.Rows.Count < 1){
        MessageBox.Show(Lan.g(this,"There are no Patients in the Recall table.  Must have at least one to print."));    
        return;
      }
			if(PrefC.GetLong(PrefName.RecallStatusMailed)==0){
				MsgBox.Show(this,"You need to set a status first in the Recall Setup window.");
				return;
			}
			if(gridMain.SelectedIndices.Length==0){
				ContactMethod cmeth;
				for(int i=0;i<table.Rows.Count;i++){
					if(table.Rows[i]["status"].ToString()!=""){//we only want rows without a status
						continue;
					}
					cmeth=(ContactMethod)PIn.Long(table.Rows[i]["PreferRecallMethod"].ToString());
					if(cmeth!=ContactMethod.Mail && cmeth!=ContactMethod.None){
						continue;
					}
					gridMain.SetSelected(i,true);
				}
				if(gridMain.SelectedIndices.Length==0){
					MsgBox.Show(this,"No patients of mail type.");
					return;
				}
				if(!MsgBox.Show(this,true,"Preview labels for all of the selected patients?")) {
					return;
				}
			}
			List<long> recallNums=new List<long>();
      for(int i=0;i<gridMain.SelectedIndices.Length;i++){
        recallNums.Add(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["RecallNum"].ToString()));
      }
			RecallListSort sortBy=(RecallListSort)comboSort.SelectedIndex;
			addrTable=Recalls.GetAddrTable(recallNums,checkGroupFamilies.Checked,sortBy);
			pagesPrinted=0;
			patientsPrinted=0;
			pd=new PrintDocument();
			pd.PrintPage+=new PrintPageEventHandler(this.pdLabels_PrintPage);
			pd.OriginAtMargins=true;
			pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			printPreview=new FormPrintPreview(PrintSituation.LabelSheet
				,pd,(int)Math.Ceiling((double)addrTable.Rows.Count/30),0,"Recall list labels printed");
			//printPreview.Document=pd;
			//printPreview.TotalPages=;
			printPreview.ShowDialog();
			if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Change statuses and make commlog entries for all of the selected patients?")) {
				Cursor=Cursors.WaitCursor;
				for(int i=0;i<gridMain.SelectedIndices.Length;i++) {
					//make commlog entries for each patient
					Commlogs.InsertForRecall(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PatNum"].ToString()),CommItemMode.Mail,
						PIn.Int(table.Rows[gridMain.SelectedIndices[i]]["numberOfReminders"].ToString()),PrefC.GetLong(PrefName.RecallStatusMailed));
				}
				for(int i=0;i<gridMain.SelectedIndices.Length;i++) {
					Recalls.UpdateStatus(
						PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["RecallNum"].ToString()),PrefC.GetLong(PrefName.RecallStatusMailed));
				}
			}
			FillMain(null);
			Cursor=Cursors.Default;
		}
Example #9
0
		///<summary>Print timecards for selected employees only.</summary>
		private void butPrintSelected_Click(object sender,EventArgs e) {
			_pagesPrinted=0;
			PrintDocument pd=new PrintDocument();
			pd.PrintPage += new PrintPageEventHandler(this.pd2_PrintPageSelective);
			FormPrintPreview pView=new FormPrintPreview(PrintSituation.Default,pd,gridMain.SelectedIndices.Length,0,"Employee timecards printed");
			pView.ShowDialog();
		}
Example #10
0
		///<Summary></Summary>
		public static void Print(Sheet sheet,int copies,bool isRxControlled){
			//parameter null check moved to SheetFiller.
			//could validate field names here later.
			SheetList=new List<Sheet>();
			for(int i=0;i<copies;i++){
				SheetList.Add(sheet.Copy());
			}
			sheetsPrinted=0;
			PrintDocument pd=new PrintDocument();
			pd.OriginAtMargins=true;
			pd.PrintPage+=new PrintPageEventHandler(pd_PrintPage);
			if(pd.DefaultPageSettings.PrintableArea.Width==0) {
				//prevents bug in some printers that do not specify paper size
				pd.DefaultPageSettings.PaperSize=new PaperSize("paper",850,1100);
			}
			if(sheet.SheetType==SheetTypeEnum.LabelPatient
				|| sheet.SheetType==SheetTypeEnum.LabelCarrier
				|| sheet.SheetType==SheetTypeEnum.LabelAppointment
				|| sheet.SheetType==SheetTypeEnum.LabelReferral) 
			{//I think this causes problems for non-label sheet types.
				if(sheet.Width>0 && sheet.Height>0) {
					pd.DefaultPageSettings.PaperSize=new PaperSize("Default",sheet.Width,sheet.Height);
				}
			}
			PrintSituation sit=PrintSituation.Default;
			pd.DefaultPageSettings.Landscape=sheet.IsLandscape;
			switch(sheet.SheetType){
				case SheetTypeEnum.LabelPatient:
				case SheetTypeEnum.LabelCarrier:
				case SheetTypeEnum.LabelReferral:
				case SheetTypeEnum.LabelAppointment:
					sit=PrintSituation.LabelSingle;
					break;
				case SheetTypeEnum.ReferralSlip:
					sit=PrintSituation.Default;
					break;
				case SheetTypeEnum.Rx:
					if(isRxControlled){
						sit=PrintSituation.RxControlled;
					}
					else{
						sit=PrintSituation.Rx;
					}
					break;
			}
			//later: add a check here for print preview.
			#if DEBUG
				pd.DefaultPageSettings.Margins=new Margins(20,20,0,0);
				FormPrintPreview printPreview;
				printPreview=new FormPrintPreview(sit,pd,SheetList.Count,sheet.PatNum,sheet.Description+" sheet from "+sheet.DateTimeSheet.ToShortDateString()+" printed");
				printPreview.ShowDialog();
			#else
				try {
					if(sheet.PatNum!=null){
						if(!PrinterL.SetPrinter(pd,sit,sheet.PatNum,sheet.Description+" sheet from "+sheet.DateTimeSheet.ToShortDateString()+" printed")) {
							return;
						}
					}
					else{
						if(!PrinterL.SetPrinter(pd,sit,0,sheet.Description+" sheet from "+sheet.DateTimeSheet.ToShortDateString()+" printed")) {
							return;
						}
					}
					pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
					pd.Print();
				}
				catch(Exception ex){
					throw ex;
					//MessageBox.Show(Lan.g("Sheet","Printer not available"));
				}
			#endif
		}
Example #11
0
		private void buildLabels() {
			if(AddrTable.Rows.Count > 0) {
				if(iLabelStart > 0) {
					addBlankLabels();
				}
				pagesPrinted = 0;
				labelsPrinted = 0;
				pd = new PrintDocument();
				pd.PrintPage += new PrintPageEventHandler(this.pdLabels_PrintPage);
				pd.OriginAtMargins = true;
				pd.DefaultPageSettings.Margins = new Margins(0,0,0,0);
				printPreview = new FormPrintPreview(PrintSituation.LabelSheet
						,pd,(int)Math.Ceiling((double)AddrTable.Rows.Count / 30),0,"Laser labels printed");
				printPreview.ShowDialog();
			}
			else {
				MessageBox.Show("No Labels to Print for Selected Criteria");
			}
		}
Example #12
0
		private void butLabelPreview_Click(object sender,EventArgs e) {
			if(gridMain.SelectedIndices.Length==0){
				MsgBox.Show(this,"Please select patient(s) first.");
		    return;
			}
			pagesPrinted=0;
			patientsPrinted=0;
			pd=new PrintDocument();
			pd.PrintPage+=new PrintPageEventHandler(this.pdLabels_PrintPage);
			pd.OriginAtMargins=true;
			pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			FormPrintPreview printPreview=new FormPrintPreview(PrintSituation.LabelSheet
			  ,pd,(int)Math.Ceiling((double)gridMain.SelectedIndices.Length/30),0,"Treatment finder labels printed");
			printPreview.ShowDialog();
		}
Example #13
0
		/////<summary>Not used. This code is copied and pasted in several locations. Easiest to find by searching for "info.Verb="print";"</summary>
		//public static void PrintStatement(object parameters) {
		//	List<object> listParams=(List<object>)parameters;
		//	SheetDef sheetDef=(SheetDef)listParams[0];
		//	Statement stmt=(Statement)listParams[1];
		//	string filePath=(string)listParams[2];
		//	try {
		//		ProcessStartInfo info=new ProcessStartInfo();
		//		info.Arguments = "\"" + Printers.GetForSit(PrintSituation.Statement).PrinterName + "\"";
		//		info.UseShellExecute = true;
		//		info.Verb="PrintTo";
		//		info.FileName=filePath;
		//		info.CreateNoWindow=true;
		//		info.WindowStyle=ProcessWindowStyle.Hidden;
		//		Process p=new Process();
		//		p.StartInfo=info;
		//		p.Start();
		//		p.WaitForInputIdle();
		//		System.Threading.Thread.Sleep(3000);
		//		if(p.CloseMainWindow()==false) {
		//			p.Kill();
		//		}
		//	}
		//	catch(Exception ex) {
		//		//Must restet sheet, as PDF printing modifies fields.
		//		Sheet sheet=SheetUtil.CreateSheet(sheetDef,stmt.PatNum,stmt.HidePayment);
		//		SheetFiller.FillFields(sheet,stmt);
		//		SheetUtil.CalculateHeights(sheet,Graphics.FromImage(new Bitmap(sheet.HeightPage,sheet.WidthPage)),stmt);
		//		SheetPrinting.Print(sheet,1,false,stmt);//use GDI+ printing, which is slightly different than the pdf.
		//	}
		//}

		///<summary>Surround with try/catch.</summary>
		public static void PrintBatch(List<Sheet> sheetBatch,Statement stmt=null){
			//currently no validation for parameters in a batch because of the way it was created.
			//could validate field names here later.
			_sheetList=sheetBatch;
			_sheetsPrinted=0;
			_pagesPrinted=0;
			_yPosPrint=0;
			PrintDocument pd=new PrintDocument();
			pd.OriginAtMargins=true;
			pd.PrintPage+=new PrintPageEventHandler(pd_PrintPage);
			if(sheetBatch[0].Width>0 && sheetBatch[0].Height>0){
				pd.DefaultPageSettings.PaperSize=new PaperSize("Default",sheetBatch[0].Width,sheetBatch[0].Height);
			}
			PrintSituation sit=PrintSituation.Default;
			pd.DefaultPageSettings.Landscape=sheetBatch[0].IsLandscape;
			switch(sheetBatch[0].SheetType){
				case SheetTypeEnum.LabelPatient:
				case SheetTypeEnum.LabelCarrier:
				case SheetTypeEnum.LabelReferral:
					sit=PrintSituation.LabelSingle;
					break;
				case SheetTypeEnum.ReferralSlip:
					sit=PrintSituation.Default;
					break;
			}
			//Moved Calculate heights here because we need to caluclate height before printing, not while we are printing.
			foreach(Sheet s in _sheetList) {
				SheetUtil.CalculateHeights(s,Graphics.FromImage(new Bitmap(s.WidthPage,s.HeightPage)),stmt,_isPrinting,_printMargin.Top,_printMargin.Bottom);
			}
			//later: add a check here for print preview.
			#if DEBUG
				pd.DefaultPageSettings.Margins=new Margins(20,20,0,0);
				int pageCount=0;
				foreach(Sheet s in _sheetList) {
					//SetForceSinglePage(s);
					SheetUtil.CalculateHeights(s,Graphics.FromImage(new Bitmap(s.WidthPage,s.HeightPage)),stmt,_isPrinting,_printMargin.Top,_printMargin.Bottom);
					pageCount+=Sheets.CalculatePageCount(s,_printMargin);//(_forceSinglePage?1:Sheets.CalculatePageCount(s,_printMargin));
				}
				FormPrintPreview printPreview=new FormPrintPreview(sit,pd,pageCount,0,"Batch of "+sheetBatch[0].Description+" printed");
				printPreview.ShowDialog();
			#else
				try {
					foreach(Sheet s in _sheetList) {
						s.SheetFields.Sort(OpenDentBusiness.SheetFields.SortDrawingOrderLayers);
					}
					if(!PrinterL.SetPrinter(pd,sit,0,"Batch of "+sheetBatch[0].Description+" printed")) {
						return;
					}
					pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
					pd.Print();
				}
				catch(Exception ex){
					throw ex;
					//MessageBox.Show(Lan.g("Sheet","Printer not available"));
				}
			#endif
		}
Example #14
0
		///<Summary></Summary>
		public static void Print(Sheet sheet,int copies=1,bool isRxControlled=false,Statement stmt=null,MedLab medLab=null){
			//parameter null check moved to SheetFiller.
			//could validate field names here later.
			_stmt=stmt;
			_medLab=medLab;
			_isPrinting=true;
			_sheetsPrinted=0;
			_yPosPrint=0;// _printMargin.Top;
			PrintDocument pd=new PrintDocument();
			pd.OriginAtMargins=true;
			pd.PrintPage+=new PrintPageEventHandler(pd_PrintPage);
			if(pd.DefaultPageSettings.PrintableArea.Width==0) {
				//prevents bug in some printers that do not specify paper size
				pd.DefaultPageSettings.PaperSize=new PaperSize("paper",850,1100);
			}
			if(sheet.SheetType==SheetTypeEnum.LabelPatient
				|| sheet.SheetType==SheetTypeEnum.LabelCarrier
				|| sheet.SheetType==SheetTypeEnum.LabelAppointment
				|| sheet.SheetType==SheetTypeEnum.LabelReferral) 
			{//I think this causes problems for non-label sheet types.
				if(sheet.Width>0 && sheet.Height>0) {
					pd.DefaultPageSettings.PaperSize=new PaperSize("Default",sheet.Width,sheet.Height);
				}
			}
			pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			pd.OriginAtMargins=true;
			PrintSituation sit=PrintSituation.Default;
			pd.DefaultPageSettings.Landscape=sheet.IsLandscape;
			switch(sheet.SheetType){
				case SheetTypeEnum.LabelPatient:
				case SheetTypeEnum.LabelCarrier:
				case SheetTypeEnum.LabelReferral:
				case SheetTypeEnum.LabelAppointment:
					sit=PrintSituation.LabelSingle;
					break;
				case SheetTypeEnum.ReferralSlip:
					sit=PrintSituation.Default;
					break;
				case SheetTypeEnum.Rx:
					if(isRxControlled){
						sit=PrintSituation.RxControlled;
					}
					else{
						sit=PrintSituation.Rx;
					}
					break;
				case SheetTypeEnum.Statement:
					sit= PrintSituation.Statement;
					break;
			}
			_printMargin.Top=40;//default top margin
			if(sheet.SheetType==SheetTypeEnum.MedLabResults) {
				_printMargin.Top=120;
			}
			Sheets.SetPageMargin(sheet,_printMargin);
			Graphics g=Graphics.FromImage(new Bitmap(sheet.WidthPage,sheet.HeightPage));
			g.SmoothingMode=SmoothingMode.HighQuality;
			g.InterpolationMode=InterpolationMode.HighQualityBicubic;//Necessary for very large images that need to be scaled down.
			SheetUtil.CalculateHeights(sheet,g,_stmt,_isPrinting,_printMargin.Top,_printMargin.Bottom,_medLab);
			_sheetList=new List<Sheet>();
			for(int i=0;i<copies;i++) {
				_sheetList.Add(sheet.Copy());
			}
			//later: add a check here for print preview.
		#if DEBUG
			FormPrintPreview printPreview;
			int pageCount=0;
			foreach(Sheet s in _sheetList) {
				pageCount+=Sheets.CalculatePageCount(s,_printMargin);
			}
			printPreview=new FormPrintPreview(sit,pd,pageCount,sheet.PatNum,sheet.Description+" sheet from "+sheet.DateTimeSheet.ToShortDateString()+" printed");
			printPreview.ShowDialog();
		#else
				try {
					if(sheet.PatNum!=null){
						if(!PrinterL.SetPrinter(pd,sit,sheet.PatNum,sheet.Description+" sheet from "+sheet.DateTimeSheet.ToShortDateString()+" printed")) {
							return;
						}
					}
					else{
						if(!PrinterL.SetPrinter(pd,sit,0,sheet.Description+" sheet from "+sheet.DateTimeSheet.ToShortDateString()+" printed")) {
							return;
						}
					}
					pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
					pd.Print();
				}
				catch(Exception ex){
					throw ex;
					//MessageBox.Show(Lan.g("Sheet","Printer not available"));
				}
		#endif
			_isPrinting=false;
			g.Dispose();
			g=null;
			GC.Collect();
		}
		private void butPrint_Click(object sender,EventArgs e) {
			LogTextPrint=textLog.Text;
			pd2 = new PrintDocument();
			pd2.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage);
			pd2.DefaultPageSettings.Margins=new Margins(40,50,50,60);
			try {
				#if DEBUG
				FormPrintPreview printPreview=new FormPrintPreview(PrintSituation.Default,pd2,0,0,"Database Maintenance log printed");
				printPreview.ShowDialog();
				#else
				pd2.Print();
				#endif
			}
			catch {
				MessageBox.Show("Printer not available");
			}
		}
Example #16
0
		private void butPostcards_Click(object sender,EventArgs e) {
			if(errorProvider1.GetError(textDateFrom) != ""
				|| errorProvider1.GetError(textDateTo) != "") {
				MsgBox.Show(this,"Please fix data entry errors first.");
				return;
			}
			DateTime dateFrom=DateTime.ParseExact(textDateFrom.Text,cultureDateFormat,CultureInfo.CurrentCulture);
			DateTime dateTo=DateTime.ParseExact(textDateTo.Text,cultureDateFormat,CultureInfo.CurrentCulture);
			//DateTime dateFrom=PIn.PDate(textDateFrom.Text);
			//DateTime dateTo=PIn.PDate(textDateTo.Text);
			if(dateTo < dateFrom) {
				MsgBox.Show(this,"To date cannot be before From date.");
				return;
			}
			BirthdayTable=Patients.GetBirthdayList(dateFrom,dateTo);
			if(BirthdayTable.Rows.Count==0) {
				MsgBox.Show(this,"No postcards to preview.");
				return;
			}
			pagesPrinted=0;
			patientsPrinted=0;
			pd=new PrintDocument();
			pd.PrintPage+=new PrintPageEventHandler(this.pdCards_PrintPage);
			pd.OriginAtMargins=true;
			pd.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			if(PrefC.GetLong(PrefName.RecallPostcardsPerSheet)==1) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",400,600);
				pd.DefaultPageSettings.Landscape=true;
			}
			else if(PrefC.GetLong(PrefName.RecallPostcardsPerSheet)==3) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",850,1100);
			}
			else {//4
				pd.DefaultPageSettings.PaperSize=new PaperSize("Postcard",850,1100);
				pd.DefaultPageSettings.Landscape=true;
			}
			printPreview=new FormPrintPreview(PrintSituation.Postcard,pd,
				(int)Math.Ceiling((double)BirthdayTable.Rows.Count/(double)PrefC.GetLong(PrefName.RecallPostcardsPerSheet)),0,"Birthday report postcards printed");
			printPreview.ShowDialog();
		}
Example #17
0
		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;
			pd.DefaultPageSettings.Landscape=true;
			if(pd.DefaultPageSettings.PrintableArea.Height==0) {
				pd.DefaultPageSettings.PaperSize=new PaperSize("default",850,1100);
			}
			headingPrinted=false;
			#if DEBUG
				FormPrintPreview printPreview=new FormPrintPreview(PrintSituation.Default,pd,1,0,"Audit trail printed");
				printPreview.ShowDialog();
			#else
				try {
					if(PrinterL.SetPrinter(pd,PrintSituation.Default,0,"Audit trail printed")) {
						pd.Print();
					}
				}
				catch {
					MessageBox.Show(Lan.g(this,"Printer not available"));
				}
			#endif
		}
Example #18
0
		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 DEBUG
				FormPrintPreview printPreview=new FormPrintPreview(PrintSituation.Default,pd,1,0,"Time card for "+EmployeeCur.LName+","+EmployeeCur.FName+" printed");
				printPreview.ShowDialog();
			#else
				try {
					if(PrinterL.SetPrinter(pd,PrintSituation.Default,0,"Time card for "+EmployeeCur.LName+","+EmployeeCur.FName+" printed")) {
						pd.Print();
					}
				}
				catch {
					MessageBox.Show(Lan.g(this,"Printer not available"));
				}
			#endif
		}
		//Prints one timecard for each employee.
		private void butPrintAll_Click(object sender,EventArgs e) {
			pagesPrinted=0;
			PrintDocument pd=new PrintDocument();
			pd.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage);
			FormPrintPreview pView=new FormPrintPreview(PrintSituation.Default,pd,gridMain.Rows.Count,0,"Employee timecards printed");
			pView.ShowDialog();
		}