Пример #1
0
 ///<summary>Returns true if Update(EhrQuarterlyKey,EhrQuarterlyKey) 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(EhrQuarterlyKey ehrQuarterlyKey, EhrQuarterlyKey oldEhrQuarterlyKey)
 {
     if (ehrQuarterlyKey.YearValue != oldEhrQuarterlyKey.YearValue)
     {
         return(true);
     }
     if (ehrQuarterlyKey.QuarterValue != oldEhrQuarterlyKey.QuarterValue)
     {
         return(true);
     }
     if (ehrQuarterlyKey.PracticeName != oldEhrQuarterlyKey.PracticeName)
     {
         return(true);
     }
     if (ehrQuarterlyKey.KeyValue != oldEhrQuarterlyKey.KeyValue)
     {
         return(true);
     }
     if (ehrQuarterlyKey.PatNum != oldEhrQuarterlyKey.PatNum)
     {
         return(true);
     }
     if (ehrQuarterlyKey.Notes != oldEhrQuarterlyKey.Notes)
     {
         return(true);
     }
     return(false);
 }
Пример #2
0
 ///<summary>Inserts one EhrQuarterlyKey into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(EhrQuarterlyKey ehrQuarterlyKey,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         ehrQuarterlyKey.EhrQuarterlyKeyNum=ReplicationServers.GetKey("ehrquarterlykey","EhrQuarterlyKeyNum");
     }
     string command="INSERT INTO ehrquarterlykey (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="EhrQuarterlyKeyNum,";
     }
     command+="YearValue,QuarterValue,PracticeName,KeyValue,PatNum,Notes) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum)+",";
     }
     command+=
              POut.Int   (ehrQuarterlyKey.YearValue)+","
         +    POut.Int   (ehrQuarterlyKey.QuarterValue)+","
         +"'"+POut.String(ehrQuarterlyKey.PracticeName)+"',"
         +"'"+POut.String(ehrQuarterlyKey.KeyValue)+"',"
         +    POut.Long  (ehrQuarterlyKey.PatNum)+","
         +"'"+POut.String(ehrQuarterlyKey.Notes)+"')";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         ehrQuarterlyKey.EhrQuarterlyKeyNum=Db.NonQ(command,true);
     }
     return ehrQuarterlyKey.EhrQuarterlyKeyNum;
 }
Пример #3
0
        ///<summary>Updates one EhrQuarterlyKey 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>
        internal static void Update(EhrQuarterlyKey ehrQuarterlyKey, EhrQuarterlyKey oldEhrQuarterlyKey)
        {
            string command = "";

            if (ehrQuarterlyKey.YearValue != oldEhrQuarterlyKey.YearValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "YearValue = " + POut.Int(ehrQuarterlyKey.YearValue) + "";
            }
            if (ehrQuarterlyKey.QuarterValue != oldEhrQuarterlyKey.QuarterValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "QuarterValue = " + POut.Int(ehrQuarterlyKey.QuarterValue) + "";
            }
            if (ehrQuarterlyKey.PracticeName != oldEhrQuarterlyKey.PracticeName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PracticeName = '" + POut.String(ehrQuarterlyKey.PracticeName) + "'";
            }
            if (ehrQuarterlyKey.KeyValue != oldEhrQuarterlyKey.KeyValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "KeyValue = '" + POut.String(ehrQuarterlyKey.KeyValue) + "'";
            }
            if (ehrQuarterlyKey.PatNum != oldEhrQuarterlyKey.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(ehrQuarterlyKey.PatNum) + "";
            }
            if (ehrQuarterlyKey.Notes != oldEhrQuarterlyKey.Notes)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Notes = '" + POut.String(ehrQuarterlyKey.Notes) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE ehrquarterlykey SET " + command
                      + " WHERE EhrQuarterlyKeyNum = " + POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum);
            Db.NonQ(command);
        }
