Esempio n. 1
0
        ///<summary>Inserts one MountItemDef into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(MountItemDef mountItemDef, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                mountItemDef.MountItemDefNum = ReplicationServers.GetKey("mountitemdef", "MountItemDefNum");
            }
            string command = "INSERT INTO mountitemdef (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "MountItemDefNum,";
            }
            command += "MountDefNum,Xpos,Ypos,Width,Height) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(mountItemDef.MountItemDefNum) + ",";
            }
            command +=
                POut.Long(mountItemDef.MountDefNum) + ","
                + POut.Int(mountItemDef.Xpos) + ","
                + POut.Int(mountItemDef.Ypos) + ","
                + POut.Int(mountItemDef.Width) + ","
                + POut.Int(mountItemDef.Height) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                mountItemDef.MountItemDefNum = Db.NonQ(command, true);
            }
            return(mountItemDef.MountItemDefNum);
        }
Esempio n. 2
0
 ///<summary>Inserts one MountItemDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(MountItemDef mountItemDef)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         mountItemDef.MountItemDefNum = DbHelper.GetNextOracleKey("mountitemdef", "MountItemDefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(mountItemDef, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     mountItemDef.MountItemDefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(mountItemDef, false));
     }
 }
Esempio n. 3
0
        ///<summary>Inserts one MountItemDef into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(MountItemDef mountItemDef, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO mountitemdef (";

            if (!useExistingPK && isRandomKeys)
            {
                mountItemDef.MountItemDefNum = ReplicationServers.GetKeyNoCache("mountitemdef", "MountItemDefNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "MountItemDefNum,";
            }
            command += "MountDefNum,Xpos,Ypos,Width,Height) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(mountItemDef.MountItemDefNum) + ",";
            }
            command +=
                POut.Long(mountItemDef.MountDefNum) + ","
                + POut.Int(mountItemDef.Xpos) + ","
                + POut.Int(mountItemDef.Ypos) + ","
                + POut.Int(mountItemDef.Width) + ","
                + POut.Int(mountItemDef.Height) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                mountItemDef.MountItemDefNum = Db.NonQ(command, true, "MountItemDefNum", "mountItemDef");
            }
            return(mountItemDef.MountItemDefNum);
        }
Esempio n. 4
0
 ///<summary>Inserts one MountItemDef into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(MountItemDef mountItemDef,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         mountItemDef.MountItemDefNum=ReplicationServers.GetKey("mountitemdef","MountItemDefNum");
     }
     string command="INSERT INTO mountitemdef (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="MountItemDefNum,";
     }
     command+="MountDefNum,Xpos,Ypos,Width,Height) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(mountItemDef.MountItemDefNum)+",";
     }
     command+=
              POut.Long  (mountItemDef.MountDefNum)+","
         +    POut.Int   (mountItemDef.Xpos)+","
         +    POut.Int   (mountItemDef.Ypos)+","
         +    POut.Int   (mountItemDef.Width)+","
         +    POut.Int   (mountItemDef.Height)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         mountItemDef.MountItemDefNum=Db.NonQ(command,true);
     }
     return mountItemDef.MountItemDefNum;
 }
Esempio n. 5
0
 ///<summary>Inserts one MountItemDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(MountItemDef mountItemDef)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         mountItemDef.MountItemDefNum=DbHelper.GetNextOracleKey("mountitemdef","MountItemDefNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(mountItemDef,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     mountItemDef.MountItemDefNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(mountItemDef,false);
     }
 }
Esempio n. 6
0
        ///<summary>Updates one MountItemDef 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(MountItemDef mountItemDef, MountItemDef oldMountItemDef)
        {
            string command = "";

            if (mountItemDef.MountDefNum != oldMountItemDef.MountDefNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MountDefNum = " + POut.Long(mountItemDef.MountDefNum) + "";
            }
            if (mountItemDef.Xpos != oldMountItemDef.Xpos)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Xpos = " + POut.Int(mountItemDef.Xpos) + "";
            }
            if (mountItemDef.Ypos != oldMountItemDef.Ypos)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Ypos = " + POut.Int(mountItemDef.Ypos) + "";
            }
            if (mountItemDef.Width != oldMountItemDef.Width)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Width = " + POut.Int(mountItemDef.Width) + "";
            }
            if (mountItemDef.Height != oldMountItemDef.Height)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Height = " + POut.Int(mountItemDef.Height) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE mountitemdef SET " + command
                      + " WHERE MountItemDefNum = " + POut.Long(mountItemDef.MountItemDefNum);
            Db.NonQ(command);
            return(true);
        }
