public static void InitDefaultRepositoryGridLookUpEdit(String strTableName, ABCRepositoryGridLookupEdit repo, Boolean isCreateNewView) { ABCGridView view; if (isCreateNewView) { view = new ABCGridView(strTableName); InitDefaultColumns(strTableName, view); } else { view = GetDefaultGridView(strTableName); } repo.View = view; repo.ValueMember = DataStructureProvider.GetPrimaryKeyColumn(strTableName); String strDisplayCol = DataStructureProvider.GetDisplayColumn(strTableName); if (String.IsNullOrWhiteSpace(strDisplayCol)) { strDisplayCol = repo.ValueMember; } repo.DisplayMember = strDisplayCol; if (view.Columns.Count <= 7) { repo.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; } else { repo.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFit; repo.PopupFormSize = new System.Drawing.Size(700, 400); } }
public void UpdateFieldName(ABCCommonTreeListNode obj) { if (obj == null || obj.InnerData == null) { return; } if (obj.ParentNode != null) { ABCCommonTreeListNode objparent = obj.ParentNode; ABCBindingConfig currentBind = (ABCBindingConfig)obj.InnerData; ABCBindingConfig parentBind = (ABCBindingConfig)objparent.InnerData; if (currentBind != null && parentBind != null) { if (currentBind.ParentName != parentBind.TableName || (currentBind.ParentName == parentBind.TableName && (String.IsNullOrWhiteSpace(currentBind.ParentField) || String.IsNullOrWhiteSpace(currentBind.ChildField)))) { if (DataStructureProvider.IsExistedTable(parentBind.TableName)) { currentBind.ParentField = DataStructureProvider.GetPrimaryKeyColumn(parentBind.TableName); } if (DataStructureProvider.IsExistedTable(currentBind.TableName)) { currentBind.ChildField = DataStructureProvider.GetTable(currentBind.TableName).GetForeignKeyOfTableName(parentBind.TableName); } } currentBind.ParentName = parentBind.Name; } } //foreach ( TreeListNode nodeChild in node.Nodes ) // UpdateFieldName( nodeChild ); }
void Menu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (e.Item.Tag != null && e.Item.Tag.ToString() == "New") { TableChooserForm form = new TableChooserForm(); String strTableName = form.ShowChooseOne(); if (form.DialogResult == DialogResult.Cancel) { return; } if (DataStructureProvider.IsExistedTable(strTableName) == false) { return; } TreeConfigData configData = new TreeConfigData(); configData.Name = "objNew" + this.Manager.ConfigList.Count; configData.DefaultLoad = true; configData.TableName = strTableName; configData.ColumnFieldNames = new Dictionary <string, string>(); TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(DataConfigTreeCtrl.FocusedNode); if (obj == null) { new TreeConfigNode(Manager.RootConfig, configData); } else { configData.ParentTableName = obj.InnerData.TableName; configData.ParentField = DataStructureProvider.GetPrimaryKeyColumn(obj.InnerData.TableName); configData.ChildField = DataStructureProvider.GetForeignKeyOfTableName(configData.TableName, obj.InnerData.TableName); new TreeConfigNode(obj, configData); } UpdateDataConfigs(); RefreshDataConfigTree(); } if (e.Item.Tag != null && e.Item.Tag.ToString() == "Delete") { TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(DataConfigTreeCtrl.FocusedNode); if (obj == null || (TreeConfigData)obj.InnerData == null) { return; } DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want to delete selected Object ? ", "Delete Object", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { obj.ParentNode.ChildrenNodes.Remove(obj.InnerData.Name); obj.ParentNode = null; UpdateDataConfigs(); RefreshDataConfigTree(); } } }
public void RefreshDisplayTree( ) { DisplayTreeListCtrl.TableName = this.TableName; DisplayTreeListCtrl.InnerTreeList.Columns.Clear(); DisplayTreeListCtrl.ColumnConfigs = this.ColumnList; DisplayTreeListCtrl.Manager.ConfigList = this.Manager.ConfigList;//new DisplayTreeListCtrl.InitColumns(); #region Script if (String.IsNullOrWhiteSpace(this.TableName)) { if (String.IsNullOrWhiteSpace(Script) == false) { DataSet ds = DataQueryProvider.RunQuery(Script); if (ds != null && ds.Tables.Count > 0) { Manager.Invalidate(ds); DisplayTreeListCtrl.InnerTreeList.ColumnsCustomization(); } } return; } #endregion if (DataCachingProvider.LookupTables.ContainsKey(this.TableName)) { Manager.Invalidate(DataCachingProvider.LookupTables[this.TableName]); } else { ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder(); strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0} ", this.TableName)); if (DataStructureProvider.IsExistABCStatus(this.TableName)) { strBuilder.AddCondition(QueryGenerator.GenerateCondition(this.TableName, ABCCommon.ABCColumnType.ABCStatus)); } strBuilder.Append(String.Format(@" ORDER BY {0} DESC", DataStructureProvider.GetPrimaryKeyColumn(this.TableName))); try { DataSet ds = DataQueryProvider.RunQuery(strBuilder.ToString()); if (ds != null && ds.Tables.Count > 0) { this.DisplayTreeListCtrl.InnerTreeList.DataSource = ds.Tables[0]; } } catch (Exception ex) { } } this.DisplayTreeListCtrl.InnerTreeList.RefreshDataSource(); DisplayTreeListCtrl.InnerTreeList.ColumnsCustomization(); }
public static Guid GetIDValue(BusinessObject obj) { if (obj == null) { return(Guid.Empty); } string strPrimaryKeyColumn = DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName); return(ABCHelper.DataConverter.ConvertToGuid(ABCDynamicInvoker.GetValue(obj, strPrimaryKeyColumn))); }
public void RefreshData(Boolean includeParent, Boolean includeChildren, Boolean defaultOnly) { #region Current Node if (InnerData != null) { BusinessObjectController ctrller = BusinessControllerFactory.GetBusinessController(InnerData.AATableName); String strPK = DataStructureProvider.GetPrimaryKeyColumn(InnerData.AATableName); Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(InnerData, strPK)); InnerData = ctrller.GetObjectByID(iID); if (InnerData == null) { if (this.ParentNode != null) { this.ParentNode.ChildrenNodes.Remove(iID); this.ParentNode = null; } Dictionary <Guid, ABCTreeListNode> innerList = null; if (this.Manager.DataList.TryGetValue(this.ObjectName, out innerList)) { if (innerList.ContainsKey(iID)) { innerList.Remove(iID); } } } } #endregion List <ABCTreeListNode> lstTemps = new List <ABCTreeListNode>(); foreach (ABCTreeListNode childNode in this.ChildrenNodes.Values) { lstTemps.Add(childNode); } if (includeChildren) { foreach (ABCTreeListNode childNode in lstTemps) { childNode.RefreshData(false, includeChildren, defaultOnly); } } if (includeParent && this.ParentNode != null) { this.ParentNode.RefreshData(true, false, defaultOnly); } ExpandData(includeChildren, defaultOnly); }
public void RefreshDisplayGrid( ) { DisplayGridCtrl.TableName = this.TableName; DisplayGridCtrl.Grid.Fields.Clear(); DisplayGridCtrl.FieldConfigs = this.FieldsList; DisplayGridCtrl.InitFields(); DisplayGridCtrl.Grid.OptionsView.RowTreeWidth = RowTreeWidth; DisplayGridCtrl.UseChartControl = UseChartControl; DisplayGridCtrl.Script = Script; if (String.IsNullOrWhiteSpace(this.TableName)) { DisplayGridCtrl.LoadDataSourceFromScript(); return; } if (DataCachingProvider.LookupTables.ContainsKey(this.TableName)) { this.DisplayGridCtrl.GridDataSource = DataCachingProvider.LookupTables[this.TableName]; } else { ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder(); strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0}", this.TableName)); if (DataStructureProvider.IsExistABCStatus(this.TableName)) { strBuilder.AddCondition(QueryGenerator.GenerateCondition(this.TableName, ABCCommon.ABCColumnType.ABCStatus)); } strBuilder.Append(String.Format(@" ORDER BY {0} DESC", DataStructureProvider.GetPrimaryKeyColumn(this.TableName))); try { DataSet ds = DataQueryProvider.RunQuery(strBuilder.ToString()); if (ds != null && ds.Tables.Count > 0) { this.DisplayGridCtrl.GridDataSource = ds.Tables[0]; } } catch (Exception ex) { } } this.DisplayGridCtrl.RefreshDataSource(); DisplayGridCtrl.Grid.FieldsCustomization(splitContainerControl2.Panel2); }
public Nullable <Guid> GetIDByNo(String strObjectNo) { BusinessObject obj = GetObjectByNo(strObjectNo); if (obj == null) { return(null); } object objID = ABCDynamicInvoker.GetValue(obj, DataStructureProvider.GetPrimaryKeyColumn(TableName)); if (objID == null) { return(null); } return((Nullable <Guid>)objID); }
public void Initialize(ABCView view) { OwnerView = view; InitControl(); String strFieldName = this.DataMember.Split(':')[0]; if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName)) { this.LookupTableName = DataStructureProvider.GetTableNameOfForeignKey(this.TableName, strFieldName); this.ValueMember = DataStructureProvider.GetPrimaryKeyColumn(this.LookupTableName); this.DisplayMember = DataStructureProvider.GetDisplayColumn(this.LookupTableName); } this.DummyText = "..."; }
public static bool IsModifiedObject(BusinessObject obj) { String strPKCol = DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName); object objID = ABCDynamicInvoker.GetValue(obj, strPKCol); if (objID == null || objID == DBNull.Value) { return(true); } Guid id = Guid.Empty; if (objID is Guid) { id = (Guid)objID; } else if (objID is Nullable <Guid> && ((Nullable <Guid>)objID).HasValue) { id = ((Nullable <Guid>)objID).Value; } else { return(true); } BusinessObject obj2 = BusinessControllerFactory.GetBusinessController(obj.AATableName).GetObjectByID(id); InitPropertyList(obj.AATableName); foreach (PropertyInfo proInfo in PropertyList[obj.AATableName].Values) { object pro1 = proInfo.GetValue(obj, null); object pro2 = proInfo.GetValue(obj2, null); if (pro1 == pro2 || (pro1 == null && pro2 == null) || (pro1 != null && pro2 != null && pro1.ToString() == pro2.ToString())) { continue; } return(true); } return(false); }
public virtual Guid CreateObject(BusinessObject obj) { #region Default Value if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colSelected)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colSelected, false); } if (String.IsNullOrWhiteSpace(ABCBaseUserProvider.CurrentUserName) == false && DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateUser)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colCreateUser, ABCBaseUserProvider.CurrentUserName); } if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime)) { ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colCreateTime, ABCApp.ABCDataGlobal.WorkingDate); } #endregion Guid iID = Guid.Empty; if (DatabaseHelper.IsSQLConnection()) { iID = ABCHelper.DataConverter.ConvertToGuid((DatabaseHelper as SqlDatabaseHelper).RunStoredProcedure(StoredProcedureGenerator.GetSPName(StoredProcedureGenerator.SPType.Insert, TableName), obj)); } else { String strQuery = QueryTemplateGenerator.GenInsert(TableName); iID = Guid.NewGuid(); strQuery = strQuery.Replace(String.Format("@{0}", DataStructureProvider.GetPrimaryKeyColumn(TableName)), "'" + iID.ToString() + "'"); DatabaseHelper.RunScript(strQuery, obj); } ABCDynamicInvoker.SetValue(obj, DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName), iID); if (BusinessObjectHelper.GenerateNoColumn(obj, true)) { UpdateObject(obj); } return(iID); }
public void DeleteObject(BusinessObject obj) { object objID = (object)ABCDynamicInvoker.GetValue(obj, DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName)); Guid id = Guid.Empty; if (objID is Guid) { id = (Guid)objID; } else if (objID is Nullable <Guid> && ((Nullable <Guid>)objID).HasValue) { id = ((Nullable <Guid>)objID).Value; } else { return; } DeleteObject(id); }
public void RefreshCachingNodes(TreeConfigNode configNode) { try { if (configNode.InnerData != null && configNode.ParentNode != null) { Dictionary <Guid, ABCTreeListNode> innerList = null; if (this.DataList.TryGetValue(configNode.InnerData.Name, out innerList) == false) { innerList = new Dictionary <Guid, ABCTreeListNode>(); this.DataList.Add(configNode.InnerData.Name, innerList); } DataView view = DataCachingProvider.TryToGetDataView(configNode.InnerData.TableName, false); BusinessObjectController Controller = BusinessControllerFactory.GetBusinessController(configNode.InnerData.TableName); String strPK = DataStructureProvider.GetPrimaryKeyColumn(configNode.InnerData.TableName); foreach (DataRow dr in view.Table.Rows) { BusinessObject obj = Controller.GetObjectFromDataRow(dr); if (obj != null) { Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(obj, strPK)); if (innerList.ContainsKey(iID) == false) { ABCTreeListNode node = new ABCTreeListNode(null, configNode.InnerData.Name, obj); node.Manager = this; node.CachingNode(); } else { innerList[iID].InnerData = obj; } } } } } catch (Exception ex) { } }
public static Dictionary <String, object> GetSameColumnValues(List <Guid> lstObjects, String strTableName) { String strQuery = QueryGenerator.GenSelect(strTableName, "*", false); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@"{0} IN ({1})", DataStructureProvider.GetPrimaryKeyColumn(strTableName), string.Format("'{0}'", String.Join("','", lstObjects)))); return(GetSameColumnValues(BusinessControllerFactory.GetBusinessController(strTableName).GetList(strQuery))); }
public static void SetIDValue(BusinessObject obj, Guid iID) { string strPrimaryKeyColumn = DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName); ABCDynamicInvoker.SetValue(obj, strPrimaryKeyColumn, iID); }
public void CachingNode( ) { try { if (Manager != null) { Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(this.InnerData, DataStructureProvider.GetPrimaryKeyColumn(this.InnerData.AATableName))); Dictionary <Guid, ABCTreeListNode> innerList = null; if (this.Manager.DataList.TryGetValue(this.ObjectName, out innerList) == false) { innerList = new Dictionary <Guid, ABCTreeListNode>(); this.Manager.DataList.Add(this.ObjectName, innerList); } if (innerList.ContainsKey(iID) == false) { innerList.Add(iID, this); } else { innerList[iID] = this; } } } catch (Exception ex) { } }
public void RefreshDisplayGrid( ) { DisplayGridView.TableName = this.TableName; DisplayGridView.Columns.Clear(); DisplayGridView.Bands.Clear(); DisplayGridView.BandConfigs = this.BandsList; DisplayGridView.ColumnConfigs = this.ColumnList; DisplayGridView.LoadBands(); #region Script if (String.IsNullOrWhiteSpace(this.TableName)) { if (String.IsNullOrWhiteSpace(Script) == false) { DataSet ds = DataQueryProvider.RunQuery(Script); if (ds != null && ds.Tables.Count > 0) { this.DisplayGridCtrl.DataSource = ds.Tables[0]; this.DisplayGridCtrl.RefreshDataSource(); DisplayGridView.ShowCustomization(); } } return; } #endregion if (DataCachingProvider.LookupTables.ContainsKey(this.TableName)) { this.DisplayGridCtrl.DataSource = DataCachingProvider.LookupTables[this.TableName]; } else { ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder(); strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0}", this.TableName)); if (DataStructureProvider.IsExistABCStatus(this.TableName)) { strBuilder.AddCondition(QueryGenerator.GenerateCondition(this.TableName, ABCCommon.ABCColumnType.ABCStatus)); } strBuilder.Append(String.Format(@" ORDER BY {0} DESC", DataStructureProvider.GetPrimaryKeyColumn(this.TableName))); try { DataSet ds = DataQueryProvider.RunQuery(strBuilder.ToString()); if (ds != null && ds.Tables.Count > 0) { this.DisplayGridCtrl.DataSource = ds.Tables[0]; } } catch (Exception ex) { } } this.DisplayGridCtrl.RefreshDataSource(); if (DisplayGridView.CustomizationForm == null || DisplayGridView.CustomizationForm.Visible == false) { DisplayGridView.ShowCustomization(); } }
public Guid GetIDByName(String strObjectName) { BusinessObject obj = GetObjectByName(strObjectName); return((Guid)ABCDynamicInvoker.GetValue(obj, DataStructureProvider.GetPrimaryKeyColumn(TableName))); }
public void DeleteItem(BusinessObject objT) { if (objT is T == false) { return; } foreach (String strChildName in Binding.Config.Children.Keys) { if (Binding.DataManager.DataObjectsList[strChildName].Config.DisplayOnly) { continue; } String strFK = Binding.DataManager.DataObjectsList[strChildName].Config.ChildField; String strFKTableName = Binding.DataManager.DataObjectsList[strChildName].TableName; Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(objT, DataStructureProvider.GetPrimaryKeyColumn(this.TableName))); if (iID != Guid.Empty) { BusinessObjectController ctrller = BusinessControllerFactory.GetBusinessController(strFKTableName); if (ctrller != null) { ctrller.DeleteObjectsByFK(strFK, iID); } } } Controller.DeleteObject(objT); }
public ABCTreeListNode(ABCTreeListNode parent, String strObjectName, BusinessObject _data) { this.ObjectName = strObjectName; this.ParentNode = parent; if (parent != null) { this.Level = parent.Level + 1; this.Manager = this.ParentNode.Manager; } this.InnerData = _data; if (this.InnerData != null) { Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(this.InnerData, DataStructureProvider.GetPrimaryKeyColumn(this.InnerData.AATableName))); if (this.ParentNode != null) { this.ParentNode.ChildrenNodes.Add(iID, this); } CachingNode(); } }
public void ExpandData(Boolean includeChildren, Boolean defaultOnly) { if (Manager == null || this.InnerData == null) { return; } TreeConfigNode config = null; if (Manager.ConfigList.TryGetValue(ObjectName, out config) == false) { return; } #region Current Childrens if (config.ParentNode == null || config.ParentNode.InnerData == null) { if (DataStructureProvider.IsTableColumn(config.InnerData.TableName, config.InnerData.ParentField) && DataStructureProvider.IsTableColumn(config.InnerData.TableName, config.InnerData.ChildField)) { String strPK = DataStructureProvider.GetPrimaryKeyColumn(config.InnerData.TableName); object objParentValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(this.InnerData, config.InnerData.ParentField); foreach (ABCTreeListNode childNode in Manager.DataList[config.InnerData.Name].Values) { object objChildValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(childNode.InnerData, config.InnerData.ChildField); if (objChildValue != null && (int)objChildValue == (int)objParentValue) { Guid iChildID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(childNode.InnerData, strPK)); if (this.ChildrenNodes.ContainsKey(iChildID) == false) { childNode.ParentNode = this; this.ChildrenNodes.Add(iChildID, childNode); childNode.ExpandData(includeChildren, defaultOnly); } } } } } #endregion #region Other Config Childrens foreach (TreeConfigNode childConfig in config.ChildrenNodes.Values) { if (defaultOnly && childConfig.InnerData != null && childConfig.InnerData.DefaultLoad == false) { continue; } String strPK = DataStructureProvider.GetPrimaryKeyColumn(childConfig.InnerData.TableName); object objParentValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(this.InnerData, childConfig.InnerData.ParentField); foreach (ABCTreeListNode childNode in Manager.DataList[childConfig.InnerData.Name].Values) { object objChildValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(childNode.InnerData, childConfig.InnerData.ChildField); if (objChildValue != null && (int)objChildValue == (int)objParentValue) { Guid iChildID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(childNode.InnerData, strPK)); if (this.ChildrenNodes.ContainsKey(iChildID) == false) { childNode.ParentNode = this; this.ChildrenNodes.Add(iChildID, childNode); if (includeChildren) { childNode.ExpandData(true, defaultOnly); } } } } #region old //#region Generate Query //ABCHelper.ConditionBuilder strBuilder=new ABCHelper.ConditionBuilder(); //strBuilder.Append( String.Format( @"SELECT * FROM {0}" , childConfig.InnerData.TableName ) ); //if ( objParentValue is String||objParentValue is DateTime) // strBuilder.AddCondition( String.Format( @" {0} = '{1}' " , childConfig.InnerData.ChildField , objParentValue.ToString() ) ); //else // strBuilder.AddCondition( String.Format( @" {0} = {1} " , childConfig.InnerData.ChildField , objParentValue ) ); //String strFilterCondintion=DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetMsSqlWhere( DevExpress.Data.Filtering.CriteriaOperator.Parse( childConfig.InnerData.FilterCondition ) ); //strBuilder.AddCondition( strFilterCondintion ); //if ( DataStructureProvider.IsExistABCStatus( childConfig.InnerData.TableName ) ) // strBuilder.AddCondition( Generation.QueryGenerator.GenerateCondition( childConfig.InnerData.TableName , ABCCommon.ABCConstString.ColumnType.ABCStatus ) ); //strBuilder.AddCondition( Security.DataAuthentication.GetAuthenticationString( childConfig.InnerData.TableName ) ); //#endregion //BusinessObjectController Controller=BusinessControllerFactory.GetBusinessController( childConfig.InnerData.TableName ); //DataSet ds=DataQueryProvider.RunQuery( strBuilder.ToString() ); //if ( ds!=null&&ds.Tables.Count>0 ) //{ // foreach ( DataRow dr in ds.Tables[0].Rows ) // { // BusinessObject objChild=Controller.GetObjectFromDataRow( dr ); // if ( objChild!=null ) // { // ABCTreeListNode childNode=new ABCTreeListNode( this , childConfig.InnerData.Name , objChild ); // if ( includeChildren ) // childNode.Expand( true , defaultOnly ); // } // } //} #endregion } #endregion }