コード例 #1
0
 ///<summary>Inserts one ApptFieldDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(ApptFieldDef apptFieldDef)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         apptFieldDef.ApptFieldDefNum = DbHelper.GetNextOracleKey("apptfielddef", "ApptFieldDefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(apptFieldDef, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     apptFieldDef.ApptFieldDefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(apptFieldDef, false));
     }
 }
コード例 #2
0
        ///<summary>Inserts one ApptFieldDef into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(ApptFieldDef apptFieldDef, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                apptFieldDef.ApptFieldDefNum = ReplicationServers.GetKey("apptfielddef", "ApptFieldDefNum");
            }
            string command = "INSERT INTO apptfielddef (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ApptFieldDefNum,";
            }
            command += "FieldName) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(apptFieldDef.ApptFieldDefNum) + ",";
            }
            command +=
                "'" + POut.String(apptFieldDef.FieldName) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                apptFieldDef.ApptFieldDefNum = Db.NonQ(command, true);
            }
            return(apptFieldDef.ApptFieldDefNum);
        }
コード例 #3
0
ファイル: ApptFieldDefCrud.cs プロジェクト: nampn/ODental
 ///<summary>Inserts one ApptFieldDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(ApptFieldDef apptFieldDef)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         apptFieldDef.ApptFieldDefNum=DbHelper.GetNextOracleKey("apptfielddef","ApptFieldDefNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(apptFieldDef,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     apptFieldDef.ApptFieldDefNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(apptFieldDef,false);
     }
 }
コード例 #4
0
        ///<summary>Updates one ApptFieldDef in the database.</summary>
        internal static void Update(ApptFieldDef apptFieldDef)
        {
            string command = "UPDATE apptfielddef SET "
                             + "FieldName      = '" + POut.String(apptFieldDef.FieldName) + "' "
                             + "WHERE ApptFieldDefNum = " + POut.Long(apptFieldDef.ApptFieldDefNum);

            Db.NonQ(command);
        }
コード例 #5
0
 ///<summary></summary>
 public FormApptFieldDefEdit(ApptFieldDef fieldDef)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     Lan.F(this);
     FieldDef = fieldDef;
 }
コード例 #6
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            ApptFieldDef         def   = new ApptFieldDef();
            FormApptFieldDefEdit FormP = new FormApptFieldDefEdit(def);

            FormP.IsNew = true;
            FormP.ShowDialog();
            FillGrid();
        }
コード例 #7
0
        ///<summary>Updates one ApptFieldDef in the database.</summary>
        public static void Update(ApptFieldDef apptFieldDef)
        {
            string command = "UPDATE apptfielddef SET "
                             + "FieldName      = '" + POut.String(apptFieldDef.FieldName) + "', "
                             + "FieldType      =  " + POut.Int((int)apptFieldDef.FieldType) + ", "
                             + "PickList       = '" + POut.String(apptFieldDef.PickList) + "' "
                             + "WHERE ApptFieldDefNum = " + POut.Long(apptFieldDef.ApptFieldDefNum);

            Db.NonQ(command);
        }
