Example #1
0
        ///<summary>Inserts one AutoCode into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(AutoCode autoCode, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                autoCode.AutoCodeNum = ReplicationServers.GetKey("autocode", "AutoCodeNum");
            }
            string command = "INSERT INTO autocode (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "AutoCodeNum,";
            }
            command += "Description,IsHidden,LessIntrusive) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(autoCode.AutoCodeNum) + ",";
            }
            command +=
                "'" + POut.String(autoCode.Description) + "',"
                + POut.Bool(autoCode.IsHidden) + ","
                + POut.Bool(autoCode.LessIntrusive) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                autoCode.AutoCodeNum = Db.NonQ(command, true);
            }
            return(autoCode.AutoCodeNum);
        }
Example #2
0
        ///<summary></summary>
        public static void Refresh()
        {
            string    command = "SELECT * from autocode";
            DataTable table   = General.GetTable(command);

            HList = new Hashtable();
            List  = new AutoCode[table.Rows.Count];
            ArrayList ALshort = new ArrayList();          //int of indexes of short list

            for (int i = 0; i < List.Length; i++)
            {
                List[i]               = new AutoCode();
                List[i].AutoCodeNum   = PIn.PInt(table.Rows[i][0].ToString());
                List[i].Description   = PIn.PString(table.Rows[i][1].ToString());
                List[i].IsHidden      = PIn.PBool(table.Rows[i][2].ToString());
                List[i].LessIntrusive = PIn.PBool(table.Rows[i][3].ToString());
                HList.Add(List[i].AutoCodeNum, List[i]);
                if (!List[i].IsHidden)
                {
                    ALshort.Add(i);
                }
            }
            ListShort = new AutoCode[ALshort.Count];
            for (int i = 0; i < ALshort.Count; i++)
            {
                ListShort[i] = List[(int)ALshort[i]];
            }
        }
Example #3
0
 ///<summary>Inserts one AutoCode into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(AutoCode autoCode,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         autoCode.AutoCodeNum=ReplicationServers.GetKey("autocode","AutoCodeNum");
     }
     string command="INSERT INTO autocode (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="AutoCodeNum,";
     }
     command+="Description,IsHidden,LessIntrusive) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(autoCode.AutoCodeNum)+",";
     }
     command+=
          "'"+POut.String(autoCode.Description)+"',"
         +    POut.Bool  (autoCode.IsHidden)+","
         +    POut.Bool  (autoCode.LessIntrusive)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         autoCode.AutoCodeNum=Db.NonQ(command,true);
     }
     return autoCode.AutoCodeNum;
 }
Example #4
0
 ///<summary>Inserts one AutoCode into the database.  Returns the new priKey.</summary>
 internal static long Insert(AutoCode autoCode)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         autoCode.AutoCodeNum = DbHelper.GetNextOracleKey("autocode", "AutoCodeNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(autoCode, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     autoCode.AutoCodeNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(autoCode, false));
     }
 }
Example #5
0
 ///<summary>Inserts one AutoCode into the database.  Returns the new priKey.</summary>
 internal static long Insert(AutoCode autoCode)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         autoCode.AutoCodeNum=DbHelper.GetNextOracleKey("autocode","AutoCodeNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(autoCode,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     autoCode.AutoCodeNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(autoCode,false);
     }
 }
Example #6
0
        ///<summary>Inserts one AutoCode into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(AutoCode autoCode, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO autocode (";

            if (!useExistingPK && isRandomKeys)
            {
                autoCode.AutoCodeNum = ReplicationServers.GetKeyNoCache("autocode", "AutoCodeNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "AutoCodeNum,";
            }
            command += "Description,IsHidden,LessIntrusive) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(autoCode.AutoCodeNum) + ",";
            }
            command +=
                "'" + POut.String(autoCode.Description) + "',"
                + POut.Bool(autoCode.IsHidden) + ","
                + POut.Bool(autoCode.LessIntrusive) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                autoCode.AutoCodeNum = Db.NonQ(command, true, "AutoCodeNum", "autoCode");
            }
            return(autoCode.AutoCodeNum);
        }
Example #7
0
        ///<summary></summary>
        public static void Update(AutoCode Cur)
        {
            string command = "UPDATE autocode SET "
                             + "Description='" + POut.PString(Cur.Description) + "'"
                             + ",IsHidden = '" + POut.PBool(Cur.IsHidden) + "'"
                             + ",LessIntrusive = '" + POut.PBool(Cur.LessIntrusive) + "'"
                             + " WHERE autocodenum = '" + POut.PInt(Cur.AutoCodeNum) + "'";

            General.NonQ(command);
        }