Пример #4
0
 ///<summary>Inserts one EhrQuarterlyKey into the database.  Returns the new priKey.</summary>
 internal static long Insert(EhrQuarterlyKey ehrQuarterlyKey)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         ehrQuarterlyKey.EhrQuarterlyKeyNum = DbHelper.GetNextOracleKey("ehrquarterlykey", "EhrQuarterlyKeyNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(ehrQuarterlyKey, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     ehrQuarterlyKey.EhrQuarterlyKeyNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(ehrQuarterlyKey, false));
     }
 }
Пример #5
0
 ///<summary>Inserts one EhrQuarterlyKey into the database.  Returns the new priKey.</summary>
 internal static long Insert(EhrQuarterlyKey ehrQuarterlyKey)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         ehrQuarterlyKey.EhrQuarterlyKeyNum=DbHelper.GetNextOracleKey("ehrquarterlykey","EhrQuarterlyKeyNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(ehrQuarterlyKey,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     ehrQuarterlyKey.EhrQuarterlyKeyNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(ehrQuarterlyKey,false);
     }
 }
Пример #6
0
        ///<summary>Inserts one EhrQuarterlyKey into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(EhrQuarterlyKey ehrQuarterlyKey, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                ehrQuarterlyKey.EhrQuarterlyKeyNum = ReplicationServers.GetKey("ehrquarterlykey", "EhrQuarterlyKeyNum");
            }
            string command = "INSERT INTO ehrquarterlykey (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "EhrQuarterlyKeyNum,";
            }
            command += "YearValue,QuarterValue,PracticeName,KeyValue,PatNum,Notes) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum) + ",";
            }
            command +=
                POut.Int(ehrQuarterlyKey.YearValue) + ","
                + POut.Int(ehrQuarterlyKey.QuarterValue) + ","
                + "'" + POut.String(ehrQuarterlyKey.PracticeName) + "',"
                + "'" + POut.String(ehrQuarterlyKey.KeyValue) + "',"
                + POut.Long(ehrQuarterlyKey.PatNum) + ","
                + "'" + POut.String(ehrQuarterlyKey.Notes) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                ehrQuarterlyKey.EhrQuarterlyKeyNum = Db.NonQ(command, true);
            }
            return(ehrQuarterlyKey.EhrQuarterlyKeyNum);
        }
Пример #7
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormEhrQuarterlyKeyEdit formE  = new FormEhrQuarterlyKeyEdit();
            EhrQuarterlyKey         keycur = new EhrQuarterlyKey();

            keycur.IsNew = true;
            formE.KeyCur = keycur;
            formE.ShowDialog();
            FillGrid();
        }
Пример #8
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            FormEhrQuarterlyKeyEdit formE  = new FormEhrQuarterlyKeyEdit();
            EhrQuarterlyKey         keycur = listKeys[e.Row];

            keycur.IsNew = false;
            formE.KeyCur = keycur;
            formE.ShowDialog();
            FillGrid();
        }
Пример #9
0
        ///<summary>Updates one EhrQuarterlyKey in the database.</summary>
        internal static void Update(EhrQuarterlyKey ehrQuarterlyKey)
        {
            string command = "UPDATE ehrquarterlykey SET "
                             + "YearValue         =  " + POut.Int(ehrQuarterlyKey.YearValue) + ", "
                             + "QuarterValue      =  " + POut.Int(ehrQuarterlyKey.QuarterValue) + ", "
                             + "PracticeName      = '" + POut.String(ehrQuarterlyKey.PracticeName) + "', "
                             + "KeyValue          = '" + POut.String(ehrQuarterlyKey.KeyValue) + "', "
                             + "PatNum            =  " + POut.Long(ehrQuarterlyKey.PatNum) + ", "
                             + "Notes             = '" + POut.String(ehrQuarterlyKey.Notes) + "' "
                             + "WHERE EhrQuarterlyKeyNum = " + POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum);

            Db.NonQ(command);
        }
