///<summary>Inserts one ProcButtonQuick into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ProcButtonQuick procButtonQuick, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO procbuttonquick (";

            if (!useExistingPK && isRandomKeys)
            {
                procButtonQuick.ProcButtonQuickNum = ReplicationServers.GetKeyNoCache("procbuttonquick", "ProcButtonQuickNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ProcButtonQuickNum,";
            }
            command += "Description,CodeValue,Surf,YPos,ItemOrder,IsLabel) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(procButtonQuick.ProcButtonQuickNum) + ",";
            }
            command +=
                "'" + POut.String(procButtonQuick.Description) + "',"
                + "'" + POut.String(procButtonQuick.CodeValue) + "',"
                + "'" + POut.String(procButtonQuick.Surf) + "',"
                + POut.Int(procButtonQuick.YPos) + ","
                + POut.Int(procButtonQuick.ItemOrder) + ","
                + POut.Bool(procButtonQuick.IsLabel) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                procButtonQuick.ProcButtonQuickNum = Db.NonQ(command, true, "ProcButtonQuickNum", "procButtonQuick");
            }
            return(procButtonQuick.ProcButtonQuickNum);
        }
 ///<summary>Returns true if Update(ProcButtonQuick,ProcButtonQuick) 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(ProcButtonQuick procButtonQuick, ProcButtonQuick oldProcButtonQuick)
 {
     if (procButtonQuick.Description != oldProcButtonQuick.Description)
     {
         return(true);
     }
     if (procButtonQuick.CodeValue != oldProcButtonQuick.CodeValue)
     {
         return(true);
     }
     if (procButtonQuick.Surf != oldProcButtonQuick.Surf)
     {
         return(true);
     }
     if (procButtonQuick.YPos != oldProcButtonQuick.YPos)
     {
         return(true);
     }
     if (procButtonQuick.ItemOrder != oldProcButtonQuick.ItemOrder)
     {
         return(true);
     }
     if (procButtonQuick.IsLabel != oldProcButtonQuick.IsLabel)
     {
         return(true);
     }
     return(false);
 }
Example #3
0
 ///<summary>Inserts one ProcButtonQuick into the database.  Returns the new priKey.</summary>
 public static long Insert(ProcButtonQuick procButtonQuick)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         procButtonQuick.ProcButtonQuickNum = DbHelper.GetNextOracleKey("procbuttonquick", "ProcButtonQuickNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(procButtonQuick, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     procButtonQuick.ProcButtonQuickNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(procButtonQuick, false));
     }
 }
        ///<summary>Updates one ProcButtonQuick in the database.</summary>
        public static void Update(ProcButtonQuick procButtonQuick)
        {
            string command = "UPDATE procbuttonquick SET "
                             + "Description       = '" + POut.String(procButtonQuick.Description) + "', "
                             + "CodeValue         = '" + POut.String(procButtonQuick.CodeValue) + "', "
                             + "Surf              = '" + POut.String(procButtonQuick.Surf) + "', "
                             + "YPos              =  " + POut.Int(procButtonQuick.YPos) + ", "
                             + "ItemOrder         =  " + POut.Int(procButtonQuick.ItemOrder) + ", "
                             + "IsLabel           =  " + POut.Bool(procButtonQuick.IsLabel) + " "
                             + "WHERE ProcButtonQuickNum = " + POut.Long(procButtonQuick.ProcButtonQuickNum);

            Db.NonQ(command);
        }
Example #5
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)
     {
         pbqCur       = null;
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         ProcButtonQuicks.Delete(pbqCur.ProcButtonQuickNum);
         pbqCur       = null;
         DialogResult = DialogResult.OK;
     }
 }
Example #6
0
 ///<summary>Inserts one ProcButtonQuick into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ProcButtonQuick procButtonQuick)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(procButtonQuick, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             procButtonQuick.ProcButtonQuickNum = DbHelper.GetNextOracleKey("procbuttonquick", "ProcButtonQuickNum");                  //Cacheless method
         }
         return(InsertNoCache(procButtonQuick, true));
     }
 }
