context: using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Data;
  using System.Windows.Forms;
  using OpenDental.UI;
  using OpenDentBusiness;
  using CodeBase;
  
  namespace OpenDental{
  
  	///<summary></summary>
  	public class ContrStaff : System.Windows.Forms.UserControl{
  		private OpenDental.UI.Button butTimeCard;
  		private System.Windows.Forms.ListBox listStatus;
  		private System.Windows.Forms.Label textTime;
  		private System.Windows.Forms.Timer timer1;
  		private OpenDental.UI.Button butClockIn;
  		private OpenDental.UI.Button butClockOut;
  		private System.Windows.Forms.GroupBox groupBox1;
  		private System.Windows.Forms.GroupBox groupBox2;
  		private System.Windows.Forms.TextBox textMessage;
  		private System.Windows.Forms.Label label2;
  		private System.ComponentModel.IContainer components;
  		private OpenDental.UI.Button butSendClaims;
  		private OpenDental.UI.Button butTasks;
  		private OpenDental.UI.Button butBackup;
  		private OpenDental.UI.ODGrid gridEmp;
  		private System.Windows.Forms.GroupBox groupBox3;
  		private OpenDental.UI.Button butDeposit;
  		private OpenDental.UI.Button butBreaks;
  		private OpenDental.UI.Button butBilling;
  		private OpenDental.UI.Button butAccounting;
  		private Label label7;
  		private ListBox listMessages;
  		private Label label5;
  		private ListBox listExtras;
  		private Label label4;
  		private ListBox listFrom;
  		private Label label3;
  		private ListBox listTo;
  		private Label label1;
  		private ODGrid gridMessages;
  		private CheckBox checkIncludeAck;
  		///<summary>Server time minus local computer time, usually +/- 1 or 2 minutes</summary>
  		private TimeSpan TimeDelta;
  		private OpenDental.UI.Button butSend;
  		private Label label6;
  		private ComboBox comboViewUser;
  		private Label labelDays;
  		private TextBox textDays;
  		///<summary></summary>
  		[Category("Data"),Description("Occurs when user changes current patient, usually by clicking on the Select Patient button.")]
  		public event PatientSelectedEventHandler PatientSelected=null;
  		///<summary>Collection of Signals</summary>
  		private List<Signalod> SignalList;
  		private SigElementDef[] sigElementDefUser;
  		private SigElementDef[] sigElementDefExtras;
  		private Label labelSending;
  		private Timer timerSending;
  		private ErrorProvider errorProvider1=new ErrorProvider();
  		private OpenDental.UI.Button butAck;
  		private SigElementDef[] sigElementDefMessages;
  		private OpenDental.UI.Button butSupply;
  		private Employee EmployeeCur;
  		private FormBilling FormB;
  		private UI.Button butClaimPay;
  		private UI.Button butManage;
  		private long PatCurNum;
  		private UI.Button butEmailInbox;
  		//private bool InitializedOnStartup;
  		///<summary>This is public so that FormOpenDental can access it.</summary>
  		public FormTasks FormT;
  		public FormAccounting FormA;
  		private List<Employee> _listEmployees=new List<Employee>();
  
  		///<summary></summary>
  		public ContrStaff(){
  			Logger.openlog.Log("Initializing management module...",Logger.Severity.INFO);
  			InitializeComponent();
  			this.listStatus.Click += new System.EventHandler(this.listStatus_Click);
  		}
  
  		///<summary></summary>
  		protected override void Dispose( bool disposing ){
  			if( disposing ){
  				if(components != null){
  					components.Dispose();
  				}
  			}
  			base.Dispose( disposing );
  		}
  
  		#region Component Designer generated code
  
  		private void InitializeComponent(){
  			this.components = new System.ComponentModel.Container();
  			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ContrStaff));
  			this.listStatus = new System.Windows.Forms.ListBox();
  			this.textTime = new System.Windows.Forms.Label();
  			this.timer1 = new System.Windows.Forms.Timer(this.components);
  			this.groupBox1 = new System.Windows.Forms.GroupBox();
  			this.butManage = new OpenDental.UI.Button();
  			this.butBreaks = new OpenDental.UI.Button();
  			this.gridEmp = new OpenDental.UI.ODGrid();
  			this.label2 = new System.Windows.Forms.Label();
  			this.butClockOut = new OpenDental.UI.Button();
  			this.butTimeCard = new OpenDental.UI.Button();
  			this.butClockIn = new OpenDental.UI.Button();
  			this.groupBox2 = new System.Windows.Forms.GroupBox();
  			this.listMessages = new System.Windows.Forms.ListBox();
  			this.butSend = new OpenDental.UI.Button();
  			this.butAck = new OpenDental.UI.Button();
  			this.labelSending = new System.Windows.Forms.Label();
  			this.textDays = new System.Windows.Forms.TextBox();
  			this.labelDays = new System.Windows.Forms.Label();
  			this.label6 = new System.Windows.Forms.Label();
  			this.comboViewUser = new System.Windows.Forms.ComboBox();
  			this.gridMessages = new OpenDental.UI.ODGrid();
  			this.checkIncludeAck = new System.Windows.Forms.CheckBox();
  			this.label7 = new System.Windows.Forms.Label();
  			this.label5 = new System.Windows.Forms.Label();
  			this.listExtras = new System.Windows.Forms.ListBox();
  			this.label4 = new System.Windows.Forms.Label();
  			this.listFrom = new System.Windows.Forms.ListBox();
  			this.label3 = new System.Windows.Forms.Label();
  			this.listTo = new System.Windows.Forms.ListBox();
  			this.label1 = new System.Windows.Forms.Label();
  			this.textMessage = new System.Windows.Forms.TextBox();
  			this.groupBox3 = new System.Windows.Forms.GroupBox();
  			this.butEmailInbox = new OpenDental.UI.Button();
  			this.butSupply = new OpenDental.UI.Button();
  			this.butClaimPay = new OpenDental.UI.Button();
  			this.butBilling = new OpenDental.UI.Button();
  			this.butAccounting = new OpenDental.UI.Button();
  			this.butBackup = new OpenDental.UI.Button();
  			this.butDeposit = new OpenDental.UI.Button();
  			this.butSendClaims = new OpenDental.UI.Button();
  			this.butTasks = new OpenDental.UI.Button();
  			this.timerSending = new System.Windows.Forms.Timer(this.components);
  			this.groupBox1.SuspendLayout();
  			this.groupBox2.SuspendLayout();
  			this.groupBox3.SuspendLayout();
  			this.SuspendLayout();
  			// 
  			// listStatus
  			// 
  			this.listStatus.Location = new System.Drawing.Point(367, 192);
  			this.listStatus.Name = "listStatus";
  			this.listStatus.Size = new System.Drawing.Size(107, 43);
  			this.listStatus.TabIndex = 12;
  			// 
  			// textTime
  			// 
  			this.textTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  			this.textTime.Location = new System.Drawing.Point(365, 113);
  			this.textTime.Name = "textTime";
  			this.textTime.Size = new System.Drawing.Size(109, 21);
  			this.textTime.TabIndex = 17;
  			this.textTime.Text = "12:00:00 PM";
  			this.textTime.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
  			// 
  			// timer1
  			// 
  			this.timer1.Enabled = true;
  			this.timer1.Interval = 1000;
  			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
  			// 
  			// groupBox1
  			// 
  			this.groupBox1.Controls.Add(this.butManage);
  			this.groupBox1.Controls.Add(this.butBreaks);
  			this.groupBox1.Controls.Add(this.gridEmp);
  			this.groupBox1.Controls.Add(this.label2);
  			this.groupBox1.Controls.Add(this.listStatus);
  			this.groupBox1.Controls.Add(this.butClockOut);
  			this.groupBox1.Controls.Add(this.butTimeCard);
  			this.groupBox1.Controls.Add(this.textTime);
  			this.groupBox1.Controls.Add(this.butClockIn);
  			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
  			this.groupBox1.Location = new System.Drawing.Point(349, 5);
  			this.groupBox1.Name = "groupBox1";
  			this.groupBox1.Size = new System.Drawing.Size(510, 247);
  			this.groupBox1.TabIndex = 18;
  			this.groupBox1.TabStop = false;
  			this.groupBox1.Text = "Time Clock";
  			// 
  			// butManage
  			// 
  			this.butManage.AdjustImageLocation = new System.Drawing.Point(0, 0);
  			this.butManage.Autosize = true;
  			this.butManage.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butManage.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butManage.CornerRadius = 4F;
  			this.butManage.Location = new System.Drawing.Point(366, 13);
  			this.butManage.Name = "butManage";
  			this.butManage.Size = new System.Drawing.Size(108, 25);
  			this.butManage.TabIndex = 23;
  			this.butManage.Text = "Manage";
  			this.butManage.Click += new System.EventHandler(this.butManage_Click);
  			// 
  			// butBreaks
  			// 
  			this.butBreaks.AdjustImageLocation = new System.Drawing.Point(0, 0);
  			this.butBreaks.Autosize = true;
  			this.butBreaks.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butBreaks.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butBreaks.CornerRadius = 4F;
  			this.butBreaks.Location = new System.Drawing.Point(366, 67);
  			this.butBreaks.Name = "butBreaks";
  			this.butBreaks.Size = new System.Drawing.Size(108, 25);
  			this.butBreaks.TabIndex = 22;
  			this.butBreaks.Text = "View Breaks";
  			this.butBreaks.Click += new System.EventHandler(this.butBreaks_Click);
  			// 
  			// gridEmp
  			// 
  			this.gridEmp.AllowSelection = false;
  			this.gridEmp.HScrollVisible = false;
  			this.gridEmp.Location = new System.Drawing.Point(22, 22);
  			this.gridEmp.Name = "gridEmp";
  			this.gridEmp.ScrollValue = 0;
  			this.gridEmp.Size = new System.Drawing.Size(303, 213);
  			this.gridEmp.TabIndex = 21;
  			this.gridEmp.Title = "Employee";
  			this.gridEmp.TranslationName = "TableEmpClock";
  			this.gridEmp.CellDoubleClick += new OpenDental.UI.ODGridClickEventHandler(this.gridEmp_CellDoubleClick);
  			this.gridEmp.CellClick += new OpenDental.UI.ODGridClickEventHandler(this.gridEmp_CellClick);
  			// 
  			// label2
  			// 
  			this.label2.Location = new System.Drawing.Point(376, 94);
  			this.label2.Name = "label2";
  			this.label2.Size = new System.Drawing.Size(88, 19);
  			this.label2.TabIndex = 20;
  			this.label2.Text = "Server Time";
  			this.label2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
  			// 
  			// butClockOut
  			// 
  			this.butClockOut.AdjustImageLocation = new System.Drawing.Point(0, 0);
  			this.butClockOut.Autosize = true;
  			this.butClockOut.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butClockOut.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butClockOut.CornerRadius = 4F;
  			this.butClockOut.Location = new System.Drawing.Point(366, 164);
  			this.butClockOut.Name = "butClockOut";
  			this.butClockOut.Size = new System.Drawing.Size(108, 25);
  			this.butClockOut.TabIndex = 14;
  			this.butClockOut.Text = "Clock Out For:";
  			this.butClockOut.Click += new System.EventHandler(this.butClockOut_Click);
  			// 
  			// butTimeCard
  			// 
  			this.butTimeCard.AdjustImageLocation = new System.Drawing.Point(0, 0);
  			this.butTimeCard.Autosize = true;
  			this.butTimeCard.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butTimeCard.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butTimeCard.CornerRadius = 4F;
  			this.butTimeCard.Location = new System.Drawing.Point(366, 40);
  			this.butTimeCard.Name = "butTimeCard";
  			this.butTimeCard.Size = new System.Drawing.Size(108, 25);
  			this.butTimeCard.TabIndex = 16;
  			this.butTimeCard.Text = "View Time Card";
  			this.butTimeCard.Click += new System.EventHandler(this.butTimeCard_Click);
  			// 
  			// butClockIn
  			// 
  			this.butClockIn.AdjustImageLocation = new System.Drawing.Point(0, 0);
  			this.butClockIn.Autosize = true;
  			this.butClockIn.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butClockIn.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butClockIn.CornerRadius = 4F;
  			this.butClockIn.Location = new System.Drawing.Point(366, 137);
  			this.butClockIn.Name = "butClockIn";
  			this.butClockIn.Size = new System.Drawing.Size(108, 25);
  			this.butClockIn.TabIndex = 11;
  			this.butClockIn.Text = "Clock In";
  			this.butClockIn.Click += new System.EventHandler(this.butClockIn_Click);
  			// 
  			// groupBox2
  			// 
  			this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
              | System.Windows.Forms.AnchorStyles.Left)));
  			this.groupBox2.Controls.Add(this.listMessages);
  			this.groupBox2.Controls.Add(this.butSend);
  			this.groupBox2.Controls.Add(this.butAck);
  			this.groupBox2.Controls.Add(this.labelSending);
  			this.groupBox2.Controls.Add(this.textDays);
  			this.groupBox2.Controls.Add(this.labelDays);
  			this.groupBox2.Controls.Add(this.label6);
  			this.groupBox2.Controls.Add(this.comboViewUser);
  			this.groupBox2.Controls.Add(this.gridMessages);
  			this.groupBox2.Controls.Add(this.checkIncludeAck);
  			this.groupBox2.Controls.Add(this.label7);
  			this.groupBox2.Controls.Add(this.label5);
  			this.groupBox2.Controls.Add(this.listExtras);
  			this.groupBox2.Controls.Add(this.label4);
  			this.groupBox2.Controls.Add(this.listFrom);
  			this.groupBox2.Controls.Add(this.label3);
  			this.groupBox2.Controls.Add(this.listTo);
  			this.groupBox2.Controls.Add(this.label1);
  			this.groupBox2.Controls.Add(this.textMessage);
  			this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System;
  			this.groupBox2.Location = new System.Drawing.Point(3, 252);
  			this.groupBox2.Name = "groupBox2";
  			this.groupBox2.Size = new System.Drawing.Size(902, 447);
  			this.groupBox2.TabIndex = 19;
  			this.groupBox2.TabStop = false;
  			this.groupBox2.Text = "Messaging";
  			// 
  			// listMessages
  			// 
  			this.listMessages.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
              | System.Windows.Forms.AnchorStyles.Left)));
  			this.listMessages.FormattingEnabled = true;
  			this.listMessages.Location = new System.Drawing.Point(252, 35);
  			this.listMessages.Name = "listMessages";
  			this.listMessages.Size = new System.Drawing.Size(98, 355);
  			this.listMessages.TabIndex = 10;
  			this.listMessages.Click += new System.EventHandler(this.listMessages_Click);
  			// 
  			// butSend
  			// 
  			this.butSend.AdjustImageLocation = new System.Drawing.Point(0, 0);
  			this.butSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  			this.butSend.Autosize = true;
  			this.butSend.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butSend.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butSend.CornerRadius = 4F;
  			this.butSend.Location = new System.Drawing.Point(252, 417);
  			this.butSend.Name = "butSend";
  			this.butSend.Size = new System.Drawing.Size(98, 25);
  			this.butSend.TabIndex = 15;
  			this.butSend.Text = "Send Text";
  			this.butSend.Click += new System.EventHandler(this.butSend_Click);
  			// 
  			// butAck
  			// 
  			this.butAck.AdjustImageLocation = new System.Drawing.Point(0, 0);
  			this.butAck.Autosize = true;
  			this.butAck.BtnShape = OpenDental.UI.enumType.BtnShape.Rectangle;
  			this.butAck.BtnStyle = OpenDental.UI.enumType.XPStyle.Silver;
  			this.butAck.CornerRadius = 4F;
  			this.butAck.Location = new System.Drawing.Point(645, 10);
  			this.butAck.Name = "butAck";
  			this.butAck.Size = new System.Drawing.Size(67, 22);
  			this.butAck.TabIndex = 25;
  			this.butAck.Text = "Ack";
  			this.butAck.Click += new System.EventHandler(this.butAck_Click);
  			// 
  			// labelSending
  			// 
  			this.labelSending.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  			this.labelSending.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  			this.labelSending.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
  			this.labelSending.Location = new System.Drawing.Point(251, 393);
  			this.labelSending.Name = "labelSending";
  			this.labelSending.Size = new System.Drawing.Size(100, 21);
  			this.labelSending.TabIndex = 24;
  			this.labelSending.Text = "Sending";
  			this.labelSending.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
  			this.labelSending.Visible = false;
  			// 
  			// textDays
  			// 
  			this.textDays.Location = new System.Drawing.Point(594, 12);
  			this.textDays.Name = "textDays";
  			this.textDays.Size = new System.Drawing.Size(45, 20);
  			this.textDays.TabIndex = 19;
  			this.textDays.Visible = false;
  			this.textDays.TextChanged += new System.EventHandler(this.textDays_TextChanged);
  			// 
  			// labelDays
  			// 
  			this.labelDays.Location = new System.Drawing.Point(531, 14);
  			this.labelDays.Name = "labelDays";
  			this.labelDays.Size = new System.Drawing.Size(61, 16);
  			this.labelDays.TabIndex = 18;
  			this.labelDays.Text = "Days";
  			this.labelDays.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  			this.labelDays.Visible = false;
  			// 
  			// label6
  			// 
  			this.label6.Location = new System.Drawing.Point(725, 14);
  			this.label6.Name = "label6";
  			this.label6.Size = new System.Drawing.Size(57, 16);
  			this.label6.TabIndex = 17;
  			this.label6.Text = "To User";
  			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  			// 
  			// comboViewUser
  			// 
  			this.comboViewUser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  			this.comboViewUser.FormattingEnabled = true;
  			this.comboViewUser.Location = new System.Drawing.Point(783, 11);
  			this.comboViewUser.Name = "comboViewUser";
  			this.comboViewUser.Size = new System.Drawing.Size(114, 21);
  			this.comboViewUser.TabIndex = 16;
  			this.comboViewUser.SelectionChangeCommitted += new System.EventHandler(this.comboViewUser_SelectionChangeCommitted);
  			// 
  			// gridMessages
  			// 
  			this.gridMessages.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
              | System.Windows.Forms.AnchorStyles.Left)));
  			this.gridMessages.HScrollVisible = false;
  			this.gridMessages.Location = new System.Drawing.Point(356, 35);
  			this.gridMessages.Name = "gridMessages";
  			this.gridMessages.ScrollValue = 0;
  			this.gridMessages.SelectionMode = OpenDental.UI.GridSelectionMode.MultiExtended;
  
gt: 			this.gridMessages.Size = new System.Drawing.Size(540, 406);