Example #1
0
        ///<summary>Inserts one AppointmentRule into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(AppointmentRule appointmentRule, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO appointmentrule (";

            if (!useExistingPK && isRandomKeys)
            {
                appointmentRule.AppointmentRuleNum = ReplicationServers.GetKeyNoCache("appointmentrule", "AppointmentRuleNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "AppointmentRuleNum,";
            }
            command += "RuleDesc,CodeStart,CodeEnd,IsEnabled) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(appointmentRule.AppointmentRuleNum) + ",";
            }
            command +=
                "'" + POut.String(appointmentRule.RuleDesc) + "',"
                + "'" + POut.String(appointmentRule.CodeStart) + "',"
                + "'" + POut.String(appointmentRule.CodeEnd) + "',"
                + POut.Bool(appointmentRule.IsEnabled) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                appointmentRule.AppointmentRuleNum = Db.NonQ(command, true, "AppointmentRuleNum", "appointmentRule");
            }
            return(appointmentRule.AppointmentRuleNum);
        }
Example #2
0
		///<summary>Inserts one AppointmentRule into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(AppointmentRule appointmentRule,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				appointmentRule.AppointmentRuleNum=ReplicationServers.GetKey("appointmentrule","AppointmentRuleNum");
			}
			string command="INSERT INTO appointmentrule (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="AppointmentRuleNum,";
			}
			command+="RuleDesc,CodeStart,CodeEnd,IsEnabled) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(appointmentRule.AppointmentRuleNum)+",";
			}
			command+=
				 "'"+POut.String(appointmentRule.RuleDesc)+"',"
				+"'"+POut.String(appointmentRule.CodeStart)+"',"
				+"'"+POut.String(appointmentRule.CodeEnd)+"',"
				+    POut.Bool  (appointmentRule.IsEnabled)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				appointmentRule.AppointmentRuleNum=Db.NonQ(command,true);
			}
			return appointmentRule.AppointmentRuleNum;
		}
Example #3
0
        ///<summary>Inserts one AppointmentRule into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(AppointmentRule appointmentRule, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                appointmentRule.AppointmentRuleNum = ReplicationServers.GetKey("appointmentrule", "AppointmentRuleNum");
            }
            string command = "INSERT INTO appointmentrule (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "AppointmentRuleNum,";
            }
            command += "RuleDesc,CodeStart,CodeEnd,IsEnabled) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(appointmentRule.AppointmentRuleNum) + ",";
            }
            command +=
                "'" + POut.String(appointmentRule.RuleDesc) + "',"
                + "'" + POut.String(appointmentRule.CodeStart) + "',"
                + "'" + POut.String(appointmentRule.CodeEnd) + "',"
                + POut.Bool(appointmentRule.IsEnabled) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                appointmentRule.AppointmentRuleNum = Db.NonQ(command, true);
            }
            return(appointmentRule.AppointmentRuleNum);
        }
Example #4
0
 ///<summary>Inserts one AppointmentRule into the database.  Returns the new priKey.</summary>
 internal static long Insert(AppointmentRule appointmentRule)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         appointmentRule.AppointmentRuleNum = DbHelper.GetNextOracleKey("appointmentrule", "AppointmentRuleNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(appointmentRule, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     appointmentRule.AppointmentRuleNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(appointmentRule, false));
     }
 }
Example #5
0
 ///<summary>Inserts one AppointmentRule into the database.  Returns the new priKey.</summary>
 internal static long Insert(AppointmentRule appointmentRule)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         appointmentRule.AppointmentRuleNum=DbHelper.GetNextOracleKey("appointmentrule","AppointmentRuleNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(appointmentRule,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     appointmentRule.AppointmentRuleNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(appointmentRule,false);
     }
 }
        ///<summary></summary>
        public static void Delete(AppointmentRule rule)
        {
            string command = "DELETE FROM appointmentrule"
                             + " WHERE AppointmentRuleNum = " + POut.PInt(rule.AppointmentRuleNum);

            General.NonQ(command);
        }
Example #7
0
		///<summary></summary>
		public static void Insert(AppointmentRule rule){
			string command= "INSERT INTO appointmentrule (RuleDesc,ADACodeStart,ADACodeEnd,IsEnabled) VALUES("
				+"'"+POut.PString(rule.RuleDesc)+"', "
				+"'"+POut.PString(rule.ADACodeStart)+"', "
				+"'"+POut.PString(rule.ADACodeEnd)+"', "
				+"'"+POut.PBool  (rule.IsEnabled)+"')";
 			rule.AppointmentRuleNum=General.NonQ(command,true);
		}
Example #8
0
		///<summary></summary>
		public static void Update(AppointmentRule rule){
			string command= "UPDATE appointmentrule SET " 
				+ "RuleDesc = '"      +POut.PString(rule.RuleDesc)+"'"
				+ ",ADACodeStart = '" +POut.PString(rule.ADACodeStart)+"'"
				+ ",ADACodeEnd = '"   +POut.PString(rule.ADACodeEnd)+"'"
				+ ",IsEnabled = '"    +POut.PBool  (rule.IsEnabled)+"'"
				+" WHERE AppointmentRuleNum = '" +POut.PInt   (rule.AppointmentRuleNum)+"'";
 			General.NonQ(command);
		}
