///<summary></summary> public static void Update(ProgramProperty Cur){ if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(),Cur); return; } Crud.ProgramPropertyCrud.Update(Cur); }
///<summary>This can only be called from ClassConversions. Users not allowed to add properties so there is no user interface.</summary> public static long Insert(ProgramProperty Cur){ if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { Cur.ProgramPropertyNum=Meth.GetLong(MethodBase.GetCurrentMethod(),Cur); return Cur.ProgramPropertyNum; } return Crud.ProgramPropertyCrud.Insert(Cur); }
///<summary></summary> public static bool Update(ProgramProperty programProp, ProgramProperty programPropOld) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetBool(MethodBase.GetCurrentMethod(), programProp, programPropOld)); } return(Crud.ProgramPropertyCrud.Update(programProp, programPropOld)); }
///<summary>This can only be called from ClassConversions. Users not allowed to delete properties so there is no user interface.</summary> public static void Delete(ProgramProperty Cur){ if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(),Cur); return; } string command= "DELETE from programproperty WHERE programpropertynum = '"+Cur.ProgramPropertyNum.ToString()+"'"; Db.NonQ(command); }
///<summary>Returns the path override for the current computer and the specified programNum. Returns empty string if no override found.</summary> public static string GetLocalPathOverrideForProgram(long programNum) { //No need to check RemotingRole; no call to db. ProgramProperty programProperty = GetFirstOrDefault(x => x.ProgramNum == programNum && x.PropertyDesc == "" && x.ComputerName.ToUpper() == Environment.MachineName.ToUpper()); return(programProperty == null ? "" : programProperty.PropertyValue); }
///<summary>This is called from FormClinicEdit and from InsertOrUpdateLocalOverridePath. PayConnect can have clinic specific login credentials, ///so the ProgramProperties for PayConnect are duplicated for each clinic. The properties duplicated are Username, Password, and PaymentType. ///There's also a 'Headquarters' or no clinic set of these props with ClinicNum 0, which is the set of props inserted with each new clinic.</summary> public static long Insert(ProgramProperty programProp) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { programProp.ProgramPropertyNum = Meth.GetLong(MethodBase.GetCurrentMethod(), programProp); return(programProp.ProgramPropertyNum); } return(Crud.ProgramPropertyCrud.Insert(programProp)); }
///<summary></summary> public static void Update(ProgramProperty programProp) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), programProp); return; } Crud.ProgramPropertyCrud.Update(programProp); }
///<summary>Returns the PropertyVal from the list by PropertyDesc and ClinicNum. ///For the 'Headquarters' or for clinics not enabled, omit clinicNum or send clinicNum 0. If not found returns an empty string. ///Primarily used when a local list has been copied from the cache and may differ from what's in the database. Also possibly useful if dealing with a filtered list </summary> public static string GetPropValFromList(List <ProgramProperty> listProps, string propertyDesc, long clinicNum = 0) { string retval = ""; ProgramProperty prop = listProps.Where(x => x.ClinicNum == clinicNum).Where(x => x.PropertyDesc == propertyDesc).FirstOrDefault(); if (prop != null) { retval = prop.PropertyValue; } return(retval); }
///<summary>Returns true if the program property was updated. False if no change needed. Callers need to invalidate cache as needed.</summary> public static bool UpdateProgramPropertyWithValue(ProgramProperty programProp, string newValue) { //No need to check RemotingRole; no call to db. if (programProp.PropertyValue == newValue) { return(false); } programProp.PropertyValue = newValue; ProgramProperties.Update(programProp); return(true); }
///<summary>This can only be called from ClassConversions. Users not allowed to delete properties so there is no user interface.</summary> public static void Delete(ProgramProperty Cur) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), Cur); return; } string command = "DELETE from programproperty WHERE programpropertynum = '" + Cur.ProgramPropertyNum.ToString() + "'"; Db.NonQ(command); }
///<summary>Throws exception if program property is not found.</summary> public static string GetPropVal(long programNum, string desc) { //No need to check RemotingRole; no call to db. ProgramProperty programProperty = GetFirstOrDefault(x => x.ProgramNum == programNum && x.PropertyDesc == desc); if (programProperty != null) { return(programProperty.PropertyValue); } throw new ApplicationException("Property not found: " + desc); }
///<summary>Returns the property with the matching description from the provided list. Null if the property cannot be found by the description.</summary> public static ProgramProperty GetPropByDesc(string propertyDesc, List <ProgramProperty> listProperties) { //No need to check RemotingRole; no call to db. ProgramProperty property = null; for (int i = 0; i < listProperties.Count; i++) { if (listProperties[i].PropertyDesc == propertyDesc) { property = listProperties[i]; break; } } return(property); }
///<summary>Deletes a given programproperty from the table based upon its programPropertyNum. ///Must have a property description in the GetDeletablePropertyDescriptions() list to delete</summary> public static void Delete(ProgramProperty prop) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), prop); return; } if (!GetDeletablePropertyDescriptions().Contains(prop.PropertyDesc)) { throw new Exception("Not allowed to delete the ProgramProperty with a description of: " + prop.PropertyDesc); } string command = "DELETE FROM programproperty WHERE ProgramPropertyNum=" + POut.Long(prop.ProgramPropertyNum); Db.NonQ(command); }
public static ErxOption GetErxOption() { Program progCur = Programs.GetCur(ProgramName.eRx); if (progCur == null) { throw new ODException(Lans.g("eRx", "The eRx bridge is missing from the database.")); } List <ProgramProperty> listProgramProperties = ProgramProperties.GetForProgram(progCur.ProgramNum); ProgramProperty propCur = listProgramProperties.FirstOrDefault(x => x.PropertyDesc == PropertyDescs.ErxOption); if (propCur == null) { throw new ODException(Lans.g("eRx", "The eRx Option program property is missing from the database.")); } return(PIn.Enum <ErxOption>(propCur.PropertyValue)); }
///<summary>This will insert or update a local path override property for the specified programNum.</summary> public static void InsertOrUpdateLocalOverridePath(long programNum, string newPath) { //No need to check RemotingRole; no call to db. ProgramProperty programProperty = GetFirstOrDefault(x => x.ProgramNum == programNum && x.PropertyDesc == "" && x.ComputerName.ToUpper() == Environment.MachineName.ToUpper()); if (programProperty != null) { programProperty.PropertyValue = newPath; ProgramProperties.Update(programProperty); return; //Will only be one override per computer per program. } //Path override does not exist for the current computer so create a new one. ProgramProperty pp = new ProgramProperty(); pp.ProgramNum = programNum; pp.PropertyValue = newPath; pp.ComputerName = Environment.MachineName.ToUpper(); ProgramProperties.Insert(pp); }
///<summary>This will insert or update a local path override property for the specified programNum.</summary> public static void InsertOrUpdateLocalOverridePath(long programNum, string newPath) { //No need to check RemotingRole; no call to db. for (int i = 0; i < ProgramPropertyC.Listt.Count; i++) { if (ProgramPropertyC.Listt[i].ProgramNum == programNum && ProgramPropertyC.Listt[i].PropertyDesc == "" && ProgramPropertyC.Listt[i].ComputerName.ToUpper() == Environment.MachineName.ToUpper()) { ProgramPropertyC.Listt[i].PropertyValue = newPath; ProgramProperties.Update(ProgramPropertyC.Listt[i]); return; //Will only be one override per computer per program. } } //Path override does not exist for the current computer so create a new one. ProgramProperty pp = new ProgramProperty(); pp.ProgramNum = programNum; pp.PropertyValue = newPath; pp.ComputerName = Environment.MachineName.ToUpper(); ProgramProperties.Insert(pp); }
private void FormXchargeSetup_Load(object sender,EventArgs e) { prog=Programs.GetCur(ProgramName.PayConnect); if(prog==null){ return; } checkEnabled.Checked=prog.Enabled; List <ProgramProperty> props=ProgramProperties.GetListForProgram(prog.ProgramNum); for(int i=0;i<props.Count;i++){ if(props[i].PropertyDesc=="Username"){ propUsername=props[i]; } else if(props[i].PropertyDesc=="Password"){ propPassword=props[i]; } else if(props[i].PropertyDesc=="PaymentType"){ propPayType=props[i]; } } textUsername.Text=propUsername.PropertyValue; textPassword.Text=propPassword.PropertyValue; for(int i=0;i<DefC.Short[(int)DefCat.PaymentTypes].Length;i++) { comboPaymentType.Items.Add(DefC.Short[(int)DefCat.PaymentTypes][i].ItemName); if(DefC.Short[(int)DefCat.PaymentTypes][i].DefNum.ToString()==propPayType.PropertyValue) { comboPaymentType.SelectedIndex=i; } } }
private void butPayConnect_Click(object sender,EventArgs e) { Program prog=Programs.GetCur(ProgramName.PayConnect); if(!prog.Enabled) { FormPayConnectSetup fpcs=new FormPayConnectSetup(); fpcs.ShowDialog(); CheckUIState(); return; } if(textAmount.Text=="" || textAmount.Text=="0.00") { MsgBox.Show(this,"Please enter an amount first."); return; } CreditCard CCard=null; List<CreditCard> creditCards=CreditCards.Refresh(PatCur.PatNum); for(int i=0;i<creditCards.Count;i++) { if(i==comboCreditCards.SelectedIndex) { CCard=creditCards[i]; } } FormPayConnect FormP; FormP=new FormPayConnect(PaymentCur,PatCur,textAmount.Text,CCard); FormP.ShowDialog(); ArrayList props=ProgramProperties.GetForProgram(prog.ProgramNum); ProgramProperty prop=null; for(int i=0;i<props.Count;i++) { ProgramProperty curProp=(ProgramProperty)props[i]; if(curProp.PropertyDesc=="PaymentType") { prop=curProp; break; } } //still need to add functionality for accountingAutoPay listPayType.SelectedIndex=DefC.GetOrder(DefCat.PaymentTypes,PIn.Long(prop.PropertyValue)); SetComboDepositAccounts(); if(FormP.Response!=null) { textNote.Text+=((textNote.Text=="")?"":Environment.NewLine)+Lan.g(this,"Transaction Type")+": "+Enum.GetName(typeof(PayConnectService.transType),FormP.TranType)+Environment.NewLine+ Lan.g(this,"Status")+": "+FormP.Response.Status.description; if(FormP.Response.Status.code==0) { //The transaction succeeded. payConnectWarn=true;//Show a warning if user cancels out of window. textNote.Text+=Environment.NewLine +Lan.g(this,"Amount")+": "+FormP.AmountCharged+Environment.NewLine +Lan.g(this,"Auth Code")+": "+FormP.Response.AuthCode+Environment.NewLine +Lan.g(this,"Ref Number")+": "+FormP.Response.RefNumber; textNote.Select(textNote.Text.Length-1,0); textNote.ScrollToCaret();//Scroll to the end of the text box to see the newest notes. if(FormP.TranType==PayConnectService.transType.VOID || FormP.TranType==PayConnectService.transType.RETURN) { textAmount.Text="-"+FormP.AmountCharged; } else if(FormP.TranType==PayConnectService.transType.AUTH) { textAmount.Text=FormP.AmountCharged; } else if(FormP.TranType==PayConnectService.transType.SALE) { textAmount.Text=FormP.AmountCharged; PaymentCur.Receipt=FormP.ReceiptStr; //There is only a receipt when a sale takes place. } } } if(FormP.Response==null || FormP.Response.Status.code!=0) { //The transaction failed. if(FormP.TranType==PayConnectService.transType.SALE || FormP.TranType==PayConnectService.transType.AUTH) { textAmount.Text=FormP.AmountCharged;//Preserve the amount so the user can try the payment again more easily. } } }
private void panelXcharge_MouseClick(object sender,MouseEventArgs e) { if(e.Button != MouseButtons.Left) { return; } if(textAmount.Text=="") { MsgBox.Show(this,"Please enter an amount first."); return; } if(!HasXCharge()) { return; } bool needToken=false; bool newCard=false; bool hasXToken=false; bool notRecurring=false; prop=(ProgramProperty)ProgramProperties.GetForProgram(prog.ProgramNum)[0]; //still need to add functionality for accountingAutoPay listPayType.SelectedIndex=DefC.GetOrder(DefCat.PaymentTypes,PIn.Long(prop.PropertyValue)); SetComboDepositAccounts(); /*XCharge.exe [/TRANSACTIONTYPE:type] [/AMOUNT:amount] [/ACCOUNT:account] [/EXP:exp] [“/TRACK:track”] [/ZIP:zip] [/ADDRESS:address] [/RECEIPT:receipt] [/CLERK:clerk] [/APPROVALCODE:approval] [/AUTOPROCESS] [/AUTOCLOSE] [/STAYONTOP] [/MID] [/RESULTFILE:”C:\Program Files\X-Charge\LocalTran\XCResult.txt”*/ ProcessStartInfo info=new ProcessStartInfo(prog.Path); Patient pat=Patients.GetPat(PaymentCur.PatNum); PatientNote patnote=PatientNotes.Refresh(pat.PatNum,pat.Guarantor); string resultfile=Path.Combine(Path.GetDirectoryName(prog.Path),"XResult.txt"); File.Delete(resultfile);//delete the old result file. info.Arguments=""; double amt=PIn.Double(textAmount.Text); if(amt>0) { info.Arguments+="/AMOUNT:"+amt.ToString("F2")+" /LOCKAMOUNT "; } CreditCard CCard=null; List<CreditCard> creditCards=CreditCards.Refresh(PatCur.PatNum); for(int i=0;i<creditCards.Count;i++) { if(i==comboCreditCards.SelectedIndex) { CCard=creditCards[i]; } } //Show window to lock in the transaction type. FormXchargeTrans FormXT=new FormXchargeTrans(); FormXT.ShowDialog(); if(FormXT.DialogResult!=DialogResult.OK) { return; } int tranType=FormXT.TransactionType; string cashBack=FormXT.CashBackAmount.ToString("F2"); if(CCard!=null) { //Have credit card on file if(CCard.XChargeToken!="") {//Recurring charge hasXToken=true; /* ***** An example of how recurring charges work***** C:\Program Files\X-Charge\XCharge.exe /TRANSACTIONTYPE:Purchase /LOCKTRANTYPE /AMOUNT:10.00 /LOCKAMOUNT /XCACCOUNTID:XAW0JWtx5kjG8 /RECEIPT:RC001 /LOCKRECEIPT /CLERK:Clerk /LOCKCLERK /RESULTFILE:C:\ResultFile.txt /USERID:system /PASSWORD:system /STAYONTOP /AUTOPROCESS /AUTOCLOSE /HIDEMAINWINDOW /RECURRING /SMALLWINDOW /NORESULTDIALOG */ } else {//Not recurring charge, on file and might need a token. notRecurring=true; if(!PrefC.GetBool(PrefName.StoreCCnumbers)) {//Use token only if user has has pref unchecked in module setup (allow store credit card nums). needToken=true;//Will create a token from result file so credit card info isn't saved in our db. } } } else {//Add card option was selected in credit card drop down. No other possibility. newCard=true; } info.Arguments+=GetXChargeTransactionTypeCommands(tranType,hasXToken,notRecurring,CCard,cashBack); if(newCard) { info.Arguments+="\"/ZIP:"+pat.Zip+"\" "; info.Arguments+="\"/ADDRESS:"+pat.Address+"\" "; } else { if(CCard.CCExpiration!=null && CCard.CCExpiration.Year>2005) { info.Arguments+="/EXP:"+CCard.CCExpiration.ToString("MMyy")+" "; } if(CCard.Zip!="") { info.Arguments+="\"/ZIP:"+CCard.Zip+"\" "; } else { info.Arguments+="\"/ZIP:"+pat.Zip+"\" "; } if(CCard.Address!="") { info.Arguments+="\"/ADDRESS:"+CCard.Address+"\" "; } else { info.Arguments+="\"/ADDRESS:"+pat.Address+"\" "; } if(hasXToken) {//Special parameter for tokens. info.Arguments+="/RECURRING "; } } info.Arguments+="/RECEIPT:Pat"+PaymentCur.PatNum.ToString()+" ";//aka invoice# info.Arguments+="\"/CLERK:"+Security.CurUser.UserName+"\" /LOCKCLERK "; info.Arguments+="/RESULTFILE:\""+resultfile+"\" "; info.Arguments+="/USERID:"+ProgramProperties.GetPropVal(prog.ProgramNum,"Username")+" "; info.Arguments+="/PASSWORD:"******"Password")+" "; info.Arguments+="/PARTIALAPPROVALSUPPORT:T "; info.Arguments+="/AUTOCLOSE "; info.Arguments+="/HIDEMAINWINDOW "; info.Arguments+="/SMALLWINDOW "; info.Arguments+="/GETXCACCOUNTID "; info.Arguments+="/NORESULTDIALOG "; 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=""; bool showApprovedAmtNotice=false; bool xAdjust=false; bool xVoid=false; double approvedAmt=0; double additionalFunds=0; string xChargeToken=""; string accountMasked=""; string expiration=""; using(TextReader reader=new StreamReader(resultfile)) { line=reader.ReadLine(); /*Example of successful transaction: RESULT=SUCCESS TYPE=Purchase APPROVALCODE=000064 ACCOUNT=XXXXXXXXXXXX6781 ACCOUNTTYPE=VISA* AMOUNT=1.77 AVSRESULT=Y CVRESULT=M */ while(line!=null) { if(resulttext!="") { resulttext+="\r\n"; } resulttext+=line; if(line.StartsWith("RESULT=")) { if(line!="RESULT=SUCCESS") { //Charge was a failure and there might be a description as to why it failed. Continue to loop through line. while(line!=null) { line=reader.ReadLine(); resulttext+="\r\n"+line; } needToken=false;//Don't update CCard due to failure newCard=false;//Don't insert CCard due to failure break; } if(tranType==6) { xAdjust=true; } if(tranType==7) { xVoid=true; } } if(line.StartsWith("APPROVEDAMOUNT=")) { approvedAmt=PIn.Double(line.Substring(15)); if(approvedAmt != amt) { showApprovedAmtNotice=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=")) { expiration=PIn.String(line.Substring(11)); } if(line.StartsWith("ADDITIONALFUNDSREQUIRED=")) { additionalFunds=PIn.Double(line.Substring(24)); } line=reader.ReadLine(); } if(needToken && xChargeToken!="") { //Only way this code can be hit is if they have set up a credit card and it does not have a token. //So we'll use the created token from result file and assign it to the coresponding account. //Also will delete the credit card number and replace it with secure masked number. CCard.XChargeToken=xChargeToken; CCard.CCNumberMasked=accountMasked; CCard.CCExpiration=new DateTime(Convert.ToInt32("20"+expiration.Substring(2,2)),Convert.ToInt32(expiration.Substring(0,2)),1); CreditCards.Update(CCard); } if(newCard) { if(xChargeToken=="") {//Shouldn't happen again but leaving just in case. MsgBox.Show(this,"X-Charge didn't return a token so credit card information couldn't be saved."); } else { if(FormXT.SaveToken) { CCard=new CreditCard(); List<CreditCard> itemOrderCount=CreditCards.Refresh(PatCur.PatNum); CCard.ItemOrder=itemOrderCount.Count; CCard.PatNum=PatCur.PatNum; CCard.CCExpiration=new DateTime(Convert.ToInt32("20"+expiration.Substring(2,2)),Convert.ToInt32(expiration.Substring(0,2)),1); CCard.XChargeToken=xChargeToken; CCard.CCNumberMasked=accountMasked; CreditCards.Insert(CCard); } } } } if(showApprovedAmtNotice && !xVoid && !xAdjust) { if(MessageBox.Show(Lan.g(this,"The amount you typed in: ")+amt.ToString("C")+" \r\n"+Lan.g(this,"does not match the approved amount returned: ")+approvedAmt.ToString("C") +"\r\n"+Lan.g(this,"Change the amount to match?"),"Alert",MessageBoxButtons.OKCancel,MessageBoxIcon.Exclamation)==DialogResult.OK) { textAmount.Text=approvedAmt.ToString("F"); } } if(xAdjust) { MessageBox.Show(Lan.g(this,"The amount will be changed to the X-Charge approved amount: ")+approvedAmt.ToString("C")); textNote.Text=""; textAmount.Text=approvedAmt.ToString("F"); } if(xVoid) { if(IsNew) { textAmount.Text="-"+approvedAmt.ToString("F"); } } if(additionalFunds>0) { MessageBox.Show(Lan.g(this,"Additional funds required: ")+additionalFunds.ToString("C")); } if(textNote.Text!="") { textNote.Text+="\r\n"; } textNote.Text+=resulttext; }
///<summary>This will insert or update a local path override property for the specified programNum.</summary> public static void InsertOrUpdateLocalOverridePath(long programNum,string newPath) { //No need to check RemotingRole; no call to db. List<ProgramProperty> listProgramProperties=ProgramPropertyC.GetListt(); for(int i=0;i<listProgramProperties.Count;i++) { if(listProgramProperties[i].ProgramNum==programNum && listProgramProperties[i].PropertyDesc=="" && listProgramProperties[i].ComputerName.ToUpper()==Environment.MachineName.ToUpper()) { listProgramProperties[i].PropertyValue=newPath; ProgramProperties.Update(listProgramProperties[i]); return;//Will only be one override per computer per program. } } //Path override does not exist for the current computer so create a new one. ProgramProperty pp=new ProgramProperty(); pp.ProgramNum=programNum; pp.PropertyValue=newPath; pp.ComputerName=Environment.MachineName.ToUpper(); ProgramProperties.Insert(pp); }