Ejemplo n.º 1
0
 ///<summary>Inserts one OrthoChart into the database.  Returns the new priKey.</summary>
 internal static long Insert(OrthoChart orthoChart)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         orthoChart.OrthoChartNum=DbHelper.GetNextOracleKey("orthochart","OrthoChartNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(orthoChart,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     orthoChart.OrthoChartNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(orthoChart,false);
     }
 }
Ejemplo n.º 2
0
		///<summary>Inserts one OrthoChart into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(OrthoChart orthoChart,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				orthoChart.OrthoChartNum=ReplicationServers.GetKey("orthochart","OrthoChartNum");
			}
			string command="INSERT INTO orthochart (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="OrthoChartNum,";
			}
			command+="PatNum,DateService,FieldName,FieldValue) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(orthoChart.OrthoChartNum)+",";
			}
			command+=
				     POut.Long  (orthoChart.PatNum)+","
				+    POut.Date  (orthoChart.DateService)+","
				+"'"+POut.String(orthoChart.FieldName)+"',"
				+"'"+POut.String(orthoChart.FieldValue)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				orthoChart.OrthoChartNum=Db.NonQ(command,true);
			}
			return orthoChart.OrthoChartNum;
		}
Ejemplo n.º 3
0
 ///<summary>Inserts one OrthoChart into the database.  Returns the new priKey.</summary>
 public static long Insert(OrthoChart orthoChart)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         orthoChart.OrthoChartNum = DbHelper.GetNextOracleKey("orthochart", "OrthoChartNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(orthoChart, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     orthoChart.OrthoChartNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(orthoChart, false));
     }
 }
Ejemplo n.º 4
0
        ///<summary>Inserts one OrthoChart into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(OrthoChart orthoChart, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                orthoChart.OrthoChartNum = ReplicationServers.GetKey("orthochart", "OrthoChartNum");
            }
            string command = "INSERT INTO orthochart (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "OrthoChartNum,";
            }
            command += "PatNum,DateService,FieldName,FieldValue) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(orthoChart.OrthoChartNum) + ",";
            }
            command +=
                POut.Long(orthoChart.PatNum) + ","
                + POut.Date(orthoChart.DateService) + ","
                + "'" + POut.String(orthoChart.FieldName) + "',"
                + "'" + POut.String(orthoChart.FieldValue) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                orthoChart.OrthoChartNum = Db.NonQ(command, true);
            }
            return(orthoChart.OrthoChartNum);
        }
Ejemplo n.º 5
0
        ///<summary>Updates one OrthoChart in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(OrthoChart orthoChart, OrthoChart oldOrthoChart)
        {
            string command = "";

            if (orthoChart.PatNum != oldOrthoChart.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(orthoChart.PatNum) + "";
            }
            if (orthoChart.DateService.Date != oldOrthoChart.DateService.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateService = " + POut.Date(orthoChart.DateService) + "";
            }
            if (orthoChart.FieldName != oldOrthoChart.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(orthoChart.FieldName) + "'";
            }
            if (orthoChart.FieldValue != oldOrthoChart.FieldValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldValue = " + DbHelper.ParamChar + "paramFieldValue";
            }
            if (orthoChart.UserNum != oldOrthoChart.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(orthoChart.UserNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (orthoChart.FieldValue == null)
            {
                orthoChart.FieldValue = "";
            }
            OdSqlParameter paramFieldValue = new OdSqlParameter("paramFieldValue", OdDbType.Text, POut.StringParam(orthoChart.FieldValue));

            command = "UPDATE orthochart SET " + command
                      + " WHERE OrthoChartNum = " + POut.Long(orthoChart.OrthoChartNum);
            Db.NonQ(command, paramFieldValue);
            return(true);
        }
Ejemplo n.º 6
0
        ///<summary>Updates one OrthoChart in the database.</summary>
        public static void Update(OrthoChart orthoChart)
        {
            string command = "UPDATE orthochart SET "
                             + "PatNum       =  " + POut.Long(orthoChart.PatNum) + ", "
                             + "DateService  =  " + POut.Date(orthoChart.DateService) + ", "
                             + "FieldName    = '" + POut.String(orthoChart.FieldName) + "', "
                             + "FieldValue   = '" + POut.String(orthoChart.FieldValue) + "' "
                             + "WHERE OrthoChartNum = " + POut.Long(orthoChart.OrthoChartNum);

            Db.NonQ(command);
        }
Ejemplo n.º 7
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<OrthoChart> TableToList(DataTable table){
			List<OrthoChart> retVal=new List<OrthoChart>();
			OrthoChart orthoChart;
			for(int i=0;i<table.Rows.Count;i++) {
				orthoChart=new OrthoChart();
				orthoChart.OrthoChartNum= PIn.Long  (table.Rows[i]["OrthoChartNum"].ToString());
				orthoChart.PatNum       = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				orthoChart.DateService  = PIn.Date  (table.Rows[i]["DateService"].ToString());
				orthoChart.FieldName    = PIn.String(table.Rows[i]["FieldName"].ToString());
				orthoChart.FieldValue   = PIn.String(table.Rows[i]["FieldValue"].ToString());
				retVal.Add(orthoChart);
			}
			return retVal;
		}
Ejemplo n.º 8
0
 ///<summary>Inserts one OrthoChart into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(OrthoChart orthoChart)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(orthoChart, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             orthoChart.OrthoChartNum = DbHelper.GetNextOracleKey("orthochart", "OrthoChartNum");                  //Cacheless method
         }
         return(InsertNoCache(orthoChart, true));
     }
 }
