Exemplo n.º 1
0
 ///<summary>Inserts one PatFieldDef into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(PatFieldDef patFieldDef,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         patFieldDef.PatFieldDefNum=ReplicationServers.GetKey("patfielddef","PatFieldDefNum");
     }
     string command="INSERT INTO patfielddef (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="PatFieldDefNum,";
     }
     command+="FieldName,FieldType,PickList) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(patFieldDef.PatFieldDefNum)+",";
     }
     command+=
          "'"+POut.String(patFieldDef.FieldName)+"',"
         +    POut.Int   ((int)patFieldDef.FieldType)+","
         +"'"+POut.String(patFieldDef.PickList)+"')";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         patFieldDef.PatFieldDefNum=Db.NonQ(command,true);
     }
     return patFieldDef.PatFieldDefNum;
 }
Exemplo n.º 2
0
 ///<summary>Inserts one PatFieldDef into the database.  Returns the new priKey.</summary>
 public static long Insert(PatFieldDef patFieldDef)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         patFieldDef.PatFieldDefNum = DbHelper.GetNextOracleKey("patfielddef", "PatFieldDefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(patFieldDef, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     patFieldDef.PatFieldDefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(patFieldDef, false));
     }
 }
Exemplo n.º 3
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            if (_isSelectionMode)
            {
                SelectedPatFieldDef = _listPatFieldDefs[e.Row];
                DialogResult        = DialogResult.OK;
                return;
            }
            FormPatFieldDefEdit FormPFDE = new FormPatFieldDefEdit();

            FormPFDE.FieldDef = _listPatFieldDefs[e.Row];
            FormPFDE.ShowDialog();
            if (FormPFDE.DialogResult == DialogResult.OK)
            {
                if (FormPFDE.FieldDef == null)
                {
                    _listPatFieldDefs.Remove(_listPatFieldDefs[e.Row]);
                }
                else
                {
                    _listPatFieldDefs[e.Row] = FormPFDE.FieldDef;
                }
                _hasChanged = true;
                FillGrid();
            }
        }
Exemplo n.º 4
0
 ///<summary>Inserts one PatFieldDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(PatFieldDef patFieldDef)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         patFieldDef.PatFieldDefNum=DbHelper.GetNextOracleKey("patfielddef","PatFieldDefNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(patFieldDef,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     patFieldDef.PatFieldDefNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(patFieldDef,false);
     }
 }
Exemplo n.º 5
0
        ///<summary></summary>
        public static void Insert(PatFieldDef p)
        {
            string command = "INSERT INTO patfielddef (FieldName) VALUES("
                             + "'" + POut.PString(p.FieldName) + "')";

            p.PatFieldDefNum = General.NonQ(command, true);
        }
Exemplo n.º 6
0
        ///<summary>Inserts one PatFieldDef into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(PatFieldDef patFieldDef, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                patFieldDef.PatFieldDefNum = ReplicationServers.GetKey("patfielddef", "PatFieldDefNum");
            }
            string command = "INSERT INTO patfielddef (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "PatFieldDefNum,";
            }
            command += "FieldName,FieldType,PickList) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(patFieldDef.PatFieldDefNum) + ",";
            }
            command +=
                "'" + POut.String(patFieldDef.FieldName) + "',"
                + POut.Int((int)patFieldDef.FieldType) + ","
                + "'" + POut.String(patFieldDef.PickList) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                patFieldDef.PatFieldDefNum = Db.NonQ(command, true);
            }
            return(patFieldDef.PatFieldDefNum);
        }
Exemplo n.º 7
0
        ///<summary>Updates one PatFieldDef 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(PatFieldDef patFieldDef, PatFieldDef oldPatFieldDef)
        {
            string command = "";

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

            command = "UPDATE patfielddef SET " + command
                      + " WHERE PatFieldDefNum = " + POut.Long(patFieldDef.PatFieldDefNum);
            Db.NonQ(command, paramPickList);
            return(true);
        }
Exemplo n.º 8
0
 ///<summary></summary>
 public FormPatFieldDefEdit(PatFieldDef fieldDef)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     Lan.F(this);
     FieldDef = fieldDef;
 }
Exemplo n.º 9
0
        ///<summary>Updates one PatFieldDef in the database.</summary>
        internal static void Update(PatFieldDef patFieldDef)
        {
            string command = "UPDATE patfielddef SET "
                             + "FieldName     = '" + POut.String(patFieldDef.FieldName) + "', "
                             + "FieldType     =  " + POut.Int((int)patFieldDef.FieldType) + ", "
                             + "PickList      = '" + POut.String(patFieldDef.PickList) + "' "
                             + "WHERE PatFieldDefNum = " + POut.Long(patFieldDef.PatFieldDefNum);

            Db.NonQ(command);
        }
