private void FillGrid()
 {
     //Currently only working for X-Charge. If more added then move this check out of FillGrid.
     #region XCharge Check
     if (prog == null)
     {
         MsgBox.Show(this, "X-Charge entry is missing from the database.");               //should never happen
         return;
     }
     if (!prog.Enabled)
     {
         if (Security.IsAuthorized(Permissions.Setup))
         {
             FormXchargeSetup FormX = new FormXchargeSetup();
             FormX.ShowDialog();
         }
         return;
     }
     if (!File.Exists(xPath))
     {
         MsgBox.Show(this, "Path is not valid.");
         if (Security.IsAuthorized(Permissions.Setup))
         {
             FormXchargeSetup FormX = new FormXchargeSetup();
             FormX.ShowDialog();
         }
         return;
     }
     #endregion
     table = CreditCards.GetRecurringChargeList();
     gridMain.BeginUpdate();
     gridMain.Columns.Clear();
     ODGridColumn col = new ODGridColumn(Lan.g("TableRecurring", "PatNum"), 110);
     gridMain.Columns.Add(col);
     col = new ODGridColumn(Lan.g("TableRecurring", "Name"), 250);
     gridMain.Columns.Add(col);
     col = new ODGridColumn(Lan.g("TableRecurring", "Total Bal"), 90, HorizontalAlignment.Right);
     gridMain.Columns.Add(col);
     col = new ODGridColumn(Lan.g("TableRecurring", "ChargeAmt"), 100, HorizontalAlignment.Right);
     gridMain.Columns.Add(col);
     gridMain.Rows.Clear();
     OpenDental.UI.ODGridRow row;
     for (int i = 0; i < table.Rows.Count; i++)
     {
         row = new OpenDental.UI.ODGridRow();
         Double famBalTotal = PIn.Double(table.Rows[i]["FamBalTotal"].ToString());
         Double chargeAmt   = PIn.Double(table.Rows[i]["ChargeAmt"].ToString());
         row.Cells.Add(table.Rows[i]["PatNum"].ToString());
         row.Cells.Add(table.Rows[i]["PatName"].ToString());
         row.Cells.Add(famBalTotal.ToString("c"));
         row.Cells.Add(chargeAmt.ToString("c"));
         gridMain.Rows.Add(row);
     }
     gridMain.EndUpdate();
     labelTotal.Text    = Lan.g(this, "Total=") + table.Rows.Count.ToString();
     labelSelected.Text = Lan.g(this, "Selected=") + gridMain.SelectedIndices.Length.ToString();
 }
Exemplo n.º 2
0
		private void FillGrid() {
			//Currently only working for X-Charge. If more added then move this check out of FillGrid.
			#region XCharge Check
			if(prog==null){
				MsgBox.Show(this,"X-Charge entry is missing from the database.");//should never happen
				return;
			}
			if(!prog.Enabled) {
				if(Security.IsAuthorized(Permissions.Setup)) {
					FormXchargeSetup FormX=new FormXchargeSetup();
					FormX.ShowDialog();
				}
				return;
			}
			if(!File.Exists(xPath)) {
				MsgBox.Show(this,"Path is not valid.");
				if(Security.IsAuthorized(Permissions.Setup)){
					FormXchargeSetup FormX=new FormXchargeSetup();
					FormX.ShowDialog();
				}
				return;
			}
			#endregion
			table=CreditCards.GetRecurringChargeList();
			gridMain.BeginUpdate();
			gridMain.Columns.Clear();
			ODGridColumn col=new ODGridColumn(Lan.g("TableRecurring","PatNum"),110);
			gridMain.Columns.Add(col);
			col=new ODGridColumn(Lan.g("TableRecurring","Name"),250);
			gridMain.Columns.Add(col);
			col=new ODGridColumn(Lan.g("TableRecurring","Total Bal"),90,HorizontalAlignment.Right);
			gridMain.Columns.Add(col);
			col=new ODGridColumn(Lan.g("TableRecurring","ChargeAmt"),100,HorizontalAlignment.Right);
			gridMain.Columns.Add(col);
			gridMain.Rows.Clear();
			OpenDental.UI.ODGridRow row;
			for(int i=0;i<table.Rows.Count;i++) {
				row=new OpenDental.UI.ODGridRow();
				Double famBalTotal=PIn.Double(table.Rows[i]["FamBalTotal"].ToString());
				Double chargeAmt=PIn.Double(table.Rows[i]["ChargeAmt"].ToString());
				row.Cells.Add(table.Rows[i]["PatNum"].ToString());
				row.Cells.Add(table.Rows[i]["PatName"].ToString());
				row.Cells.Add(famBalTotal.ToString("c"));
				row.Cells.Add(chargeAmt.ToString("c"));
				gridMain.Rows.Add(row);
			}
			gridMain.EndUpdate();
			labelTotal.Text=Lan.g(this,"Total=")+table.Rows.Count.ToString();
			labelSelected.Text=Lan.g(this,"Selected=")+gridMain.SelectedIndices.Length.ToString();
		}