Example #8
0
        ///<summary>Updates one AutoCode in the database.</summary>
        internal static void Update(AutoCode autoCode)
        {
            string command = "UPDATE autocode SET "
                             + "Description  = '" + POut.String(autoCode.Description) + "', "
                             + "IsHidden     =  " + POut.Bool(autoCode.IsHidden) + ", "
                             + "LessIntrusive=  " + POut.Bool(autoCode.LessIntrusive) + " "
                             + "WHERE AutoCodeNum = " + POut.Long(autoCode.AutoCodeNum);

            Db.NonQ(command);
        }
Example #9
0
        ///<summary></summary>
        public static void Insert(AutoCode Cur)
        {
            string command = "INSERT INTO autocode (Description,IsHidden,LessIntrusive) "
                             + "VALUES ("
                             + "'" + POut.PString(Cur.Description) + "', "
                             + "'" + POut.PBool(Cur.IsHidden) + "', "
                             + "'" + POut.PBool(Cur.LessIntrusive) + "')";

            //MessageBox.Show(string command);
            Cur.AutoCodeNum = General.NonQ(command, true);
        }
Example #10
0
        private void butDelete_Click(object sender, System.EventArgs e)
        {
            if (listAutoCodes.SelectedIndex < 0)
            {
                MessageBox.Show(Lan.g(this, "You must first select a row"));
                return;
            }
            AutoCode AutoCodeCur = AutoCodes.List[listAutoCodes.SelectedIndex];

            AutoCodes.Delete(AutoCodeCur);
            changed = true;
            FillList();
        }
Example #11
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<AutoCode> TableToList(DataTable table){
			List<AutoCode> retVal=new List<AutoCode>();
			AutoCode autoCode;
			for(int i=0;i<table.Rows.Count;i++) {
				autoCode=new AutoCode();
				autoCode.AutoCodeNum  = PIn.Long  (table.Rows[i]["AutoCodeNum"].ToString());
				autoCode.Description  = PIn.String(table.Rows[i]["Description"].ToString());
				autoCode.IsHidden     = PIn.Bool  (table.Rows[i]["IsHidden"].ToString());
				autoCode.LessIntrusive= PIn.Bool  (table.Rows[i]["LessIntrusive"].ToString());
				retVal.Add(autoCode);
			}
			return retVal;
		}
Example #12
0
 ///<summary>Inserts one AutoCode into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(AutoCode autoCode)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(autoCode, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             autoCode.AutoCodeNum = DbHelper.GetNextOracleKey("autocode", "AutoCodeNum");                  //Cacheless method
         }
         return(InsertNoCache(autoCode, true));
     }
 }
Example #13
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <AutoCode> TableToList(DataTable table)
        {
            List <AutoCode> retVal = new List <AutoCode>();
            AutoCode        autoCode;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                autoCode               = new AutoCode();
                autoCode.AutoCodeNum   = PIn.Long(table.Rows[i]["AutoCodeNum"].ToString());
                autoCode.Description   = PIn.String(table.Rows[i]["Description"].ToString());
                autoCode.IsHidden      = PIn.Bool(table.Rows[i]["IsHidden"].ToString());
                autoCode.LessIntrusive = PIn.Bool(table.Rows[i]["LessIntrusive"].ToString());
                retVal.Add(autoCode);
            }
            return(retVal);
        }
Example #14
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <AutoCode> TableToList(DataTable table)
        {
            List <AutoCode> retVal = new List <AutoCode>();
            AutoCode        autoCode;

            foreach (DataRow row in table.Rows)
            {
                autoCode               = new AutoCode();
                autoCode.AutoCodeNum   = PIn.Long(row["AutoCodeNum"].ToString());
                autoCode.Description   = PIn.String(row["Description"].ToString());
                autoCode.IsHidden      = PIn.Bool(row["IsHidden"].ToString());
                autoCode.LessIntrusive = PIn.Bool(row["LessIntrusive"].ToString());
                retVal.Add(autoCode);
            }
            return(retVal);
        }
Example #15
0
 ///<summary>Returns true if Update(AutoCode,AutoCode) 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(AutoCode autoCode, AutoCode oldAutoCode)
 {
     if (autoCode.Description != oldAutoCode.Description)
     {
         return(true);
     }
     if (autoCode.IsHidden != oldAutoCode.IsHidden)
     {
         return(true);
     }
     if (autoCode.LessIntrusive != oldAutoCode.LessIntrusive)
     {
         return(true);
     }
     return(false);
 }