Exemplo n.º 10
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            //Employers.Cur=new Employer();
            PatFieldDef         def   = new PatFieldDef();
            FormPatFieldDefEdit FormP = new FormPatFieldDefEdit(def);

            FormP.IsNew = true;
            FormP.ShowDialog();
            FillGrid();
        }
Exemplo n.º 11
0
        ///<summary>Must supply the old field name so that the patient lists can be updated.</summary>
        public static void Update(PatFieldDef p, string oldFieldName)
        {
            string command = "UPDATE patfielddef SET "
                             + "FieldName = '" + POut.PString(p.FieldName) + "'"
                             + " WHERE PatFieldDefNum  ='" + POut.PInt(p.PatFieldDefNum) + "'";

            General.NonQ(command);
            command = "UPDATE patfield SET FieldName='" + POut.PString(p.FieldName) + "'"
                      + " WHERE FieldName='" + POut.PString(oldFieldName) + "'";
            General.NonQ(command);
        }
Exemplo n.º 12
0
        ///<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);
            }
        }
Exemplo n.º 13
0
        ///<summary>Pop a def picker to allow the user to select which def they wish to use for tax exempt customers</summary>
        private void butChooseTaxExempt_Click(object sender, EventArgs e)
        {
            FormPatFieldDefs formPFD = new FormPatFieldDefs(true);

            formPFD.ShowDialog();
            if (formPFD.DialogResult == DialogResult.OK)
            {
                _patFieldDefCurrentTaxExempt = formPFD.SelectedPatFieldDef;
                textTaxExempt.Text           = _patFieldDefCurrentTaxExempt.FieldName;
            }
        }
Exemplo n.º 14
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<PatFieldDef> TableToList(DataTable table){
			List<PatFieldDef> retVal=new List<PatFieldDef>();
			PatFieldDef patFieldDef;
			for(int i=0;i<table.Rows.Count;i++) {
				patFieldDef=new PatFieldDef();
				patFieldDef.PatFieldDefNum= PIn.Long  (table.Rows[i]["PatFieldDefNum"].ToString());
				patFieldDef.FieldName     = PIn.String(table.Rows[i]["FieldName"].ToString());
				patFieldDef.FieldType     = (OpenDentBusiness.PatFieldType)PIn.Int(table.Rows[i]["FieldType"].ToString());
				patFieldDef.PickList      = PIn.String(table.Rows[i]["PickList"].ToString());
				retVal.Add(patFieldDef);
			}
			return retVal;
		}
Exemplo n.º 15
0
        ///<summary>Gets a list of all PatFieldDefs when program first opens.</summary>
        public static void Refresh()
        {
            string    command = "SELECT * FROM patfielddef";
            DataTable table   = General.GetTable(command);

            List = new PatFieldDef[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i] = new PatFieldDef();
                List[i].PatFieldDefNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].FieldName      = PIn.PString(table.Rows[i][1].ToString());
            }
        }
Exemplo n.º 16
0
 ///<summary>Inserts one PatFieldDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PatFieldDef patFieldDef)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(patFieldDef, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             patFieldDef.PatFieldDefNum = DbHelper.GetNextOracleKey("patfielddef", "PatFieldDefNum");                  //Cacheless method
         }
         return(InsertNoCache(patFieldDef, true));
     }
 }
Exemplo n.º 17
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <PatFieldDef> TableToList(DataTable table)
        {
            List <PatFieldDef> retVal = new List <PatFieldDef>();
            PatFieldDef        patFieldDef;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                patFieldDef = new PatFieldDef();
                patFieldDef.PatFieldDefNum = PIn.Long(table.Rows[i]["PatFieldDefNum"].ToString());
                patFieldDef.FieldName      = PIn.String(table.Rows[i]["FieldName"].ToString());
                patFieldDef.FieldType      = (PatFieldType)PIn.Int(table.Rows[i]["FieldType"].ToString());
                patFieldDef.PickList       = PIn.String(table.Rows[i]["PickList"].ToString());
                retVal.Add(patFieldDef);
            }
            return(retVal);
        }