コード例 #8
0
ファイル: FormFieldDefLink.cs プロジェクト: royedwards/DRDNet
        ///<summary>Fills the hidden grid with all hidden field defs for the location selected.
        ///This should be enhanced in the future to include indication rows when there is a potential for one location to serve multiple types.</summary>
        private void FillGridHidden()
        {
            int selectedIdx = gridHidden.GetSelectedIndex();

            gridHidden.BeginUpdate();
            gridHidden.Columns.Clear();
            gridHidden.Columns.Add(new ODGridColumn("", 0));
            gridHidden.Rows.Clear();
            ODGridRow           row;
            List <FieldDefLink> listFieldDefLinksForLoc = _listFieldDefLinks.FindAll(x => x.FieldLocation == (FieldLocations)comboFieldLocation.SelectedIndex);
            List <FieldDefLink> listLinksToDelete       = new List <FieldDefLink>();  //Some links could exists to deleted FieldDefs prior to 18.1

            foreach (FieldDefLink fieldDefLink in listFieldDefLinksForLoc)
            {
                switch (fieldDefLink.FieldDefType)
                {
                case FieldDefTypes.Patient:
                    PatFieldDef patFieldDef = _listPatFieldDefs.Find(x => x.PatFieldDefNum == fieldDefLink.FieldDefNum);
                    if (patFieldDef == null)                           //orphanded FK link to deleted PatFieldDef
                    {
                        listLinksToDelete.Add(fieldDefLink);           //orphanded FK link to deleted PatFieldDef
                        continue;
                    }
                    row = new ODGridRow();
                    row.Cells.Add(patFieldDef.FieldName);
                    row.Tag = fieldDefLink;
                    gridHidden.Rows.Add(row);
                    break;

                case FieldDefTypes.Appointment:
                    ApptFieldDef apptFieldDef = _listApptFieldDefs.Find(x => x.ApptFieldDefNum == fieldDefLink.FieldDefNum);
                    if (apptFieldDef == null)                           //orphaned FK link to deleted ApptFieldDef
                    {
                        listLinksToDelete.Add(fieldDefLink);            //orphaned FK link to deleted ApptFieldDef
                        continue;
                    }
                    row = new ODGridRow();
                    row.Cells.Add(apptFieldDef.FieldName);
                    row.Tag = fieldDefLink;
                    gridHidden.Rows.Add(row);
                    break;
                }
            }
            //Remove all orphaned links
            foreach (FieldDefLink fieldDefLink in listLinksToDelete)
            {
                _listFieldDefLinks.Remove(fieldDefLink);
            }
            gridHidden.EndUpdate();
            if (gridHidden.Rows.Count - 1 >= selectedIdx)
            {
                gridHidden.SetSelected(selectedIdx, true);
            }
        }
コード例 #9
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ApptFieldDef> TableToList(DataTable table){
			List<ApptFieldDef> retVal=new List<ApptFieldDef>();
			ApptFieldDef apptFieldDef;
			for(int i=0;i<table.Rows.Count;i++) {
				apptFieldDef=new ApptFieldDef();
				apptFieldDef.ApptFieldDefNum= PIn.Long  (table.Rows[i]["ApptFieldDefNum"].ToString());
				apptFieldDef.FieldName      = PIn.String(table.Rows[i]["FieldName"].ToString());
				apptFieldDef.FieldType      = (ApptFieldType)PIn.Int(table.Rows[i]["FieldType"].ToString());
				apptFieldDef.PickList       = PIn.String(table.Rows[i]["PickList"].ToString());
				retVal.Add(apptFieldDef);
			}
			return retVal;
		}
コード例 #10
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <ApptFieldDef> TableToList(DataTable table)
        {
            List <ApptFieldDef> retVal = new List <ApptFieldDef>();
            ApptFieldDef        apptFieldDef;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                apptFieldDef = new ApptFieldDef();
                apptFieldDef.ApptFieldDefNum = PIn.Long(table.Rows[i]["ApptFieldDefNum"].ToString());
                apptFieldDef.FieldName       = PIn.String(table.Rows[i]["FieldName"].ToString());
                retVal.Add(apptFieldDef);
            }
            return(retVal);
        }
コード例 #11
0
 ///<summary>Inserts one ApptFieldDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ApptFieldDef apptFieldDef)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(apptFieldDef, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             apptFieldDef.ApptFieldDefNum = DbHelper.GetNextOracleKey("apptfielddef", "ApptFieldDefNum");                  //Cacheless method
         }
         return(InsertNoCache(apptFieldDef, true));
     }
 }
