public static long Insert(ClaimAttach attach) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				attach.ClaimAttachNum=Meth.GetLong(MethodBase.GetCurrentMethod(),attach);
				return attach.ClaimAttachNum;
			}
			return Crud.ClaimAttachCrud.Insert(attach);
		}
		private void butAttachPerio_Click(object sender,EventArgs e) {
			//Patient PatCur=Patients.GetPat(PatNum);
			if(!PrefC.AtoZfolderUsed) {
				MsgBox.Show(this,"Error. Not using AtoZ images folder.");
				return;
			}
			ContrPerio gridP=new ContrPerio();
			gridP.BackColor = System.Drawing.SystemColors.Window;
			gridP.Size = new System.Drawing.Size(595,665);
			PerioExams.Refresh(PatCur.PatNum);
			PerioMeasures.Refresh(PatCur.PatNum,PerioExams.ListExams);
			gridP.SelectedExam=PerioExams.ListExams.Count-1;
			gridP.LoadData();
			Bitmap bitmap=new Bitmap(595,665);
			Graphics g=Graphics.FromImage(bitmap);
			gridP.DrawChart(g);
			g.Dispose();
			Bitmap bitmapBig=new Bitmap(595,715);
			g=Graphics.FromImage(bitmapBig);
			g.Clear(Color.White);
			string text=PatCur.GetNameFL();
			Font font=new Font("Microsoft Sans Serif",12,FontStyle.Bold);
			g.DrawString(text,font,Brushes.Black,595/2-g.MeasureString(text,font).Width/2,5);
			text=PrefC.GetString(PrefName.PracticeTitle);
			font=new Font("Microsoft Sans Serif",9,FontStyle.Bold);
			g.DrawString(text,font,Brushes.Black,595/2-g.MeasureString(text,font).Width/2,28);
			g.DrawImage(bitmap,0,50);
			g.Dispose();
			Random rnd=new Random();
			string newName=DateTime.Now.ToString("yyyyMMdd")+"_"+DateTime.Now.TimeOfDay.Ticks.ToString()+rnd.Next(1000).ToString()+".jpg";
			string attachPath=EmailMessages.GetEmailAttachPath();
			string newPath=ODFileUtils.CombinePaths(attachPath,newName);
			try {
				bitmapBig.Save(newPath);
			}
			catch(Exception ex) {
				MessageBox.Show(ex.Message);
				return;
			}
			ClaimAttach claimAttach=new ClaimAttach();
			claimAttach.DisplayedFileName=Lan.g(this,"PerioChart.jpg");
			claimAttach.ActualFileName=newName;
			ClaimCur.Attachments.Add(claimAttach);
			FillAttachments();
		}
		private void SaveAttachment(){
			Patient PatCur=Patients.GetPat(PatNum);
			//if(PatCur.ImageFolder=="") {
			//	MsgBox.Show(this,"Invalid patient image folder.");
			//	return;
			//}
			if(!PrefC.AtoZfolderUsed) {
				MsgBox.Show(this,"Error. Not using AtoZ images folder.");
				return;
			}
			string patfolder=ImageStore.GetPatientFolder(PatCur,ImageStore.GetPreferredAtoZpath());
				//ODFileUtils.CombinePaths(
				//FormPath.GetPreferredImagePath(),PatCur.ImageFolder.Substring(0,1).ToUpper(),PatCur.ImageFolder);
			//if(!Directory.Exists(patfolder)) {
			//	MsgBox.Show(this,"Patient folder not found in AtoZ folder.");
			//	return;
			//}
			Document doc=Docs[gridMain.GetSelectedIndex()];
			if(!ImageHelper.HasImageExtension(doc.FileName)){
				MsgBox.Show(this,"Invalid file.  Only images may be attached, no other file format.");
				return;
			}
			string oldPath=ODFileUtils.CombinePaths(patfolder,doc.FileName);
			Random rnd=new Random();
			string newName=DateTime.Now.ToString("yyyyMMdd")+"_"+DateTime.Now.TimeOfDay.Ticks.ToString()+rnd.Next(1000).ToString()
				+Path.GetExtension(oldPath);
			string attachPath=EmailMessages.GetEmailAttachPath();
			string newPath=ODFileUtils.CombinePaths(attachPath,newName);
			try {
				if(ImageHelper.HasImageExtension(oldPath)) {
					if(doc.CropH !=0
						|| doc.CropW !=0
						|| doc.CropX !=0
						|| doc.CropY !=0
						|| doc.DegreesRotated !=0
						|| doc.IsFlipped
						|| doc.WindowingMax !=0
						|| doc.WindowingMin !=0) 
					{
						//this does result in a significantly larger images size if jpg.  A later optimization would recompress it.
						Bitmap bitmapold=(Bitmap)Bitmap.FromFile(oldPath);
						Bitmap bitmapnew=ImageHelper.ApplyDocumentSettingsToImage(doc,bitmapold,ImageSettingFlags.ALL);
						bitmapnew.Save(newPath);
					}
					else {
						File.Copy(oldPath,newPath);
					}
				}
				else {
					File.Copy(oldPath,newPath);
				}
				ClaimAttachNew=new ClaimAttach();
				ClaimAttachNew.DisplayedFileName=Docs[gridMain.GetSelectedIndex()].FileName;
				ClaimAttachNew.ActualFileName=newName;
				DialogResult=DialogResult.OK;
			}
			catch(FileNotFoundException ex) {
				MessageBox.Show(Lan.g(this,"File not found: ")+ex.Message);
				return;
			}
			catch(Exception ex) {
				MessageBox.Show(ex.Message);
			}
		}