Пример #10
0
 ///<summary>Inserts one EhrQuarterlyKey into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EhrQuarterlyKey ehrQuarterlyKey)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(ehrQuarterlyKey, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             ehrQuarterlyKey.EhrQuarterlyKeyNum = DbHelper.GetNextOracleKey("ehrquarterlykey", "EhrQuarterlyKeyNum");                  //Cacheless method
         }
         return(InsertNoCache(ehrQuarterlyKey, true));
     }
 }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<EhrQuarterlyKey> TableToList(DataTable table){
			List<EhrQuarterlyKey> retVal=new List<EhrQuarterlyKey>();
			EhrQuarterlyKey ehrQuarterlyKey;
			for(int i=0;i<table.Rows.Count;i++) {
				ehrQuarterlyKey=new EhrQuarterlyKey();
				ehrQuarterlyKey.EhrQuarterlyKeyNum= PIn.Long  (table.Rows[i]["EhrQuarterlyKeyNum"].ToString());
				ehrQuarterlyKey.YearValue         = PIn.Int   (table.Rows[i]["YearValue"].ToString());
				ehrQuarterlyKey.QuarterValue      = PIn.Int   (table.Rows[i]["QuarterValue"].ToString());
				ehrQuarterlyKey.PracticeName      = PIn.String(table.Rows[i]["PracticeName"].ToString());
				ehrQuarterlyKey.KeyValue          = PIn.String(table.Rows[i]["KeyValue"].ToString());
				ehrQuarterlyKey.PatNum            = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				ehrQuarterlyKey.Notes             = PIn.String(table.Rows[i]["Notes"].ToString());
				retVal.Add(ehrQuarterlyKey);
			}
			return retVal;
		}
Пример #12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <EhrQuarterlyKey> TableToList(DataTable table)
        {
            List <EhrQuarterlyKey> retVal = new List <EhrQuarterlyKey>();
            EhrQuarterlyKey        ehrQuarterlyKey;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                ehrQuarterlyKey = new EhrQuarterlyKey();
                ehrQuarterlyKey.EhrQuarterlyKeyNum = PIn.Long(table.Rows[i]["EhrQuarterlyKeyNum"].ToString());
                ehrQuarterlyKey.YearValue          = PIn.Int(table.Rows[i]["YearValue"].ToString());
                ehrQuarterlyKey.QuarterValue       = PIn.Int(table.Rows[i]["QuarterValue"].ToString());
                ehrQuarterlyKey.PracticeName       = PIn.String(table.Rows[i]["PracticeName"].ToString());
                ehrQuarterlyKey.KeyValue           = PIn.String(table.Rows[i]["KeyValue"].ToString());
                ehrQuarterlyKey.PatNum             = PIn.Long(table.Rows[i]["PatNum"].ToString());
                ehrQuarterlyKey.Notes = PIn.String(table.Rows[i]["Notes"].ToString());
                retVal.Add(ehrQuarterlyKey);
            }
            return(retVal);
        }
Пример #13
0
        ///<summary>Updates one EhrQuarterlyKey in the database.</summary>
        public static void Update(EhrQuarterlyKey ehrQuarterlyKey)
        {
            string command = "UPDATE ehrquarterlykey SET "
                             + "YearValue         =  " + POut.Int(ehrQuarterlyKey.YearValue) + ", "
                             + "QuarterValue      =  " + POut.Int(ehrQuarterlyKey.QuarterValue) + ", "
                             + "PracticeName      = '" + POut.String(ehrQuarterlyKey.PracticeName) + "', "
                             + "KeyValue          = '" + POut.String(ehrQuarterlyKey.KeyValue) + "', "
                             + "PatNum            =  " + POut.Long(ehrQuarterlyKey.PatNum) + ", "
                             + "Notes             =  " + DbHelper.ParamChar + "paramNotes "
                             + "WHERE EhrQuarterlyKeyNum = " + POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum);

            if (ehrQuarterlyKey.Notes == null)
            {
                ehrQuarterlyKey.Notes = "";
            }
            OdSqlParameter paramNotes = new OdSqlParameter("paramNotes", OdDbType.Text, POut.StringParam(ehrQuarterlyKey.Notes));

            Db.NonQ(command, paramNotes);
        }
