Exemplo n.º 1
0
        ///<summary>Inserts one LabTurnaround into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(LabTurnaround labTurnaround, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                labTurnaround.LabTurnaroundNum = ReplicationServers.GetKey("labturnaround", "LabTurnaroundNum");
            }
            string command = "INSERT INTO labturnaround (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "LabTurnaroundNum,";
            }
            command += "LaboratoryNum,Description,DaysPublished,DaysActual) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(labTurnaround.LabTurnaroundNum) + ",";
            }
            command +=
                POut.Long(labTurnaround.LaboratoryNum) + ","
                + "'" + POut.String(labTurnaround.Description) + "',"
                + POut.Int(labTurnaround.DaysPublished) + ","
                + POut.Int(labTurnaround.DaysActual) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                labTurnaround.LabTurnaroundNum = Db.NonQ(command, true, "LabTurnaroundNum", "labTurnaround");
            }
            return(labTurnaround.LabTurnaroundNum);
        }
Exemplo n.º 2
0
        ///<summary></summary>
        public static void Insert(LabTurnaround lab)
        {
            if (PrefB.RandomKeys)
            {
                lab.LabTurnaroundNum = MiscData.GetKey("labturnaround", "LabTurnaroundNum");
            }
            string command = "INSERT INTO labturnaround (";

            if (PrefB.RandomKeys)
            {
                command += "LabTurnaroundNum,";
            }
            command += "LaboratoryNum,Description,DaysPublished,DaysActual) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(lab.LabTurnaroundNum) + "', ";
            }
            command +=
                "'" + POut.PInt(lab.LaboratoryNum) + "', "
                + "'" + POut.PString(lab.Description) + "', "
                + "'" + POut.PInt(lab.DaysPublished) + "', "
                + "'" + POut.PInt(lab.DaysActual) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                lab.LabTurnaroundNum = General.NonQ(command, true);
            }
        }
Exemplo n.º 3
0
 ///<summary>Inserts one LabTurnaround into the database.  Returns the new priKey.</summary>
 public static long Insert(LabTurnaround labTurnaround)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         labTurnaround.LabTurnaroundNum = DbHelper.GetNextOracleKey("labturnaround", "LabTurnaroundNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(labTurnaround, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     labTurnaround.LabTurnaroundNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(labTurnaround, false));
     }
 }
Exemplo n.º 4
0
 ///<summary>Inserts one LabTurnaround into the database.  Returns the new priKey.</summary>
 internal static long Insert(LabTurnaround labTurnaround)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         labTurnaround.LabTurnaroundNum=DbHelper.GetNextOracleKey("labturnaround","LabTurnaroundNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(labTurnaround,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     labTurnaround.LabTurnaroundNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(labTurnaround,false);
     }
 }
Exemplo n.º 5
0
        ///<summary>Inserts one LabTurnaround into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(LabTurnaround labTurnaround, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO labturnaround (";

            if (!useExistingPK && isRandomKeys)
            {
                labTurnaround.LabTurnaroundNum = ReplicationServers.GetKeyNoCache("labturnaround", "LabTurnaroundNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "LabTurnaroundNum,";
            }
            command += "LaboratoryNum,Description,DaysPublished,DaysActual) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(labTurnaround.LabTurnaroundNum) + ",";
            }
            command +=
                POut.Long(labTurnaround.LaboratoryNum) + ","
                + "'" + POut.String(labTurnaround.Description) + "',"
                + POut.Int(labTurnaround.DaysPublished) + ","
                + POut.Int(labTurnaround.DaysActual) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                labTurnaround.LabTurnaroundNum = Db.NonQ(command, true, "LabTurnaroundNum", "labTurnaround");
            }
            return(labTurnaround.LabTurnaroundNum);
        }
Exemplo n.º 6
0
		///<summary>Inserts one LabTurnaround into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(LabTurnaround labTurnaround,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				labTurnaround.LabTurnaroundNum=ReplicationServers.GetKey("labturnaround","LabTurnaroundNum");
			}
			string command="INSERT INTO labturnaround (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="LabTurnaroundNum,";
			}
			command+="LaboratoryNum,Description,DaysPublished,DaysActual) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(labTurnaround.LabTurnaroundNum)+",";
			}
			command+=
				     POut.Long  (labTurnaround.LaboratoryNum)+","
				+"'"+POut.String(labTurnaround.Description)+"',"
				+    POut.Int   (labTurnaround.DaysPublished)+","
				+    POut.Int   (labTurnaround.DaysActual)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				labTurnaround.LabTurnaroundNum=Db.NonQ(command,true);
			}
			return labTurnaround.LabTurnaroundNum;
		}
