コード例 #1
0
        ///<summary>Updates one EServiceCodeLink 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(EServiceCodeLink eServiceCodeLink, EServiceCodeLink oldEServiceCodeLink)
        {
            string command = "";

            if (eServiceCodeLink.CodeNum != oldEServiceCodeLink.CodeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeNum = " + POut.Long(eServiceCodeLink.CodeNum) + "";
            }
            if (eServiceCodeLink.EService != oldEServiceCodeLink.EService)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "EService = " + POut.Int((int)eServiceCodeLink.EService) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE eservicecodelink SET " + command
                      + " WHERE EServiceCodeLinkNum = " + POut.Long(eServiceCodeLink.EServiceCodeLinkNum);
            Db.NonQ(command);
            return(true);
        }
コード例 #2
0
 ///<summary>Inserts one EServiceCodeLink into the database.  Returns the new priKey.</summary>
 public static long Insert(EServiceCodeLink eServiceCodeLink)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         eServiceCodeLink.EServiceCodeLinkNum = DbHelper.GetNextOracleKey("eservicecodelink", "EServiceCodeLinkNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(eServiceCodeLink, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     eServiceCodeLink.EServiceCodeLinkNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(eServiceCodeLink, false));
     }
 }
コード例 #3
0
        ///<summary>Inserts one EServiceCodeLink into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(EServiceCodeLink eServiceCodeLink, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO eservicecodelink (";

            if (!useExistingPK && isRandomKeys)
            {
                eServiceCodeLink.EServiceCodeLinkNum = ReplicationServers.GetKeyNoCache("eservicecodelink", "EServiceCodeLinkNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EServiceCodeLinkNum,";
            }
            command += "CodeNum,EService) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(eServiceCodeLink.EServiceCodeLinkNum) + ",";
            }
            command +=
                POut.Long(eServiceCodeLink.CodeNum) + ","
                + POut.Int((int)eServiceCodeLink.EService) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                eServiceCodeLink.EServiceCodeLinkNum = Db.NonQ(command, true, "EServiceCodeLinkNum", "eServiceCodeLink");
            }
            return(eServiceCodeLink.EServiceCodeLinkNum);
        }
コード例 #4
0
        ///<summary>Inserts one EServiceCodeLink into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(EServiceCodeLink eServiceCodeLink, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                eServiceCodeLink.EServiceCodeLinkNum = ReplicationServers.GetKey("eservicecodelink", "EServiceCodeLinkNum");
            }
            string command = "INSERT INTO eservicecodelink (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "EServiceCodeLinkNum,";
            }
            command += "CodeNum,EService) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(eServiceCodeLink.EServiceCodeLinkNum) + ",";
            }
            command +=
                POut.Long(eServiceCodeLink.CodeNum) + ","
                + POut.Int((int)eServiceCodeLink.EService) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                eServiceCodeLink.EServiceCodeLinkNum = Db.NonQ(command, true, "EServiceCodeLinkNum", "eServiceCodeLink");
            }
            return(eServiceCodeLink.EServiceCodeLinkNum);
        }
コード例 #5
0
ファイル: RepeatChargeT.cs プロジェクト: ChemBrain/OpenDental
 public static RepeatCharge GetRepeatChargeCustomers(eServiceCode eService, long patNum)
 {
     return(DataAction.GetCustomers(() => {
         var all = RepeatCharges.Refresh(patNum).ToList();
         var link = EServiceCodeLink.GetAll().FirstOrDefault(x => x.EService == eService) ?? new EServiceCodeLink();
         return all.FirstOrDefault(x => x.ProcCode == link.ProcCode);
     }));
 }
コード例 #6
0
        ///<summary>Updates one EServiceCodeLink in the database.</summary>
        public static void Update(EServiceCodeLink eServiceCodeLink)
        {
            string command = "UPDATE eservicecodelink SET "
                             + "CodeNum            =  " + POut.Long(eServiceCodeLink.CodeNum) + ", "
                             + "EService           =  " + POut.Int((int)eServiceCodeLink.EService) + " "
                             + "WHERE EServiceCodeLinkNum = " + POut.Long(eServiceCodeLink.EServiceCodeLinkNum);

            Db.NonQ(command);
        }
コード例 #7
0
 ///<summary>Returns true if Update(EServiceCodeLink,EServiceCodeLink) 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(EServiceCodeLink eServiceCodeLink, EServiceCodeLink oldEServiceCodeLink)
 {
     if (eServiceCodeLink.CodeNum != oldEServiceCodeLink.CodeNum)
     {
         return(true);
     }
     if (eServiceCodeLink.EService != oldEServiceCodeLink.EService)
     {
         return(true);
     }
     return(false);
 }
コード例 #8
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EServiceCodeLink> TableToList(DataTable table)
        {
            List <EServiceCodeLink> retVal = new List <EServiceCodeLink>();
            EServiceCodeLink        eServiceCodeLink;

            foreach (DataRow row in table.Rows)
            {
                eServiceCodeLink = new EServiceCodeLink();
                eServiceCodeLink.EServiceCodeLinkNum = PIn.Long(row["EServiceCodeLinkNum"].ToString());
                eServiceCodeLink.CodeNum             = PIn.Long(row["CodeNum"].ToString());
                eServiceCodeLink.EService            = (OpenDentBusiness.eServiceCode)PIn.Int(row["EService"].ToString());
                retVal.Add(eServiceCodeLink);
            }
            return(retVal);
        }
