Пример #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
 ///<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
		///<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
        ///<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
        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
		///<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
		///<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
		///<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));
 }