Example #16
0
        private void listAutoCodes_DoubleClick(object sender, System.EventArgs e)
        {
            if (listAutoCodes.SelectedIndex == -1)
            {
                return;
            }
            AutoCode         AutoCodeCur = _listAutoCodes[listAutoCodes.SelectedIndex];
            FormAutoCodeEdit FormACE     = new FormAutoCodeEdit();

            FormACE.AutoCodeCur = AutoCodeCur;
            FormACE.ShowDialog();
            if (FormACE.DialogResult != DialogResult.OK)
            {
                return;
            }
            changed = true;
            FillList();
        }
Example #17
0
        private void butDelete_Click(object sender, System.EventArgs e)
        {
            if (listAutoCodes.SelectedIndex < 0)
            {
                MessageBox.Show(Lan.g(this, "You must first select a row"));
                return;
            }
            AutoCode autoCodeCur = _listAutoCodes[listAutoCodes.SelectedIndex];

            try {
                AutoCodes.Delete(autoCodeCur);
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            changed = true;
            FillList();
        }
Example #18
0
        ///<summary>Only called when closing the procedure edit window. Usually returns the supplied adaCode, unless a better match is found.</summary>
        public static string VerifyCode(string ADACode, string toothNum, string surf, bool isAdditional, int patNum, int age,
                                        out AutoCode AutoCodeCur)
        {
            bool allCondsMet;

            AutoCodeCur = null;
            if (!HList.ContainsKey(ADACode))
            {
                return(ADACode);
            }
            if (!AutoCodes.HList.ContainsKey((int)HList[ADACode]))
            {
                return(ADACode);               //just in case.
            }
            AutoCodeCur = (AutoCode)AutoCodes.HList[(int)HList[ADACode]];
            if (AutoCodeCur.LessIntrusive)
            {
                return(ADACode);
            }
            bool willBeMissing = Procedures.WillBeMissing(toothNum, patNum);

            //AutoCode verAutoCode=(AutoCode)HList[ADACode];
            GetListForCode((int)HList[ADACode]);
            for (int i = 0; i < ListForCode.Length; i++)
            {
                AutoCodeConds.GetListForItem(ListForCode[i].AutoCodeItemNum);
                allCondsMet = true;
                for (int j = 0; j < AutoCodeConds.ListForItem.Length; j++)
                {
                    if (!AutoCodeConds.ConditionIsMet
                            (AutoCodeConds.ListForItem[j].Cond, toothNum, surf, isAdditional, willBeMissing, age))
                    {
                        allCondsMet = false;
                    }
                }
                if (allCondsMet)
                {
                    return(ListForCode[i].ADACode);
                }
            }
            return(ADACode);           //if couldn't find a better match
        }
Example #19
0
        ///<summary>Updates one AutoCode 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(AutoCode autoCode, AutoCode oldAutoCode)
        {
            string command = "";

            if (autoCode.Description != oldAutoCode.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(autoCode.Description) + "'";
            }
            if (autoCode.IsHidden != oldAutoCode.IsHidden)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsHidden = " + POut.Bool(autoCode.IsHidden) + "";
            }
            if (autoCode.LessIntrusive != oldAutoCode.LessIntrusive)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LessIntrusive = " + POut.Bool(autoCode.LessIntrusive) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE autocode SET " + command
                      + " WHERE AutoCodeNum = " + POut.Long(autoCode.AutoCodeNum);
            Db.NonQ(command);
            return(true);
        }