コード例 #12
0
 ///<summary>Returns true if Update(ApptFieldDef,ApptFieldDef) 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(ApptFieldDef apptFieldDef, ApptFieldDef oldApptFieldDef)
 {
     if (apptFieldDef.FieldName != oldApptFieldDef.FieldName)
     {
         return(true);
     }
     if (apptFieldDef.FieldType != oldApptFieldDef.FieldType)
     {
         return(true);
     }
     if (apptFieldDef.PickList != oldApptFieldDef.PickList)
     {
         return(true);
     }
     return(false);
 }
コード例 #13
0
        ///<summary>Updates one ApptFieldDef in the database.</summary>
        public static void Update(ApptFieldDef apptFieldDef)
        {
            string command = "UPDATE apptfielddef SET "
                             + "FieldName      = '" + POut.String(apptFieldDef.FieldName) + "', "
                             + "FieldType      =  " + POut.Int((int)apptFieldDef.FieldType) + ", "
                             + "PickList       =  " + DbHelper.ParamChar + "paramPickList "
                             + "WHERE ApptFieldDefNum = " + POut.Long(apptFieldDef.ApptFieldDefNum);

            if (apptFieldDef.PickList == null)
            {
                apptFieldDef.PickList = "";
            }
            OdSqlParameter paramPickList = new OdSqlParameter("paramPickList", OdDbType.Text, POut.StringParam(apptFieldDef.PickList));

            Db.NonQ(command, paramPickList);
        }
コード例 #14
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ApptFieldDef> TableToList(DataTable table)
        {
            List <ApptFieldDef> retVal = new List <ApptFieldDef>();
            ApptFieldDef        apptFieldDef;

            foreach (DataRow row in table.Rows)
            {
                apptFieldDef = new ApptFieldDef();
                apptFieldDef.ApptFieldDefNum = PIn.Long(row["ApptFieldDefNum"].ToString());
                apptFieldDef.FieldName       = PIn.String(row["FieldName"].ToString());
                apptFieldDef.FieldType       = (OpenDentBusiness.ApptFieldType)PIn.Int(row["FieldType"].ToString());
                apptFieldDef.PickList        = PIn.String(row["PickList"].ToString());
                retVal.Add(apptFieldDef);
            }
            return(retVal);
        }
コード例 #15
0
        ///<summary>Updates one ApptFieldDef 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(ApptFieldDef apptFieldDef, ApptFieldDef oldApptFieldDef)
        {
            string command = "";

            if (apptFieldDef.FieldName != oldApptFieldDef.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(apptFieldDef.FieldName) + "'";
            }
            if (apptFieldDef.FieldType != oldApptFieldDef.FieldType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldType = " + POut.Int((int)apptFieldDef.FieldType) + "";
            }
            if (apptFieldDef.PickList != oldApptFieldDef.PickList)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PickList = " + DbHelper.ParamChar + "paramPickList";
            }
            if (command == "")
            {
                return(false);
            }
            if (apptFieldDef.PickList == null)
            {
                apptFieldDef.PickList = "";
            }
            OdSqlParameter paramPickList = new OdSqlParameter("paramPickList", OdDbType.Text, POut.StringParam(apptFieldDef.PickList));

            command = "UPDATE apptfielddef SET " + command
                      + " WHERE ApptFieldDefNum = " + POut.Long(apptFieldDef.ApptFieldDefNum);
            Db.NonQ(command, paramPickList);
            return(true);
        }