Ejemplo n.º 9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <OrthoChart> TableToList(DataTable table)
        {
            List <OrthoChart> retVal = new List <OrthoChart>();
            OrthoChart        orthoChart;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                orthoChart = new OrthoChart();
                orthoChart.OrthoChartNum = PIn.Long(table.Rows[i]["OrthoChartNum"].ToString());
                orthoChart.PatNum        = PIn.Long(table.Rows[i]["PatNum"].ToString());
                orthoChart.DateService   = PIn.Date(table.Rows[i]["DateService"].ToString());
                orthoChart.FieldName     = PIn.String(table.Rows[i]["FieldName"].ToString());
                orthoChart.FieldValue    = PIn.String(table.Rows[i]["FieldValue"].ToString());
                retVal.Add(orthoChart);
            }
            return(retVal);
        }
Ejemplo n.º 10
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <OrthoChart> TableToList(DataTable table)
        {
            List <OrthoChart> retVal = new List <OrthoChart>();
            OrthoChart        orthoChart;

            foreach (DataRow row in table.Rows)
            {
                orthoChart = new OrthoChart();
                orthoChart.OrthoChartNum = PIn.Long(row["OrthoChartNum"].ToString());
                orthoChart.PatNum        = PIn.Long(row["PatNum"].ToString());
                orthoChart.DateService   = PIn.Date(row["DateService"].ToString());
                orthoChart.FieldName     = PIn.String(row["FieldName"].ToString());
                orthoChart.FieldValue    = PIn.String(row["FieldValue"].ToString());
                orthoChart.UserNum       = PIn.Long(row["UserNum"].ToString());
                retVal.Add(orthoChart);
            }
            return(retVal);
        }
Ejemplo n.º 11
0
        ///<summary>Updates one OrthoChart in the database.</summary>
        public static void Update(OrthoChart orthoChart)
        {
            string command = "UPDATE orthochart SET "
                             + "PatNum       =  " + POut.Long(orthoChart.PatNum) + ", "
                             + "DateService  =  " + POut.Date(orthoChart.DateService) + ", "
                             + "FieldName    = '" + POut.String(orthoChart.FieldName) + "', "
                             + "FieldValue   =  " + DbHelper.ParamChar + "paramFieldValue, "
                             + "UserNum      =  " + POut.Long(orthoChart.UserNum) + " "
                             + "WHERE OrthoChartNum = " + POut.Long(orthoChart.OrthoChartNum);

            if (orthoChart.FieldValue == null)
            {
                orthoChart.FieldValue = "";
            }
            OdSqlParameter paramFieldValue = new OdSqlParameter("paramFieldValue", OdDbType.Text, POut.StringParam(orthoChart.FieldValue));

            Db.NonQ(command, paramFieldValue);
        }
