private static void OnSelectedObjectPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { ULookupSearch2 control = sender as ULookupSearch2; MBaseModel v = (MBaseModel)e.NewValue; if (v != null) { CTable obj = v.GetDbObject(); CLookupConfig cfg = (CLookupConfig)control.lookupTypeConfigs[control.Lookup]; control.txtCode.Text = obj.GetFieldValue(cfg.CodeFieldName); control.txtName.Text = obj.GetFieldValue(cfg.NameFieldName); } else { control.txtCode.Text = ""; control.txtName.Text = ""; } control.isEmpty = control.txtCode.Text.Equals(""); if (control.SelectedObjectChanged != null) { control.SelectedObjectChanged(control, null); } }
private static void OnLookupPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { ULookupSearch2 control = sender as ULookupSearch2; control.Lookup = (LookupSearchType2)e.NewValue; CLookupConfig cfg = (CLookupConfig)control.lookupTypeConfigs[control.Lookup]; control.txtCode.TextSearchNameSpace = cfg.SearchNameSpace; control.txtCode.MasterRefType = lookupTypeToMasterRef(control.Lookup); }
private void GetObjectInfo(String code) { CLookupConfig cfg = (CLookupConfig)lookupTypeConfigs[Lookup]; ArrayList arr = null; CTable tb = new CTable(""); tb.SetFieldValue(cfg.CodeFieldName, code); tb.SetFieldValue("!EXT_EQUAL_STRING_COMPARE_FIELDS", cfg.TableAlias + cfg.CodeFieldName); if (!cfg.ExtraFieldValue.Equals("")) { tb.SetFieldValue(cfg.ExtraFieldName, cfg.ExtraFieldValue); } if (!cfg.ExtraFieldValue2.Equals("")) { tb.SetFieldValue(cfg.ExtraFieldName2, cfg.ExtraFieldValue2); } CUtil.EnableForm(false, this); arr = cfg.ListFunction(tb); if ((arr == null) || (arr.Count <= 0)) { SelectedObject = null; isEmpty = true; } else { CTable o = (CTable)arr[0]; MBaseModel instance = (MBaseModel)Activator.CreateInstance(cfg.ModelType, new object[] { o }); SelectedObject = instance; txtCode.Text = o.GetFieldValue(cfg.CodeFieldName); txtName.Text = o.GetFieldValue(cfg.NameFieldName); isEmpty = false; } CUtil.EnableForm(true, this); }
private void addLookupTypeConfig(LookupSearchType2 ltype, String codeFieldName, String nameFieldName, String extraFieldName, String extraFieldValue, String extraFieldName2, String extraFieldValue2, GetListFunction func, Type mt, String crName, TextSearchNameSpace ns, String tbAlias) { CLookupConfig cfg = new CLookupConfig(); cfg.CodeFieldName = codeFieldName; cfg.NameFieldName = nameFieldName; cfg.ExtraFieldName = extraFieldName; cfg.ExtraFieldValue = extraFieldValue; cfg.ExtraFieldName2 = extraFieldName2; cfg.ExtraFieldValue2 = extraFieldValue2; cfg.ListFunction = func; cfg.ModelType = mt; cfg.ScreenCriteriaClassName = FactoryCriteria.GetFqdnClassName(crName); cfg.SearchNameSpace = ns; cfg.TableAlias = tbAlias; lookupTypeConfigs.Add(ltype, cfg); }
private void mnuSearch_Click(object sender, RoutedEventArgs e) { CLookupConfig cfg = (CLookupConfig)lookupTypeConfigs[Lookup]; CCriteriaBase cr = (CCriteriaBase)Activator.CreateInstance(Type.GetType(cfg.ScreenCriteriaClassName)); cr.SetActionEnable(false); criteriaInitFunc(cr); String caption = Caption; if (Caption.Equals("")) { caption = lookupTypeToCaption(Lookup); } WinLookupSearch2 w = new WinLookupSearch2(cr, caption); w.ShowDialog(); if (w.IsOK) { SelectedObject = w.ReturnedObj; } }