コード例 #1
0
        ///<summary>Updates one RecallTrigger 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(RecallTrigger recallTrigger, RecallTrigger oldRecallTrigger)
        {
            string command = "";

            if (recallTrigger.RecallTypeNum != oldRecallTrigger.RecallTypeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RecallTypeNum = " + POut.Long(recallTrigger.RecallTypeNum) + "";
            }
            if (recallTrigger.CodeNum != oldRecallTrigger.CodeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeNum = " + POut.Long(recallTrigger.CodeNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE recalltrigger SET " + command
                      + " WHERE RecallTriggerNum = " + POut.Long(recallTrigger.RecallTriggerNum);
            Db.NonQ(command);
            return(true);
        }
コード例 #2
0
 ///<summary>Inserts one RecallTrigger into the database.  Returns the new priKey.</summary>
 public static long Insert(RecallTrigger recallTrigger)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         recallTrigger.RecallTriggerNum = DbHelper.GetNextOracleKey("recalltrigger", "RecallTriggerNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(recallTrigger, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     recallTrigger.RecallTriggerNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(recallTrigger, false));
     }
 }
コード例 #3
0
        ///<summary>Inserts one RecallTrigger into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(RecallTrigger recallTrigger, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO recalltrigger (";

            if (!useExistingPK && isRandomKeys)
            {
                recallTrigger.RecallTriggerNum = ReplicationServers.GetKeyNoCache("recalltrigger", "RecallTriggerNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "RecallTriggerNum,";
            }
            command += "RecallTypeNum,CodeNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(recallTrigger.RecallTriggerNum) + ",";
            }
            command +=
                POut.Long(recallTrigger.RecallTypeNum) + ","
                + POut.Long(recallTrigger.CodeNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                recallTrigger.RecallTriggerNum = Db.NonQ(command, true, "RecallTriggerNum", "recallTrigger");
            }
            return(recallTrigger.RecallTriggerNum);
        }
コード例 #4
0
        ///<summary>Inserts one RecallTrigger into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(RecallTrigger recallTrigger, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                recallTrigger.RecallTriggerNum = ReplicationServers.GetKey("recalltrigger", "RecallTriggerNum");
            }
            string command = "INSERT INTO recalltrigger (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "RecallTriggerNum,";
            }
            command += "RecallTypeNum,CodeNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(recallTrigger.RecallTriggerNum) + ",";
            }
            command +=
                POut.Long(recallTrigger.RecallTypeNum) + ","
                + POut.Long(recallTrigger.CodeNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                recallTrigger.RecallTriggerNum = Db.NonQ(command, true, "RecallTriggerNum", "recallTrigger");
            }
            return(recallTrigger.RecallTriggerNum);
        }
コード例 #5
0
ファイル: RecallTriggerCrud.cs プロジェクト: nampn/ODental
 ///<summary>Inserts one RecallTrigger into the database.  Returns the new priKey.</summary>
 internal static long Insert(RecallTrigger recallTrigger)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         recallTrigger.RecallTriggerNum=DbHelper.GetNextOracleKey("recalltrigger","RecallTriggerNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(recallTrigger,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     recallTrigger.RecallTriggerNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(recallTrigger,false);
     }
 }
コード例 #6
0
        ///<summary>Updates one RecallTrigger in the database.</summary>
        public static void Update(RecallTrigger recallTrigger)
        {
            string command = "UPDATE recalltrigger SET "
                             + "RecallTypeNum   =  " + POut.Long(recallTrigger.RecallTypeNum) + ", "
                             + "CodeNum         =  " + POut.Long(recallTrigger.CodeNum) + " "
                             + "WHERE RecallTriggerNum = " + POut.Long(recallTrigger.RecallTriggerNum);

            Db.NonQ(command);
        }
コード例 #7
0
 ///<summary>Returns true if Update(RecallTrigger,RecallTrigger) 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(RecallTrigger recallTrigger, RecallTrigger oldRecallTrigger)
 {
     if (recallTrigger.RecallTypeNum != oldRecallTrigger.RecallTypeNum)
     {
         return(true);
     }
     if (recallTrigger.CodeNum != oldRecallTrigger.CodeNum)
     {
         return(true);
     }
     return(false);
 }
コード例 #8
0
ファイル: RecallTriggerCrud.cs プロジェクト: mnisl/OD
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<RecallTrigger> TableToList(DataTable table){
			List<RecallTrigger> retVal=new List<RecallTrigger>();
			RecallTrigger recallTrigger;
			for(int i=0;i<table.Rows.Count;i++) {
				recallTrigger=new RecallTrigger();
				recallTrigger.RecallTriggerNum= PIn.Long  (table.Rows[i]["RecallTriggerNum"].ToString());
				recallTrigger.RecallTypeNum   = PIn.Long  (table.Rows[i]["RecallTypeNum"].ToString());
				recallTrigger.CodeNum         = PIn.Long  (table.Rows[i]["CodeNum"].ToString());
				retVal.Add(recallTrigger);
			}
			return retVal;
		}