Ejemplo n.º 12
0
        ///<summary>Updates one OrthoChart in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
        public static void Update(OrthoChart orthoChart, OrthoChart oldOrthoChart)
        {
            string command = "";

            if (orthoChart.PatNum != oldOrthoChart.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(orthoChart.PatNum) + "";
            }
            if (orthoChart.DateService != oldOrthoChart.DateService)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateService = " + POut.Date(orthoChart.DateService) + "";
            }
            if (orthoChart.FieldName != oldOrthoChart.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(orthoChart.FieldName) + "'";
            }
            if (orthoChart.FieldValue != oldOrthoChart.FieldValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldValue = '" + POut.String(orthoChart.FieldValue) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE orthochart SET " + command
                      + " WHERE OrthoChartNum = " + POut.Long(orthoChart.OrthoChartNum);
            Db.NonQ(command);
        }
Ejemplo n.º 13
0
 ///<summary>Sets the value in _dictOrthoCharts for the specified date and column heading.</summary>
 private void SetValueInDict(string newValue, DateTime orthoDate, string columnHeading)
 {
     if (!_dictOrthoCharts.ContainsKey(orthoDate))
     {
         _dictOrthoCharts.Add(orthoDate, new List <OrthoChart>());
     }
     if (!_dictOrthoCharts[orthoDate].Exists(x => x.FieldName == columnHeading))
     {
         OrthoChart chart = new OrthoChart();
         chart.DateService = orthoDate;
         chart.FieldName   = columnHeading;
         chart.FieldValue  = newValue;
         chart.PatNum      = _patCur.PatNum;
         chart.UserNum     = Security.CurUser.UserNum;
         _dictOrthoCharts[orthoDate].Add(chart);
         return;
     }
     _dictOrthoCharts[orthoDate].Find(x => x.FieldName == columnHeading).FieldValue = newValue;
     _dictOrthoCharts[orthoDate].Find(x => x.FieldName == columnHeading).UserNum    = Security.CurUser.UserNum;
 }
Ejemplo n.º 14
0
        ///<summary>Inserts one OrthoChart into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(OrthoChart orthoChart, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO orthochart (";

            if (!useExistingPK && isRandomKeys)
            {
                orthoChart.OrthoChartNum = ReplicationServers.GetKeyNoCache("orthochart", "OrthoChartNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "OrthoChartNum,";
            }
            command += "PatNum,DateService,FieldName,FieldValue,UserNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(orthoChart.OrthoChartNum) + ",";
            }
            command +=
                POut.Long(orthoChart.PatNum) + ","
                + POut.Date(orthoChart.DateService) + ","
                + "'" + POut.String(orthoChart.FieldName) + "',"
                + DbHelper.ParamChar + "paramFieldValue,"
                + POut.Long(orthoChart.UserNum) + ")";
            if (orthoChart.FieldValue == null)
            {
                orthoChart.FieldValue = "";
            }
            OdSqlParameter paramFieldValue = new OdSqlParameter("paramFieldValue", OdDbType.Text, POut.StringParam(orthoChart.FieldValue));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramFieldValue);
            }
            else
            {
                orthoChart.OrthoChartNum = Db.NonQ(command, true, "OrthoChartNum", "orthoChart", paramFieldValue);
            }
            return(orthoChart.OrthoChartNum);
        }
