Example #1
0
 ///<summary>Inserts one ScheduleOp into the database.  Returns the new priKey.</summary>
 public static long Insert(ScheduleOp scheduleOp)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         scheduleOp.ScheduleOpNum = DbHelper.GetNextOracleKey("scheduleop", "ScheduleOpNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(scheduleOp, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     scheduleOp.ScheduleOpNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(scheduleOp, false));
     }
 }
Example #2
0
 ///<summary>Inserts one ScheduleOp into the database.  Returns the new priKey.</summary>
 internal static long Insert(ScheduleOp scheduleOp)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         scheduleOp.ScheduleOpNum=DbHelper.GetNextOracleKey("scheduleop","ScheduleOpNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(scheduleOp,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     scheduleOp.ScheduleOpNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(scheduleOp,false);
     }
 }
Example #3
0
        ///<summary></summary>
        public static Schedule CreateSchedule(DateTime schedDate, TimeSpan startTime, TimeSpan stopTime, ScheduleType schedType = ScheduleType.Practice
                                              , SchedStatus status = SchedStatus.Open, long blockoutType = 0, long clinicNum = 0, long employeNum = 0, long provNum = 0, List <long> listOpNums = null)
        {
            Schedule schedule = new Schedule();

            schedule.BlockoutType = blockoutType;
            schedule.ClinicNum    = clinicNum;
            schedule.EmployeeNum  = employeNum;
            schedule.ProvNum      = provNum;
            schedule.SchedDate    = schedDate;
            schedule.SchedType    = schedType;
            schedule.StartTime    = startTime;
            schedule.Status       = status;
            schedule.StopTime     = stopTime;
            Schedules.Insert(schedule, false);
            if (listOpNums != null)
            {
                schedule.Ops = listOpNums;
                foreach (long opNum in listOpNums)
                {
                    ScheduleOp schedOp = new ScheduleOp();
                    schedOp.OperatoryNum = opNum;
                    schedOp.ScheduleNum  = schedule.ScheduleNum;
                    ScheduleOps.Insert(schedOp);
                }
            }
            return(schedule);
        }
Example #4
0
        ///<summary>Updates one ScheduleOp 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(ScheduleOp scheduleOp, ScheduleOp oldScheduleOp)
        {
            string command = "";

            if (scheduleOp.ScheduleNum != oldScheduleOp.ScheduleNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ScheduleNum = " + POut.Long(scheduleOp.ScheduleNum) + "";
            }
            if (scheduleOp.OperatoryNum != oldScheduleOp.OperatoryNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OperatoryNum = " + POut.Long(scheduleOp.OperatoryNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE scheduleop SET " + command
                      + " WHERE ScheduleOpNum = " + POut.Long(scheduleOp.ScheduleOpNum);
            Db.NonQ(command);
            return(true);
        }
Example #5
0
        ///<summary>Inserts one ScheduleOp into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ScheduleOp scheduleOp, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO scheduleop (";

            if (!useExistingPK && isRandomKeys)
            {
                scheduleOp.ScheduleOpNum = ReplicationServers.GetKeyNoCache("scheduleop", "ScheduleOpNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ScheduleOpNum,";
            }
            command += "ScheduleNum,OperatoryNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(scheduleOp.ScheduleOpNum) + ",";
            }
            command +=
                POut.Long(scheduleOp.ScheduleNum) + ","
                + POut.Long(scheduleOp.OperatoryNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                scheduleOp.ScheduleOpNum = Db.NonQ(command, true, "ScheduleOpNum", "scheduleOp");
            }
            return(scheduleOp.ScheduleOpNum);
        }
Example #6
0
        ///<summary>Inserts one ScheduleOp into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(ScheduleOp scheduleOp, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                scheduleOp.ScheduleOpNum = ReplicationServers.GetKey("scheduleop", "ScheduleOpNum");
            }
            string command = "INSERT INTO scheduleop (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ScheduleOpNum,";
            }
            command += "ScheduleNum,OperatoryNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(scheduleOp.ScheduleOpNum) + ",";
            }
            command +=
                POut.Long(scheduleOp.ScheduleNum) + ","
                + POut.Long(scheduleOp.OperatoryNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                scheduleOp.ScheduleOpNum = Db.NonQ(command, true, "ScheduleOpNum", "scheduleOp");
            }
            return(scheduleOp.ScheduleOpNum);
        }
