private void InsertDetails(IList <IAddressValidatorSetting> list) { var existingRecords = new Dictionary <string, AddressValidatorPluginDetail>(); foreach (AddressValidatorPluginDetail detail in SelectDetails.Select()) { existingRecords.Add(detail.SettingID.ToUpper(), detail); } foreach (var item in list) { AddressValidatorPluginDetail existingRecord; if (existingRecords.TryGetValue(item.SettingID.ToUpper(), out existingRecord)) { var copy = PXCache <AddressValidatorPluginDetail> .CreateCopy(existingRecord); if (!string.IsNullOrEmpty(item.Description)) { copy.Description = item.Description; } copy.ControlType = item.ControlType; copy.ComboValues = item.ComboValues; copy.SortOrder = item.SortOrder; if (existingRecord.Description != copy.Description || existingRecord.ControlTypeValue != copy.ControlTypeValue || existingRecord.ComboValuesStr != copy.ComboValuesStr || existingRecord.SortOrder != copy.SortOrder) { SelectDetails.Update(copy); } } else { var addressValidatorPluginDetail = new AddressValidatorPluginDetail { SettingID = item.SettingID.ToUpper(), SortOrder = item.SortOrder, Description = item.Description, Value = item.Value, ControlType = item.ControlType, ComboValues = item.ComboValues }; SelectDetails.Insert(addressValidatorPluginDetail); } } }
protected virtual void AddressValidatorPluginDetail_Value_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { AddressValidatorPluginDetail row = e.Row as AddressValidatorPluginDetail; if (row != null) { string fieldName = typeof(AddressValidatorPluginDetail.value).Name; switch (row.ControlTypeValue) { case AddressValidatorPluginDetail.Combo: List <string> labels = new List <string>(); List <string> values = new List <string>(); foreach (var kv in row.ComboValues) { values.Add(kv.Key); labels.Add(kv.Value); } e.ReturnState = PXStringState.CreateInstance(e.ReturnState, AddressValidatorPluginDetail.ValueFieldLength, null, fieldName, false, 1, null, values.ToArray(), labels.ToArray(), true, null); break; case AddressValidatorPluginDetail.CheckBox: e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(Boolean), false, null, -1, null, null, null, fieldName, null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null); break; case AddressValidatorPluginDetail.Password: if (e.ReturnState != null) { string strValue = e.ReturnState.ToString(); string encripted = new string('*', strValue.Length); e.ReturnState = PXFieldState.CreateInstance(encripted, typeof(string), false, null, -1, null, null, null, fieldName, null, null, null, PXErrorLevel.Undefined, null, null, null, PXUIVisibility.Undefined, null, null, null); } break; default: break; } } }