///<summary>Updates one RecurringCharge in the database.</summary>
        public static void Update(RecurringCharge recurringCharge)
        {
            string command = "UPDATE recurringcharge SET "
                             + "PatNum            =  " + POut.Long(recurringCharge.PatNum) + ", "
                             + "ClinicNum         =  " + POut.Long(recurringCharge.ClinicNum) + ", "
                             + "DateTimeCharge    =  " + POut.DateT(recurringCharge.DateTimeCharge) + ", "
                             + "ChargeStatus      =  " + POut.Int((int)recurringCharge.ChargeStatus) + ", "
                             + "FamBal            = '" + POut.Double(recurringCharge.FamBal) + "', "
                             + "PayPlanDue        = '" + POut.Double(recurringCharge.PayPlanDue) + "', "
                             + "TotalDue          = '" + POut.Double(recurringCharge.TotalDue) + "', "
                             + "RepeatAmt         = '" + POut.Double(recurringCharge.RepeatAmt) + "', "
                             + "ChargeAmt         = '" + POut.Double(recurringCharge.ChargeAmt) + "', "
                             + "UserNum           =  " + POut.Long(recurringCharge.UserNum) + ", "
                             + "PayNum            =  " + POut.Long(recurringCharge.PayNum) + ", "
                             + "CreditCardNum     =  " + POut.Long(recurringCharge.CreditCardNum) + ", "
                             + "ErrorMsg          =  " + DbHelper.ParamChar + "paramErrorMsg "
                             + "WHERE RecurringChargeNum = " + POut.Long(recurringCharge.RecurringChargeNum);

            if (recurringCharge.ErrorMsg == null)
            {
                recurringCharge.ErrorMsg = "";
            }
            OdSqlParameter paramErrorMsg = new OdSqlParameter("paramErrorMsg", OdDbType.Text, POut.StringParam(recurringCharge.ErrorMsg));

            Db.NonQ(command, paramErrorMsg);
        }
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <RecurringCharge> TableToList(DataTable table)
        {
            List <RecurringCharge> retVal = new List <RecurringCharge>();
            RecurringCharge        recurringCharge;

            foreach (DataRow row in table.Rows)
            {
                recurringCharge = new RecurringCharge();
                recurringCharge.RecurringChargeNum = PIn.Long(row["RecurringChargeNum"].ToString());
                recurringCharge.PatNum             = PIn.Long(row["PatNum"].ToString());
                recurringCharge.ClinicNum          = PIn.Long(row["ClinicNum"].ToString());
                recurringCharge.DateTimeCharge     = PIn.DateT(row["DateTimeCharge"].ToString());
                recurringCharge.ChargeStatus       = (OpenDentBusiness.RecurringChargeStatus)PIn.Int(row["ChargeStatus"].ToString());
                recurringCharge.FamBal             = PIn.Double(row["FamBal"].ToString());
                recurringCharge.PayPlanDue         = PIn.Double(row["PayPlanDue"].ToString());
                recurringCharge.TotalDue           = PIn.Double(row["TotalDue"].ToString());
                recurringCharge.RepeatAmt          = PIn.Double(row["RepeatAmt"].ToString());
                recurringCharge.ChargeAmt          = PIn.Double(row["ChargeAmt"].ToString());
                recurringCharge.UserNum            = PIn.Long(row["UserNum"].ToString());
                recurringCharge.PayNum             = PIn.Long(row["PayNum"].ToString());
                recurringCharge.CreditCardNum      = PIn.Long(row["CreditCardNum"].ToString());
                recurringCharge.ErrorMsg           = PIn.String(row["ErrorMsg"].ToString());
                retVal.Add(recurringCharge);
            }
            return(retVal);
        }