Exemplo n.º 7
0
        ///<summary>Updates one LabTurnaround in the database.</summary>
        public static void Update(LabTurnaround labTurnaround)
        {
            string command = "UPDATE labturnaround SET "
                             + "LaboratoryNum   =  " + POut.Long(labTurnaround.LaboratoryNum) + ", "
                             + "Description     = '" + POut.String(labTurnaround.Description) + "', "
                             + "DaysPublished   =  " + POut.Int(labTurnaround.DaysPublished) + ", "
                             + "DaysActual      =  " + POut.Int(labTurnaround.DaysActual) + " "
                             + "WHERE LabTurnaroundNum = " + POut.Long(labTurnaround.LabTurnaroundNum);

            Db.NonQ(command);
        }
Exemplo n.º 8
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<LabTurnaround> TableToList(DataTable table){
			List<LabTurnaround> retVal=new List<LabTurnaround>();
			LabTurnaround labTurnaround;
			for(int i=0;i<table.Rows.Count;i++) {
				labTurnaround=new LabTurnaround();
				labTurnaround.LabTurnaroundNum= PIn.Long  (table.Rows[i]["LabTurnaroundNum"].ToString());
				labTurnaround.LaboratoryNum   = PIn.Long  (table.Rows[i]["LaboratoryNum"].ToString());
				labTurnaround.Description     = PIn.String(table.Rows[i]["Description"].ToString());
				labTurnaround.DaysPublished   = PIn.Int   (table.Rows[i]["DaysPublished"].ToString());
				labTurnaround.DaysActual      = PIn.Int   (table.Rows[i]["DaysActual"].ToString());
				retVal.Add(labTurnaround);
			}
			return retVal;
		}
Exemplo n.º 9
0
 ///<summary>Inserts one LabTurnaround into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(LabTurnaround labTurnaround)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(labTurnaround, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             labTurnaround.LabTurnaroundNum = DbHelper.GetNextOracleKey("labturnaround", "LabTurnaroundNum");                  //Cacheless method
         }
         return(InsertNoCache(labTurnaround, true));
     }
 }
Exemplo n.º 10
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <LabTurnaround> TableToList(DataTable table)
        {
            List <LabTurnaround> retVal = new List <LabTurnaround>();
            LabTurnaround        labTurnaround;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                labTurnaround = new LabTurnaround();
                labTurnaround.LabTurnaroundNum = PIn.Long(table.Rows[i]["LabTurnaroundNum"].ToString());
                labTurnaround.LaboratoryNum    = PIn.Long(table.Rows[i]["LaboratoryNum"].ToString());
                labTurnaround.Description      = PIn.String(table.Rows[i]["Description"].ToString());
                labTurnaround.DaysPublished    = PIn.Int(table.Rows[i]["DaysPublished"].ToString());
                labTurnaround.DaysActual       = PIn.Int(table.Rows[i]["DaysActual"].ToString());
                retVal.Add(labTurnaround);
            }
            return(retVal);
        }
Exemplo n.º 11
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <LabTurnaround> TableToList(DataTable table)
        {
            List <LabTurnaround> retVal = new List <LabTurnaround>();
            LabTurnaround        labTurnaround;

            foreach (DataRow row in table.Rows)
            {
                labTurnaround = new LabTurnaround();
                labTurnaround.LabTurnaroundNum = PIn.Long(row["LabTurnaroundNum"].ToString());
                labTurnaround.LaboratoryNum    = PIn.Long(row["LaboratoryNum"].ToString());
                labTurnaround.Description      = PIn.String(row["Description"].ToString());
                labTurnaround.DaysPublished    = PIn.Int(row["DaysPublished"].ToString());
                labTurnaround.DaysActual       = PIn.Int(row["DaysActual"].ToString());
                retVal.Add(labTurnaround);
            }
            return(retVal);
        }
