public static klib.Dynamic ValidValue(SAPbouiCOM.ValidValue validValue) { return new klib.Dynamic(validValue.Value, validValue.Description); }
private void reload(SAPbouiCOM.Form form, string customerID, ref List<SAPCust> list, ref SAPCust sel, bool bAll = false) { try { sel = new SAPCust(); list = new List<SAPCust>(); SAPbouiCOM.ComboBox oCB = form.Items.Item(cbPaymentMethod).Specific; try { while (oCB.ValidValues.Count > 0) oCB.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index); } catch (Exception) { } oCB.ValidValues.Add("New Card", "New Card"); oCB.ValidValues.Add("New eCheck", "New eCheck"); var q = from a in db.CCCUSTs where a.CustomerID == customerID select a; if (q.Count() == 0) { int n = oCB.ValidValues.Count - 2; SBO_Application.SetStatusBarMessage("Number of record in combo= " + n.ToString(), SAPbouiCOM.BoMessageTime.bmt_Medium, false); oCB.Select("New Card"); populateCustFromDB(form); SBO_Application.SetStatusBarMessage("Credit card for customer: " + getLabelCaption(form, stRecordID) + " loaded. No credit card record found", SAPbouiCOM.BoMessageTime.bmt_Medium, false); return; } if (q.Count() > 0) { bool hasDefault = false; foreach(CCCUST cust in q) { if (cust.active == 'Y' || bAll) { SAPCust sapcust = new SAPCust(); sapcust.cccust = cust; string id = cust.CustomerID + "_" + cust.recID.ToString(); sapcust.custObj = getCustomer(id); if (sapcust.custObj.PaymentMethods.Count() == 0) { db.CCCUSTs.DeleteOnSubmit(cust); db.SubmitChanges(); } else { if(sapcust.custObj.PaymentMethods[0].MethodType == "check") sapcust.key = cust.recID.ToString() + "_" + sapcust.custObj.PaymentMethods[0].Routing + " " + sapcust.custObj.PaymentMethods[0].Account + "(" + sapcust.custObj.BillingAddress.FirstName + " " + sapcust.custObj.BillingAddress.LastName + ")"; else sapcust.key = cust.recID.ToString() + "_" + sapcust.custObj.PaymentMethods[0].CardNumber + " " + sapcust.custObj.PaymentMethods[0].CardExpiration + "(" + sapcust.custObj.BillingAddress.FirstName + " " + sapcust.custObj.BillingAddress.LastName + ")"; if (cust.Declined == 'Y') sapcust.key = sapcust.key + ", Declined"; SAPbouiCOM.ValidValue v = oCB.ValidValues.Add(sapcust.key, sapcust.key); list.Add(sapcust); if (!hasDefault) sel = sapcust; if (cust.@default == 'Y') { hasDefault = true; sel = sapcust; } } } } } if (sel.key != null) oCB.Select(sel.key); populateCCInfo(form, sel); SBO_Application.SetStatusBarMessage("Credit card for customer: " + getLabelCaption(form, stRecordID) + " loaded. " + oCB.ValidValues.Count + " credit card record(s) found", SAPbouiCOM.BoMessageTime.bmt_Medium, false); }catch(Exception ex) { errorLog(ex); } }