Example #7
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ProcButtonQuick> TableToList(DataTable table){
			List<ProcButtonQuick> retVal=new List<ProcButtonQuick>();
			ProcButtonQuick procButtonQuick;
			for(int i=0;i<table.Rows.Count;i++) {
				procButtonQuick=new ProcButtonQuick();
				procButtonQuick.ProcButtonQuickNum= PIn.Long  (table.Rows[i]["ProcButtonQuickNum"].ToString());
				procButtonQuick.Description       = PIn.String(table.Rows[i]["Description"].ToString());
				procButtonQuick.CodeValue         = PIn.String(table.Rows[i]["CodeValue"].ToString());
				procButtonQuick.Surf              = PIn.String(table.Rows[i]["Surf"].ToString());
				procButtonQuick.YPos              = PIn.Int   (table.Rows[i]["YPos"].ToString());
				procButtonQuick.ItemOrder         = PIn.Int   (table.Rows[i]["ItemOrder"].ToString());
				procButtonQuick.IsLabel           = PIn.Bool  (table.Rows[i]["IsLabel"].ToString());
				retVal.Add(procButtonQuick);
			}
			return retVal;
		}
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ProcButtonQuick> TableToList(DataTable table)
        {
            List <ProcButtonQuick> retVal = new List <ProcButtonQuick>();
            ProcButtonQuick        procButtonQuick;

            foreach (DataRow row in table.Rows)
            {
                procButtonQuick = new ProcButtonQuick();
                procButtonQuick.ProcButtonQuickNum = PIn.Long(row["ProcButtonQuickNum"].ToString());
                procButtonQuick.Description        = PIn.String(row["Description"].ToString());
                procButtonQuick.CodeValue          = PIn.String(row["CodeValue"].ToString());
                procButtonQuick.Surf      = PIn.String(row["Surf"].ToString());
                procButtonQuick.YPos      = PIn.Int(row["YPos"].ToString());
                procButtonQuick.ItemOrder = PIn.Int(row["ItemOrder"].ToString());
                procButtonQuick.IsLabel   = PIn.Bool(row["IsLabel"].ToString());
                retVal.Add(procButtonQuick);
            }
            return(retVal);
        }
Example #9
0
		///<summary>Inserts one ProcButtonQuick into the database.  Returns the new priKey.</summary>
		public static long Insert(ProcButtonQuick procButtonQuick){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				procButtonQuick.ProcButtonQuickNum=DbHelper.GetNextOracleKey("procbuttonquick","ProcButtonQuickNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(procButtonQuick,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							procButtonQuick.ProcButtonQuickNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(procButtonQuick,false);
			}
		}
        ///<summary>Updates one ProcButtonQuick 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(ProcButtonQuick procButtonQuick, ProcButtonQuick oldProcButtonQuick)
        {
            string command = "";

            if (procButtonQuick.Description != oldProcButtonQuick.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(procButtonQuick.Description) + "'";
            }
            if (procButtonQuick.CodeValue != oldProcButtonQuick.CodeValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeValue = '" + POut.String(procButtonQuick.CodeValue) + "'";
            }
            if (procButtonQuick.Surf != oldProcButtonQuick.Surf)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Surf = '" + POut.String(procButtonQuick.Surf) + "'";
            }
            if (procButtonQuick.YPos != oldProcButtonQuick.YPos)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "YPos = " + POut.Int(procButtonQuick.YPos) + "";
            }
            if (procButtonQuick.ItemOrder != oldProcButtonQuick.ItemOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ItemOrder = " + POut.Int(procButtonQuick.ItemOrder) + "";
            }
            if (procButtonQuick.IsLabel != oldProcButtonQuick.IsLabel)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsLabel = " + POut.Bool(procButtonQuick.IsLabel) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE procbuttonquick SET " + command
                      + " WHERE ProcButtonQuickNum = " + POut.Long(procButtonQuick.ProcButtonQuickNum);
            Db.NonQ(command);
            return(true);
        }
 ///<summary>Inserts one ProcButtonQuick into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ProcButtonQuick procButtonQuick)
 {
     return(InsertNoCache(procButtonQuick, false));
 }