Exemplo n.º 3
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            if (!PrefC.GetBool(PrefName.StoreCCnumbers))
            {
                if (Programs.IsEnabled(ProgramName.Xcharge))
                {
                    Program prog = Programs.GetCur(ProgramName.Xcharge);
                    if (!File.Exists(prog.Path))
                    {
                        MsgBox.Show(this, "Path is not valid.");
                        if (Security.IsAuthorized(Permissions.Setup))
                        {
                            FormXchargeSetup FormX = new FormXchargeSetup();
                            FormX.ShowDialog();
                            if (FormX.DialogResult != DialogResult.OK)
                            {
                                return;
                            }
                        }
                    }
                    string           user       = ProgramProperties.GetPropVal(prog.ProgramNum, "Username");
                    string           password   = ProgramProperties.GetPropVal(prog.ProgramNum, "Password");
                    ProcessStartInfo info       = new ProcessStartInfo(prog.Path);
                    string           resultfile = Path.Combine(Path.GetDirectoryName(prog.Path), "XResult.txt");
                    File.Delete(resultfile);                    //delete the old result file.
                    info.Arguments  = "";
                    info.Arguments += "/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE ";
                    info.Arguments += "/RESULTFILE:\"" + resultfile + "\" ";
                    info.Arguments += "/USERID:" + user + " ";
                    info.Arguments += "/PASSWORD:"******" ";
                    info.Arguments += "/VALIDATEARCHIVEVAULTACCOUNT ";
                    info.Arguments += "/STAYONTOP ";
                    info.Arguments += "/SMARTAUTOPROCESS ";
                    info.Arguments += "/AUTOCLOSE ";
                    info.Arguments += "/HIDEMAINWINDOW ";
                    info.Arguments += "/SMALLWINDOW ";
                    info.Arguments += "/NORESULTDIALOG ";
                    info.Arguments += "/TOOLBAREXITBUTTON ";
                    Cursor          = Cursors.WaitCursor;
                    Process process = new Process();
                    process.StartInfo           = info;
                    process.EnableRaisingEvents = true;
                    process.Start();
                    while (!process.HasExited)
                    {
                        Application.DoEvents();
                    }
                    Thread.Sleep(200);                    //Wait 2/10 second to give time for file to be created.
                    Cursor = Cursors.Default;
                    string resulttext    = "";
                    string line          = "";
                    string xChargeToken  = "";
                    string accountMasked = "";
                    string exp           = "";;
                    bool   insertCard    = false;
                    using (TextReader reader = new StreamReader(resultfile)) {
                        line = reader.ReadLine();
                        while (line != null)
                        {
                            if (resulttext != "")
                            {
                                resulttext += "\r\n";
                            }
                            resulttext += line;
                            if (line.StartsWith("RESULT="))
                            {
                                if (line != "RESULT=SUCCESS")
                                {
                                    break;
                                }
                                insertCard = true;
                            }
                            if (line.StartsWith("XCACCOUNTID="))
                            {
                                xChargeToken = PIn.String(line.Substring(12));
                            }
                            if (line.StartsWith("ACCOUNT="))
                            {
                                accountMasked = PIn.String(line.Substring(8));
                            }
                            if (line.StartsWith("EXPIRATION="))
                            {
                                exp = PIn.String(line.Substring(11));
                            }
                            line = reader.ReadLine();
                        }
                        if (insertCard && xChargeToken != "")                       //Might not be necessary but we've had successful charges with no tokens returned before.
                        {
                            CreditCard        creditCardCur  = new CreditCard();
                            List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum);
                            creditCardCur.PatNum         = PatCur.PatNum;
                            creditCardCur.ItemOrder      = itemOrderCount.Count;
                            creditCardCur.CCNumberMasked = accountMasked;
                            creditCardCur.XChargeToken   = xChargeToken;
                            creditCardCur.CCExpiration   = new DateTime(Convert.ToInt32("20" + PIn.String(exp.Substring(2, 2))), Convert.ToInt32(PIn.String(exp.Substring(0, 2))), 1);
                            CreditCards.Insert(creditCardCur);
                        }
                    }
                    RefreshCardList();
                    return;
                }
                else
                {
                    MsgBox.Show(this, "Not allowed to store credit cards.");
                    return;
                }
            }
            bool remember  = false;
            int  placement = listCreditCards.SelectedIndex;

            if (placement != -1)
            {
                remember = true;
            }
            FormCreditCardEdit FormCCE = new FormCreditCardEdit(PatCur);

            FormCCE.CreditCardCur       = new CreditCard();
            FormCCE.CreditCardCur.IsNew = true;
            FormCCE.ShowDialog();
            RefreshCardList();
            if (remember)             //in case they canceled and had one selected
            {
                listCreditCards.SelectedIndex = placement;
            }
            if (FormCCE.DialogResult == DialogResult.OK && creditCards.Count > 0)
            {
                listCreditCards.SelectedIndex = 0;
            }
        }
Exemplo n.º 4
0
        private void listProgram_DoubleClick(object sender, System.EventArgs e)
        {
            if (listProgram.SelectedIndex == -1)
            {
                return;
            }
            Program program = ProgramC.Listt[listProgram.SelectedIndex].Copy();

            if (program.ProgName == "UAppoint")
            {
                FormUAppoint FormU = new FormUAppoint();
                FormU.ProgramCur = program;
                FormU.ShowDialog();
                if (FormU.DialogResult == DialogResult.OK)
                {
                    changed = true;
                    FillList();
                }
                return;
            }
            if (program.ProgName == "eClinicalWorks")
            {
                if (!Security.IsAuthorized(Permissions.SecurityAdmin))
                {
                    return;
                }
                FormEClinicalWorks FormECW = new FormEClinicalWorks();
                FormECW.ProgramCur = program;
                FormECW.ShowDialog();
                if (FormECW.DialogResult == DialogResult.OK)
                {
                    changed = true;
                    FillList();
                }
                return;
            }
            if (program.ProgName == "Mountainside")
            {
                FormMountainside FormM = new FormMountainside();
                FormM.ProgramCur = program;
                FormM.ShowDialog();
                if (FormM.DialogResult == DialogResult.OK)
                {
                    changed = true;
                    FillList();
                }
                return;
            }
            if (program.ProgName == "PayConnect")
            {
                FormPayConnectSetup fpcs = new FormPayConnectSetup();
                fpcs.ShowDialog();
                if (fpcs.DialogResult == DialogResult.OK)
                {
                    changed = true;
                    FillList();
                }
                return;
            }
            if (program.ProgName == "Xcharge")
            {
                FormXchargeSetup fxcs = new FormXchargeSetup();
                fxcs.ShowDialog();
                if (fxcs.DialogResult == DialogResult.OK)
                {
                    changed = true;
                    FillList();
                }
                return;
            }
            FormProgramLinkEdit FormPE = new FormProgramLinkEdit();

            FormPE.ProgramCur = program;
            FormPE.ShowDialog();
            changed = true;
            FillList();
        }
Exemplo n.º 5
0
        private void FormRecurringCharges_Load(object sender, EventArgs e)
        {
            if (Programs.HasMultipleCreditCardProgramsEnabled())
            {
                gridMain.HScrollVisible = true;
            }
            if (!PrefC.IsODHQ)
            {
                checkHideBold.Checked = true;
                checkHideBold.Visible = false;
            }
            Program progCur = null;

            if (Programs.IsEnabled(ProgramName.PaySimple))
            {
                progCur = Programs.GetCur(ProgramName.PaySimple);
                labelUpdated.Visible         = false;
                checkForceDuplicates.Checked = false;
                checkForceDuplicates.Visible = false;              //PaySimple always rejects identical transactions made within 5 minutes of eachother.
            }
            if (Programs.IsEnabled(ProgramName.PayConnect))
            {
                progCur = Programs.GetCur(ProgramName.PayConnect);
                labelUpdated.Visible         = false;
                checkForceDuplicates.Visible = true;
                checkForceDuplicates.Checked = PIn.Bool(ProgramProperties.GetPropValForClinicOrDefault(progCur.ProgramNum,
                                                                                                       PayConnect.ProgramProperties.PayConnectForceRecurringCharge, Clinics.ClinicNum));
            }
            if (Programs.IsEnabled(ProgramName.Xcharge))
            {
                progCur = Programs.GetCur(ProgramName.Xcharge);
                labelUpdated.Visible         = true;
                checkForceDuplicates.Visible = true;
                string xPath = Programs.GetProgramPath(progCur);
                checkForceDuplicates.Checked = PIn.Bool(ProgramProperties.GetPropValForClinicOrDefault(progCur.ProgramNum,
                                                                                                       ProgramProperties.PropertyDescs.XCharge.XChargeForceRecurringCharge, Clinics.ClinicNum));
                if (!File.Exists(xPath))                 //program path is invalid
                //if user has setup permission and they want to edit the program path, show the X-Charge setup window
                {
                    if (Security.IsAuthorized(Permissions.Setup) &&
                        MsgBox.Show(this, MsgBoxButtons.YesNo, "The X-Charge path is not valid.  Would you like to edit the path?"))
                    {
                        FormXchargeSetup FormX = new FormXchargeSetup();
                        FormX.ShowDialog();
                        if (FormX.DialogResult == DialogResult.OK)
                        {
                            //The user could have correctly enabled the X-Charge bridge, we need to update our local _programCur and _xPath variable2
                            progCur = Programs.GetCur(ProgramName.Xcharge);
                            xPath   = Programs.GetProgramPath(progCur);
                        }
                    }
                    //if the program path still does not exist, whether or not they attempted to edit the program link, tell them to edit and close the form
                    if (!File.Exists(xPath))
                    {
                        MsgBox.Show(this, "The X-Charge program path is not valid.  Edit the program link in order to use the CC Recurring Charges feature.");
                        Close();
                        return;
                    }
                }
            }
            if (progCur == null)
            {
                MsgBox.Show(this, "The PayConnect, PaySimple, or X-Charge program link must be enabled in order to use the CC Recurring Charges feature.");
                Close();
                return;
            }
            _isSelecting     = true;
            _listUserClinics = new List <Clinic>();
            if (PrefC.HasClinicsEnabled)
            {
                if (!Security.CurUser.ClinicIsRestricted)
                {
                    _listUserClinics.Add(new Clinic()
                    {
                        Description = Lan.g(this, "Unassigned")
                    });
                }
                Clinics.GetForUserod(Security.CurUser).ForEach(x => _listUserClinics.Add(x));
                for (int i = 0; i < _listUserClinics.Count; i++)
                {
                    listClinics.Items.Add(_listUserClinics[i].Description);
                    listClinics.SetSelected(i, true);
                }
                //checkAllClin.Checked=true;//checked true by default in designer so we don't trigger the event to select all and fill grid
            }
            else
            {
                groupClinics.Visible = false;
            }
            _charger = new RecurringChargerator(new ShowErrors(this), true);
            _charger.SingleCardFinished = new Action(() => {
                this.Invoke(() => {
                    labelCharged.Text = Lans.g(this, "Charged=") + _charger.Success;
                    labelFailed.Text  = Lans.g(this, "Failed=") + _charger.Failed;
                    labelUpdated.Text = Lans.g(this, "Updated=") + _charger.Updated;
                });
            });
            GeneralProgramEvent.Fired += StopRecurringCharges;          //This is so we'll be alerted in case of a shutdown.
            labelCharged.Text          = Lan.g(this, "Charged=") + "0";
            labelFailed.Text           = Lan.g(this, "Failed=") + "0";
            FillGrid(true);
            gridMain.SetSelected(true);
            labelSelected.Text = Lan.g(this, "Selected=") + gridMain.SelectedIndices.Length.ToString();
        }
