Пример #1
0
        ///<summary>Inserts one ScreenPat into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ScreenPat screenPat, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO screenpat (";

            if (!useExistingPK && isRandomKeys)
            {
                screenPat.ScreenPatNum = ReplicationServers.GetKeyNoCache("screenpat", "ScreenPatNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ScreenPatNum,";
            }
            command += "PatNum,ScreenGroupNum,SheetNum,PatScreenPerm) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(screenPat.ScreenPatNum) + ",";
            }
            command +=
                POut.Long(screenPat.PatNum) + ","
                + POut.Long(screenPat.ScreenGroupNum) + ","
                + POut.Long(screenPat.SheetNum) + ","
                + POut.Int((int)screenPat.PatScreenPerm) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                screenPat.ScreenPatNum = Db.NonQ(command, true, "ScreenPatNum", "screenPat");
            }
            return(screenPat.ScreenPatNum);
        }
Пример #2
0
        ///<summary>Inserts one ScreenPat into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(ScreenPat screenPat, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                screenPat.ScreenPatNum = ReplicationServers.GetKey("screenpat", "ScreenPatNum");
            }
            string command = "INSERT INTO screenpat (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ScreenPatNum,";
            }
            command += "PatNum,ScreenGroupNum,SheetNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(screenPat.ScreenPatNum) + ",";
            }
            command +=
                POut.Long(screenPat.PatNum) + ","
                + POut.Long(screenPat.ScreenGroupNum) + ","
                + POut.Long(screenPat.SheetNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                screenPat.ScreenPatNum = Db.NonQ(command, true);
            }
            return(screenPat.ScreenPatNum);
        }
Пример #3
0
 ///<summary>Inserts one ScreenPat into the database.  Returns the new priKey.</summary>
 public static long Insert(ScreenPat screenPat)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         screenPat.ScreenPatNum = DbHelper.GetNextOracleKey("screenpat", "ScreenPatNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(screenPat, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     screenPat.ScreenPatNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(screenPat, false));
     }
 }
Пример #4
0
        ///<summary>Updates one ScreenPat in the database.</summary>
        public static void Update(ScreenPat screenPat)
        {
            string command = "UPDATE screenpat SET "
                             + "PatNum        =  " + POut.Long(screenPat.PatNum) + ", "
                             + "ScreenGroupNum=  " + POut.Long(screenPat.ScreenGroupNum) + ", "
                             + "SheetNum      =  " + POut.Long(screenPat.SheetNum) + " "
                             + "WHERE ScreenPatNum = " + POut.Long(screenPat.ScreenPatNum);

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

            for (int i = 0; i < table.Rows.Count; i++)
            {
                screenPat = new ScreenPat();
                screenPat.ScreenPatNum   = PIn.Long(table.Rows[i]["ScreenPatNum"].ToString());
                screenPat.PatNum         = PIn.Long(table.Rows[i]["PatNum"].ToString());
                screenPat.ScreenGroupNum = PIn.Long(table.Rows[i]["ScreenGroupNum"].ToString());
                screenPat.SheetNum       = PIn.Long(table.Rows[i]["SheetNum"].ToString());
                retVal.Add(screenPat);
            }
            return(retVal);
        }
Пример #8
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ScreenPat> TableToList(DataTable table)
        {
            List <ScreenPat> retVal = new List <ScreenPat>();
            ScreenPat        screenPat;

            foreach (DataRow row in table.Rows)
            {
                screenPat = new ScreenPat();
                screenPat.ScreenPatNum   = PIn.Long(row["ScreenPatNum"].ToString());
                screenPat.PatNum         = PIn.Long(row["PatNum"].ToString());
                screenPat.ScreenGroupNum = PIn.Long(row["ScreenGroupNum"].ToString());
                screenPat.SheetNum       = PIn.Long(row["SheetNum"].ToString());
                screenPat.PatScreenPerm  = (OpenDentBusiness.PatScreenPerm)PIn.Int(row["PatScreenPerm"].ToString());
                retVal.Add(screenPat);
            }
            return(retVal);
        }