Пример #14
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EhrQuarterlyKey> TableToList(DataTable table)
        {
            List <EhrQuarterlyKey> retVal = new List <EhrQuarterlyKey>();
            EhrQuarterlyKey        ehrQuarterlyKey;

            foreach (DataRow row in table.Rows)
            {
                ehrQuarterlyKey = new EhrQuarterlyKey();
                ehrQuarterlyKey.EhrQuarterlyKeyNum = PIn.Long(row["EhrQuarterlyKeyNum"].ToString());
                ehrQuarterlyKey.YearValue          = PIn.Int(row["YearValue"].ToString());
                ehrQuarterlyKey.QuarterValue       = PIn.Int(row["QuarterValue"].ToString());
                ehrQuarterlyKey.PracticeName       = PIn.String(row["PracticeName"].ToString());
                ehrQuarterlyKey.KeyValue           = PIn.String(row["KeyValue"].ToString());
                ehrQuarterlyKey.PatNum             = PIn.Long(row["PatNum"].ToString());
                ehrQuarterlyKey.Notes = PIn.String(row["Notes"].ToString());
                retVal.Add(ehrQuarterlyKey);
            }
            return(retVal);
        }
Пример #15
0
        ///<summary>Inserts one EhrQuarterlyKey into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(EhrQuarterlyKey ehrQuarterlyKey, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO ehrquarterlykey (";

            if (!useExistingPK && isRandomKeys)
            {
                ehrQuarterlyKey.EhrQuarterlyKeyNum = ReplicationServers.GetKeyNoCache("ehrquarterlykey", "EhrQuarterlyKeyNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EhrQuarterlyKeyNum,";
            }
            command += "YearValue,QuarterValue,PracticeName,KeyValue,PatNum,Notes) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum) + ",";
            }
            command +=
                POut.Int(ehrQuarterlyKey.YearValue) + ","
                + POut.Int(ehrQuarterlyKey.QuarterValue) + ","
                + "'" + POut.String(ehrQuarterlyKey.PracticeName) + "',"
                + "'" + POut.String(ehrQuarterlyKey.KeyValue) + "',"
                + POut.Long(ehrQuarterlyKey.PatNum) + ","
                + DbHelper.ParamChar + "paramNotes)";
            if (ehrQuarterlyKey.Notes == null)
            {
                ehrQuarterlyKey.Notes = "";
            }
            OdSqlParameter paramNotes = new OdSqlParameter("paramNotes", OdDbType.Text, POut.StringParam(ehrQuarterlyKey.Notes));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNotes);
            }
            else
            {
                ehrQuarterlyKey.EhrQuarterlyKeyNum = Db.NonQ(command, true, "EhrQuarterlyKeyNum", "ehrQuarterlyKey", paramNotes);
            }
            return(ehrQuarterlyKey.EhrQuarterlyKeyNum);
        }