Example #7
0
        ///<summary></summary>
        public static ScheduleOp CreateScheduleOp(long operatoryNum, long scheduleNum)
        {
            ScheduleOp schedOp = new ScheduleOp();

            schedOp.OperatoryNum = operatoryNum;
            schedOp.ScheduleNum  = scheduleNum;
            ScheduleOps.Insert(schedOp);
            return(schedOp);
        }
Example #8
0
        ///<summary>Updates one ScheduleOp in the database.</summary>
        public static void Update(ScheduleOp scheduleOp)
        {
            string command = "UPDATE scheduleop SET "
                             + "ScheduleNum  =  " + POut.Long(scheduleOp.ScheduleNum) + ", "
                             + "OperatoryNum =  " + POut.Long(scheduleOp.OperatoryNum) + " "
                             + "WHERE ScheduleOpNum = " + POut.Long(scheduleOp.ScheduleOpNum);

            Db.NonQ(command);
        }
Example #9
0
 ///<summary>Returns true if Update(ScheduleOp,ScheduleOp) 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(ScheduleOp scheduleOp, ScheduleOp oldScheduleOp)
 {
     if (scheduleOp.ScheduleNum != oldScheduleOp.ScheduleNum)
     {
         return(true);
     }
     if (scheduleOp.OperatoryNum != oldScheduleOp.OperatoryNum)
     {
         return(true);
     }
     return(false);
 }
Example #10
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ScheduleOp> TableToList(DataTable table){
			List<ScheduleOp> retVal=new List<ScheduleOp>();
			ScheduleOp scheduleOp;
			for(int i=0;i<table.Rows.Count;i++) {
				scheduleOp=new ScheduleOp();
				scheduleOp.ScheduleOpNum= PIn.Long  (table.Rows[i]["ScheduleOpNum"].ToString());
				scheduleOp.ScheduleNum  = PIn.Long  (table.Rows[i]["ScheduleNum"].ToString());
				scheduleOp.OperatoryNum = PIn.Long  (table.Rows[i]["OperatoryNum"].ToString());
				retVal.Add(scheduleOp);
			}
			return retVal;
		}
Example #11
0
 ///<summary>Inserts many ScheduleOps into the database.  Provides option to use the existing priKey.</summary>
 public static void InsertMany(List <ScheduleOp> listScheduleOps)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle || PrefC.RandomKeys)
     {
         foreach (ScheduleOp scheduleOp in listScheduleOps)
         {
             Insert(scheduleOp);
         }
     }
     else
     {
         StringBuilder sbCommands = null;
         int           index      = 0;
         while (index < listScheduleOps.Count)
         {
             ScheduleOp    scheduleOp = listScheduleOps[index];
             StringBuilder sbRow      = new StringBuilder("(");
             bool          hasComma   = false;
             if (sbCommands == null)
             {
                 sbCommands = new StringBuilder();
                 sbCommands.Append("INSERT INTO scheduleop (");
                 sbCommands.Append("ScheduleNum,OperatoryNum) VALUES ");
             }
             else
             {
                 hasComma = true;
             }
             sbRow.Append(POut.Long(scheduleOp.ScheduleNum)); sbRow.Append(",");
             sbRow.Append(POut.Long(scheduleOp.OperatoryNum)); sbRow.Append(")");
             if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount)
             {
                 Db.NonQ(sbCommands.ToString());
                 sbCommands = null;
             }
             else
             {
                 if (hasComma)
                 {
                     sbCommands.Append(",");
                 }
                 sbCommands.Append(sbRow.ToString());
                 if (index == listScheduleOps.Count - 1)
                 {
                     Db.NonQ(sbCommands.ToString());
                 }
                 index++;
             }
         }
     }
 }