Exemplo n.º 6
0
		private void butOK_Click(object sender,EventArgs e) {
			if(!VerifyData()) {
				return;
			}
			CreditCardCur.Address=textAddress.Text;
			CreditCardCur.CCNumberMasked=textCardNumber.Text;
			CreditCardCur.PatNum=PatCur.PatNum;
			CreditCardCur.Zip=textZip.Text;
			if(IsXCharge) {//Only update recurring if using X-Charge.
				CreditCardCur.ChargeAmt=PIn.Double(textChargeAmt.Text);
				CreditCardCur.DateStart=PIn.Date(textDateStart.Text);
				CreditCardCur.DateStop=PIn.Date(textDateStop.Text);
				CreditCardCur.Note=textNote.Text;
				if(comboPaymentPlans.SelectedIndex>0) {
					CreditCardCur.PayPlanNum=PayPlanList[comboPaymentPlans.SelectedIndex-1].PayPlanNum;
				}
				else {
					CreditCardCur.PayPlanNum=0;//Allows users to change from a recurring payplan charge to a normal one.
				}
			}
			if(CreditCardCur.IsNew) {
				List<CreditCard> itemOrderCount=CreditCards.Refresh(PatCur.PatNum);
				CreditCardCur.ItemOrder=itemOrderCount.Count;
				CreditCards.Insert(CreditCardCur);
			}
			else {
				#region X-Charge
				//Special logic for had a token and changed number or expiration date
				if(CreditCardCur.XChargeToken!="" && IsXCharge &&
					(CreditCardOld.CCNumberMasked!=CreditCardCur.CCNumberMasked || CreditCardOld.CCExpiration!=CreditCardCur.CCExpiration)) 
				{ 
					Program prog=Programs.GetCur(ProgramName.Xcharge);
					string path=Programs.GetProgramPath(prog);
					if(prog==null){
						MsgBox.Show(this,"X-Charge entry is missing from the database.");//should never happen
						return;
					}
					if(!prog.Enabled){
						if(Security.IsAuthorized(Permissions.Setup)){
							FormXchargeSetup FormX=new FormXchargeSetup();
							FormX.ShowDialog();
						}
						return;
					}
					if(!File.Exists(path)){
						MsgBox.Show(this,"Path is not valid.");
						if(Security.IsAuthorized(Permissions.Setup)){
							FormXchargeSetup FormX=new FormXchargeSetup();
							FormX.ShowDialog();
						}
						return;
					}
					//Either update the exp date or update credit card number by deleting archive so new token can be created next time it's used.
					ProgramProperty prop=(ProgramProperty)ProgramProperties.GetForProgram(prog.ProgramNum)[0];
					ProcessStartInfo info=new ProcessStartInfo(path);
					string resultfile=Path.Combine(Path.GetDirectoryName(path),"XResult.txt");
					try {
						File.Delete(resultfile);//delete the old result file.
					}
					catch {
						MsgBox.Show(this,"Could not delete XResult.txt file.  It may be in use by another program, flagged as read-only, or you might not have sufficient permissions.");
						return;
					}
					if(CreditCardOld.CCNumberMasked!=CreditCardCur.CCNumberMasked) {//They changed card number which we have to delete archived token which will create a new one next time card is charged.
						info.Arguments+="/TRANSACTIONTYPE:ARCHIVEVAULTDELETE ";
						info.Arguments+="/XCACCOUNTID:"+CreditCardCur.XChargeToken+" ";
						info.Arguments+="/RESULTFILE:\""+resultfile+"\" ";
						info.Arguments+="/USERID:"+ProgramProperties.GetPropVal(prog.ProgramNum,"Username")+" ";
						info.Arguments+="/PASSWORD:"******"Password"))+" ";
						info.Arguments+="/AUTOPROCESS ";
						info.Arguments+="/AUTOCLOSE ";
						CreditCardCur.XChargeToken="";//Clear the XChargeToken in our db.
					}
					else {//We can only change exp date for X-Charge via ARCHIVEAULTUPDATE.
						info.Arguments+="/TRANSACTIONTYPE:ARCHIVEVAULTUPDATE ";
						info.Arguments+="/XCACCOUNTID:"+CreditCardCur.XChargeToken+" ";
						if(CreditCardCur.CCExpiration!=null && CreditCardCur.CCExpiration.Year>2005) {
							info.Arguments+="/EXP:"+CreditCardCur.CCExpiration.ToString("MMyy")+" ";
						}
						info.Arguments+="/RESULTFILE:\""+resultfile+"\" ";
						info.Arguments+="/USERID:"+ProgramProperties.GetPropVal(prog.ProgramNum,"Username")+" ";
						info.Arguments+="/PASSWORD:"******"Password"))+" ";
						info.Arguments+="/AUTOPROCESS ";
						info.Arguments+="/AUTOCLOSE ";
					}
					Cursor=Cursors.WaitCursor;
					Process process=new Process();
					process.StartInfo=info;
					process.EnableRaisingEvents=true;
					process.Start();
					while(!process.HasExited) {
						Application.DoEvents();
					}
					Thread.Sleep(200);//Wait 2/10 second to give time for file to be created.
					Cursor=Cursors.Default;
					string resulttext="";
					string line="";
					try {
						using(TextReader reader=new StreamReader(resultfile)) {
							line=reader.ReadLine();
							while(line!=null) {
								if(resulttext!="") {
									resulttext+="\r\n";
								}
								resulttext+=line;
								if(line.StartsWith("RESULT=")) {
									if(line!="RESULT=SUCCESS") {
										CreditCardCur=CreditCards.GetOne(CreditCardCur.CreditCardNum);
										FillData();
										return;
									}
								}
								line=reader.ReadLine();
							}
						}
					}
					catch {
						MsgBox.Show(this,"There was a problem creating or editing this card with X-Charge.  Please try again.");
						return;
					}
				}//End of special token logic
				#endregion
				CreditCards.Update(CreditCardCur);
			}
			DialogResult=DialogResult.OK;
		}