Ejemplo n.º 15
0
 ///<summary>Returns true if Update(OrthoChart,OrthoChart) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(OrthoChart orthoChart, OrthoChart oldOrthoChart)
 {
     if (orthoChart.PatNum != oldOrthoChart.PatNum)
     {
         return(true);
     }
     if (orthoChart.DateService.Date != oldOrthoChart.DateService.Date)
     {
         return(true);
     }
     if (orthoChart.FieldName != oldOrthoChart.FieldName)
     {
         return(true);
     }
     if (orthoChart.FieldValue != oldOrthoChart.FieldValue)
     {
         return(true);
     }
     if (orthoChart.UserNum != oldOrthoChart.UserNum)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 16
0
        private bool CanEditRow(DateTime orthoDate)
        {
            if (_dictCanEditDay.ContainsKey(orthoDate))
            {
                return(_dictCanEditDay[orthoDate]);
            }
            if (Security.IsAuthorized(Permissions.OrthoChartEditFull, orthoDate, true))
            {
                _dictCanEditDay[orthoDate] = true;
                return(true);
            }
            if (!Security.IsAuthorized(Permissions.OrthoChartEditUser, orthoDate, true))
            {
                _dictCanEditDay[orthoDate] = false;
                return(false);               //User doesn't have any permission.
            }
            //User has permission to edit the ones that they have signed or ones that no one has signed.
            if (!_showSigBox)
            {
                _dictCanEditDay[orthoDate] = true;
                return(true);
            }
            OrthoChart sigChart = _dictOrthoCharts[orthoDate].Find(x => x.FieldName == _listDisplayFieldNames[_sigTableOrthoColIdx]);

            if (sigChart == null || sigChart.UserNum == Security.CurUser.UserNum)
            {
                _dictCanEditDay[orthoDate] = true;
                return(true);
            }
            bool           canEditRow;
            OrthoSignature sig = new OrthoSignature(sigChart.FieldValue);

            canEditRow = string.IsNullOrEmpty(sig.SigString);          //User has partial permission and somebody else signed it.
            _dictCanEditDay[orthoDate] = canEditRow;
            return(canEditRow);
        }
Ejemplo n.º 17
0
 public FormOrthoChartEdit()
 {
     InitializeComponent();
     Lan.F(this);
     OrthoCur = new OrthoChart();
 }
Ejemplo n.º 18
0
 ///<summary>Inserts one OrthoChart into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(OrthoChart orthoChart)
 {
     return(InsertNoCache(orthoChart, false));
 }
Ejemplo n.º 19
0
        private void FormOrthoChart_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Save data from grid to table
            for (int i = 0; i < gridMain.Rows.Count; i++)
            {
                table.Rows[i]["Date"] = gridMain.Rows[i].Tag;              //store date
                for (int j = 0; j < listOrthDisplayFields.Count; j++)
                {
                    table.Rows[i][j + 1] = gridMain.Rows[i].Cells[j + 1].Text;
                }
            }
            List <OrthoChart> tempOrthoChartsFromDB    = OrthoCharts.GetAllForPatient(PatCur.PatNum);
            List <OrthoChart> tempOrthoChartsFromTable = new List <OrthoChart>();

            for (int r = 0; r < table.Rows.Count; r++)
            {
                for (int c = 1; c < table.Columns.Count; c++)           //skip col 0
                {
                    OrthoChart tempChart = new OrthoChart();
                    tempChart.DateService = (DateTime)table.Rows[r]["Date"];
                    tempChart.FieldName   = listOrthDisplayFields[c - 1].Description;
                    tempChart.FieldValue  = table.Rows[r][c].ToString();
                    tempChart.PatNum      = PatCur.PatNum;
                    tempOrthoChartsFromTable.Add(tempChart);
                }
            }
            //Check table list vs DB list for inserts, updates, and deletes.
            for (int i = 0; i < tempOrthoChartsFromTable.Count; i++)
            {
                //Either delete an existing record from the DB or ignore this non-entry.
                if (tempOrthoChartsFromTable[i].FieldValue == "")
                {
                    for (int j = 0; j < tempOrthoChartsFromDB.Count; j++)
                    {
                        if (tempOrthoChartsFromDB[j].DateService == tempOrthoChartsFromTable[i].DateService &&
                            tempOrthoChartsFromDB[j].FieldName == tempOrthoChartsFromTable[i].FieldName)
                        {
                            OrthoCharts.Delete(tempOrthoChartsFromDB[j].OrthoChartNum);
                            break;
                        }
                    }
                    continue;                    //i loop
                }
                //Update the Record if it already exists or Insert if it's new.
                for (int j = 0; j <= tempOrthoChartsFromDB.Count; j++)
                {
                    //Insert if you've made it through the whole list.
                    if (j == tempOrthoChartsFromDB.Count)
                    {
                        OrthoCharts.Insert(tempOrthoChartsFromTable[i]);
                        break;
                    }
                    //Update if type and date match
                    if (tempOrthoChartsFromDB[j].DateService == tempOrthoChartsFromTable[i].DateService &&
                        tempOrthoChartsFromDB[j].FieldName == tempOrthoChartsFromTable[i].FieldName)
                    {
                        tempOrthoChartsFromTable[i].OrthoChartNum = tempOrthoChartsFromDB[j].OrthoChartNum;
                        OrthoCharts.Update(tempOrthoChartsFromTable[i]);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 20
0
		///<summary>Updates one OrthoChart in the database.</summary>
		public static void Update(OrthoChart orthoChart){
			string command="UPDATE orthochart SET "
				+"PatNum       =  "+POut.Long  (orthoChart.PatNum)+", "
				+"DateService  =  "+POut.Date  (orthoChart.DateService)+", "
				+"FieldName    = '"+POut.String(orthoChart.FieldName)+"', "
				+"FieldValue   = '"+POut.String(orthoChart.FieldValue)+"' "
				+"WHERE OrthoChartNum = "+POut.Long(orthoChart.OrthoChartNum);
			Db.NonQ(command);
		}
Ejemplo n.º 21
0
		///<summary>Updates one OrthoChart in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(OrthoChart orthoChart,OrthoChart oldOrthoChart){
			string command="";
			if(orthoChart.PatNum != oldOrthoChart.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(orthoChart.PatNum)+"";
			}
			if(orthoChart.DateService != oldOrthoChart.DateService) {
				if(command!=""){ command+=",";}
				command+="DateService = "+POut.Date(orthoChart.DateService)+"";
			}
			if(orthoChart.FieldName != oldOrthoChart.FieldName) {
				if(command!=""){ command+=",";}
				command+="FieldName = '"+POut.String(orthoChart.FieldName)+"'";
			}
			if(orthoChart.FieldValue != oldOrthoChart.FieldValue) {
				if(command!=""){ command+=",";}
				command+="FieldValue = '"+POut.String(orthoChart.FieldValue)+"'";
			}
			if(command==""){
				return false;
			}
			command="UPDATE orthochart SET "+command
				+" WHERE OrthoChartNum = "+POut.Long(orthoChart.OrthoChartNum);
			Db.NonQ(command);
			return true;
		}
Ejemplo n.º 22
0
        ///<summary>Clears the current grid and fills from datatable.  Do not call unless you have saved changes to database first.</summary>
        private void FillGrid()
        {
            if (tabControl.SelectedIndex == -1)
            {
                return;                //This happens when the tab pages are cleared (updating the selected index).
            }
            //else if(_indexInitialTab!=0) {
            //	tabControl.SelectedIndex=_indexInitialTab;
            //	_indexInitialTab=0;
            //}
            Cursor = Cursors.WaitCursor;
            //Get all the corresponding fields from the OrthoChartTabLink table that are associated to the currently selected ortho tab.
            OrthoChartTab       orthoChartTab = _listOrthoChartTabs[tabControl.SelectedIndex];
            List <DisplayField> listSelectedTabDisplayFields =
                OrthoChartTabLinks.GetWhere(x => x.OrthoChartTabNum == orthoChartTab.OrthoChartTabNum)           //Determines the number of items that will be returned
                .OrderBy(x => x.ItemOrder)                                                                       //Each tab is ordered based on the ortho tab link entry
                .Select(x => _listOrthDisplayFields.FirstOrDefault(y => y.DisplayFieldNum == x.DisplayFieldNum)) //Project all corresponding display fields in order
                .Where(x => x != null)                                                                           //Can happen when there is an OrthoChartTabLink in the database pointing to an invalid display field.
                .ToList();                                                                                       //Casts the projection to a list of display fields

            _sigColIdx = -1;                                                                                     //Clear out the signature column index cause it will most likely change or disappear (switching tabs)
            int gridMainScrollValue = gridMain.ScrollValue;

            gridMain.BeginUpdate();
            //Set the title of the grid to the title of the currently selected ortho chart tab.  This is so that medical users don't see Ortho Chart.
            gridMain.Title = orthoChartTab.TabName;
            gridMain.Columns.Clear();
            ODGridColumn col;

            //First column will always be the date.  gridMain_CellLeave() depends on this fact.
            col = new ODGridColumn(Lan.g(this, "Date"), 70);
            gridMain.Columns.Add(col);
            foreach (DisplayField field in listSelectedTabDisplayFields)
            {
                string columnHeader = string.IsNullOrEmpty(field.DescriptionOverride) ? field.Description : field.DescriptionOverride;
                if (!string.IsNullOrEmpty(field.PickList))
                {
                    List <string> listComboOptions = field.PickList.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList();
                    col = new ODGridColumn(columnHeader, field.ColumnWidth, listComboOptions);
                }
                else
                {
                    col = new ODGridColumn(columnHeader, field.ColumnWidth, true);
                    if (field.InternalName == "Signature")
                    {
                        _sigColIdx     = gridMain.Columns.Count;
                        col.TextAlign  = HorizontalAlignment.Center;
                        col.IsEditable = false;
                    }
                }
                col.Tag = field.Description;
                gridMain.Columns.Add(col);
            }
            gridMain.Rows.Clear();
            ODGridRow row;

            foreach (KeyValuePair <DateTime, List <OrthoChart> > kvPair in _dictOrthoCharts)
            {
                row = new ODGridRow();
                DateTime tempDate = kvPair.Key;
                row.Cells.Add(tempDate.ToShortDateString());
                row.Tag = tempDate;
                bool areAllColumnsBlank = true;
                foreach (DisplayField field in listSelectedTabDisplayFields)
                {
                    string cellValue = "";
                    if (field.InternalName != "Signature")
                    {
                        //Find the index of the corresponding column in our table via the column title.
                        OrthoChart chart = kvPair.Value.Find(x => x.FieldName == field.Description);
                        if (chart != null)
                        {
                            cellValue = chart.FieldValue;
                        }
                    }
                    if (!string.IsNullOrEmpty(field.PickList))
                    {
                        List <string> listComboOptions = field.PickList.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList();
                        int           selectedIndex    = listComboOptions.FindIndex(x => x == cellValue);
                        row.Cells.Add(cellValue, selectedIndex);
                    }
                    else
                    {
                        row.Cells.Add(cellValue);
                    }
                    if (cellValue != "")
                    {
                        areAllColumnsBlank = false;
                    }
                }
                if (!areAllColumnsBlank || _listDatesAdded.Contains(tempDate))
                {
                    gridMain.Rows.Add(row);
                }
                CanEditRow(tempDate);
            }
            gridMain.EndUpdate();
            if (gridMainScrollValue == 0)
            {
                gridMain.ScrollToEnd();
            }
            else
            {
                gridMain.ScrollValue = gridMainScrollValue;
                gridMainScrollValue  = 0;
            }
            //Show the signature control if a signature display field is present on any tab.
            _showSigBox = _listOrthDisplayFields.Any(x => x.InternalName == "Signature");
            signatureBoxWrapper.Visible = _showSigBox;          //Hide the signature box if this tab does not have the signature column present.
            if (_showSigBox)
            {
                for (int i = 0; i < gridMain.Rows.Count; i++)
                {
                    DisplaySignature(i, false);
                }
                signatureBoxWrapper.ClearSignature();
                signatureBoxWrapper.Enabled = false;              //We don't want it to be enabled unless the user has clicked on a row.
                _prevRow = -1;
            }
            Cursor = Cursors.Default;
        }