Example #12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ScheduleOp> TableToList(DataTable table)
        {
            List <ScheduleOp> retVal = new List <ScheduleOp>();
            ScheduleOp        scheduleOp;

            foreach (DataRow row in table.Rows)
            {
                scheduleOp = new ScheduleOp();
                scheduleOp.ScheduleOpNum = PIn.Long(row["ScheduleOpNum"].ToString());
                scheduleOp.ScheduleNum   = PIn.Long(row["ScheduleNum"].ToString());
                scheduleOp.OperatoryNum  = PIn.Long(row["OperatoryNum"].ToString());
                retVal.Add(scheduleOp);
            }
            return(retVal);
        }
Example #13
0
 ///<summary>Inserts one ScheduleOp into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ScheduleOp scheduleOp)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(scheduleOp, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             scheduleOp.ScheduleOpNum = DbHelper.GetNextOracleKey("scheduleop", "ScheduleOpNum");                  //Cacheless method
         }
         return(InsertNoCache(scheduleOp, true));
     }
 }
Example #14
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <ScheduleOp> TableToList(DataTable table)
        {
            List <ScheduleOp> retVal = new List <ScheduleOp>();
            ScheduleOp        scheduleOp;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                scheduleOp = new ScheduleOp();
                scheduleOp.ScheduleOpNum = PIn.Long(table.Rows[i]["ScheduleOpNum"].ToString());
                scheduleOp.ScheduleNum   = PIn.Long(table.Rows[i]["ScheduleNum"].ToString());
                scheduleOp.OperatoryNum  = PIn.Long(table.Rows[i]["OperatoryNum"].ToString());
                retVal.Add(scheduleOp);
            }
            return(retVal);
        }
Example #15
0
		///<summary>Inserts one ScheduleOp into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(ScheduleOp scheduleOp,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				scheduleOp.ScheduleOpNum=ReplicationServers.GetKey("scheduleop","ScheduleOpNum");
			}
			string command="INSERT INTO scheduleop (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="ScheduleOpNum,";
			}
			command+="ScheduleNum,OperatoryNum) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(scheduleOp.ScheduleOpNum)+",";
			}
			command+=
				     POut.Long  (scheduleOp.ScheduleNum)+","
				+    POut.Long  (scheduleOp.OperatoryNum)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				scheduleOp.ScheduleOpNum=Db.NonQ(command,true);
			}
			return scheduleOp.ScheduleOpNum;
		}
Example #16
0
		///<summary>Updates one ScheduleOp 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(ScheduleOp scheduleOp,ScheduleOp oldScheduleOp){
			string command="";
			if(scheduleOp.ScheduleNum != oldScheduleOp.ScheduleNum) {
				if(command!=""){ command+=",";}
				command+="ScheduleNum = "+POut.Long(scheduleOp.ScheduleNum)+"";
			}
			if(scheduleOp.OperatoryNum != oldScheduleOp.OperatoryNum) {
				if(command!=""){ command+=",";}
				command+="OperatoryNum = "+POut.Long(scheduleOp.OperatoryNum)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE scheduleop SET "+command
				+" WHERE ScheduleOpNum = "+POut.Long(scheduleOp.ScheduleOpNum);
			Db.NonQ(command);
			return true;
		}
Example #17
0
		///<summary>Updates one ScheduleOp in the database.</summary>
		public static void Update(ScheduleOp scheduleOp){
			string command="UPDATE scheduleop SET "
				+"ScheduleNum  =  "+POut.Long  (scheduleOp.ScheduleNum)+", "
				+"OperatoryNum =  "+POut.Long  (scheduleOp.OperatoryNum)+" "
				+"WHERE ScheduleOpNum = "+POut.Long(scheduleOp.ScheduleOpNum);
			Db.NonQ(command);
		}
Example #18
0
 ///<summary>Inserts one ScheduleOp into the database.  Returns the new priKey.</summary>
 public static long Insert(ScheduleOp scheduleOp)
 {
     return(Insert(scheduleOp, false));
 }