Esempio n. 7
0
        ///<summary></summary>
        public static void Insert(MountItemDef def)
        {
            string command = "INSERT INTO mountitemdef (MountDefNum,Xpos,Ypos,Width,Height"
                             + ") VALUES("
                             + "'" + POut.PInt(def.MountDefNum) + "', "
                             + "'" + POut.PInt(def.Xpos) + "', "
                             + "'" + POut.PInt(def.Ypos) + "', "
                             + "'" + POut.PInt(def.Width) + "', "
                             + "'" + POut.PInt(def.Height) + "')";

            def.MountItemDefNum = General.NonQ(command, true);
        }
Esempio n. 8
0
        ///<summary></summary>
        public static void Update(MountItemDef def)
        {
            string command = "UPDATE mountitemdef SET "
                             + "MountDefNum = '" + POut.PInt(def.MountDefNum) + "'"
                             + ",Xpos = '" + POut.PInt(def.Xpos) + "'"
                             + ",Ypos = '" + POut.PInt(def.Ypos) + "'"
                             + ",Width = '" + POut.PInt(def.Width) + "'"
                             + ",Height = '" + POut.PInt(def.Height) + "'"
                             + " WHERE MountItemDefNum  ='" + POut.PInt(def.MountItemDefNum) + "'";

            General.NonQ(command);
        }
Esempio n. 9
0
        ///<summary>Updates one MountItemDef in the database.</summary>
        internal static void Update(MountItemDef mountItemDef)
        {
            string command = "UPDATE mountitemdef SET "
                             + "MountDefNum    =  " + POut.Long(mountItemDef.MountDefNum) + ", "
                             + "Xpos           =  " + POut.Int(mountItemDef.Xpos) + ", "
                             + "Ypos           =  " + POut.Int(mountItemDef.Ypos) + ", "
                             + "Width          =  " + POut.Int(mountItemDef.Width) + ", "
                             + "Height         =  " + POut.Int(mountItemDef.Height) + " "
                             + "WHERE MountItemDefNum = " + POut.Long(mountItemDef.MountItemDefNum);

            Db.NonQ(command);
        }
Esempio n. 10
0
 ///<summary>Inserts one MountItemDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MountItemDef mountItemDef)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(mountItemDef, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             mountItemDef.MountItemDefNum = DbHelper.GetNextOracleKey("mountitemdef", "MountItemDefNum");                  //Cacheless method
         }
         return(InsertNoCache(mountItemDef, true));
     }
 }
Esempio n. 11
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<MountItemDef> TableToList(DataTable table){
			List<MountItemDef> retVal=new List<MountItemDef>();
			MountItemDef mountItemDef;
			for(int i=0;i<table.Rows.Count;i++) {
				mountItemDef=new MountItemDef();
				mountItemDef.MountItemDefNum= PIn.Long  (table.Rows[i]["MountItemDefNum"].ToString());
				mountItemDef.MountDefNum    = PIn.Long  (table.Rows[i]["MountDefNum"].ToString());
				mountItemDef.Xpos           = PIn.Int   (table.Rows[i]["Xpos"].ToString());
				mountItemDef.Ypos           = PIn.Int   (table.Rows[i]["Ypos"].ToString());
				mountItemDef.Width          = PIn.Int   (table.Rows[i]["Width"].ToString());
				mountItemDef.Height         = PIn.Int   (table.Rows[i]["Height"].ToString());
				retVal.Add(mountItemDef);
			}
			return retVal;
		}
Esempio n. 12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <MountItemDef> TableToList(DataTable table)
        {
            List <MountItemDef> retVal = new List <MountItemDef>();
            MountItemDef        mountItemDef;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                mountItemDef = new MountItemDef();
                mountItemDef.MountItemDefNum = PIn.Long(table.Rows[i]["MountItemDefNum"].ToString());
                mountItemDef.MountDefNum     = PIn.Long(table.Rows[i]["MountDefNum"].ToString());
                mountItemDef.Xpos            = PIn.Int(table.Rows[i]["Xpos"].ToString());
                mountItemDef.Ypos            = PIn.Int(table.Rows[i]["Ypos"].ToString());
                mountItemDef.Width           = PIn.Int(table.Rows[i]["Width"].ToString());
                mountItemDef.Height          = PIn.Int(table.Rows[i]["Height"].ToString());
                retVal.Add(mountItemDef);
            }
            return(retVal);
        }
