context: using System;
  using System.Drawing;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using OpenDentBusiness;
  using OpenDental.UI;
  
  namespace OpenDental{
  	/// <summary>
  	/// Summary description for FormBasicTemplate.
  	/// </summary>
  	public class FormSites:System.Windows.Forms.Form {
  		private OpenDental.UI.Button butAdd;
  		private OpenDental.UI.Button butClose;
  		/// <summary>
  		/// Required designer variable.
  		/// </summary>
  		private System.ComponentModel.Container components = null;
  		private System.Windows.Forms.Label label1;
  		private OpenDental.UI.ODGrid gridMain;
  		private bool changed;
  		private OpenDental.UI.Button butOK;
  		public bool IsSelectionMode;
  		private OpenDental.UI.Button butNone;
  		///<summary>Only used if IsSelectionMode.  On OK, contains selected siteNum.  Can be 0.  Can also be set ahead of time externally.</summary>
  		public long SelectedSiteNum;
  
  		///<summary></summary>
  		public FormSites()
  		{
  			//
  			// Required for Windows Form Designer support
  			//
  			InitializeComponent();
  			Lan.F(this);
  		}
  
  		/// <summary>
  		/// Clean up any resources being used.
  		/// </summary>
  		protected override void Dispose( bool disposing )
  		{
  			if( disposing )
  			{
  				if(components != null)
  				{
  					components.Dispose();
  				}
  			}
  			base.Dispose( disposing );
  		}
  
  		#region Windows Form Designer generated code
  		/// <summary>
  		/// Required method for Designer support - do not modify
  		/// the contents of this method with the code editor.
  		/// </summary>
  		private void InitializeComponent()
  		{
  			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormSites));
  			this.label1 = new System.Windows.Forms.Label();
  			this.butNone = new OpenDental.UI.Button();
  			this.butOK = new OpenDental.UI.Button();
  			this.gridMain = new OpenDental.UI.ODGrid();
  			this.butAdd = new OpenDental.UI.Button();
  			this.butClose = new OpenDental.UI.Button();
  			this.SuspendLayout();
  			// 
  			// label1
  			// 
  			this.label1.Location = new System.Drawing.Point(17,2);
  			this.label1.Name = "label1";
  			this.label1.Size = new System.Drawing.Size(371,18);
  			this.label1.TabIndex = 11;
  			this.label1.Text = "Used to keep track of multiple service locations for mobile clinics";
  			// 
  			// butNone
  			// 
  			this.butNone.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butNone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  			this.butNone.Autosize = true;
  			this.butNone.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butNone.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butNone.CornerRadius = 4F;
  			this.butNone.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  			this.butNone.Location = new System.Drawing.Point(504,642);
  			this.butNone.Name = "butNone";
  			this.butNone.Size = new System.Drawing.Size(68,24);
  			this.butNone.TabIndex = 14;
  			this.butNone.Text = "None";
  			this.butNone.Click += new System.EventHandler(this.butNone_Click);
  			// 
  			// butOK
  			// 
  			this.butOK.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  			this.butOK.Autosize = true;
  			this.butOK.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butOK.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butOK.CornerRadius = 4F;
  			this.butOK.Location = new System.Drawing.Point(652,612);
  			this.butOK.Name = "butOK";
  			this.butOK.Size = new System.Drawing.Size(75,24);
  			this.butOK.TabIndex = 13;
  			this.butOK.Text = "OK";
  			this.butOK.Click += new System.EventHandler(this.butOK_Click);
  			// 
  			// gridMain
  			// 
  			this.gridMain.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
              | System.Windows.Forms.AnchorStyles.Left) 
              | System.Windows.Forms.AnchorStyles.Right)));
  			this.gridMain.HScrollVisible = false;
  			this.gridMain.Location = new System.Drawing.Point(17,23);
  			this.gridMain.Name = "gridMain";
  			this.gridMain.ScrollValue = 0;
  			this.gridMain.Size = new System.Drawing.Size(608,605);
  			this.gridMain.TabIndex = 12;
  			this.gridMain.Title = "Sites";
  			this.gridMain.TranslationName = null;
  			this.gridMain.CellDoubleClick += new OpenDental.UI.ODGridClickEventHandler(this.gridMain_CellDoubleClick);
  			// 
  			// butAdd
  			// 
  			this.butAdd.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  			this.butAdd.Autosize = true;
  			this.butAdd.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butAdd.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butAdd.CornerRadius = 4F;
  			this.butAdd.Image = global::OpenDental.Properties.Resources.Add;
  			this.butAdd.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  			this.butAdd.Location = new System.Drawing.Point(17,642);
  			this.butAdd.Name = "butAdd";
  			this.butAdd.Size = new System.Drawing.Size(80,24);
  			this.butAdd.TabIndex = 10;
  			this.butAdd.Text = "&Add";
  			this.butAdd.Click += new System.EventHandler(this.butAdd_Click);
  			// 
  			// butClose
  			// 
  			this.butClose.AdjustImageLocation = new System.Drawing.Point(0,0);
  			this.butClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  			this.butClose.Autosize = true;
  			this.butClose.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butClose.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butClose.CornerRadius = 4F;
  			this.butClose.Location = new System.Drawing.Point(652,642);
  			this.butClose.Name = "butClose";
  			this.butClose.Size = new System.Drawing.Size(75,24);
  			this.butClose.TabIndex = 0;
  			this.butClose.Text = "&Close";
  			this.butClose.Click += new System.EventHandler(this.butClose_Click);
  			// 
  			// FormSites
  			// 
  			this.AutoScaleBaseSize = new System.Drawing.Size(5,13);
  			this.ClientSize = new System.Drawing.Size(739,674);
  			this.Controls.Add(this.butNone);
  			this.Controls.Add(this.butOK);
  			this.Controls.Add(this.gridMain);
  			this.Controls.Add(this.label1);
  			this.Controls.Add(this.butAdd);
  			this.Controls.Add(this.butClose);
  			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  			this.MaximizeBox = false;
  			this.MinimizeBox = false;
  			this.Name = "FormSites";
  			this.ShowInTaskbar = false;
  			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  			this.Text = "Sites";
  			this.Load += new System.EventHandler(this.FormSites_Load);
  			this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSites_FormClosing);
  			this.ResumeLayout(false);
  
  		}
  		#endregion
  
  		private void FormSites_Load(object sender, System.EventArgs e) {
  			if(IsSelectionMode){
  				butClose.Text=Lan.g(this,"Cancel");
  				if(!Security.IsAuthorized(Permissions.Setup,true)){
  					butAdd.Visible=false;
  				}
  			}
  			else{
  				butOK.Visible=false;
  				butNone.Visible=false;
  			}
  			FillGrid();
  			if(SelectedSiteNum!=0){
  				for(int i=0;i<SiteC.List.Length;i++){
  					if(SiteC.List[i].SiteNum==SelectedSiteNum){
  						gridMain.SetSelected(i,true);
  						break;
  					}
  				}
  			}
  		}
  
  		private void FillGrid(){
  			Sites.RefreshCache();
  			gridMain.BeginUpdate();
  			gridMain.Columns.Clear();
  			ODGridColumn col=new ODGridColumn(Lan.g("TableSites","Description"),250);
  			gridMain.Columns.Add(col);
  			col=new ODGridColumn(Lan.g("TableSites","Note"),100);
  			gridMain.Columns.Add(col);
  			gridMain.Rows.Clear();
  			ODGridRow row;
  			for(int i=0;i<SiteC.List.Length;i++){
  				row=new ODGridRow();
  				row.Cells.Add(SiteC.List[i].Description);
  				row.Cells.Add(SiteC.List[i].Note);
  				gridMain.Rows.Add(row);
  			}
  			gridMain.EndUpdate();
  		}
  
  		private void butAdd_Click(object sender, System.EventArgs e) {
  			//This button is not visible unless user has appropriate permission for setup.
  
gt: 			FormSiteEdit FormS=new FormSiteEdit();