Пример #1
0
 ///<summary>Inserts one ApptField into the database.  Returns the new priKey.</summary>
 internal static long Insert(ApptField apptField)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         apptField.ApptFieldNum=DbHelper.GetNextOracleKey("apptfield","ApptFieldNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(apptField,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     apptField.ApptFieldNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(apptField,false);
     }
 }
Пример #2
0
 ///<summary>Inserts one ApptField into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(ApptField apptField,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         apptField.ApptFieldNum=ReplicationServers.GetKey("apptfield","ApptFieldNum");
     }
     string command="INSERT INTO apptfield (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="ApptFieldNum,";
     }
     command+="AptNum,FieldName,FieldValue) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(apptField.ApptFieldNum)+",";
     }
     command+=
              POut.Long  (apptField.AptNum)+","
         +"'"+POut.String(apptField.FieldName)+"',"
         +"'"+POut.String(apptField.FieldValue)+"')";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         apptField.ApptFieldNum=Db.NonQ(command,true);
     }
     return apptField.ApptFieldNum;
 }
Пример #3
0
 ///<summary>Inserts one ApptField into the database.  Returns the new priKey.</summary>
 internal static long Insert(ApptField apptField)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         apptField.ApptFieldNum = DbHelper.GetNextOracleKey("apptfield", "ApptFieldNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(apptField, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     apptField.ApptFieldNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(apptField, false));
     }
 }
Пример #4
0
        ///<summary>Inserts one ApptField into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(ApptField apptField, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                apptField.ApptFieldNum = ReplicationServers.GetKey("apptfield", "ApptFieldNum");
            }
            string command = "INSERT INTO apptfield (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ApptFieldNum,";
            }
            command += "AptNum,FieldName,FieldValue) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(apptField.ApptFieldNum) + ",";
            }
            command +=
                POut.Long(apptField.AptNum) + ","
                + "'" + POut.String(apptField.FieldName) + "',"
                + "'" + POut.String(apptField.FieldValue) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                apptField.ApptFieldNum = Db.NonQ(command, true);
            }
            return(apptField.ApptFieldNum);
        }
Пример #5
0
 ///<summary></summary>
 public FormApptFieldEdit(ApptField field)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     Lan.F(this);
     Field = field;
 }
Пример #6
0
        ///<summary>Updates one ApptField in the database.</summary>
        internal static void Update(ApptField apptField)
        {
            string command = "UPDATE apptfield SET "
                             + "AptNum      =  " + POut.Long(apptField.AptNum) + ", "
                             + "FieldName   = '" + POut.String(apptField.FieldName) + "', "
                             + "FieldValue  = '" + POut.String(apptField.FieldValue) + "' "
                             + "WHERE ApptFieldNum = " + POut.Long(apptField.ApptFieldNum);

            Db.NonQ(command);
        }
Пример #7
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ApptField> TableToList(DataTable table){
			List<ApptField> retVal=new List<ApptField>();
			ApptField apptField;
			for(int i=0;i<table.Rows.Count;i++) {
				apptField=new ApptField();
				apptField.ApptFieldNum= PIn.Long  (table.Rows[i]["ApptFieldNum"].ToString());
				apptField.AptNum      = PIn.Long  (table.Rows[i]["AptNum"].ToString());
				apptField.FieldName   = PIn.String(table.Rows[i]["FieldName"].ToString());
				apptField.FieldValue  = PIn.String(table.Rows[i]["FieldValue"].ToString());
				retVal.Add(apptField);
			}
			return retVal;
		}
Пример #8
0
 ///<summary>Inserts one ApptField into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ApptField apptField)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(apptField, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             apptField.ApptFieldNum = DbHelper.GetNextOracleKey("apptfield", "ApptFieldNum");                  //Cacheless method
         }
         return(InsertNoCache(apptField, true));
     }
 }
Пример #9
0
 ///<summary>Returns true if Update(ApptField,ApptField) 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(ApptField apptField, ApptField oldApptField)
 {
     if (apptField.AptNum != oldApptField.AptNum)
     {
         return(true);
     }
     if (apptField.FieldName != oldApptField.FieldName)
     {
         return(true);
     }
     if (apptField.FieldValue != oldApptField.FieldValue)
     {
         return(true);
     }
     return(false);
 }
Пример #10
0
        ///<summary>Updates one ApptField in the database.</summary>
        public static void Update(ApptField apptField)
        {
            string command = "UPDATE apptfield SET "
                             + "AptNum      =  " + POut.Long(apptField.AptNum) + ", "
                             + "FieldName   = '" + POut.String(apptField.FieldName) + "', "
                             + "FieldValue  =  " + DbHelper.ParamChar + "paramFieldValue "
                             + "WHERE ApptFieldNum = " + POut.Long(apptField.ApptFieldNum);

            if (apptField.FieldValue == null)
            {
                apptField.FieldValue = "";
            }
            OdSqlParameter paramFieldValue = new OdSqlParameter("paramFieldValue", OdDbType.Text, POut.StringParam(apptField.FieldValue));

            Db.NonQ(command, paramFieldValue);
        }
Пример #11
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <ApptField> TableToList(DataTable table)
        {
            List <ApptField> retVal = new List <ApptField>();
            ApptField        apptField;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                apptField = new ApptField();
                apptField.ApptFieldNum = PIn.Long(table.Rows[i]["ApptFieldNum"].ToString());
                apptField.AptNum       = PIn.Long(table.Rows[i]["AptNum"].ToString());
                apptField.FieldName    = PIn.String(table.Rows[i]["FieldName"].ToString());
                apptField.FieldValue   = PIn.String(table.Rows[i]["FieldValue"].ToString());
                retVal.Add(apptField);
            }
            return(retVal);
        }