Esempio n. 13
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MountItemDef> TableToList(DataTable table)
        {
            List <MountItemDef> retVal = new List <MountItemDef>();
            MountItemDef        mountItemDef;

            foreach (DataRow row in table.Rows)
            {
                mountItemDef = new MountItemDef();
                mountItemDef.MountItemDefNum = PIn.Long(row["MountItemDefNum"].ToString());
                mountItemDef.MountDefNum     = PIn.Long(row["MountDefNum"].ToString());
                mountItemDef.Xpos            = PIn.Int(row["Xpos"].ToString());
                mountItemDef.Ypos            = PIn.Int(row["Ypos"].ToString());
                mountItemDef.Width           = PIn.Int(row["Width"].ToString());
                mountItemDef.Height          = PIn.Int(row["Height"].ToString());
                retVal.Add(mountItemDef);
            }
            return(retVal);
        }
Esempio n. 14
0
        ///<summary>Gets a list of all MountItemDefs when program first opens.</summary>
        public static void Refresh()
        {
            string    command = "SELECT * FROM mountitemdef";
            DataTable table   = General.GetTable(command);

            Listt = new List <MountItemDef>();
            MountItemDef mount;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                mount = new MountItemDef();
                mount.MountItemDefNum = PIn.PInt(table.Rows[i][0].ToString());
                mount.MountDefNum     = PIn.PInt(table.Rows[i][1].ToString());
                mount.Xpos            = PIn.PInt(table.Rows[i][2].ToString());
                mount.Ypos            = PIn.PInt(table.Rows[i][3].ToString());
                mount.Width           = PIn.PInt(table.Rows[i][4].ToString());
                mount.Height          = PIn.PInt(table.Rows[i][5].ToString());
                Listt.Add(mount);
            }
        }
Esempio n. 15
0
 ///<summary>Returns true if Update(MountItemDef,MountItemDef) 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(MountItemDef mountItemDef, MountItemDef oldMountItemDef)
 {
     if (mountItemDef.MountDefNum != oldMountItemDef.MountDefNum)
     {
         return(true);
     }
     if (mountItemDef.Xpos != oldMountItemDef.Xpos)
     {
         return(true);
     }
     if (mountItemDef.Ypos != oldMountItemDef.Ypos)
     {
         return(true);
     }
     if (mountItemDef.Width != oldMountItemDef.Width)
     {
         return(true);
     }
     if (mountItemDef.Height != oldMountItemDef.Height)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 16
0
 ///<summary>Inserts one MountItemDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MountItemDef mountItemDef)
 {
     return(InsertNoCache(mountItemDef, false));
 }
Esempio n. 17
0
 ///<summary>Updates one MountItemDef 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(MountItemDef mountItemDef,MountItemDef oldMountItemDef)
 {
     string command="";
     if(mountItemDef.MountDefNum != oldMountItemDef.MountDefNum) {
         if(command!=""){ command+=",";}
         command+="MountDefNum = "+POut.Long(mountItemDef.MountDefNum)+"";
     }
     if(mountItemDef.Xpos != oldMountItemDef.Xpos) {
         if(command!=""){ command+=",";}
         command+="Xpos = "+POut.Int(mountItemDef.Xpos)+"";
     }
     if(mountItemDef.Ypos != oldMountItemDef.Ypos) {
         if(command!=""){ command+=",";}
         command+="Ypos = "+POut.Int(mountItemDef.Ypos)+"";
     }
     if(mountItemDef.Width != oldMountItemDef.Width) {
         if(command!=""){ command+=",";}
         command+="Width = "+POut.Int(mountItemDef.Width)+"";
     }
     if(mountItemDef.Height != oldMountItemDef.Height) {
         if(command!=""){ command+=",";}
         command+="Height = "+POut.Int(mountItemDef.Height)+"";
     }
     if(command==""){
         return;
     }
     command="UPDATE mountitemdef SET "+command
         +" WHERE MountItemDefNum = "+POut.Long(mountItemDef.MountItemDefNum);
     Db.NonQ(command);
 }
Esempio n. 18
0
 ///<summary>Updates one MountItemDef in the database.</summary>
 internal static void Update(MountItemDef mountItemDef)
 {
     string command="UPDATE mountitemdef SET "
         +"MountDefNum    =  "+POut.Long  (mountItemDef.MountDefNum)+", "
         +"Xpos           =  "+POut.Int   (mountItemDef.Xpos)+", "
         +"Ypos           =  "+POut.Int   (mountItemDef.Ypos)+", "
         +"Width          =  "+POut.Int   (mountItemDef.Width)+", "
         +"Height         =  "+POut.Int   (mountItemDef.Height)+" "
         +"WHERE MountItemDefNum = "+POut.Long(mountItemDef.MountItemDefNum);
     Db.NonQ(command);
 }