예제 #1
0
        protected virtual void CarrierPluginDetail_Value_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            CarrierPluginDetail row = e.Row as CarrierPluginDetail;

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

                switch (row.ControlType)
                {
                case CarrierPluginDetail.Combo:
                    List <string> labels = new List <string>();
                    List <string> values = new List <string>();
                    foreach (KeyValuePair <string, string> kv in row.GetComboValues())
                    {
                        values.Add(kv.Key);
                        labels.Add(kv.Value);
                    }
                    e.ReturnState = PXStringState.CreateInstance(e.ReturnState, CarrierDetail.ValueFieldLength, null, fieldName, false, 1, null,
                                                                 values.ToArray(), labels.ToArray(), true, null);
                    break;

                case CarrierPluginDetail.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 CarrierPluginDetail.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;
                }
            }
        }
예제 #2
0
        private void InsertDetails(IList <ICarrierDetail> list)
        {
            Dictionary <string, CarrierPluginDetail> existingRecords = new Dictionary <string, CarrierPluginDetail>();

            foreach (CarrierPluginDetail detail in SelectDetails.Select())
            {
                existingRecords.Add(detail.DetailID.ToUpper(), detail);
            }

            foreach (ICarrierDetail item in list)
            {
                if (!existingRecords.ContainsKey(item.DetailID.ToUpper()))
                {
                    CarrierPluginDetail row = (CarrierPluginDetail)SelectDetails.Insert(new CarrierPluginDetail {
                        DetailID = item.DetailID
                    });
                    row.Descr       = item.Descr;
                    row.Value       = item.Value;
                    row.ControlType = item.ControlType;
                    row.SetComboValues(item.GetComboValues());
                }
                else
                {
                    CarrierPluginDetail cd   = existingRecords[item.DetailID];
                    CarrierPluginDetail copy = PXCache <CarrierPluginDetail> .CreateCopy(cd);

                    if (!string.IsNullOrEmpty(item.Descr))
                    {
                        copy.Descr = item.Descr;
                    }
                    copy.ControlType = item.ControlType;
                    copy.SetComboValues(item.GetComboValues());

                    if (cd.Descr != copy.Descr || cd.ControlType != copy.ControlType || cd.ComboValues != copy.ComboValues)
                    {
                        SelectDetails.Update(copy);
                    }
                }
            }
        }