Пример #1
0
		///<summary>Inserts one CustRefEntry into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(CustRefEntry custRefEntry,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				custRefEntry.CustRefEntryNum=ReplicationServers.GetKey("custrefentry","CustRefEntryNum");
			}
			string command="INSERT INTO custrefentry (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="CustRefEntryNum,";
			}
			command+="PatNumCust,PatNumRef,DateEntry,Note) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(custRefEntry.CustRefEntryNum)+",";
			}
			command+=
				     POut.Long  (custRefEntry.PatNumCust)+","
				+    POut.Long  (custRefEntry.PatNumRef)+","
				+    POut.Date  (custRefEntry.DateEntry)+","
				+"'"+POut.String(custRefEntry.Note)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				custRefEntry.CustRefEntryNum=Db.NonQ(command,true);
			}
			return custRefEntry.CustRefEntryNum;
		}
Пример #2
0
 ///<summary>Inserts one CustRefEntry into the database.  Returns the new priKey.</summary>
 public static long Insert(CustRefEntry custRefEntry)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         custRefEntry.CustRefEntryNum = DbHelper.GetNextOracleKey("custrefentry", "CustRefEntryNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(custRefEntry, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     custRefEntry.CustRefEntryNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(custRefEntry, false));
     }
 }
Пример #3
0
        ///<summary>Inserts one CustRefEntry into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(CustRefEntry custRefEntry, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO custrefentry (";

            if (!useExistingPK && isRandomKeys)
            {
                custRefEntry.CustRefEntryNum = ReplicationServers.GetKeyNoCache("custrefentry", "CustRefEntryNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "CustRefEntryNum,";
            }
            command += "PatNumCust,PatNumRef,DateEntry,Note) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(custRefEntry.CustRefEntryNum) + ",";
            }
            command +=
                POut.Long(custRefEntry.PatNumCust) + ","
                + POut.Long(custRefEntry.PatNumRef) + ","
                + POut.Date(custRefEntry.DateEntry) + ","
                + "'" + POut.String(custRefEntry.Note) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                custRefEntry.CustRefEntryNum = Db.NonQ(command, true, "CustRefEntryNum", "custRefEntry");
            }
            return(custRefEntry.CustRefEntryNum);
        }
Пример #4
0
        ///<summary>Inserts one CustRefEntry into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(CustRefEntry custRefEntry, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                custRefEntry.CustRefEntryNum = ReplicationServers.GetKey("custrefentry", "CustRefEntryNum");
            }
            string command = "INSERT INTO custrefentry (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "CustRefEntryNum,";
            }
            command += "PatNumCust,PatNumRef,DateEntry,Note) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(custRefEntry.CustRefEntryNum) + ",";
            }
            command +=
                POut.Long(custRefEntry.PatNumCust) + ","
                + POut.Long(custRefEntry.PatNumRef) + ","
                + POut.Date(custRefEntry.DateEntry) + ","
                + "'" + POut.String(custRefEntry.Note) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                custRefEntry.CustRefEntryNum = Db.NonQ(command, true, "CustRefEntryNum", "custRefEntry");
            }
            return(custRefEntry.CustRefEntryNum);
        }
Пример #5
0
        ///<summary>Updates one CustRefEntry in the database.</summary>
        public static void Update(CustRefEntry custRefEntry)
        {
            string command = "UPDATE custrefentry SET "
                             + "PatNumCust     =  " + POut.Long(custRefEntry.PatNumCust) + ", "
                             + "PatNumRef      =  " + POut.Long(custRefEntry.PatNumRef) + ", "
                             + "DateEntry      =  " + POut.Date(custRefEntry.DateEntry) + ", "
                             + "Note           = '" + POut.String(custRefEntry.Note) + "' "
                             + "WHERE CustRefEntryNum = " + POut.Long(custRefEntry.CustRefEntryNum);

            Db.NonQ(command);
        }
Пример #6
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<CustRefEntry> TableToList(DataTable table){
			List<CustRefEntry> retVal=new List<CustRefEntry>();
			CustRefEntry custRefEntry;
			for(int i=0;i<table.Rows.Count;i++) {
				custRefEntry=new CustRefEntry();
				custRefEntry.CustRefEntryNum= PIn.Long  (table.Rows[i]["CustRefEntryNum"].ToString());
				custRefEntry.PatNumCust     = PIn.Long  (table.Rows[i]["PatNumCust"].ToString());
				custRefEntry.PatNumRef      = PIn.Long  (table.Rows[i]["PatNumRef"].ToString());
				custRefEntry.DateEntry      = PIn.Date  (table.Rows[i]["DateEntry"].ToString());
				custRefEntry.Note           = PIn.String(table.Rows[i]["Note"].ToString());
				retVal.Add(custRefEntry);
			}
			return retVal;
		}
Пример #7
0
 ///<summary>Inserts one CustRefEntry into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(CustRefEntry custRefEntry)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(custRefEntry, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             custRefEntry.CustRefEntryNum = DbHelper.GetNextOracleKey("custrefentry", "CustRefEntryNum");                  //Cacheless method
         }
         return(InsertNoCache(custRefEntry, true));
     }
 }
Пример #8
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <CustRefEntry> TableToList(DataTable table)
        {
            List <CustRefEntry> retVal = new List <CustRefEntry>();
            CustRefEntry        custRefEntry;

            foreach (DataRow row in table.Rows)
            {
                custRefEntry = new CustRefEntry();
                custRefEntry.CustRefEntryNum = PIn.Long(row["CustRefEntryNum"].ToString());
                custRefEntry.PatNumCust      = PIn.Long(row["PatNumCust"].ToString());
                custRefEntry.PatNumRef       = PIn.Long(row["PatNumRef"].ToString());
                custRefEntry.DateEntry       = PIn.Date(row["DateEntry"].ToString());
                custRefEntry.Note            = PIn.String(row["Note"].ToString());
                retVal.Add(custRefEntry);
            }
            return(retVal);
        }