Пример #9
0
        ///<summary>Updates one ScreenPat 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(ScreenPat screenPat, ScreenPat oldScreenPat)
        {
            string command = "";

            if (screenPat.PatNum != oldScreenPat.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(screenPat.PatNum) + "";
            }
            if (screenPat.ScreenGroupNum != oldScreenPat.ScreenGroupNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ScreenGroupNum = " + POut.Long(screenPat.ScreenGroupNum) + "";
            }
            if (screenPat.SheetNum != oldScreenPat.SheetNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SheetNum = " + POut.Long(screenPat.SheetNum) + "";
            }
            if (screenPat.PatScreenPerm != oldScreenPat.PatScreenPerm)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatScreenPerm = " + POut.Int((int)screenPat.PatScreenPerm) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE screenpat SET " + command
                      + " WHERE ScreenPatNum = " + POut.Long(screenPat.ScreenPatNum);
            Db.NonQ(command);
            return(true);
        }
Пример #10
0
 ///<summary>Returns true if Update(ScreenPat,ScreenPat) 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(ScreenPat screenPat, ScreenPat oldScreenPat)
 {
     if (screenPat.PatNum != oldScreenPat.PatNum)
     {
         return(true);
     }
     if (screenPat.ScreenGroupNum != oldScreenPat.ScreenGroupNum)
     {
         return(true);
     }
     if (screenPat.SheetNum != oldScreenPat.SheetNum)
     {
         return(true);
     }
     if (screenPat.PatScreenPerm != oldScreenPat.PatScreenPerm)
     {
         return(true);
     }
     return(false);
 }
Пример #11
0
        ///<summary>Updates one ScreenPat 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(ScreenPat screenPat, ScreenPat oldScreenPat)
        {
            string command = "";

            if (screenPat.PatNum != oldScreenPat.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(screenPat.PatNum) + "";
            }
            if (screenPat.ScreenGroupNum != oldScreenPat.ScreenGroupNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ScreenGroupNum = " + POut.Long(screenPat.ScreenGroupNum) + "";
            }
            if (screenPat.SheetNum != oldScreenPat.SheetNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SheetNum = " + POut.Long(screenPat.SheetNum) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE screenpat SET " + command
                      + " WHERE ScreenPatNum = " + POut.Long(screenPat.ScreenPatNum);
            Db.NonQ(command);
        }
Пример #12
0
		///<summary>Inserts one ScreenPat into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(ScreenPat screenPat,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				screenPat.ScreenPatNum=ReplicationServers.GetKey("screenpat","ScreenPatNum");
			}
			string command="INSERT INTO screenpat (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="ScreenPatNum,";
			}
			command+="PatNum,ScreenGroupNum,SheetNum) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(screenPat.ScreenPatNum)+",";
			}
			command+=
				     POut.Long  (screenPat.PatNum)+","
				+    POut.Long  (screenPat.ScreenGroupNum)+","
				+    POut.Long  (screenPat.SheetNum)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				screenPat.ScreenPatNum=Db.NonQ(command,true);
			}
			return screenPat.ScreenPatNum;
		}
Пример #13
0
		///<summary>Inserts one ScreenPat into the database.  Returns the new priKey.</summary>
		public static long Insert(ScreenPat screenPat){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				screenPat.ScreenPatNum=DbHelper.GetNextOracleKey("screenpat","ScreenPatNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(screenPat,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							screenPat.ScreenPatNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(screenPat,false);
			}
		}
Пример #14
0
 ///<summary>Inserts one ScreenPat into the database.  Returns the new priKey.</summary>
 public static long Insert(ScreenPat screenPat)
 {
     return(Insert(screenPat, false));
 }
