protected virtual RepositoryItemLookUpEdit InitColumnLookupEdit(string lookupTableName, string columnCaption) { if (!this.LookupTables.ContainsKey((object)lookupTableName)) { GELookupTablesInfo objectByTableName = new GELookupTablesController().GetObjectByTableName(lookupTableName); if (objectByTableName != null) { DataSet lookupTableData = ((IBaseModuleERP)this.Screen.Module).GetLookupTableData(lookupTableName); this.LookupTables.Add((object)lookupTableName, (object)lookupTableData); this.LookupTableObjects.Add(lookupTableName, objectByTableName); } } if (this.LookupTables[(object)lookupTableName] == null) { return((RepositoryItemLookUpEdit)null); } VinaDbUtil vinaDbUtil = new VinaDbUtil(); RepositoryItemLookUpEdit repositoryItemLookUpEdit = new RepositoryItemLookUpEdit(); repositoryItemLookUpEdit.BestFitMode = BestFitMode.BestFitResizePopup; repositoryItemLookUpEdit.SearchMode = SearchMode.AutoFilter; repositoryItemLookUpEdit.TextEditStyle = TextEditStyles.Standard; repositoryItemLookUpEdit.NullText = string.Empty; repositoryItemLookUpEdit.Tag = (object)lookupTableName; string tablePrimaryColumn = vinaDbUtil.GetTablePrimaryColumn(lookupTableName); string tableDisplayColumn = this.GetLookupTableDisplayColumn(lookupTableName); repositoryItemLookUpEdit.ValueMember = tablePrimaryColumn; repositoryItemLookUpEdit.DisplayMember = tableDisplayColumn; repositoryItemLookUpEdit.DataSource = (object)((DataSet)this.LookupTables[(object)lookupTableName]).Tables[0]; repositoryItemLookUpEdit.Columns.Add(new LookUpColumnInfo() { Caption = columnCaption, FieldName = repositoryItemLookUpEdit.DisplayMember, Width = 100 }); //rep.QueryPopUp += new CancelEventHandler(this.RepositoryItemLookupEdit_QueryPopup); repositoryItemLookUpEdit.Leave += new System.EventHandler(this.RepositoryItemLookupEdit_Leave); //rep.QueryCloseUp += new CancelEventHandler(this.RepositoryItemLookupEdit_QueryCloseUp); repositoryItemLookUpEdit.KeyDown += new KeyEventHandler(this.RepositoryItemLookUpEdit_KeyDown); return(repositoryItemLookUpEdit); }
protected bool InitObjectDataFromLookupTable(string strLookupTable) { VinaDbUtil vinaDbUtil = new VinaDbUtil(); if (this.LookupTables != null) { if (!this.LookupTables.ContainsKey((object)strLookupTable)) { GELookupTablesInfo objectByTableName = new GELookupTablesController().GetObjectByTableName(strLookupTable); if (objectByTableName != null) { DataSet lookupTableData = ((IBaseModuleERP)this.Screen.Module).GetLookupTableData(strLookupTable); this.LookupTables.Add((object)strLookupTable, (object)lookupTableData); this.LookupTableObjects.Add(strLookupTable, objectByTableName); } } if (this.LookupTables[(object)strLookupTable] != null) { this.InitObjectDataFromLookupTable(((DataSet)this.LookupTables[(object)strLookupTable]).Tables[0], strLookupTable); return(true); } } return(false); }
protected virtual string GetLookupTableDisplayColumn(string strLookupTableName) { try { VinaDbUtil vinaDbUtil = new VinaDbUtil(); GELookupTablesInfo lookupTablesInfo; if (this.LookupTableObjects.ContainsKey(strLookupTableName)) { lookupTablesInfo = this.LookupTableObjects[strLookupTableName]; } else { lookupTablesInfo = new GELookupTablesController().GetObjectByTableName(strLookupTableName); this.LookupTableObjects.Add(strLookupTableName, lookupTablesInfo); } if (lookupTablesInfo != null && !string.IsNullOrEmpty(lookupTablesInfo.GELookupTableDisplayColumn)) { return(lookupTablesInfo.GELookupTableDisplayColumn); } string tablePrimaryColumn = vinaDbUtil.GetTablePrimaryColumn(strLookupTableName); string str = tablePrimaryColumn.Substring(0, tablePrimaryColumn.Length - 2); if (vinaDbUtil.ColumnIsExist(strLookupTableName, str + "Name")) { return(str + "Name"); } if (vinaDbUtil.ColumnIsExist(strLookupTableName, str + "No")) { return(str + "No"); } } catch (Exception ex) { throw ex; } return(string.Empty); }