private void FormXchargeTokenTool_Load(object sender, EventArgs e) { Program prog = Programs.GetCur(ProgramName.Xcharge); if (prog == null || !prog.Enabled) { MsgBox.Show(this, "X-Charge program link is not set up."); DialogResult = DialogResult.Cancel; return; } string path = Programs.GetProgramPath(prog); if (!File.Exists(path)) { MsgBox.Show(this, "X-Charge path is not valid."); DialogResult = DialogResult.Cancel; return; } //In order for X-Charge to be enabled, the enabled flag must be set and there must be a valid Username, Password, and PaymentType //If clinics are enabled, the Username, Password, and PaymentType fields are allowed to be blank/invalid for any clinic not using X-Charge //Therefore, we will validate the credentials and payment type using FormOpenDental.ClinicNum string paymentType = ProgramProperties.GetPropVal(prog.ProgramNum, "PaymentType", Clinics.ClinicNum); List <Def> _listPayTypeDefs = Defs.GetDefsForCategory(DefCat.PaymentTypes, true).FindAll(x => x.DefNum.ToString() == paymentType); //should be a list of 0 or 1 _xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum); _xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum); if (string.IsNullOrEmpty(_xUsername) || string.IsNullOrEmpty(_xPassword) || _listPayTypeDefs.Count < 1) { MsgBox.Show(this, "X-Charge username, password, or payment type for this clinic is invalid."); DialogResult = DialogResult.Cancel; return; } _listCreditCards = CreditCards.GetCardsWithTokenBySource( new List <CreditCardSource> { CreditCardSource.XServer, CreditCardSource.XServerPayConnect }); textTotal.Text = _listCreditCards.Count.ToString(); textVerified.Text = "0"; textInvalid.Text = "0"; if (_listCreditCards.Count == 0) { MsgBox.Show(this, "There are no credit cards with stored X-Charge tokens in the database."); return; } }
private void butCheck_Click(object sender, EventArgs e) { gridMain.BeginUpdate(); gridMain.Rows.Clear(); gridMain.EndUpdate(); _listCreditCards = CreditCards.GetCardsWithTokenBySource( new List <CreditCardSource> { CreditCardSource.XServer, CreditCardSource.XServerPayConnect }); textTotal.Text = _listCreditCards.Count.ToString(); textVerified.Text = "0"; textInvalid.Text = "0"; if (_listCreditCards.Count == 0) { MsgBox.Show(this, "There are no credit cards with stored X-Charge tokens in the database."); return; } FillGrid(); }