コード例 #16
0
        ///<summary>Updates one ApptFieldDef 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>
        internal static void Update(ApptFieldDef apptFieldDef, ApptFieldDef oldApptFieldDef)
        {
            string command = "";

            if (apptFieldDef.FieldName != oldApptFieldDef.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(apptFieldDef.FieldName) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE apptfielddef SET " + command
                      + " WHERE ApptFieldDefNum = " + POut.Long(apptFieldDef.ApptFieldDefNum);
            Db.NonQ(command);
        }
コード例 #17
0
        ///<summary>Inserts one ApptFieldDef into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ApptFieldDef apptFieldDef, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO apptfielddef (";

            if (!useExistingPK && isRandomKeys)
            {
                apptFieldDef.ApptFieldDefNum = ReplicationServers.GetKeyNoCache("apptfielddef", "ApptFieldDefNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ApptFieldDefNum,";
            }
            command += "FieldName,FieldType,PickList) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(apptFieldDef.ApptFieldDefNum) + ",";
            }
            command +=
                "'" + POut.String(apptFieldDef.FieldName) + "',"
                + POut.Int((int)apptFieldDef.FieldType) + ","
                + DbHelper.ParamChar + "paramPickList)";
            if (apptFieldDef.PickList == null)
            {
                apptFieldDef.PickList = "";
            }
            OdSqlParameter paramPickList = new OdSqlParameter("paramPickList", OdDbType.Text, POut.StringParam(apptFieldDef.PickList));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramPickList);
            }
            else
            {
                apptFieldDef.ApptFieldDefNum = Db.NonQ(command, true, "ApptFieldDefNum", "apptFieldDef", paramPickList);
            }
            return(apptFieldDef.ApptFieldDefNum);
        }
コード例 #18
0
ファイル: ApptFieldDefCrud.cs プロジェクト: nampn/ODental
 ///<summary>Inserts one ApptFieldDef into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(ApptFieldDef apptFieldDef,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         apptFieldDef.ApptFieldDefNum=ReplicationServers.GetKey("apptfielddef","ApptFieldDefNum");
     }
     string command="INSERT INTO apptfielddef (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="ApptFieldDefNum,";
     }
     command+="FieldName) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(apptFieldDef.ApptFieldDefNum)+",";
     }
     command+=
          "'"+POut.String(apptFieldDef.FieldName)+"')";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         apptFieldDef.ApptFieldDefNum=Db.NonQ(command,true);
     }
     return apptFieldDef.ApptFieldDefNum;
 }
コード例 #19
0
        ///<summary>Updates one ApptFieldDef 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(ApptFieldDef apptFieldDef, ApptFieldDef oldApptFieldDef)
        {
            string command = "";

            if (apptFieldDef.FieldName != oldApptFieldDef.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(apptFieldDef.FieldName) + "'";
            }
            if (apptFieldDef.FieldType != oldApptFieldDef.FieldType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldType = " + POut.Int((int)apptFieldDef.FieldType) + "";
            }
            if (apptFieldDef.PickList != oldApptFieldDef.PickList)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PickList = '" + POut.String(apptFieldDef.PickList) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE apptfielddef SET " + command
                      + " WHERE ApptFieldDefNum = " + POut.Long(apptFieldDef.ApptFieldDefNum);
            Db.NonQ(command);
        }
コード例 #20
0
ファイル: FormFieldDefLink.cs プロジェクト: royedwards/DRDNet
        private void butRight_Click(object sender, EventArgs e)
        {
            //Add the selected field def from the display grid to the _listFieldDefLinks as a new link.  Refill grid.
            if (gridDisplayed.GetSelectedIndex() < 0)
            {
                return;                //Button pressed with nothing selected
            }
            FieldDefLink fieldDefLink = new FieldDefLink();

            switch ((FieldLocations)comboFieldLocation.SelectedIndex)
            {
            case FieldLocations.Account:
            case FieldLocations.Chart:
            case FieldLocations.Family:
            case FieldLocations.GroupNote:
            case FieldLocations.OrthoChart:
                PatFieldDef patFieldDef = (PatFieldDef)gridDisplayed.Rows[gridDisplayed.GetSelectedIndex()].Tag;
                fieldDefLink               = new FieldDefLink();
                fieldDefLink.FieldDefNum   = patFieldDef.PatFieldDefNum;
                fieldDefLink.FieldDefType  = FieldDefTypes.Patient;
                fieldDefLink.FieldLocation = (FieldLocations)comboFieldLocation.SelectedIndex;
                _listFieldDefLinks.Add(fieldDefLink);
                break;

            case FieldLocations.AppointmentEdit:                    //AppointmentEdit is the only place where ApptFields are used.
                ApptFieldDef apptFieldDef = (ApptFieldDef)gridDisplayed.Rows[gridDisplayed.GetSelectedIndex()].Tag;
                fieldDefLink               = new FieldDefLink();
                fieldDefLink.FieldDefNum   = apptFieldDef.ApptFieldDefNum;
                fieldDefLink.FieldDefType  = FieldDefTypes.Appointment;
                fieldDefLink.FieldLocation = (FieldLocations)comboFieldLocation.SelectedIndex;
                _listFieldDefLinks.Add(fieldDefLink);
                break;
            }
            FillGridDisplayed();
            FillGridHidden();
        }