Exemplo n.º 18
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     try{
         PatFieldDefs.Delete(FieldDef);                                                      //Throws if in use.
         FieldDefLinks.DeleteForFieldDefNum(FieldDef.PatFieldDefNum, FieldDefTypes.Patient); //Delete any FieldDefLinks to this PatFieldDef
         FieldDef     = null;
         DialogResult = DialogResult.OK;
     }
     catch (ApplicationException ex) {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 19
0
 private void gridPat_CellDoubleClick(object sender, ODGridClickEventArgs e)
 {
     if (gridPat.Rows[e.Row].Tag is PatFieldDef)             //patfield for an existing PatFieldDef
     {
         PatFieldDef patFieldDef = (PatFieldDef)gridPat.Rows[e.Row].Tag;
         PatField    field       = PatFields.GetByName(patFieldDef.FieldName, _arrayPatientFields);
         PatFieldL.OpenPatField(field, patFieldDef, _patCur.PatNum, true);
     }
     else if (gridPat.Rows[e.Row].Tag is PatField)             //PatField for a PatFieldDef that no longer exists
     {
         PatField         field  = (PatField)gridPat.Rows[e.Row].Tag;
         FormPatFieldEdit FormPF = new FormPatFieldEdit(field);
         FormPF.IsLaunchedFromOrtho = true;
         FormPF.ShowDialog();
     }
     FillGridPat();
 }
Exemplo n.º 20
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            //Employers.Cur=new Employer();
            PatFieldDef def = new PatFieldDef();

            def.ItemOrder = _listPatFieldDefs.Count;
            FormPatFieldDefEdit FormPFDE = new FormPatFieldDefEdit();

            FormPFDE.FieldDef = def;
            FormPFDE.IsNew    = true;
            FormPFDE.ShowDialog();
            if (FormPFDE.DialogResult == DialogResult.OK)
            {
                _hasChanged = true;
                _listPatFieldDefs.Add(FormPFDE.FieldDef);
                FillGrid();
            }
        }
Exemplo n.º 21
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PatFieldDef> TableToList(DataTable table)
        {
            List <PatFieldDef> retVal = new List <PatFieldDef>();
            PatFieldDef        patFieldDef;

            foreach (DataRow row in table.Rows)
            {
                patFieldDef = new PatFieldDef();
                patFieldDef.PatFieldDefNum = PIn.Long(row["PatFieldDefNum"].ToString());
                patFieldDef.FieldName      = PIn.String(row["FieldName"].ToString());
                patFieldDef.FieldType      = (OpenDentBusiness.PatFieldType)PIn.Int(row["FieldType"].ToString());
                patFieldDef.PickList       = PIn.String(row["PickList"].ToString());
                patFieldDef.ItemOrder      = PIn.Int(row["ItemOrder"].ToString());
                patFieldDef.IsHidden       = PIn.Bool(row["IsHidden"].ToString());
                retVal.Add(patFieldDef);
            }
            return(retVal);
        }
Exemplo n.º 22
0
        ///<summary>Updates one PatFieldDef in the database.</summary>
        public static void Update(PatFieldDef patFieldDef)
        {
            string command = "UPDATE patfielddef SET "
                             + "FieldName     = '" + POut.String(patFieldDef.FieldName) + "', "
                             + "FieldType     =  " + POut.Int((int)patFieldDef.FieldType) + ", "
                             + "PickList      =  " + DbHelper.ParamChar + "paramPickList, "
                             + "ItemOrder     =  " + POut.Int(patFieldDef.ItemOrder) + ", "
                             + "IsHidden      =  " + POut.Bool(patFieldDef.IsHidden) + " "
                             + "WHERE PatFieldDefNum = " + POut.Long(patFieldDef.PatFieldDefNum);

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

            Db.NonQ(command, paramPickList);
        }