Пример #15
0
		///<summary>Updates one ScreenPat in the database.</summary>
		public static void Update(ScreenPat screenPat){
			string command="UPDATE screenpat SET "
				+"PatNum        =  "+POut.Long  (screenPat.PatNum)+", "
				+"ScreenGroupNum=  "+POut.Long  (screenPat.ScreenGroupNum)+", "
				+"SheetNum      =  "+POut.Long  (screenPat.SheetNum)+" "
				+"WHERE ScreenPatNum = "+POut.Long(screenPat.ScreenPatNum);
			Db.NonQ(command);
		}
Пример #16
0
		///<summary>Updates one ScreenPat 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(ScreenPat screenPat,ScreenPat oldScreenPat){
			string command="";
			if(screenPat.PatNum != oldScreenPat.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(screenPat.PatNum)+"";
			}
			if(screenPat.ScreenGroupNum != oldScreenPat.ScreenGroupNum) {
				if(command!=""){ command+=",";}
				command+="ScreenGroupNum = "+POut.Long(screenPat.ScreenGroupNum)+"";
			}
			if(screenPat.SheetNum != oldScreenPat.SheetNum) {
				if(command!=""){ command+=",";}
				command+="SheetNum = "+POut.Long(screenPat.SheetNum)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE screenpat SET "+command
				+" WHERE ScreenPatNum = "+POut.Long(screenPat.ScreenPatNum);
			Db.NonQ(command);
		}
Пример #17
0
 private void butAdd_Click(object sender, System.EventArgs e)
 {
     if (PrefC.GetBool(PrefName.PublicHealthScreeningUsePat))
     {
         /*
          * FormScreenPatEdit FormSPE=new FormScreenPatEdit();
          * FormSPE.IsNew=true;
          * while(true) {
          *      FormSPE.ScreenPatCur=new ScreenPat();
          *      FormSPE.ScreenPatCur.ScreenGroupNum=ScreenGroupCur.ScreenGroupNum;
          *      FormSPE.ScreenPatCur.SheetNum=PrefC.GetLong(PrefName.PublicHealthScreeningSheet);
          *      FormSPE.ScreenGroupCur=ScreenGroupCur;
          *      FormSPE.ScreenGroupCur.Description=textDescription.Text;
          *      FormSPE.ShowDialog();
          *      if(FormSPE.DialogResult!=DialogResult.OK) {
          *              return;
          *      }
          *      FillGridScreenPat();
          * }
          */
         FormScreenPatEdit FormSPE = new FormScreenPatEdit();
         while (true)
         {
             FormPatientSelect FormPS = new FormPatientSelect();
             FormPS.ShowDialog();
             if (FormPS.DialogResult != DialogResult.OK)
             {
                 return;
             }
             ScreenPat screenPat = new ScreenPat();
             screenPat.ScreenGroupNum = ScreenGroupCur.ScreenGroupNum;
             screenPat.SheetNum       = PrefC.GetLong(PrefName.PublicHealthScreeningSheet);
             screenPat.PatNum         = FormPS.SelectedPatNum;
             ScreenPats.Insert(screenPat);
             if (FormPS.DialogResult != DialogResult.OK)
             {
                 return;
             }
             FillGridScreenPat();
         }
     }
     else
     {
         FormScreenEdit FormSE = new FormScreenEdit();
         FormSE.ScreenGroupCur = ScreenGroupCur;
         FormSE.IsNew          = true;
         if (ScreenList.Length == 0)
         {
             FormSE.ScreenCur = new OpenDentBusiness.Screen();
             FormSE.ScreenCur.ScreenGroupOrder = 1;
         }
         else
         {
             FormSE.ScreenCur = ScreenList[ScreenList.Length - 1];                      //'remembers' the last entry
             FormSE.ScreenCur.ScreenGroupOrder = FormSE.ScreenCur.ScreenGroupOrder + 1; //increments for next
         }
         while (true)
         {
             FormSE.ShowDialog();
             if (FormSE.DialogResult != DialogResult.OK)
             {
                 return;
             }
             FormSE.ScreenCur.ScreenGroupOrder++;
             FillGrid();
         }
     }
 }