コード例 #21
0
ファイル: ApptFieldDefCrud.cs プロジェクト: nampn/ODental
 ///<summary>Updates one ApptFieldDef 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>
 internal static void Update(ApptFieldDef apptFieldDef,ApptFieldDef oldApptFieldDef)
 {
     string command="";
     if(apptFieldDef.FieldName != oldApptFieldDef.FieldName) {
         if(command!=""){ command+=",";}
         command+="FieldName = '"+POut.String(apptFieldDef.FieldName)+"'";
     }
     if(command==""){
         return;
     }
     command="UPDATE apptfielddef SET "+command
         +" WHERE ApptFieldDefNum = "+POut.Long(apptFieldDef.ApptFieldDefNum);
     Db.NonQ(command);
 }
コード例 #22
0
ファイル: ApptFieldDefCrud.cs プロジェクト: nampn/ODental
 ///<summary>Updates one ApptFieldDef in the database.</summary>
 internal static void Update(ApptFieldDef apptFieldDef)
 {
     string command="UPDATE apptfielddef SET "
         +"FieldName      = '"+POut.String(apptFieldDef.FieldName)+"' "
         +"WHERE ApptFieldDefNum = "+POut.Long(apptFieldDef.ApptFieldDefNum);
     Db.NonQ(command);
 }
コード例 #23
0
		///<summary>Updates one ApptFieldDef 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(ApptFieldDef apptFieldDef,ApptFieldDef oldApptFieldDef){
			string command="";
			if(apptFieldDef.FieldName != oldApptFieldDef.FieldName) {
				if(command!=""){ command+=",";}
				command+="FieldName = '"+POut.String(apptFieldDef.FieldName)+"'";
			}
			if(apptFieldDef.FieldType != oldApptFieldDef.FieldType) {
				if(command!=""){ command+=",";}
				command+="FieldType = "+POut.Int   ((int)apptFieldDef.FieldType)+"";
			}
			if(apptFieldDef.PickList != oldApptFieldDef.PickList) {
				if(command!=""){ command+=",";}
				command+="PickList = '"+POut.String(apptFieldDef.PickList)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE apptfielddef SET "+command
				+" WHERE ApptFieldDefNum = "+POut.Long(apptFieldDef.ApptFieldDefNum);
			Db.NonQ(command);
		}
コード例 #24
0
		///<summary>Updates one ApptFieldDef in the database.</summary>
		public static void Update(ApptFieldDef apptFieldDef){
			string command="UPDATE apptfielddef SET "
				+"FieldName      = '"+POut.String(apptFieldDef.FieldName)+"', "
				+"FieldType      =  "+POut.Int   ((int)apptFieldDef.FieldType)+", "
				+"PickList       = '"+POut.String(apptFieldDef.PickList)+"' "
				+"WHERE ApptFieldDefNum = "+POut.Long(apptFieldDef.ApptFieldDefNum);
			Db.NonQ(command);
		}
コード例 #25
0
 ///<summary>Inserts one ApptFieldDef into the database.  Returns the new priKey.</summary>
 public static long Insert(ApptFieldDef apptFieldDef)
 {
     return(Insert(apptFieldDef, false));
 }