Example #9
0
 ///<summary></summary>
 public FormApptRuleEdit(AppointmentRule apptRuleCur)
 {
     //
     // Required for Windows Form Designer support
     //
     ApptRuleCur = apptRuleCur.Clone();
     InitializeComponent();
     Lan.F(this);
 }
Example #10
0
        ///<summary>Updates one AppointmentRule in the database.</summary>
        internal static void Update(AppointmentRule appointmentRule)
        {
            string command = "UPDATE appointmentrule SET "
                             + "RuleDesc          = '" + POut.String(appointmentRule.RuleDesc) + "', "
                             + "CodeStart         = '" + POut.String(appointmentRule.CodeStart) + "', "
                             + "CodeEnd           = '" + POut.String(appointmentRule.CodeEnd) + "', "
                             + "IsEnabled         =  " + POut.Bool(appointmentRule.IsEnabled) + " "
                             + "WHERE AppointmentRuleNum = " + POut.Long(appointmentRule.AppointmentRuleNum);

            Db.NonQ(command);
        }
Example #11
0
		///<summary>Fills List with all AppointmentRules.</summary>
		public static void Refresh() {
			string command="SELECT * FROM appointmentrule";
			DataTable table=General.GetTable(command);
			List=new AppointmentRule[table.Rows.Count];
			for(int i=0;i<table.Rows.Count;i++) {
				List[i]=new AppointmentRule();
				List[i].AppointmentRuleNum = PIn.PInt(table.Rows[i][0].ToString());
				List[i].RuleDesc           = PIn.PString(table.Rows[i][1].ToString());
				List[i].ADACodeStart       = PIn.PString(table.Rows[i][2].ToString());
				List[i].ADACodeEnd         = PIn.PString(table.Rows[i][3].ToString());
				List[i].IsEnabled          = PIn.PBool(table.Rows[i][4].ToString());
			}
		}
Example #12
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<AppointmentRule> TableToList(DataTable table){
			List<AppointmentRule> retVal=new List<AppointmentRule>();
			AppointmentRule appointmentRule;
			for(int i=0;i<table.Rows.Count;i++) {
				appointmentRule=new AppointmentRule();
				appointmentRule.AppointmentRuleNum= PIn.Long  (table.Rows[i]["AppointmentRuleNum"].ToString());
				appointmentRule.RuleDesc          = PIn.String(table.Rows[i]["RuleDesc"].ToString());
				appointmentRule.CodeStart         = PIn.String(table.Rows[i]["CodeStart"].ToString());
				appointmentRule.CodeEnd           = PIn.String(table.Rows[i]["CodeEnd"].ToString());
				appointmentRule.IsEnabled         = PIn.Bool  (table.Rows[i]["IsEnabled"].ToString());
				retVal.Add(appointmentRule);
			}
			return retVal;
		}
Example #13
0
        ///<summary></summary>
        public static AppointmentRule CreateAppointmentRule(string desc, string codeStart, string codeEnd)
        {
            AppointmentRule apptRule = new AppointmentRule()
            {
                RuleDesc  = desc,
                CodeStart = codeStart,
                CodeEnd   = codeEnd,
                IsEnabled = true
            };

            AppointmentRules.Insert(apptRule);
            AppointmentRules.RefreshCache();
            return(apptRule);
        }
Example #14
0
 ///<summary>Inserts one AppointmentRule into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(AppointmentRule appointmentRule)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(appointmentRule, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             appointmentRule.AppointmentRuleNum = DbHelper.GetNextOracleKey("appointmentrule", "AppointmentRuleNum");                  //Cacheless method
         }
         return(InsertNoCache(appointmentRule, true));
     }
 }
Example #15
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            AppointmentRule aptRule = new AppointmentRule();

            aptRule.IsEnabled = true;
            FormApptRuleEdit FormA = new FormApptRuleEdit(aptRule);

            FormA.IsNew = true;
            FormA.ShowDialog();
            if (FormA.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            FillGrid();
            changed = true;
        }
Example #16
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <AppointmentRule> TableToList(DataTable table)
        {
            List <AppointmentRule> retVal = new List <AppointmentRule>();
            AppointmentRule        appointmentRule;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                appointmentRule = new AppointmentRule();
                appointmentRule.AppointmentRuleNum = PIn.Long(table.Rows[i]["AppointmentRuleNum"].ToString());
                appointmentRule.RuleDesc           = PIn.String(table.Rows[i]["RuleDesc"].ToString());
                appointmentRule.CodeStart          = PIn.String(table.Rows[i]["CodeStart"].ToString());
                appointmentRule.CodeEnd            = PIn.String(table.Rows[i]["CodeEnd"].ToString());
                appointmentRule.IsEnabled          = PIn.Bool(table.Rows[i]["IsEnabled"].ToString());
                retVal.Add(appointmentRule);
            }
            return(retVal);
        }