コード例 #9
0
 ///<summary>Inserts one EServiceCodeLink into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EServiceCodeLink eServiceCodeLink)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(eServiceCodeLink, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             eServiceCodeLink.EServiceCodeLinkNum = DbHelper.GetNextOracleKey("eservicecodelink", "EServiceCodeLinkNum");                  //Cacheless method
         }
         return(InsertNoCache(eServiceCodeLink, true));
     }
 }
コード例 #10
0
        private void FormRepeatChargeEdit_Load(object sender, EventArgs e)
        {
            SetPatient();
            if (IsNew)
            {
                FormProcCodes FormP = new FormProcCodes();
                FormP.IsSelectionMode = true;
                FormP.ShowDialog();
                if (FormP.DialogResult != DialogResult.OK)
                {
                    DialogResult = DialogResult.Cancel;
                    return;
                }
                ProcedureCode procCode = ProcedureCodes.GetProcCode(FormP.SelectedCodeNum);
                if (procCode.TreatArea != TreatmentArea.Mouth &&
                    procCode.TreatArea != TreatmentArea.None)
                {
                    MsgBox.Show(this, "Procedure codes that require tooth numbers are not allowed.");
                    DialogResult = DialogResult.Cancel;
                    return;
                }
                RepeatCur.ProcCode     = ProcedureCodes.GetStringProcCode(FormP.SelectedCodeNum);
                RepeatCur.IsEnabled    = true;
                RepeatCur.CreatesClaim = false;
            }
            textCode.Text      = RepeatCur.ProcCode;
            textDesc.Text      = ProcedureCodes.GetProcCode(RepeatCur.ProcCode).Descript;
            textChargeAmt.Text = RepeatCur.ChargeAmt.ToString("F");
            if (RepeatCur.DateStart.Year > 1880)
            {
                textDateStart.Text = RepeatCur.DateStart.ToShortDateString();
            }
            if (RepeatCur.DateStop.Year > 1880)
            {
                textDateStop.Text = RepeatCur.DateStop.ToShortDateString();
            }
            textNote.Text = RepeatCur.Note;
            _isErx        = false;
            if (PrefC.GetBool(PrefName.DistributorKey) && Regex.IsMatch(RepeatCur.ProcCode, "^Z[0-9]{3,}$"))            //Is eRx if HQ and a using an eRx Z code.
            {
                _isErx = true;
                labelPatNum.Visible       = true;
                textPatNum.Visible        = true;
                butMoveTo.Visible         = true;
                labelNpi.Visible          = true;
                textNpi.Visible           = true;
                labelProviderName.Visible = true;
                textProvName.Visible      = true;
                labelErxAccountId.Visible = true;
                textErxAccountId.Visible  = true;
                if (!IsNew)                 //Existing eRx repeating charge.
                {
                    textNpi.Text              = RepeatCur.Npi;
                    textErxAccountId.Text     = RepeatCur.ErxAccountId;
                    textProvName.Text         = RepeatCur.ProviderName;
                    textNpi.ReadOnly          = true;
                    textErxAccountId.ReadOnly = true;
                    textProvName.ReadOnly     = true;
                }
            }
            checkCopyNoteToProc.Checked = RepeatCur.CopyNoteToProc;
            checkCreatesClaim.Checked   = RepeatCur.CreatesClaim;
            checkIsEnabled.Checked      = RepeatCur.IsEnabled;
            if (PrefC.GetBool(PrefName.DistributorKey))             //OD HQ disable the IsEnabled and CreatesClaim checkboxes
            {
                checkCreatesClaim.Enabled = false;
                checkIsEnabled.Enabled    = false;
            }
            if (PrefC.IsODHQ && EServiceCodeLink.IsProcCodeAnEService(RepeatCur.ProcCode))
            {
                if (IsNew)
                {
                    MsgBox.Show(this, "You cannot manually create any eService repeating charges.\r\n"
                                + "Use the Signup Portal instead.\r\n\r\n"
                                + "The Charge Amount can be manually edited after the Signup Portal has created the desired eService repeating charge.");
                    DialogResult = DialogResult.Abort;
                    return;
                }
                //The only things that users should be able to do for eServices are:
                //1. Change the repeating charge amount.
                //2. Manipulate the Start Date.
                //3. Manipulate the Note.
                //4. Manipulate Billing Day because not all customers will have a non-eService repeating charge in order to manipulate.
                //This is because legacy users (versions prior to 17.1) need the ability to manually set their monthly charge amount, etc.
                SetFormReadOnly(this, butOK, butCancel
                                , textChargeAmt, labelChargeAmount
                                , textDateStart, labelDateStart
                                , textNote, labelNote
                                , textBillingDay, labelBillingCycleDay);
            }
            Patient pat = Patients.GetPat(RepeatCur.PatNum);          //pat should never be null. If it is, this will fail.

            //If this is a new repeat charge and no other active repeat charges exist, set the billing cycle day to today
            if (IsNew && !RepeatCharges.ActiveRepeatChargeExists(RepeatCur.PatNum))
            {
                textBillingDay.Text = DateTimeOD.Today.Day.ToString();
            }
            else
            {
                textBillingDay.Text = pat.BillingCycleDay.ToString();
            }
            if (PrefC.GetBool(PrefName.BillingUseBillingCycleDay))
            {
                labelBillingCycleDay.Visible = true;
                textBillingDay.Visible       = true;
            }
            checkUsePrepay.Checked = RepeatCur.UsePrepay;
        }
コード例 #11
0
 ///<summary>Inserts one EServiceCodeLink into the database.  Returns the new priKey.</summary>
 public static long Insert(EServiceCodeLink eServiceCodeLink)
 {
     return(Insert(eServiceCodeLink, false));
 }