Exemplo n.º 7
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            if (!PrefC.GetBool(PrefName.StoreCCnumbers))
            {
                bool hasXCharge    = false;
                bool hasPayConnect = false;
                bool hasPaySimple  = false;
                Dictionary <string, int> dictEnabledProcessors = new Dictionary <string, int>();
                int  idx = 0;
                bool hasXChargePreventCcAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.Xcharge).ProgramNum,
                                                                                    ProgramProperties.PropertyDescs.XCharge.XChargePreventSavingNewCC, Clinics.ClinicNum));
                if (Programs.IsEnabled(ProgramName.Xcharge) && !hasXChargePreventCcAdd)
                {
                    dictEnabledProcessors["X-Charge"] = idx++;
                }
                bool hasPayConnectPreventCcAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PayConnect).ProgramNum,
                                                                                       PayConnect.ProgramProperties.PayConnectPreventSavingNewCC, Clinics.ClinicNum));
                if (Programs.IsEnabled(ProgramName.PayConnect) && !hasPayConnectPreventCcAdd)
                {
                    dictEnabledProcessors["PayConnect"] = idx++;
                }
                bool hasPaySimplePreventCCAdd = PIn.Bool(ProgramProperties.GetPropVal(Programs.GetCur(ProgramName.PaySimple).ProgramNum,
                                                                                      PaySimple.PropertyDescs.PaySimplePreventSavingNewCC, Clinics.ClinicNum));
                if (Programs.IsEnabled(ProgramName.PaySimple) && !hasPaySimplePreventCCAdd)
                {
                    dictEnabledProcessors["PaySimple"] = idx++;
                }
                if (dictEnabledProcessors.Count > 1)
                {
                    List <string> listCCProcessors = dictEnabledProcessors.Select(x => x.Key).ToList();
                    InputBox      chooseProcessor  =
                        new InputBox(Lan.g(this, "For which credit card processing company would you like to add this card?"), listCCProcessors, true);
                    if (chooseProcessor.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    hasXCharge    = dictEnabledProcessors.ContainsKey("X-Charge") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["X-Charge"]);
                    hasPayConnect = dictEnabledProcessors.ContainsKey("PayConnect") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["PayConnect"]);
                    hasPaySimple  = dictEnabledProcessors.ContainsKey("PaySimple") && chooseProcessor.SelectedIndices.Contains(dictEnabledProcessors["PaySimple"]);
                }
                else if (Programs.IsEnabled(ProgramName.Xcharge) && !hasXChargePreventCcAdd)
                {
                    hasXCharge = true;
                }
                else if (Programs.IsEnabled(ProgramName.PayConnect) && !hasPayConnectPreventCcAdd)
                {
                    hasPayConnect = true;
                }
                else if (Programs.IsEnabled(ProgramName.PaySimple) && !hasPaySimplePreventCCAdd)
                {
                    hasPaySimple = true;
                }
                else                  //not storing CC numbers and both PayConnect and X-Charge are disabled
                {
                    MsgBox.Show(this, "Not allowed to store credit cards.");
                    return;
                }
                CreditCard creditCardCur = null;
                if (hasXCharge)
                {
                    if (ODBuild.IsWeb())
                    {
                        MsgBox.Show(this, "XCharge is not available while viewing through the web.");
                        return;
                    }
                    Program prog      = Programs.GetCur(ProgramName.Xcharge);
                    string  path      = Programs.GetProgramPath(prog);
                    string  xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum).Trim();
                    string  xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum).Trim();
                    //Force user to retry entering information until it's correct or they press cancel
                    while (!File.Exists(path) || string.IsNullOrEmpty(xPassword) || string.IsNullOrEmpty(xUsername))
                    {
                        MsgBox.Show(this, "The Path, Username, and/or Password for X-Charge have not been set or are invalid.");
                        if (!Security.IsAuthorized(Permissions.Setup))
                        {
                            return;
                        }
                        FormXchargeSetup FormX = new FormXchargeSetup();                 //refreshes program and program property caches on OK click
                        FormX.ShowDialog();
                        if (FormX.DialogResult != DialogResult.OK)                       //if user presses cancel, return
                        {
                            return;
                        }
                        prog      = Programs.GetCur(ProgramName.Xcharge);                 //refresh local variable prog to reflect any changes made in setup window
                        path      = Programs.GetProgramPath(prog);
                        xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum).Trim();
                        xPassword = ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum).Trim();
                    }
                    xPassword = CodeBase.MiscUtils.Decrypt(xPassword);
                    ProcessStartInfo info       = new ProcessStartInfo(path);
                    string           resultfile = PrefC.GetRandomTempFile("txt");
                    try {
                        File.Delete(resultfile);                        //delete the old result file.
                    }
                    catch {
                        MsgBox.Show(this, "Could not delete XResult.txt file.  It may be in use by another program, flagged as read-only, or you might not have sufficient permissions.");
                        return;
                    }
                    info.Arguments  = "";
                    info.Arguments += "/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE ";
                    info.Arguments += "/RESULTFILE:\"" + resultfile + "\" ";
                    info.Arguments += "/USERID:" + xUsername + " ";
                    info.Arguments += "/PASSWORD:"******" ";
                    info.Arguments += "/VALIDATEARCHIVEVAULTACCOUNT ";
                    info.Arguments += "/STAYONTOP ";
                    info.Arguments += "/SMARTAUTOPROCESS ";
                    info.Arguments += "/AUTOCLOSE ";
                    info.Arguments += "/HIDEMAINWINDOW ";
                    info.Arguments += "/SMALLWINDOW ";
                    info.Arguments += "/NORESULTDIALOG ";
                    info.Arguments += "/TOOLBAREXITBUTTON ";
                    Cursor          = Cursors.WaitCursor;
                    Process process = new Process();
                    process.StartInfo           = info;
                    process.EnableRaisingEvents = true;
                    process.Start();
                    while (!process.HasExited)
                    {
                        Application.DoEvents();
                    }
                    Thread.Sleep(200);                    //Wait 2/10 second to give time for file to be created.
                    Cursor = Cursors.Default;
                    string resulttext    = "";
                    string line          = "";
                    string xChargeToken  = "";
                    string accountMasked = "";
                    string exp           = "";;
                    bool   insertCard    = false;
                    try {
                        using (TextReader reader = new StreamReader(resultfile)) {
                            line = reader.ReadLine();
                            while (line != null)
                            {
                                if (resulttext != "")
                                {
                                    resulttext += "\r\n";
                                }
                                resulttext += line;
                                if (line.StartsWith("RESULT="))
                                {
                                    if (line != "RESULT=SUCCESS")
                                    {
                                        throw new Exception();
                                    }
                                    insertCard = true;
                                }
                                if (line.StartsWith("XCACCOUNTID="))
                                {
                                    xChargeToken = PIn.String(line.Substring(12));
                                }
                                if (line.StartsWith("ACCOUNT="))
                                {
                                    accountMasked = PIn.String(line.Substring(8));
                                }
                                if (line.StartsWith("EXPIRATION="))
                                {
                                    exp = PIn.String(line.Substring(11));
                                }
                                line = reader.ReadLine();
                            }
                            if (insertCard && xChargeToken != "")                           //Might not be necessary but we've had successful charges with no tokens returned before.
                            {
                                creditCardCur = new CreditCard();
                                List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum);
                                creditCardCur.PatNum         = PatCur.PatNum;
                                creditCardCur.ItemOrder      = itemOrderCount.Count;
                                creditCardCur.CCNumberMasked = accountMasked;
                                creditCardCur.XChargeToken   = xChargeToken;
                                creditCardCur.CCExpiration   = new DateTime(Convert.ToInt32("20" + PIn.String(exp.Substring(2, 2))), Convert.ToInt32(PIn.String(exp.Substring(0, 2))), 1);
                                creditCardCur.Procedures     = PrefC.GetString(PrefName.DefaultCCProcs);
                                creditCardCur.CCSource       = CreditCardSource.XServer;
                                creditCardCur.ClinicNum      = Clinics.ClinicNum;
                                CreditCards.Insert(creditCardCur);
                            }
                        }
                    }
                    catch (Exception) {
                        MsgBox.Show(this, "There was a problem adding the credit card.  Please try again.");
                    }
                }
                if (hasPayConnect)
                {
                    FormPayConnect FormPC = new FormPayConnect(Clinics.ClinicNum, PatCur, (decimal)0.01, creditCardCur, true);
                    FormPC.ShowDialog();
                }
                if (hasPaySimple)
                {
                    FormPaySimple formPS = new FormPaySimple(Clinics.ClinicNum, PatCur, (decimal)0.01, creditCardCur, true);
                    formPS.ShowDialog();
                }
                FillGrid();
                if (gridMain.ListGridRows.Count > 0 && creditCardCur != null)
                {
                    gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true);
                }
                return;
            }
            //storing CC numbers allowed from here down
            FormCreditCardEdit FormCCE = new FormCreditCardEdit(PatCur);

            FormCCE.CreditCardCur            = new CreditCard();
            FormCCE.CreditCardCur.IsNew      = true;
            FormCCE.CreditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs);
            FormCCE.ShowDialog();
            if (FormCCE.DialogResult == DialogResult.OK)
            {
                FillGrid();
                if (gridMain.ListGridRows.Count > 0)
                {
                    gridMain.SetSelected(gridMain.ListGridRows.Count - 1, true);
                }
            }
        }