예제 #3
0
        public async System.Threading.Tasks.Task <ActionResult> Buy()
        {
            string myShopifyUrl = Session["shop"].ToString();
            string accessToken  = db.ShopLinks.Where(w => w.Shop == myShopifyUrl).FirstOrDefault().Token;


            try
            {
                var service = new RecurringChargeService(myShopifyUrl, accessToken);
                var charge  = new RecurringCharge()
                {
                    Name  = "Premium Account",
                    Price = 7,
                    /* Test= true,*/
                    //Test = true, //Marks this charge as a test, meaning it won't charge the shop owner.
                    ReturnUrl = "https://www.leaderpush.com/Premium/Confirm"
                };

                charge = await service.CreateAsync(charge);

                ShopLink link = db.ShopLinks.Where(w => w.Shop == myShopifyUrl).FirstOrDefault();
                link.PremiumID = charge.Id;
                db.Entry(link).Property(w => w.PremiumID).IsModified = true;
                db.SaveChanges();

                return(Redirect(charge.ConfirmationUrl));
            }
            catch
            {
                return(RedirectToAction("UrlBreak", "Home"));
            }
        }
 ///<summary>Returns true if Update(RecurringCharge,RecurringCharge) 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(RecurringCharge recurringCharge, RecurringCharge oldRecurringCharge)
 {
     if (recurringCharge.PatNum != oldRecurringCharge.PatNum)
     {
         return(true);
     }
     if (recurringCharge.ClinicNum != oldRecurringCharge.ClinicNum)
     {
         return(true);
     }
     if (recurringCharge.DateTimeCharge != oldRecurringCharge.DateTimeCharge)
     {
         return(true);
     }
     if (recurringCharge.ChargeStatus != oldRecurringCharge.ChargeStatus)
     {
         return(true);
     }
     if (recurringCharge.FamBal != oldRecurringCharge.FamBal)
     {
         return(true);
     }
     if (recurringCharge.PayPlanDue != oldRecurringCharge.PayPlanDue)
     {
         return(true);
     }
     if (recurringCharge.TotalDue != oldRecurringCharge.TotalDue)
     {
         return(true);
     }
     if (recurringCharge.RepeatAmt != oldRecurringCharge.RepeatAmt)
     {
         return(true);
     }
     if (recurringCharge.ChargeAmt != oldRecurringCharge.ChargeAmt)
     {
         return(true);
     }
     if (recurringCharge.UserNum != oldRecurringCharge.UserNum)
     {
         return(true);
     }
     if (recurringCharge.PayNum != oldRecurringCharge.PayNum)
     {
         return(true);
     }
     if (recurringCharge.CreditCardNum != oldRecurringCharge.CreditCardNum)
     {
         return(true);
     }
     if (recurringCharge.ErrorMsg != oldRecurringCharge.ErrorMsg)
     {
         return(true);
     }
     return(false);
 }
예제 #5
0
        private void menuItemViewError_Click(object sender, EventArgs e)
        {
            RecurringCharge charge = gridMain.SelectedTag <RecurringCharge>();

            if (charge == null)
            {
                return;
            }
            new MsgBoxCopyPaste(charge.ErrorMsg).Show();
        }
예제 #6
0
        private void menuItemGoTo_Click(object sender, EventArgs e)
        {
            RecurringCharge charge = gridMain.SelectedTag <RecurringCharge>();

            if (charge == null || !Security.IsAuthorized(Permissions.AccountModule))
            {
                return;
            }
            GotoModule.GotoAccount(charge.PatNum);
        }
예제 #7
0
        private void contextMenu_Popup(object sender, EventArgs e)
        {
            RecurringCharge charge = gridMain.SelectedTag <RecurringCharge>();

            if (charge == null)
            {
                return;
            }
            menuItemOpenPayment.Visible   = (charge.PayNum != 0);
            menuItemViewError.Visible     = (charge.ChargeStatus == RecurringChargeStatus.ChargeFailed);
            menuItemDeletePending.Visible = (charge.ChargeStatus == RecurringChargeStatus.NotYetCharged);
        }
예제 #8
0
        public static RecurringCharge CreateRecurringCharge(long patNum, RecurringChargeStatus status, double chargeAmt, long creditCardNum,
                                                            DateDefaultToday dateCharge = default(DateDefaultToday))
        {
            RecurringCharge charge = new RecurringCharge {
                ChargeAmt      = chargeAmt,
                ChargeStatus   = status,
                CreditCardNum  = creditCardNum,
                PatNum         = patNum,
                DateTimeCharge = dateCharge.Date,
            };

            RecurringCharges.Insert(charge);
            return(charge);
        }
        ///<summary>Inserts one RecurringCharge into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(RecurringCharge recurringCharge, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO recurringcharge (";

            if (!useExistingPK && isRandomKeys)
            {
                recurringCharge.RecurringChargeNum = ReplicationServers.GetKeyNoCache("recurringcharge", "RecurringChargeNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "RecurringChargeNum,";
            }
            command += "PatNum,ClinicNum,DateTimeCharge,ChargeStatus,FamBal,PayPlanDue,TotalDue,RepeatAmt,ChargeAmt,UserNum,PayNum,CreditCardNum,ErrorMsg) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(recurringCharge.RecurringChargeNum) + ",";
            }
            command +=
                POut.Long(recurringCharge.PatNum) + ","
                + POut.Long(recurringCharge.ClinicNum) + ","
                + POut.DateT(recurringCharge.DateTimeCharge) + ","
                + POut.Int((int)recurringCharge.ChargeStatus) + ","
                + "'" + POut.Double(recurringCharge.FamBal) + "',"
                + "'" + POut.Double(recurringCharge.PayPlanDue) + "',"
                + "'" + POut.Double(recurringCharge.TotalDue) + "',"
                + "'" + POut.Double(recurringCharge.RepeatAmt) + "',"
                + "'" + POut.Double(recurringCharge.ChargeAmt) + "',"
                + POut.Long(recurringCharge.UserNum) + ","
                + POut.Long(recurringCharge.PayNum) + ","
                + POut.Long(recurringCharge.CreditCardNum) + ","
                + DbHelper.ParamChar + "paramErrorMsg)";
            if (recurringCharge.ErrorMsg == null)
            {
                recurringCharge.ErrorMsg = "";
            }
            OdSqlParameter paramErrorMsg = new OdSqlParameter("paramErrorMsg", OdDbType.Text, POut.StringParam(recurringCharge.ErrorMsg));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramErrorMsg);
            }
            else
            {
                recurringCharge.RecurringChargeNum = Db.NonQ(command, true, "RecurringChargeNum", "recurringCharge", paramErrorMsg);
            }
            return(recurringCharge.RecurringChargeNum);
        }