Example #17
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <AppointmentRule> TableToList(DataTable table)
        {
            List <AppointmentRule> retVal = new List <AppointmentRule>();
            AppointmentRule        appointmentRule;

            foreach (DataRow row in table.Rows)
            {
                appointmentRule = new AppointmentRule();
                appointmentRule.AppointmentRuleNum = PIn.Long(row["AppointmentRuleNum"].ToString());
                appointmentRule.RuleDesc           = PIn.String(row["RuleDesc"].ToString());
                appointmentRule.CodeStart          = PIn.String(row["CodeStart"].ToString());
                appointmentRule.CodeEnd            = PIn.String(row["CodeEnd"].ToString());
                appointmentRule.IsEnabled          = PIn.Bool(row["IsEnabled"].ToString());
                retVal.Add(appointmentRule);
            }
            return(retVal);
        }
Example #18
0
        ///<summary>Updates one AppointmentRule 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(AppointmentRule appointmentRule, AppointmentRule oldAppointmentRule)
        {
            string command = "";

            if (appointmentRule.RuleDesc != oldAppointmentRule.RuleDesc)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RuleDesc = '" + POut.String(appointmentRule.RuleDesc) + "'";
            }
            if (appointmentRule.CodeStart != oldAppointmentRule.CodeStart)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeStart = '" + POut.String(appointmentRule.CodeStart) + "'";
            }
            if (appointmentRule.CodeEnd != oldAppointmentRule.CodeEnd)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeEnd = '" + POut.String(appointmentRule.CodeEnd) + "'";
            }
            if (appointmentRule.IsEnabled != oldAppointmentRule.IsEnabled)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsEnabled = " + POut.Bool(appointmentRule.IsEnabled) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE appointmentrule SET " + command
                      + " WHERE AppointmentRuleNum = " + POut.Long(appointmentRule.AppointmentRuleNum);
            Db.NonQ(command);
            return(true);
        }
Example #19
0
 ///<summary>Returns true if Update(AppointmentRule,AppointmentRule) 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(AppointmentRule appointmentRule, AppointmentRule oldAppointmentRule)
 {
     if (appointmentRule.RuleDesc != oldAppointmentRule.RuleDesc)
     {
         return(true);
     }
     if (appointmentRule.CodeStart != oldAppointmentRule.CodeStart)
     {
         return(true);
     }
     if (appointmentRule.CodeEnd != oldAppointmentRule.CodeEnd)
     {
         return(true);
     }
     if (appointmentRule.IsEnabled != oldAppointmentRule.IsEnabled)
     {
         return(true);
     }
     return(false);
 }
Example #20
0
 ///<summary>Inserts one AppointmentRule into the database.  Returns the new priKey.</summary>
 public static long Insert(AppointmentRule appointmentRule)
 {
     return(Insert(appointmentRule, false));
 }
Example #21
0
		///<summary>Updates one AppointmentRule in the database.</summary>
		public static void Update(AppointmentRule appointmentRule){
			string command="UPDATE appointmentrule SET "
				+"RuleDesc          = '"+POut.String(appointmentRule.RuleDesc)+"', "
				+"CodeStart         = '"+POut.String(appointmentRule.CodeStart)+"', "
				+"CodeEnd           = '"+POut.String(appointmentRule.CodeEnd)+"', "
				+"IsEnabled         =  "+POut.Bool  (appointmentRule.IsEnabled)+" "
				+"WHERE AppointmentRuleNum = "+POut.Long(appointmentRule.AppointmentRuleNum);
			Db.NonQ(command);
		}
Example #22
0
		///<summary>Updates one AppointmentRule 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(AppointmentRule appointmentRule,AppointmentRule oldAppointmentRule){
			string command="";
			if(appointmentRule.RuleDesc != oldAppointmentRule.RuleDesc) {
				if(command!=""){ command+=",";}
				command+="RuleDesc = '"+POut.String(appointmentRule.RuleDesc)+"'";
			}
			if(appointmentRule.CodeStart != oldAppointmentRule.CodeStart) {
				if(command!=""){ command+=",";}
				command+="CodeStart = '"+POut.String(appointmentRule.CodeStart)+"'";
			}
			if(appointmentRule.CodeEnd != oldAppointmentRule.CodeEnd) {
				if(command!=""){ command+=",";}
				command+="CodeEnd = '"+POut.String(appointmentRule.CodeEnd)+"'";
			}
			if(appointmentRule.IsEnabled != oldAppointmentRule.IsEnabled) {
				if(command!=""){ command+=",";}
				command+="IsEnabled = "+POut.Bool(appointmentRule.IsEnabled)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE appointmentrule SET "+command
				+" WHERE AppointmentRuleNum = "+POut.Long(appointmentRule.AppointmentRuleNum);
			Db.NonQ(command);
			return true;
		}