Exemplo n.º 8
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (!VerifyData())
     {
         return;
     }
     CreditCardCur.Address        = textAddress.Text;
     CreditCardCur.CCNumberMasked = textCardNumber.Text;
     CreditCardCur.PatNum         = PatCur.PatNum;
     CreditCardCur.Zip            = textZip.Text;
     if (IsXCharge)             //Only update recurring if using X-Charge.
     {
         CreditCardCur.ChargeAmt = PIn.Double(textChargeAmt.Text);
         CreditCardCur.DateStart = PIn.Date(textDateStart.Text);
         CreditCardCur.DateStop  = PIn.Date(textDateStop.Text);
         CreditCardCur.Note      = textNote.Text;
         if (comboPaymentPlans.SelectedIndex > 0)
         {
             CreditCardCur.PayPlanNum = PayPlanList[comboPaymentPlans.SelectedIndex - 1].PayPlanNum;
         }
         else
         {
             CreditCardCur.PayPlanNum = 0;                  //Allows users to change from a recurring payplan charge to a normal one.
         }
     }
     if (CreditCardCur.IsNew)
     {
         List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum);
         CreditCardCur.ItemOrder = itemOrderCount.Count;
         CreditCards.Insert(CreditCardCur);
     }
     else
     {
         #region X-Charge
         //Special logic for had a token and changed number or expiration date
         if (CreditCardCur.XChargeToken != "" && IsXCharge &&
             (CreditCardOld.CCNumberMasked != CreditCardCur.CCNumberMasked || CreditCardOld.CCExpiration != CreditCardCur.CCExpiration))
         {
             Program prog = Programs.GetCur(ProgramName.Xcharge);
             if (prog == null)
             {
                 MsgBox.Show(this, "X-Charge entry is missing from the database.");                       //should never happen
                 return;
             }
             if (!prog.Enabled)
             {
                 if (Security.IsAuthorized(Permissions.Setup))
                 {
                     FormXchargeSetup FormX = new FormXchargeSetup();
                     FormX.ShowDialog();
                 }
                 return;
             }
             if (!File.Exists(prog.Path))
             {
                 MsgBox.Show(this, "Path is not valid.");
                 if (Security.IsAuthorized(Permissions.Setup))
                 {
                     FormXchargeSetup FormX = new FormXchargeSetup();
                     FormX.ShowDialog();
                 }
                 return;
             }
             //Either update the exp date or update credit card number by deleting archive so new token can be created next time it's used.
             ProgramProperty  prop       = (ProgramProperty)ProgramProperties.GetForProgram(prog.ProgramNum)[0];
             ProcessStartInfo info       = new ProcessStartInfo(prog.Path);
             string           resultfile = Path.Combine(Path.GetDirectoryName(prog.Path), "XResult.txt");
             File.Delete(resultfile);                                          //delete the old result file.
             if (CreditCardOld.CCNumberMasked != CreditCardCur.CCNumberMasked) //They changed card number which we have to delete archived token which will create a new one next time card is charged.
             {
                 info.Arguments            += "/TRANSACTIONTYPE:ARCHIVEVAULTDELETE ";
                 info.Arguments            += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " ";
                 info.Arguments            += "/RESULTFILE:\"" + resultfile + "\" ";
                 info.Arguments            += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username") + " ";
                 info.Arguments            += "/PASSWORD:"******"Password") + " ";
                 info.Arguments            += "/AUTOPROCESS ";
                 info.Arguments            += "/AUTOCLOSE ";
                 CreditCardCur.XChargeToken = ""; //Clear the XChargeToken in our db.
             }
             else                                 //We can only change exp date for X-Charge via ARCHIVEAULTUPDATE.
             {
                 info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTUPDATE ";
                 info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " ";
                 if (CreditCardCur.CCExpiration != null && CreditCardCur.CCExpiration.Year > 2005)
                 {
                     info.Arguments += "/EXP:" + CreditCardCur.CCExpiration.ToString("MMyy") + " ";
                 }
                 info.Arguments += "/RESULTFILE:\"" + resultfile + "\" ";
                 info.Arguments += "/USERID:" + ProgramProperties.GetPropVal(prog.ProgramNum, "Username") + " ";
                 info.Arguments += "/PASSWORD:"******"Password") + " ";
                 info.Arguments += "/AUTOPROCESS ";
                 info.Arguments += "/AUTOCLOSE ";
             }
             Cursor = Cursors.WaitCursor;
             Process process = new Process();
             process.StartInfo           = info;
             process.EnableRaisingEvents = true;
             process.Start();
             while (!process.HasExited)
             {
                 Application.DoEvents();
             }
             Thread.Sleep(200);                    //Wait 2/10 second to give time for file to be created.
             Cursor = Cursors.Default;
             string resulttext = "";
             string line       = "";
             using (TextReader reader = new StreamReader(resultfile)) {
                 line = reader.ReadLine();
                 while (line != null)
                 {
                     if (resulttext != "")
                     {
                         resulttext += "\r\n";
                     }
                     resulttext += line;
                     if (line.StartsWith("RESULT="))
                     {
                         if (line != "RESULT=SUCCESS")
                         {
                             CreditCardCur = CreditCards.GetOne(CreditCardCur.CreditCardNum);
                             FillData();
                             return;
                         }
                     }
                     line = reader.ReadLine();
                 }
             }
         }                //End of special token logic
         #endregion
         CreditCards.Update(CreditCardCur);
     }
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 9
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (!VerifyData())
     {
         return;
     }
     CreditCardCur.ExcludeProcSync = checkExcludeProcSync.Checked;
     CreditCardCur.Address         = textAddress.Text;
     CreditCardCur.CCNumberMasked  = textCardNumber.Text;
     CreditCardCur.PatNum          = PatCur.PatNum;
     CreditCardCur.Zip             = textZip.Text;
     //Create an Audit Trail whenever CanChargeWhenNoBal changes
     if (checkChrgWithNoBal.Checked != CreditCardCur.CanChargeWhenNoBal)
     {
         SecurityLogs.MakeLogEntry(Permissions.AccountModule, PatCur.PatNum, "Credit Card " + CreditCardCur.CCNumberMasked + " set to "
                                   + (CreditCardCur.CanChargeWhenNoBal?"":"not ") + "run charges even when no patient balance is present.");
     }
     CreditCardCur.CanChargeWhenNoBal = checkChrgWithNoBal.Checked;
     if (_isXChargeEnabled || _isPayConnectEnabled || _isPaySimpleEnabled)             //Only update recurring if using X-Charge, PayConnect,or PaySimple.
     {
         CreditCardCur.ChargeAmt = PIn.Double(textChargeAmt.Text);
         CreditCardCur.DateStart = PIn.Date(textDateStart.Text);
         CreditCardCur.DateStop  = PIn.Date(textDateStop.Text);
         CreditCardCur.Note      = textNote.Text;
         if (comboPaymentPlans.SelectedIndex > 0)
         {
             CreditCardCur.PayPlanNum = PayPlanList[comboPaymentPlans.SelectedIndex - 1].PayPlanNum;
         }
         else
         {
             CreditCardCur.PayPlanNum = 0;                  //Allows users to change from a recurring payplan charge to a normal one.
         }
         CreditCardCur.ChargeFrequency = GetFormattedChargeFrequency();
     }
     if (CreditCardCur.IsNew)
     {
         List <CreditCard> itemOrderCount = CreditCards.Refresh(PatCur.PatNum);
         CreditCardCur.ItemOrder = itemOrderCount.Count;
         CreditCardCur.CCSource  = CreditCardSource.None;
         CreditCardCur.ClinicNum = Clinics.ClinicNum;
         CreditCards.Insert(CreditCardCur);
     }
     else
     {
         #region X-Charge
         //Special logic for had a token and changed number or expiration date X-Charge
         if (_isXChargeEnabled && CreditCardCur.XChargeToken != "" &&
             (_creditCardOld.CCNumberMasked != CreditCardCur.CCNumberMasked || _creditCardOld.CCExpiration != CreditCardCur.CCExpiration))
         {
             Program prog = Programs.GetCur(ProgramName.Xcharge);
             string  path = Programs.GetProgramPath(prog);
             if (prog == null)
             {
                 MsgBox.Show(this, "X-Charge entry is missing from the database.");                       //should never happen
                 return;
             }
             if (!prog.Enabled)
             {
                 if (Security.IsAuthorized(Permissions.Setup))
                 {
                     FormXchargeSetup FormX = new FormXchargeSetup();
                     FormX.ShowDialog();
                 }
                 return;
             }
             if (!File.Exists(path))
             {
                 MsgBox.Show(this, "Path is not valid.");
                 if (Security.IsAuthorized(Permissions.Setup))
                 {
                     FormXchargeSetup FormX = new FormXchargeSetup();
                     FormX.ShowDialog();
                 }
                 return;
             }
             //Either update the exp date or update credit card number by deleting archive so new token can be created next time it's used.
             ProcessStartInfo info       = new ProcessStartInfo(path);
             string           resultfile = PrefC.GetRandomTempFile("txt");
             try {
                 File.Delete(resultfile);                        //delete the old result file.
             }
             catch {
                 MsgBox.Show(this, "Could not delete XResult.txt file.  It may be in use by another program, flagged as read-only, or you might not have sufficient permissions.");
                 return;
             }
             string xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum);
             string xPassword = CodeBase.MiscUtils.Decrypt(ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum));
             //We can only change exp date for X-Charge via ARCHIVEAULTUPDATE.
             info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTUPDATE ";
             info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " ";
             if (CreditCardCur.CCExpiration != null && CreditCardCur.CCExpiration.Year > 2005)
             {
                 info.Arguments += "/EXP:" + CreditCardCur.CCExpiration.ToString("MMyy") + " ";
             }
             info.Arguments += "/RESULTFILE:\"" + resultfile + "\" ";
             info.Arguments += "/USERID:" + xUsername + " ";
             info.Arguments += "/PASSWORD:"******" ";
             info.Arguments += "/AUTOPROCESS ";
             info.Arguments += "/AUTOCLOSE ";
             Cursor          = Cursors.WaitCursor;
             Process process = new Process();
             process.StartInfo           = info;
             process.EnableRaisingEvents = true;
             process.Start();
             while (!process.HasExited)
             {
                 Application.DoEvents();
             }
             Thread.Sleep(200);                    //Wait 2/10 second to give time for file to be created.
             Cursor = Cursors.Default;
             string resulttext = "";
             string line       = "";
             try {
                 using (TextReader reader = new StreamReader(resultfile)) {
                     line = reader.ReadLine();
                     while (line != null)
                     {
                         if (resulttext != "")
                         {
                             resulttext += "\r\n";
                         }
                         resulttext += line;
                         if (line.StartsWith("RESULT="))
                         {
                             if (line != "RESULT=SUCCESS")
                             {
                                 CreditCardCur = CreditCards.GetOne(CreditCardCur.CreditCardNum);
                                 FillData();
                                 return;
                             }
                         }
                         line = reader.ReadLine();
                     }
                 }
             }
             catch {
                 MsgBox.Show(this, "There was a problem creating or editing this card with X-Charge.  Please try again.");
                 return;
             }
         }                //End of special token logic
         #endregion
         #region PayConnect
         //Special logic for had a token and changed expiration date PayConnect
         //We have to compare the year and month of the expiration instead of just comparing expirations because the X-Charge logic stores the
         //expiration day of the month as the 1st in the db, but it makes more sense to set the expriation day of month to the last day in that month.
         //Since we only want to invalidate the PayConnect token if the expiration month or year is different, we will ignore any difference in day.
         if (_isPayConnectEnabled && CreditCardCur.PayConnectToken != "" &&
             (_creditCardOld.CCExpiration.Year != CreditCardCur.CCExpiration.Year ||
              _creditCardOld.CCExpiration.Month != CreditCardCur.CCExpiration.Month))
         {
             //if the expiration is changed, the token is no longer valid, so clear the token and token expiration so a new one can be
             //generated the next time a payment is processed using this card.
             CreditCardCur.PayConnectToken    = "";
             CreditCardCur.PayConnectTokenExp = DateTime.MinValue;
             //To match PaySimple, this should be enhanced to validate the cc number and get a new token.
         }
         #endregion
         #region PaySimple
         //Special logic for had a token and changed number or expiration date PaySimple
         //We have to compare the year and month of the expiration instead of just comparing expirations because the X-Charge logic stores the
         //expiration day of the month as the 1st in the db, but it makes more sense to set the expriation day of month to the last day in that month.
         //Since we only want to invalidate the PayConnect token if the expiration month or year is different, we will ignore any difference in day.
         if (_isPaySimpleEnabled && CreditCardCur.PaySimpleToken != "" &&
             (_creditCardOld.Zip != CreditCardCur.Zip ||
              _creditCardOld.CCExpiration.Year != CreditCardCur.CCExpiration.Year ||
              _creditCardOld.CCExpiration.Month != CreditCardCur.CCExpiration.Month))
         {
             //TODO: Open form to have user enter the CC number.  Then make API call to update cc instead of wiping out token.
             //If the billing zip or the expiration changes, the token is invalid and they need to get a new one.
             CreditCardCur.PaySimpleToken = "";
         }
         #endregion
         CreditCards.Update(CreditCardCur);
     }
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 10
0
        private void DeleteXChargeAlias()
        {
            Program prog = Programs.GetCur(ProgramName.Xcharge);
            string  path = Programs.GetProgramPath(prog);

            if (prog == null)
            {
                MsgBox.Show(this, "X-Charge entry is missing from the database.");               //should never happen
                return;
            }
            if (!prog.Enabled)
            {
                if (Security.IsAuthorized(Permissions.Setup))
                {
                    FormXchargeSetup FormX = new FormXchargeSetup();
                    FormX.ShowDialog();
                }
                return;
            }
            if (!File.Exists(path))
            {
                MsgBox.Show(this, "Path is not valid.");
                if (Security.IsAuthorized(Permissions.Setup))
                {
                    FormXchargeSetup FormX = new FormXchargeSetup();
                    FormX.ShowDialog();
                }
                return;
            }
            ProcessStartInfo info       = new ProcessStartInfo(path);
            string           resultfile = PrefC.GetRandomTempFile("txt");

            try {
                File.Delete(resultfile);                //delete the old result file.
            }
            catch {
                MsgBox.Show(this, "Could not delete XResult.txt file.  It may be in use by another program, flagged as read-only, or you might not have "
                            + "sufficient permissions.");
                return;
            }
            string xUsername = ProgramProperties.GetPropVal(prog.ProgramNum, "Username", Clinics.ClinicNum);
            string xPassword = CodeBase.MiscUtils.Decrypt(ProgramProperties.GetPropVal(prog.ProgramNum, "Password", Clinics.ClinicNum));

            info.Arguments += "/TRANSACTIONTYPE:ARCHIVEVAULTDELETE ";
            info.Arguments += "/XCACCOUNTID:" + CreditCardCur.XChargeToken + " ";
            info.Arguments += "/RESULTFILE:\"" + resultfile + "\" ";
            info.Arguments += "/USERID:" + xUsername + " ";
            info.Arguments += "/PASSWORD:"******" ";
            info.Arguments += "/AUTOPROCESS ";
            info.Arguments += "/AUTOCLOSE ";
            Cursor          = Cursors.WaitCursor;
            Process process = new Process();

            process.StartInfo           = info;
            process.EnableRaisingEvents = true;
            process.Start();
            while (!process.HasExited)
            {
                Application.DoEvents();
            }
            Thread.Sleep(200);            //Wait 2/10 second to give time for file to be created.
            Cursor = Cursors.Default;
            string line = "";

            try {
                using (TextReader reader = new StreamReader(resultfile)) {
                    line = reader.ReadLine();
                    while (line != null)
                    {
                        if (line == "RESULT=SUCCESS")
                        {
                            break;
                        }
                        if (line.StartsWith("DESCRIPTION") && !line.Contains("Alias does not exist"))                         //If token doesn't exist in X-Charge, still delete from OD
                        {
                            MsgBox.Show(this, "There was a problem deleting this card within X-Charge.  Please try again.");
                            return;                            //Don't delete the card from OD
                        }
                        line = reader.ReadLine();
                    }
                }
            }
            catch {
                MsgBox.Show(this, "Could not read XResult.txt file.  It may be in use by another program, flagged as read-only, or you might not have "
                            + "sufficient permissions.");
                return;
            }
        }
