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

            if (!useExistingPK && isRandomKeys)
            {
                payPlanLink.PayPlanLinkNum = ReplicationServers.GetKeyNoCache("payplanlink", "PayPlanLinkNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "PayPlanLinkNum,";
            }
            command += "PayPlanNum,LinkType,FKey,AmountOverride,SecDateTEntry) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(payPlanLink.PayPlanLinkNum) + ",";
            }
            command +=
                POut.Long(payPlanLink.PayPlanNum) + ","
                + POut.Int((int)payPlanLink.LinkType) + ","
                + POut.Long(payPlanLink.FKey) + ","
                + "'" + POut.Double(payPlanLink.AmountOverride) + "',"
                + DbHelper.Now() + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                payPlanLink.PayPlanLinkNum = Db.NonQ(command, true, "PayPlanLinkNum", "payPlanLink");
            }
            return(payPlanLink.PayPlanLinkNum);
        }
Пример #2
0
        ///<summary>For use with Dynamic Payment Plans. Production (proceudres and adjustments) is attached via PayPlanLinks.</summary>
        public static PayPlanLink CreatePaymentPlanLink(PayPlan payplan, long procOrAdjNum, PayPlanLinkType linkType)
        {
            PayPlanLink link = new PayPlanLink();

            link.PayPlanNum     = payplan.PayPlanNum;
            link.AmountOverride = 0;
            link.FKey           = procOrAdjNum;
            link.LinkType       = linkType;
            PayPlanLinks.Insert(link);
            return(link);
        }
Пример #3
0
        ///<summary>Updates one PayPlanLink in the database.</summary>
        public static void Update(PayPlanLink payPlanLink)
        {
            string command = "UPDATE payplanlink SET "
                             + "PayPlanNum    =  " + POut.Long(payPlanLink.PayPlanNum) + ", "
                             + "LinkType      =  " + POut.Int((int)payPlanLink.LinkType) + ", "
                             + "FKey          =  " + POut.Long(payPlanLink.FKey) + ", "
                             + "AmountOverride= '" + POut.Double(payPlanLink.AmountOverride) + "' "
                             //SecDateTEntry not allowed to change
                             + "WHERE PayPlanLinkNum = " + POut.Long(payPlanLink.PayPlanLinkNum);

            Db.NonQ(command);
        }
Пример #4
0
        ///<summary>Updates one PayPlanLink 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(PayPlanLink payPlanLink, PayPlanLink oldPayPlanLink)
        {
            string command = "";

            if (payPlanLink.PayPlanNum != oldPayPlanLink.PayPlanNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PayPlanNum = " + POut.Long(payPlanLink.PayPlanNum) + "";
            }
            if (payPlanLink.LinkType != oldPayPlanLink.LinkType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LinkType = " + POut.Int((int)payPlanLink.LinkType) + "";
            }
            if (payPlanLink.FKey != oldPayPlanLink.FKey)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FKey = " + POut.Long(payPlanLink.FKey) + "";
            }
            if (payPlanLink.AmountOverride != oldPayPlanLink.AmountOverride)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AmountOverride = '" + POut.Double(payPlanLink.AmountOverride) + "'";
            }
            //SecDateTEntry not allowed to change
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE payplanlink SET " + command
                      + " WHERE PayPlanLinkNum = " + POut.Long(payPlanLink.PayPlanLinkNum);
            Db.NonQ(command);
            return(true);
        }
Пример #5
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PayPlanLink> TableToList(DataTable table)
        {
            List <PayPlanLink> retVal = new List <PayPlanLink>();
            PayPlanLink        payPlanLink;

            foreach (DataRow row in table.Rows)
            {
                payPlanLink = new PayPlanLink();
                payPlanLink.PayPlanLinkNum = PIn.Long(row["PayPlanLinkNum"].ToString());
                payPlanLink.PayPlanNum     = PIn.Long(row["PayPlanNum"].ToString());
                payPlanLink.LinkType       = (OpenDentBusiness.PayPlanLinkType)PIn.Int(row["LinkType"].ToString());
                payPlanLink.FKey           = PIn.Long(row["FKey"].ToString());
                payPlanLink.AmountOverride = PIn.Double(row["AmountOverride"].ToString());
                payPlanLink.SecDateTEntry  = PIn.DateT(row["SecDateTEntry"].ToString());
                retVal.Add(payPlanLink);
            }
            return(retVal);
        }
Пример #6
0
 ///<summary>Returns true if Update(PayPlanLink,PayPlanLink) 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(PayPlanLink payPlanLink, PayPlanLink oldPayPlanLink)
 {
     if (payPlanLink.PayPlanNum != oldPayPlanLink.PayPlanNum)
     {
         return(true);
     }
     if (payPlanLink.LinkType != oldPayPlanLink.LinkType)
     {
         return(true);
     }
     if (payPlanLink.FKey != oldPayPlanLink.FKey)
     {
         return(true);
     }
     if (payPlanLink.AmountOverride != oldPayPlanLink.AmountOverride)
     {
         return(true);
     }
     //SecDateTEntry not allowed to change
     return(false);
 }
Пример #7
0
 ///<summary>Inserts one PayPlanLink into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PayPlanLink payPlanLink)
 {
     return(InsertNoCache(payPlanLink, false));
 }