예제 #10
0
        private void menuItemDeletePending_Click(object sender, EventArgs e)
        {
            RecurringCharge charge = gridMain.SelectedTag <RecurringCharge>();

            if (charge == null || !MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete this pending recurring charge?"
                                               + "\r\n\r\nAnother user or service may be processing this card right now."))
            {
                return;
            }
            RecurringCharge chargeDb = RecurringCharges.GetOne(charge.RecurringChargeNum);

            if (chargeDb == null || chargeDb.ChargeStatus != RecurringChargeStatus.NotYetCharged)
            {
                MsgBox.Show(this, "This recurring charge is no longer pending. Unable to delete.");
                return;
            }
            RecurringCharges.Delete(charge.RecurringChargeNum);
            RefreshRecurringCharges();
            FillGrid();
        }
예제 #11
0
        private void menuItemOpenPayment_Click(object sender, EventArgs e)
        {
            RecurringCharge charge = gridMain.SelectedTag <RecurringCharge>();

            if (charge == null || charge.PayNum == 0)
            {
                return;
            }
            Payment pay = Payments.GetPayment(charge.PayNum);

            if (pay == null)           //The payment has been deleted
            {
                MsgBox.Show(this, "This payment no longer exists.");
                return;
            }
            Patient     pat   = Patients.GetPat(pay.PatNum);
            Family      fam   = Patients.GetFamily(pat.PatNum);
            FormPayment FormP = new FormPayment(pat, fam, pay, false);

            FormP.ShowDialog();
        }
예제 #12
0
        ///<summary>Updates one RecurringCharge 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(RecurringCharge recurringCharge, RecurringCharge oldRecurringCharge)
        {
            string command = "";

            if (recurringCharge.PatNum != oldRecurringCharge.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(recurringCharge.PatNum) + "";
            }
            if (recurringCharge.ClinicNum != oldRecurringCharge.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(recurringCharge.ClinicNum) + "";
            }
            if (recurringCharge.DateTimeCharge != oldRecurringCharge.DateTimeCharge)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeCharge = " + POut.DateT(recurringCharge.DateTimeCharge) + "";
            }
            if (recurringCharge.ChargeStatus != oldRecurringCharge.ChargeStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ChargeStatus = " + POut.Int((int)recurringCharge.ChargeStatus) + "";
            }
            if (recurringCharge.FamBal != oldRecurringCharge.FamBal)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FamBal = '" + POut.Double(recurringCharge.FamBal) + "'";
            }
            if (recurringCharge.PayPlanDue != oldRecurringCharge.PayPlanDue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PayPlanDue = '" + POut.Double(recurringCharge.PayPlanDue) + "'";
            }
            if (recurringCharge.TotalDue != oldRecurringCharge.TotalDue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TotalDue = '" + POut.Double(recurringCharge.TotalDue) + "'";
            }
            if (recurringCharge.RepeatAmt != oldRecurringCharge.RepeatAmt)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RepeatAmt = '" + POut.Double(recurringCharge.RepeatAmt) + "'";
            }
            if (recurringCharge.ChargeAmt != oldRecurringCharge.ChargeAmt)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ChargeAmt = '" + POut.Double(recurringCharge.ChargeAmt) + "'";
            }
            if (recurringCharge.UserNum != oldRecurringCharge.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(recurringCharge.UserNum) + "";
            }
            if (recurringCharge.PayNum != oldRecurringCharge.PayNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PayNum = " + POut.Long(recurringCharge.PayNum) + "";
            }
            if (recurringCharge.CreditCardNum != oldRecurringCharge.CreditCardNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CreditCardNum = " + POut.Long(recurringCharge.CreditCardNum) + "";
            }
            if (recurringCharge.ErrorMsg != oldRecurringCharge.ErrorMsg)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ErrorMsg = " + DbHelper.ParamChar + "paramErrorMsg";
            }
            if (command == "")
            {
                return(false);
            }
            if (recurringCharge.ErrorMsg == null)
            {
                recurringCharge.ErrorMsg = "";
            }
            OdSqlParameter paramErrorMsg = new OdSqlParameter("paramErrorMsg", OdDbType.Text, POut.StringParam(recurringCharge.ErrorMsg));

            command = "UPDATE recurringcharge SET " + command
                      + " WHERE RecurringChargeNum = " + POut.Long(recurringCharge.RecurringChargeNum);
            Db.NonQ(command, paramErrorMsg);
            return(true);
        }
예제 #13
0
 ///<summary>Inserts one RecurringCharge into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(RecurringCharge recurringCharge)
 {
     return(InsertNoCache(recurringCharge, false));
 }