Exemplo n.º 23
0
 ///<summary>Fill the rest of the UI with the current bridge settings.</summary>
 private void FillSettings()
 {
     //Set Enabled
     checkEnabled.Checked = Programs.IsEnabled(ProgramName.AvaTax);
     //Set radio buttons
     if (AvaTax.IsProduction)
     {
         radioProdEnv.Checked = true;
     }
     else
     {
         radioTestEnv.Checked = true;
     }
     //Set username and password
     textUsername.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, ProgramProperties.PropertyDescs.Username);
     textPassword.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, ProgramProperties.PropertyDescs.Password);
     //Fill Log Level options
     listBoxLogLevel.Items.Clear();
     foreach (LogLevel lv in Enum.GetValues(typeof(LogLevel)))
     {
         ODBoxItem <LogLevel> currentItem = new ODBoxItem <LogLevel>(lv.ToString(), lv);
         listBoxLogLevel.Items.Add(currentItem);
         if (currentItem.Tag == AvaTax.LogDetailLevel)
         {
             listBoxLogLevel.SelectedItem = currentItem;
         }
     }
     //Set company code and sales tax def
     textCompanyCode.Text             = AvaTax.CompanyCode;
     _defCurrentSalesTaxAdjType       = Defs.GetDef(DefCat.AdjTypes, AvaTax.SalesTaxAdjType);
     textAdjType.Text                 = _defCurrentSalesTaxAdjType.ItemName;
     _defCurrentSalesTaxReturnAdjType = Defs.GetDef(DefCat.AdjTypes, AvaTax.SalesTaxReturnAdjType) ?? new Def();
     textReturnAdjType.Text           = _defCurrentSalesTaxReturnAdjType.ItemName;
     _patFieldDefCurrentTaxExempt     = AvaTax.TaxExemptPatField;
     textTaxExempt.Text               = (_patFieldDefCurrentTaxExempt != null) ? _patFieldDefCurrentTaxExempt.FieldName : "";
     validTaxLockDate.Text            = AvaTax.TaxLockDate.ToShortDateString();
     //Set list of procCodes
     textPrePayCodes.Text   = ProgramProperties.GetPropVal(ProgramName.AvaTax, "Prepay Proc Codes");
     textDiscountCodes.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, "Discount Proc Codes");
     //Set the list of overrides
     textOverrides.Text = ProgramProperties.GetPropVal(ProgramName.AvaTax, "Tax Code Overrides");
 }
Exemplo n.º 24
0
        ///<summary>Inserts one PatFieldDef into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(PatFieldDef patFieldDef, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO patfielddef (";

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

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramPickList);
            }
            else
            {
                patFieldDef.PatFieldDefNum = Db.NonQ(command, true, "PatFieldDefNum", "patFieldDef", paramPickList);
            }
            return(patFieldDef.PatFieldDefNum);
        }
Exemplo n.º 25
0
 ///<summary>Returns true if Update(PatFieldDef,PatFieldDef) 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(PatFieldDef patFieldDef, PatFieldDef oldPatFieldDef)
 {
     if (patFieldDef.FieldName != oldPatFieldDef.FieldName)
     {
         return(true);
     }
     if (patFieldDef.FieldType != oldPatFieldDef.FieldType)
     {
         return(true);
     }
     if (patFieldDef.PickList != oldPatFieldDef.PickList)
     {
         return(true);
     }
     if (patFieldDef.ItemOrder != oldPatFieldDef.ItemOrder)
     {
         return(true);
     }
     if (patFieldDef.IsHidden != oldPatFieldDef.IsHidden)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 26
0
        ///<summary>Surround with try/catch, because it will throw an exception if any patient is using this def.</summary>
        public static void Delete(PatFieldDef p)
        {
            string command = "SELECT LName,FName FROM patient,patfield WHERE "
                             + "patient.PatNum=patfield.PatNum "
                             + "AND FieldName='" + POut.PString(p.FieldName) + "'";
            DataTable table = General.GetTable(command);

            if (table.Rows.Count > 0)
            {
                string s = Lan.g("PatFieldDef", "Not allowed to delete. Already in use by ") + table.Rows.Count.ToString()
                           + " " + Lan.g("PatFieldDef", "patients, including") + " \r\n";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (i > 5)
                    {
                        break;
                    }
                    s += table.Rows[i][0].ToString() + ", " + table.Rows[i][1].ToString() + "\r\n";
                }
                throw new ApplicationException(s);
            }
            command = "DELETE FROM patfielddef WHERE PatFieldDefNum =" + POut.PInt(p.PatFieldDefNum);
            General.NonQ(command);
        }
Exemplo n.º 27
0
        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();
        }
Exemplo n.º 28
0
        ///<summary>Updates one PatFieldDef 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(PatFieldDef patFieldDef, PatFieldDef oldPatFieldDef)
        {
            string command = "";

            if (patFieldDef.FieldName != oldPatFieldDef.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(patFieldDef.FieldName) + "'";
            }
            if (patFieldDef.FieldType != oldPatFieldDef.FieldType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldType = " + POut.Int((int)patFieldDef.FieldType) + "";
            }
            if (patFieldDef.PickList != oldPatFieldDef.PickList)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PickList = '" + POut.String(patFieldDef.PickList) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE patfielddef SET " + command
                      + " WHERE PatFieldDefNum = " + POut.Long(patFieldDef.PatFieldDefNum);
            Db.NonQ(command);
        }