Exemplo n.º 11
0
        private void gridProgram_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            DialogResult dResult = DialogResult.None;
            Program      program = _listPrograms[gridProgram.GetSelectedIndex()].Copy();

            switch (program.ProgName)
            {
            case "UAppoint":
                FormUAppoint FormU = new FormUAppoint();
                FormU.ProgramCur = program;
                dResult          = FormU.ShowDialog();
                break;

            case "eClinicalWorks":
                if (!Security.IsAuthorized(Permissions.SecurityAdmin))
                {
                    break;
                }
                FormEClinicalWorks FormECW = new FormEClinicalWorks();
                FormECW.ProgramCur = program;
                dResult            = FormECW.ShowDialog();
                break;

            case "eRx":
                FormErxSetup FormES = new FormErxSetup();
                dResult = FormES.ShowDialog();
                break;

            case "Mountainside":
                FormMountainside FormM = new FormMountainside();
                FormM.ProgramCur = program;
                dResult          = FormM.ShowDialog();
                break;

            case "PayConnect":
                FormPayConnectSetup fpcs = new FormPayConnectSetup();
                dResult = fpcs.ShowDialog();
                break;

            case "Podium":
                FormPodiumSetup FormPS = new FormPodiumSetup();
                dResult = FormPS.ShowDialog();
                break;

            case "Xcharge":
                FormXchargeSetup fxcs = new FormXchargeSetup();
                dResult = fxcs.ShowDialog();
                break;

            case "FHIR":
                FormFHIRSetup FormFS = new FormFHIRSetup();
                dResult = FormFS.ShowDialog();
                break;

            case "Transworld":
                FormTransworldSetup FormTs = new FormTransworldSetup();
                dResult = FormTs.ShowDialog();
                break;

            case "PaySimple":
                FormPaySimpleSetup formPS = new FormPaySimpleSetup();
                dResult = formPS.ShowDialog();
                break;

            default:
                FormProgramLinkEdit FormPE = new FormProgramLinkEdit();
                if (Programs.IsStatic(program))
                {
                    FormPE.AllowToolbarChanges = false;
                }
                FormPE.ProgramCur = program;
                dResult           = FormPE.ShowDialog();
                break;
            }
            if (dResult == DialogResult.OK)
            {
                changed = true;
                FillList();
            }
        }