Пример #9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <CustRefEntry> TableToList(DataTable table)
        {
            List <CustRefEntry> retVal = new List <CustRefEntry>();
            CustRefEntry        custRefEntry;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                custRefEntry = new CustRefEntry();
                custRefEntry.CustRefEntryNum = PIn.Long(table.Rows[i]["CustRefEntryNum"].ToString());
                custRefEntry.PatNumCust      = PIn.Long(table.Rows[i]["PatNumCust"].ToString());
                custRefEntry.PatNumRef       = PIn.Long(table.Rows[i]["PatNumRef"].ToString());
                custRefEntry.DateEntry       = PIn.Date(table.Rows[i]["DateEntry"].ToString());
                custRefEntry.Note            = PIn.String(table.Rows[i]["Note"].ToString());
                retVal.Add(custRefEntry);
            }
            return(retVal);
        }
Пример #10
0
        ///<summary>Updates one CustRefEntry 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(CustRefEntry custRefEntry, CustRefEntry oldCustRefEntry)
        {
            string command = "";

            if (custRefEntry.PatNumCust != oldCustRefEntry.PatNumCust)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNumCust = " + POut.Long(custRefEntry.PatNumCust) + "";
            }
            if (custRefEntry.PatNumRef != oldCustRefEntry.PatNumRef)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNumRef = " + POut.Long(custRefEntry.PatNumRef) + "";
            }
            if (custRefEntry.DateEntry.Date != oldCustRefEntry.DateEntry.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateEntry = " + POut.Date(custRefEntry.DateEntry) + "";
            }
            if (custRefEntry.Note != oldCustRefEntry.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = '" + POut.String(custRefEntry.Note) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE custrefentry SET " + command
                      + " WHERE CustRefEntryNum = " + POut.Long(custRefEntry.CustRefEntryNum);
            Db.NonQ(command);
            return(true);
        }
Пример #11
0
 ///<summary>Returns true if Update(CustRefEntry,CustRefEntry) 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(CustRefEntry custRefEntry, CustRefEntry oldCustRefEntry)
 {
     if (custRefEntry.PatNumCust != oldCustRefEntry.PatNumCust)
     {
         return(true);
     }
     if (custRefEntry.PatNumRef != oldCustRefEntry.PatNumRef)
     {
         return(true);
     }
     if (custRefEntry.DateEntry.Date != oldCustRefEntry.DateEntry.Date)
     {
         return(true);
     }
     if (custRefEntry.Note != oldCustRefEntry.Note)
     {
         return(true);
     }
     return(false);
 }
Пример #12
0
		///<summary>Inserts one CustRefEntry into the database.  Returns the new priKey.</summary>
		public static long Insert(CustRefEntry custRefEntry){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				custRefEntry.CustRefEntryNum=DbHelper.GetNextOracleKey("custrefentry","CustRefEntryNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(custRefEntry,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							custRefEntry.CustRefEntryNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(custRefEntry,false);
			}
		}
Пример #13
0
		///<summary>Updates one CustRefEntry 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>
		public static void Update(CustRefEntry custRefEntry,CustRefEntry oldCustRefEntry){
			string command="";
			if(custRefEntry.PatNumCust != oldCustRefEntry.PatNumCust) {
				if(command!=""){ command+=",";}
				command+="PatNumCust = "+POut.Long(custRefEntry.PatNumCust)+"";
			}
			if(custRefEntry.PatNumRef != oldCustRefEntry.PatNumRef) {
				if(command!=""){ command+=",";}
				command+="PatNumRef = "+POut.Long(custRefEntry.PatNumRef)+"";
			}
			if(custRefEntry.DateEntry != oldCustRefEntry.DateEntry) {
				if(command!=""){ command+=",";}
				command+="DateEntry = "+POut.Date(custRefEntry.DateEntry)+"";
			}
			if(custRefEntry.Note != oldCustRefEntry.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(custRefEntry.Note)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE custrefentry SET "+command
				+" WHERE CustRefEntryNum = "+POut.Long(custRefEntry.CustRefEntryNum);
			Db.NonQ(command);
		}
Пример #14
0
		///<summary>Updates one CustRefEntry in the database.</summary>
		public static void Update(CustRefEntry custRefEntry){
			string command="UPDATE custrefentry SET "
				+"PatNumCust     =  "+POut.Long  (custRefEntry.PatNumCust)+", "
				+"PatNumRef      =  "+POut.Long  (custRefEntry.PatNumRef)+", "
				+"DateEntry      =  "+POut.Date  (custRefEntry.DateEntry)+", "
				+"Note           = '"+POut.String(custRefEntry.Note)+"' "
				+"WHERE CustRefEntryNum = "+POut.Long(custRefEntry.CustRefEntryNum);
			Db.NonQ(command);
		}
Пример #15
0
 public FormReferenceEntryEdit(CustRefEntry refEntry)
 {
     InitializeComponent();
     Lan.F(this);
     CustRefEntryCur = refEntry;
 }
Пример #16
0
 ///<summary>Inserts one CustRefEntry into the database.  Returns the new priKey.</summary>
 public static long Insert(CustRefEntry custRefEntry)
 {
     return(Insert(custRefEntry, false));
 }