Example #20
0
		///<summary>Updates one AutoCode 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(AutoCode autoCode,AutoCode oldAutoCode){
			string command="";
			if(autoCode.Description != oldAutoCode.Description) {
				if(command!=""){ command+=",";}
				command+="Description = '"+POut.String(autoCode.Description)+"'";
			}
			if(autoCode.IsHidden != oldAutoCode.IsHidden) {
				if(command!=""){ command+=",";}
				command+="IsHidden = "+POut.Bool(autoCode.IsHidden)+"";
			}
			if(autoCode.LessIntrusive != oldAutoCode.LessIntrusive) {
				if(command!=""){ command+=",";}
				command+="LessIntrusive = "+POut.Bool(autoCode.LessIntrusive)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE autocode SET "+command
				+" WHERE AutoCodeNum = "+POut.Long(autoCode.AutoCodeNum);
			Db.NonQ(command);
		}
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDescript.Text == "")
            {
                MessageBox.Show(Lan.g(this, "You must type in a description."));
                return;
            }
            if (listADA.Items.Count == 0 && listAutoCodes.SelectedIndices.Count == 0)
            {
                MessageBox.Show(Lan.g(this, "You must pick at least one Auto Code or Procedure Code."));
                return;
            }
            foreach (int index in listAutoCodes.SelectedIndices)
            {
                AutoCode autoCode = _listShortDeep[index];
                if (AutoCodeItems.GetListForCode(autoCode.AutoCodeNum).Count == 0)
                {
                    //This AutoCode was saved with no AutoCodeItems attached, which is invalid.
                    MessageBox.Show(this, Lan.g(this, "The following AutoCode has no associated Procedure Codes: ") + "\r\n" + autoCode.Description + "\r\n"
                                    + Lan.g(this, "AutoCode must be setup correctly before it can be used with a Quick Proc Button."));
                    return;
                }
            }
            //Point of no return.
            ProcButtonCur.Description = textDescript.Text;
            if (ProcButtonCur.Category != _listProcButtonCatDefs[comboCategory.SelectedIndex].DefNum)
            {
                //This will put it at the end of the order in the new category
                ProcButtonCur.ItemOrder
                    = ProcButtons.GetForCat(_listProcButtonCatDefs[comboCategory.SelectedIndex].DefNum).Length;
            }
            ProcButtonCur.Category     = _listProcButtonCatDefs[comboCategory.SelectedIndex].DefNum;
            ProcButtonCur.ButtonImage  = POut.Bitmap((Bitmap)pictureBox.Image, System.Drawing.Imaging.ImageFormat.Png);
            ProcButtonCur.IsMultiVisit = checkMultiVisit.Checked;
            if (IsNew)
            {
                ProcButtonCur.ItemOrder = ProcButtons.GetCount();
                ProcButtons.Insert(ProcButtonCur);
            }
            else
            {
                ProcButtons.Update(ProcButtonCur);
            }
            ProcButtonItems.DeleteAllForButton(ProcButtonCur.ProcButtonNum);
            ProcButtonItem item;

            for (int i = 0; i < listADA.Items.Count; i++)
            {
                item = new ProcButtonItem();
                item.ProcButtonNum = ProcButtonCur.ProcButtonNum;
                item.CodeNum       = ProcedureCodes.GetCodeNum(listADA.Items[i].ToString());
                item.ItemOrder     = i + 1;        //not i++, that would mess up the itteration.
                ProcButtonItems.Insert(item);
            }
            for (int i = 0; i < listAutoCodes.SelectedIndices.Count; i++)
            {
                item = new ProcButtonItem();
                item.ProcButtonNum = ProcButtonCur.ProcButtonNum;
                item.AutoCodeNum   = _listShortDeep[listAutoCodes.SelectedIndices[i]].AutoCodeNum;
                item.ItemOrder     = i + 1;        //not i++, that would mess up the itteration.
                ProcButtonItems.Insert(item);
            }
            DialogResult = DialogResult.OK;
        }
Example #22
0
        ///<summary>This could be improved since it does not delete any autocode items.</summary>
        public static void Delete(AutoCode Cur)
        {
            string command = "DELETE from autocode WHERE autocodenum = '" + POut.PInt(Cur.AutoCodeNum) + "'";

            General.NonQ(command);
        }
Example #23
0
 ///<summary>Inserts one AutoCode into the database.  Returns the new priKey.</summary>
 public static long Insert(AutoCode autoCode)
 {
     return(Insert(autoCode, false));
 }
        public void Update(string CodePrefix,string CodeFormat,DateTime LastCodeDate,DateTime? CreatedOn,DateTime? ModifiedOn,string ModifiedBy)
        {
            AutoCode item = new AutoCode();

                item.CodePrefix = CodePrefix;

                item.CodeFormat = CodeFormat;

                item.LastCodeDate = LastCodeDate;

                item.CreatedOn = CreatedOn;

                item.ModifiedOn = ModifiedOn;

                item.ModifiedBy = ModifiedBy;

            item.MarkOld();
            item.Save(UserName);
        }
Example #25
0
		///<summary>Updates one AutoCode in the database.</summary>
		public static void Update(AutoCode autoCode){
			string command="UPDATE autocode SET "
				+"Description  = '"+POut.String(autoCode.Description)+"', "
				+"IsHidden     =  "+POut.Bool  (autoCode.IsHidden)+", "
				+"LessIntrusive=  "+POut.Bool  (autoCode.LessIntrusive)+" "
				+"WHERE AutoCodeNum = "+POut.Long(autoCode.AutoCodeNum);
			Db.NonQ(command);
		}