Esempio n. 1
0
        private void InsertDetails(IList <ITaxProviderSetting> list)
        {
            var existingRecords = new Dictionary <string, TaxPluginDetail>();

            foreach (TaxPluginDetail detail in SelectDetails.Select())
            {
                existingRecords.Add(detail.SettingID.ToUpper(), detail);
            }

            foreach (var item in list)
            {
                TaxPluginDetail existingRecord;
                if (existingRecords.TryGetValue(item.SettingID.ToUpper(), out existingRecord))
                {
                    var copy = PXCache <TaxPluginDetail> .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 taxPluginDetail = new TaxPluginDetail
                    {
                        SettingID   = item.SettingID.ToUpper(),
                        Description = item.Description,
                        Value       = item.Value,
                        SortOrder   = item.SortOrder,
                        ControlType = item.ControlType,
                        ComboValues = item.ComboValues
                    };

                    var row = SelectDetails.Insert(taxPluginDetail);
                }
            }
        }
Esempio n. 2
0
        protected virtual void TaxPluginDetail_Value_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            TaxPluginDetail row = e.Row as TaxPluginDetail;

            if (row != null)
            {
                string fieldName = typeof(TaxPluginDetail.value).Name;

                switch (row.ControlTypeValue)
                {
                case TaxPluginDetail.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, TaxPluginDetail.ValueFieldLength, null, fieldName, false, 1, null,
                                                                 values.ToArray(), labels.ToArray(), true, null);
                    break;

                case TaxPluginDetail.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 TaxPluginDetail.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;
                }
            }
        }