Exemplo n.º 29
0
 ///<summary>Opens the appropriate form to edit the patient field. The patField argument can be null or the patFieldDef argument can be null,
 ///but they cannot both be null.</summary>
 public static void OpenPatField(PatField patField, PatFieldDef patFieldDef, long patNum, bool isForOrtho = false)
 {
     if (patFieldDef != null)
     {
         if (patField == null)
         {
             patField           = new PatField();
             patField.PatNum    = patNum;
             patField.FieldName = patFieldDef.FieldName;
             if (patFieldDef.FieldType == PatFieldType.Text)
             {
                 FormPatFieldEdit FormPF = new FormPatFieldEdit(patField);
                 FormPF.IsLaunchedFromOrtho = isForOrtho;
                 FormPF.IsNew = true;
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.PickList)
             {
                 FormPatFieldPickEdit FormPF = new FormPatFieldPickEdit(patField);
                 FormPF.IsNew = true;
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.Date)
             {
                 FormPatFieldDateEdit FormPF = new FormPatFieldDateEdit(patField);
                 FormPF.IsNew = true;
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.Checkbox)
             {
                 FormPatFieldCheckEdit FormPF = new FormPatFieldCheckEdit(patField);
                 FormPF.IsNew = true;
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.Currency)
             {
                 FormPatFieldCurrencyEdit FormPF = new FormPatFieldCurrencyEdit(patField);
                 FormPF.IsNew = true;
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.InCaseOfEmergency)
             {
                 //Deprecated
             }
         }
         else                  //edit existing patfield
         {
             if (patFieldDef.FieldType == PatFieldType.Text)
             {
                 FormPatFieldEdit FormPF = new FormPatFieldEdit(patField);
                 FormPF.IsLaunchedFromOrtho = isForOrtho;
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.PickList)
             {
                 FormPatFieldPickEdit FormPF = new FormPatFieldPickEdit(patField);
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.Date)
             {
                 FormPatFieldDateEdit FormPF = new FormPatFieldDateEdit(patField);
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.Checkbox)
             {
                 FormPatFieldCheckEdit FormPF = new FormPatFieldCheckEdit(patField);
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.Currency)
             {
                 FormPatFieldCurrencyEdit FormPF = new FormPatFieldCurrencyEdit(patField);
                 FormPF.ShowDialog();
             }
             if (patFieldDef.FieldType == PatFieldType.InCaseOfEmergency)
             {
                 //Deprecated
             }
         }
     }
     else if (patField != null)           //PatField for a PatFieldDef that no longer exists
     {
         FormPatFieldEdit FormPF = new FormPatFieldEdit(patField);
         FormPF.IsLaunchedFromOrtho = isForOrtho;
         FormPF.ShowDialog();
     }
 }
Exemplo n.º 30
0
		///<summary>Updates one PatFieldDef in the database.</summary>
		public static void Update(PatFieldDef patFieldDef){
			string command="UPDATE patfielddef SET "
				+"FieldName     = '"+POut.String(patFieldDef.FieldName)+"', "
				+"FieldType     =  "+POut.Int   ((int)patFieldDef.FieldType)+", "
				+"PickList      = '"+POut.String(patFieldDef.PickList)+"' "
				+"WHERE PatFieldDefNum = "+POut.Long(patFieldDef.PatFieldDefNum);
			Db.NonQ(command);
		}
Exemplo n.º 31
0
 ///<summary>Inserts one PatFieldDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PatFieldDef patFieldDef)
 {
     return(InsertNoCache(patFieldDef, false));
 }
Exemplo n.º 32
0
		///<summary>Updates one PatFieldDef 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(PatFieldDef patFieldDef,PatFieldDef oldPatFieldDef){
			string command="";
			if(patFieldDef.FieldName != oldPatFieldDef.FieldName) {
				if(command!=""){ command+=",";}
				command+="FieldName = '"+POut.String(patFieldDef.FieldName)+"'";
			}
			if(patFieldDef.FieldType != oldPatFieldDef.FieldType) {
				if(command!=""){ command+=",";}
				command+="FieldType = "+POut.Int   ((int)patFieldDef.FieldType)+"";
			}
			if(patFieldDef.PickList != oldPatFieldDef.PickList) {
				if(command!=""){ command+=",";}
				command+="PickList = '"+POut.String(patFieldDef.PickList)+"'";
			}
			if(command==""){
				return false;
			}
			command="UPDATE patfielddef SET "+command
				+" WHERE PatFieldDefNum = "+POut.Long(patFieldDef.PatFieldDefNum);
			Db.NonQ(command);
			return true;
		}