Example #12
0
		///<summary>Inserts one ProcButtonQuick into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(ProcButtonQuick procButtonQuick,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				procButtonQuick.ProcButtonQuickNum=ReplicationServers.GetKey("procbuttonquick","ProcButtonQuickNum");
			}
			string command="INSERT INTO procbuttonquick (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="ProcButtonQuickNum,";
			}
			command+="Description,CodeValue,Surf,YPos,ItemOrder,IsLabel) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(procButtonQuick.ProcButtonQuickNum)+",";
			}
			command+=
				 "'"+POut.String(procButtonQuick.Description)+"',"
				+"'"+POut.String(procButtonQuick.CodeValue)+"',"
				+"'"+POut.String(procButtonQuick.Surf)+"',"
				+    POut.Int   (procButtonQuick.YPos)+","
				+    POut.Int   (procButtonQuick.ItemOrder)+","
				+    POut.Bool  (procButtonQuick.IsLabel)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				procButtonQuick.ProcButtonQuickNum=Db.NonQ(command,true);
			}
			return procButtonQuick.ProcButtonQuickNum;
		}
Example #13
0
		///<summary>Updates one ProcButtonQuick 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(ProcButtonQuick procButtonQuick,ProcButtonQuick oldProcButtonQuick){
			string command="";
			if(procButtonQuick.Description != oldProcButtonQuick.Description) {
				if(command!=""){ command+=",";}
				command+="Description = '"+POut.String(procButtonQuick.Description)+"'";
			}
			if(procButtonQuick.CodeValue != oldProcButtonQuick.CodeValue) {
				if(command!=""){ command+=",";}
				command+="CodeValue = '"+POut.String(procButtonQuick.CodeValue)+"'";
			}
			if(procButtonQuick.Surf != oldProcButtonQuick.Surf) {
				if(command!=""){ command+=",";}
				command+="Surf = '"+POut.String(procButtonQuick.Surf)+"'";
			}
			if(procButtonQuick.YPos != oldProcButtonQuick.YPos) {
				if(command!=""){ command+=",";}
				command+="YPos = "+POut.Int(procButtonQuick.YPos)+"";
			}
			if(procButtonQuick.ItemOrder != oldProcButtonQuick.ItemOrder) {
				if(command!=""){ command+=",";}
				command+="ItemOrder = "+POut.Int(procButtonQuick.ItemOrder)+"";
			}
			if(procButtonQuick.IsLabel != oldProcButtonQuick.IsLabel) {
				if(command!=""){ command+=",";}
				command+="IsLabel = "+POut.Bool(procButtonQuick.IsLabel)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE procbuttonquick SET "+command
				+" WHERE ProcButtonQuickNum = "+POut.Long(procButtonQuick.ProcButtonQuickNum);
			Db.NonQ(command);
			return true;
		}
Example #14
0
		///<summary>Updates one ProcButtonQuick in the database.</summary>
		public static void Update(ProcButtonQuick procButtonQuick){
			string command="UPDATE procbuttonquick SET "
				+"Description       = '"+POut.String(procButtonQuick.Description)+"', "
				+"CodeValue         = '"+POut.String(procButtonQuick.CodeValue)+"', "
				+"Surf              = '"+POut.String(procButtonQuick.Surf)+"', "
				+"YPos              =  "+POut.Int   (procButtonQuick.YPos)+", "
				+"ItemOrder         =  "+POut.Int   (procButtonQuick.ItemOrder)+", "
				+"IsLabel           =  "+POut.Bool  (procButtonQuick.IsLabel)+" "
				+"WHERE ProcButtonQuickNum = "+POut.Long(procButtonQuick.ProcButtonQuickNum);
			Db.NonQ(command);
		}