Пример #16
0
 ///<summary>Inserts one EhrQuarterlyKey into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EhrQuarterlyKey ehrQuarterlyKey)
 {
     return(InsertNoCache(ehrQuarterlyKey, false));
 }
		///<summary>Updates one EhrQuarterlyKey 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(EhrQuarterlyKey ehrQuarterlyKey,EhrQuarterlyKey oldEhrQuarterlyKey){
			string command="";
			if(ehrQuarterlyKey.YearValue != oldEhrQuarterlyKey.YearValue) {
				if(command!=""){ command+=",";}
				command+="YearValue = "+POut.Int(ehrQuarterlyKey.YearValue)+"";
			}
			if(ehrQuarterlyKey.QuarterValue != oldEhrQuarterlyKey.QuarterValue) {
				if(command!=""){ command+=",";}
				command+="QuarterValue = "+POut.Int(ehrQuarterlyKey.QuarterValue)+"";
			}
			if(ehrQuarterlyKey.PracticeName != oldEhrQuarterlyKey.PracticeName) {
				if(command!=""){ command+=",";}
				command+="PracticeName = '"+POut.String(ehrQuarterlyKey.PracticeName)+"'";
			}
			if(ehrQuarterlyKey.KeyValue != oldEhrQuarterlyKey.KeyValue) {
				if(command!=""){ command+=",";}
				command+="KeyValue = '"+POut.String(ehrQuarterlyKey.KeyValue)+"'";
			}
			if(ehrQuarterlyKey.PatNum != oldEhrQuarterlyKey.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(ehrQuarterlyKey.PatNum)+"";
			}
			if(ehrQuarterlyKey.Notes != oldEhrQuarterlyKey.Notes) {
				if(command!=""){ command+=",";}
				command+="Notes = '"+POut.String(ehrQuarterlyKey.Notes)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE ehrquarterlykey SET "+command
				+" WHERE EhrQuarterlyKeyNum = "+POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum);
			Db.NonQ(command);
		}
		///<summary>Updates one EhrQuarterlyKey in the database.</summary>
		public static void Update(EhrQuarterlyKey ehrQuarterlyKey){
			string command="UPDATE ehrquarterlykey SET "
				+"YearValue         =  "+POut.Int   (ehrQuarterlyKey.YearValue)+", "
				+"QuarterValue      =  "+POut.Int   (ehrQuarterlyKey.QuarterValue)+", "
				+"PracticeName      = '"+POut.String(ehrQuarterlyKey.PracticeName)+"', "
				+"KeyValue          = '"+POut.String(ehrQuarterlyKey.KeyValue)+"', "
				+"PatNum            =  "+POut.Long  (ehrQuarterlyKey.PatNum)+", "
				+"Notes             = '"+POut.String(ehrQuarterlyKey.Notes)+"' "
				+"WHERE EhrQuarterlyKeyNum = "+POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum);
			Db.NonQ(command);
		}
Пример #19
0
        ///<summary>Updates one EhrQuarterlyKey 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(EhrQuarterlyKey ehrQuarterlyKey, EhrQuarterlyKey oldEhrQuarterlyKey)
        {
            string command = "";

            if (ehrQuarterlyKey.YearValue != oldEhrQuarterlyKey.YearValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "YearValue = " + POut.Int(ehrQuarterlyKey.YearValue) + "";
            }
            if (ehrQuarterlyKey.QuarterValue != oldEhrQuarterlyKey.QuarterValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "QuarterValue = " + POut.Int(ehrQuarterlyKey.QuarterValue) + "";
            }
            if (ehrQuarterlyKey.PracticeName != oldEhrQuarterlyKey.PracticeName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PracticeName = '" + POut.String(ehrQuarterlyKey.PracticeName) + "'";
            }
            if (ehrQuarterlyKey.KeyValue != oldEhrQuarterlyKey.KeyValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "KeyValue = '" + POut.String(ehrQuarterlyKey.KeyValue) + "'";
            }
            if (ehrQuarterlyKey.PatNum != oldEhrQuarterlyKey.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(ehrQuarterlyKey.PatNum) + "";
            }
            if (ehrQuarterlyKey.Notes != oldEhrQuarterlyKey.Notes)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Notes = " + DbHelper.ParamChar + "paramNotes";
            }
            if (command == "")
            {
                return(false);
            }
            if (ehrQuarterlyKey.Notes == null)
            {
                ehrQuarterlyKey.Notes = "";
            }
            OdSqlParameter paramNotes = new OdSqlParameter("paramNotes", OdDbType.Text, POut.StringParam(ehrQuarterlyKey.Notes));

            command = "UPDATE ehrquarterlykey SET " + command
                      + " WHERE EhrQuarterlyKeyNum = " + POut.Long(ehrQuarterlyKey.EhrQuarterlyKeyNum);
            Db.NonQ(command, paramNotes);
            return(true);
        }