コード例 #9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <RecallTrigger> TableToList(DataTable table)
        {
            List <RecallTrigger> retVal = new List <RecallTrigger>();
            RecallTrigger        recallTrigger;

            foreach (DataRow row in table.Rows)
            {
                recallTrigger = new RecallTrigger();
                recallTrigger.RecallTriggerNum = PIn.Long(row["RecallTriggerNum"].ToString());
                recallTrigger.RecallTypeNum    = PIn.Long(row["RecallTypeNum"].ToString());
                recallTrigger.CodeNum          = PIn.Long(row["CodeNum"].ToString());
                retVal.Add(recallTrigger);
            }
            return(retVal);
        }
コード例 #10
0
 ///<summary>Inserts one RecallTrigger into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(RecallTrigger recallTrigger)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(recallTrigger, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             recallTrigger.RecallTriggerNum = DbHelper.GetNextOracleKey("recalltrigger", "RecallTriggerNum");                  //Cacheless method
         }
         return(InsertNoCache(recallTrigger, true));
     }
 }
コード例 #11
0
ファイル: RecallTriggerCrud.cs プロジェクト: nampn/ODental
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <RecallTrigger> TableToList(DataTable table)
        {
            List <RecallTrigger> retVal = new List <RecallTrigger>();
            RecallTrigger        recallTrigger;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                recallTrigger = new RecallTrigger();
                recallTrigger.RecallTriggerNum = PIn.Long(table.Rows[i]["RecallTriggerNum"].ToString());
                recallTrigger.RecallTypeNum    = PIn.Long(table.Rows[i]["RecallTypeNum"].ToString());
                recallTrigger.CodeNum          = PIn.Long(table.Rows[i]["CodeNum"].ToString());
                retVal.Add(recallTrigger);
            }
            return(retVal);
        }
コード例 #12
0
ファイル: FormRecallTypeEdit.cs プロジェクト: nampn/ODental
        private void butAddTrigger_Click(object sender, EventArgs e)
        {
            FormProcCodes FormP = new FormProcCodes();

            FormP.IsSelectionMode = true;
            FormP.ShowDialog();
            if (FormP.DialogResult != DialogResult.OK)
            {
                return;
            }
            RecallTrigger trigger = new RecallTrigger();

            trigger.CodeNum = FormP.SelectedCodeNum;
            //RecallTypeNum handled during save.
            TriggerList.Add(trigger);
            FillTriggers();
        }
コード例 #13
0
ファイル: RecallTriggerCrud.cs プロジェクト: mnisl/OD
		///<summary>Inserts one RecallTrigger into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(RecallTrigger recallTrigger,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				recallTrigger.RecallTriggerNum=ReplicationServers.GetKey("recalltrigger","RecallTriggerNum");
			}
			string command="INSERT INTO recalltrigger (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="RecallTriggerNum,";
			}
			command+="RecallTypeNum,CodeNum) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(recallTrigger.RecallTriggerNum)+",";
			}
			command+=
				     POut.Long  (recallTrigger.RecallTypeNum)+","
				+    POut.Long  (recallTrigger.CodeNum)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				recallTrigger.RecallTriggerNum=Db.NonQ(command,true);
			}
			return recallTrigger.RecallTriggerNum;
		}
コード例 #14
0
ファイル: RecallTriggerCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one RecallTrigger 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(RecallTrigger recallTrigger,RecallTrigger oldRecallTrigger){
			string command="";
			if(recallTrigger.RecallTypeNum != oldRecallTrigger.RecallTypeNum) {
				if(command!=""){ command+=",";}
				command+="RecallTypeNum = "+POut.Long(recallTrigger.RecallTypeNum)+"";
			}
			if(recallTrigger.CodeNum != oldRecallTrigger.CodeNum) {
				if(command!=""){ command+=",";}
				command+="CodeNum = "+POut.Long(recallTrigger.CodeNum)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE recalltrigger SET "+command
				+" WHERE RecallTriggerNum = "+POut.Long(recallTrigger.RecallTriggerNum);
			Db.NonQ(command);
			return true;
		}
コード例 #15
0
ファイル: RecallTriggerCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one RecallTrigger in the database.</summary>
		public static void Update(RecallTrigger recallTrigger){
			string command="UPDATE recalltrigger SET "
				+"RecallTypeNum   =  "+POut.Long  (recallTrigger.RecallTypeNum)+", "
				+"CodeNum         =  "+POut.Long  (recallTrigger.CodeNum)+" "
				+"WHERE RecallTriggerNum = "+POut.Long(recallTrigger.RecallTriggerNum);
			Db.NonQ(command);
		}
コード例 #16
0
 ///<summary>Inserts one RecallTrigger into the database.  Returns the new priKey.</summary>
 public static long Insert(RecallTrigger recallTrigger)
 {
     return(Insert(recallTrigger, false));
 }