Exemplo n.º 12
0
 private void menuXcharge_Click(object sender,EventArgs e)
 {
     if(Security.IsAuthorized(Permissions.Setup)) {
         FormXchargeSetup FormX=new FormXchargeSetup();
         if(FormX.ShowDialog()==DialogResult.OK) {
             CheckUIState();
         }
     }
 }
Exemplo n.º 13
0
 private bool HasXCharge()
 {
     prog=Programs.GetCur(ProgramName.Xcharge);
     if(prog==null) {
         MsgBox.Show(this,"X-Charge entry is missing from the database.");//should never happen
         return false;
     }
     if(!prog.Enabled) {
         if(Security.IsAuthorized(Permissions.Setup)) {
             FormXchargeSetup FormX=new FormXchargeSetup();
             FormX.ShowDialog();
         }
         return false;
     }
     if(!File.Exists(prog.Path)) {
         MsgBox.Show(this,"Path is not valid.");
         if(Security.IsAuthorized(Permissions.Setup)) {
             FormXchargeSetup FormX=new FormXchargeSetup();
             FormX.ShowDialog();
         }
         return false;
     }
     return true;
 }
Exemplo n.º 14
0
		private void listProgram_DoubleClick(object sender, System.EventArgs e) {
			if(listProgram.SelectedIndex==-1){
				return;
			}
			Program program=ProgramC.Listt[listProgram.SelectedIndex].Copy();
			if(program.ProgName=="UAppoint"){
				FormUAppoint FormU=new FormUAppoint();
				FormU.ProgramCur=program;
				FormU.ShowDialog();
				if(FormU.DialogResult==DialogResult.OK){
					changed=true;
					FillList();
				}
				return;
			}
			if(program.ProgName=="eClinicalWorks") {
				if(!Security.IsAuthorized(Permissions.SecurityAdmin)) {
					return;
				}
				FormEClinicalWorks FormECW=new FormEClinicalWorks();
				FormECW.ProgramCur=program;
				FormECW.ShowDialog();
				if(FormECW.DialogResult==DialogResult.OK) {
					changed=true;
					FillList();
				}
				return;
			}
			if(program.ProgName=="Mountainside") {
				FormMountainside FormM=new FormMountainside();
				FormM.ProgramCur=program;
				FormM.ShowDialog();
				if(FormM.DialogResult==DialogResult.OK) {
					changed=true;
					FillList();
				}
				return;
			}
			if(program.ProgName=="PayConnect") {
				FormPayConnectSetup fpcs=new FormPayConnectSetup();
				fpcs.ShowDialog();
				if(fpcs.DialogResult==DialogResult.OK) {
					changed=true;
					FillList();
				}
				return;
			}
			if(program.ProgName=="Xcharge") {
				FormXchargeSetup fxcs=new FormXchargeSetup();
				fxcs.ShowDialog();
				if(fxcs.DialogResult==DialogResult.OK) {
					changed=true;
					FillList();
				}
				return;
			}
			FormProgramLinkEdit FormPE=new FormProgramLinkEdit();
			FormPE.ProgramCur=program;
			FormPE.ShowDialog();
			changed=true;
			FillList();
		}
		private void butAdd_Click(object sender,EventArgs e) {
			if(!PrefC.GetBool(PrefName.StoreCCnumbers)) {
				if(Programs.IsEnabled(ProgramName.Xcharge)) {
					Program prog=Programs.GetCur(ProgramName.Xcharge);
					string path=Programs.GetProgramPath(prog);
					if(!File.Exists(path)){
						MsgBox.Show(this,"Path is not valid.");
						if(Security.IsAuthorized(Permissions.Setup)) {
							FormXchargeSetup FormX=new FormXchargeSetup();
							FormX.ShowDialog();
							if(FormX.DialogResult!=DialogResult.OK) {
								return;
							}
						}
					}
					string user=ProgramProperties.GetPropVal(prog.ProgramNum,"Username");
					string password=ProgramProperties.GetPropVal(prog.ProgramNum,"Password");
					ProcessStartInfo info=new ProcessStartInfo(path);
					string resultfile=Path.Combine(Path.GetDirectoryName(path),"XResult.txt");
					File.Delete(resultfile);//delete the old result file.
					info.Arguments="";
					info.Arguments+="/TRANSACTIONTYPE:ArchiveVaultAdd /LOCKTRANTYPE ";
					info.Arguments+="/RESULTFILE:\""+resultfile+"\" ";
					info.Arguments+="/USERID:"+user+" ";
					info.Arguments+="/PASSWORD:"******" ";
					info.Arguments+="/VALIDATEARCHIVEVAULTACCOUNT ";
					info.Arguments+="/STAYONTOP ";
					info.Arguments+="/SMARTAUTOPROCESS ";
					info.Arguments+="/AUTOCLOSE ";
					info.Arguments+="/HIDEMAINWINDOW ";
					info.Arguments+="/SMALLWINDOW ";
					info.Arguments+="/NORESULTDIALOG ";
					info.Arguments+="/TOOLBAREXITBUTTON ";
					Cursor=Cursors.WaitCursor;
					Process process=new Process();
					process.StartInfo=info;
					process.EnableRaisingEvents=true;
					process.Start();
					while(!process.HasExited) {
						Application.DoEvents();
					}
					Thread.Sleep(200);//Wait 2/10 second to give time for file to be created.
					Cursor=Cursors.Default;
					string resulttext="";
					string line="";
					string xChargeToken="";
					string accountMasked="";
					string exp="";;
					bool insertCard=false;
					using(TextReader reader=new StreamReader(resultfile)) {
						line=reader.ReadLine();
						while(line!=null) {
							if(resulttext!="") {
								resulttext+="\r\n";
							}
							resulttext+=line;
							if(line.StartsWith("RESULT=")) {
								if(line!="RESULT=SUCCESS") {
									break;
								}
								insertCard=true;
							}
							if(line.StartsWith("XCACCOUNTID=")) {
								xChargeToken=PIn.String(line.Substring(12));
							}
							if(line.StartsWith("ACCOUNT=")) {
								accountMasked=PIn.String(line.Substring(8));
							}
							if(line.StartsWith("EXPIRATION=")) {
								exp=PIn.String(line.Substring(11));
							}
							line=reader.ReadLine();
						}
						if(insertCard && xChargeToken!="") {//Might not be necessary but we've had successful charges with no tokens returned before.
							CreditCard creditCardCur=new CreditCard();
							List<CreditCard> itemOrderCount=CreditCards.Refresh(PatCur.PatNum);
							creditCardCur.PatNum=PatCur.PatNum;
							creditCardCur.ItemOrder=itemOrderCount.Count;
							creditCardCur.CCNumberMasked=accountMasked;
							creditCardCur.XChargeToken=xChargeToken;
							creditCardCur.CCExpiration=new DateTime(Convert.ToInt32("20"+PIn.String(exp.Substring(2,2))),Convert.ToInt32(PIn.String(exp.Substring(0,2))),1);
							CreditCards.Insert(creditCardCur);
						}
					}
					RefreshCardList();
					return;
				}
				else {
					MsgBox.Show(this,"Not allowed to store credit cards.");
					return;
				}
			}
			bool remember=false;
			int placement=listCreditCards.SelectedIndex;
			if(placement!=-1) {
				remember=true;
			}
			FormCreditCardEdit FormCCE=new FormCreditCardEdit(PatCur);
			FormCCE.CreditCardCur=new CreditCard();
			FormCCE.CreditCardCur.IsNew=true;
			FormCCE.ShowDialog();
			RefreshCardList();
			if(remember) {//in case they canceled and had one selected
				listCreditCards.SelectedIndex=placement;
			}
			if(FormCCE.DialogResult==DialogResult.OK && creditCards.Count>0) {
				listCreditCards.SelectedIndex=0;
			}
		}