Пример #12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ApptField> TableToList(DataTable table)
        {
            List <ApptField> retVal = new List <ApptField>();
            ApptField        apptField;

            foreach (DataRow row in table.Rows)
            {
                apptField = new ApptField();
                apptField.ApptFieldNum = PIn.Long(row["ApptFieldNum"].ToString());
                apptField.AptNum       = PIn.Long(row["AptNum"].ToString());
                apptField.FieldName    = PIn.String(row["FieldName"].ToString());
                apptField.FieldValue   = PIn.String(row["FieldValue"].ToString());
                retVal.Add(apptField);
            }
            return(retVal);
        }
Пример #13
0
        ///<summary>Updates one ApptField 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(ApptField apptField, ApptField oldApptField)
        {
            string command = "";

            if (apptField.AptNum != oldApptField.AptNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AptNum = " + POut.Long(apptField.AptNum) + "";
            }
            if (apptField.FieldName != oldApptField.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(apptField.FieldName) + "'";
            }
            if (apptField.FieldValue != oldApptField.FieldValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldValue = " + DbHelper.ParamChar + "paramFieldValue";
            }
            if (command == "")
            {
                return(false);
            }
            if (apptField.FieldValue == null)
            {
                apptField.FieldValue = "";
            }
            OdSqlParameter paramFieldValue = new OdSqlParameter("paramFieldValue", OdDbType.Text, POut.StringParam(apptField.FieldValue));

            command = "UPDATE apptfield SET " + command
                      + " WHERE ApptFieldNum = " + POut.Long(apptField.ApptFieldNum);
            Db.NonQ(command, paramFieldValue);
            return(true);
        }
Пример #14
0
        ///<summary>Inserts one ApptField into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ApptField apptField, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO apptfield (";

            if (!useExistingPK && isRandomKeys)
            {
                apptField.ApptFieldNum = ReplicationServers.GetKeyNoCache("apptfield", "ApptFieldNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ApptFieldNum,";
            }
            command += "AptNum,FieldName,FieldValue) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(apptField.ApptFieldNum) + ",";
            }
            command +=
                POut.Long(apptField.AptNum) + ","
                + "'" + POut.String(apptField.FieldName) + "',"
                + DbHelper.ParamChar + "paramFieldValue)";
            if (apptField.FieldValue == null)
            {
                apptField.FieldValue = "";
            }
            OdSqlParameter paramFieldValue = new OdSqlParameter("paramFieldValue", OdDbType.Text, POut.StringParam(apptField.FieldValue));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramFieldValue);
            }
            else
            {
                apptField.ApptFieldNum = Db.NonQ(command, true, "ApptFieldNum", "apptField", paramFieldValue);
            }
            return(apptField.ApptFieldNum);
        }
Пример #15
0
        ///<summary>Updates one ApptField 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(ApptField apptField, ApptField oldApptField)
        {
            string command = "";

            if (apptField.AptNum != oldApptField.AptNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AptNum = " + POut.Long(apptField.AptNum) + "";
            }
            if (apptField.FieldName != oldApptField.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(apptField.FieldName) + "'";
            }
            if (apptField.FieldValue != oldApptField.FieldValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldValue = '" + POut.String(apptField.FieldValue) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE apptfield SET " + command
                      + " WHERE ApptFieldNum = " + POut.Long(apptField.ApptFieldNum);
            Db.NonQ(command);
        }
Пример #16
0
 public FormApptFieldPickEdit(ApptField field)
 {
     InitializeComponent();
     Lan.F(this);
     Field = field;
 }
Пример #17
0
		///<summary>Updates one ApptField 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(ApptField apptField,ApptField oldApptField){
			string command="";
			if(apptField.AptNum != oldApptField.AptNum) {
				if(command!=""){ command+=",";}
				command+="AptNum = "+POut.Long(apptField.AptNum)+"";
			}
			if(apptField.FieldName != oldApptField.FieldName) {
				if(command!=""){ command+=",";}
				command+="FieldName = '"+POut.String(apptField.FieldName)+"'";
			}
			if(apptField.FieldValue != oldApptField.FieldValue) {
				if(command!=""){ command+=",";}
				command+="FieldValue = '"+POut.String(apptField.FieldValue)+"'";
			}
			if(command==""){
				return false;
			}
			command="UPDATE apptfield SET "+command
				+" WHERE ApptFieldNum = "+POut.Long(apptField.ApptFieldNum);
			Db.NonQ(command);
			return true;
		}
Пример #18
0
		///<summary>Updates one ApptField in the database.</summary>
		public static void Update(ApptField apptField){
			string command="UPDATE apptfield SET "
				+"AptNum      =  "+POut.Long  (apptField.AptNum)+", "
				+"FieldName   = '"+POut.String(apptField.FieldName)+"', "
				+"FieldValue  = '"+POut.String(apptField.FieldValue)+"' "
				+"WHERE ApptFieldNum = "+POut.Long(apptField.ApptFieldNum);
			Db.NonQ(command);
		}
Пример #19
0
 ///<summary>Inserts one ApptField into the database.  Returns the new priKey.</summary>
 public static long Insert(ApptField apptField)
 {
     return(Insert(apptField, false));
 }