Exemplo n.º 12
0
        ///<summary>Updates one LabTurnaround 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(LabTurnaround labTurnaround, LabTurnaround oldLabTurnaround)
        {
            string command = "";

            if (labTurnaround.LaboratoryNum != oldLabTurnaround.LaboratoryNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LaboratoryNum = " + POut.Long(labTurnaround.LaboratoryNum) + "";
            }
            if (labTurnaround.Description != oldLabTurnaround.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(labTurnaround.Description) + "'";
            }
            if (labTurnaround.DaysPublished != oldLabTurnaround.DaysPublished)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DaysPublished = " + POut.Int(labTurnaround.DaysPublished) + "";
            }
            if (labTurnaround.DaysActual != oldLabTurnaround.DaysActual)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DaysActual = " + POut.Int(labTurnaround.DaysActual) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE labturnaround SET " + command
                      + " WHERE LabTurnaroundNum = " + POut.Long(labTurnaround.LabTurnaroundNum);
            Db.NonQ(command);
            return(true);
        }
Exemplo n.º 13
0
        ///<summary></summary>
        public static List <LabTurnaround> GetForLab(int laboratoryNum)
        {
            string               command = "SELECT * FROM labturnaround WHERE LaboratoryNum=" + POut.PInt(laboratoryNum);
            DataTable            table   = General.GetTable(command);
            List <LabTurnaround> retVal  = new List <LabTurnaround>();
            LabTurnaround        lab;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                lab = new LabTurnaround();
                lab.LabTurnaroundNum = PIn.PInt(table.Rows[i][0].ToString());
                lab.LaboratoryNum    = PIn.PInt(table.Rows[i][1].ToString());
                lab.Description      = PIn.PString(table.Rows[i][2].ToString());
                lab.DaysPublished    = PIn.PInt(table.Rows[i][3].ToString());
                lab.DaysActual       = PIn.PInt(table.Rows[i][4].ToString());
                retVal.Add(lab);
            }
            return(retVal);
        }
Exemplo n.º 14
0
 ///<summary>Returns true if Update(LabTurnaround,LabTurnaround) 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(LabTurnaround labTurnaround, LabTurnaround oldLabTurnaround)
 {
     if (labTurnaround.LaboratoryNum != oldLabTurnaround.LaboratoryNum)
     {
         return(true);
     }
     if (labTurnaround.Description != oldLabTurnaround.Description)
     {
         return(true);
     }
     if (labTurnaround.DaysPublished != oldLabTurnaround.DaysPublished)
     {
         return(true);
     }
     if (labTurnaround.DaysActual != oldLabTurnaround.DaysActual)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 15
0
		///<summary>Updates one LabTurnaround 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(LabTurnaround labTurnaround,LabTurnaround oldLabTurnaround){
			string command="";
			if(labTurnaround.LaboratoryNum != oldLabTurnaround.LaboratoryNum) {
				if(command!=""){ command+=",";}
				command+="LaboratoryNum = "+POut.Long(labTurnaround.LaboratoryNum)+"";
			}
			if(labTurnaround.Description != oldLabTurnaround.Description) {
				if(command!=""){ command+=",";}
				command+="Description = '"+POut.String(labTurnaround.Description)+"'";
			}
			if(labTurnaround.DaysPublished != oldLabTurnaround.DaysPublished) {
				if(command!=""){ command+=",";}
				command+="DaysPublished = "+POut.Int(labTurnaround.DaysPublished)+"";
			}
			if(labTurnaround.DaysActual != oldLabTurnaround.DaysActual) {
				if(command!=""){ command+=",";}
				command+="DaysActual = "+POut.Int(labTurnaround.DaysActual)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE labturnaround SET "+command
				+" WHERE LabTurnaroundNum = "+POut.Long(labTurnaround.LabTurnaroundNum);
			Db.NonQ(command);
		}
Exemplo n.º 16
0
		///<summary>Updates one LabTurnaround in the database.</summary>
		public static void Update(LabTurnaround labTurnaround){
			string command="UPDATE labturnaround SET "
				+"LaboratoryNum   =  "+POut.Long  (labTurnaround.LaboratoryNum)+", "
				+"Description     = '"+POut.String(labTurnaround.Description)+"', "
				+"DaysPublished   =  "+POut.Int   (labTurnaround.DaysPublished)+", "
				+"DaysActual      =  "+POut.Int   (labTurnaround.DaysActual)+" "
				+"WHERE LabTurnaroundNum = "+POut.Long(labTurnaround.LabTurnaroundNum);
			Db.NonQ(command);
		}
Exemplo n.º 17
0
 ///<summary>Inserts one LabTurnaround into the database.  Returns the new priKey.</summary>
 public static long Insert(LabTurnaround labTurnaround)
 {
     return(Insert(labTurnaround, false));
 }