public IList <ObjectGroupingItemData> GetChildren(int?parentID) { if (ConnParams == null) { throw new NullPropertyException("Connection parameters is null!"); } IList <ObjectGroupingItemData> result = new List <ObjectGroupingItemData>(); using (SqlConnection conn = new SqlConnection(_connParams.ConnectionString)) { string cmdText = ResManager.GetDBScript("spPragmaSQL_ObjectGroup_List"); SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.CommandTimeout = 0; AddParam(cmd, "@ParentID", System.Data.SqlDbType.Int, parentID); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); string name = String.Empty; int? type = null; int? id = null; string parentObjName = String.Empty; string createdBy = String.Empty; string updatedBy = String.Empty; string helpText = String.Empty; string helpTextFormat = String.Empty; ObjectGroupingItemData data = null; try { while (reader.Read()) { name = reader["Name"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["Name"]; type = reader["ObjType"].GetType() == typeof(DBNull) ? null : (int?)reader["ObjType"]; id = reader["ObjectID"].GetType() == typeof(DBNull) ? null : (int?)reader["ObjectID"]; parentObjName = reader["ParentObjName"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["ParentObjName"]; createdBy = reader["CreatedBy"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["CreatedBy"]; updatedBy = reader["UpdatedBy"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["UpdatedBy"]; helpText = reader["Description"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["Description"]; helpTextFormat = reader["DescriptionFormat"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["DescriptionFormat"]; data = ObjectGroupingItemDataFactory.Create(name, type, id, parentObjName, parentID, createdBy); data.HelpText = helpText; data.HelpTextFormat = helpTextFormat; data.UpdatedBy = updatedBy; result.Add(data); } } finally { reader.Close(); } } return(result); }
public IList <ObjectGroupingItemData> GetChildItemsOf(int?parentID) { if (ConnParams == null) { throw new NullPropertyException("Connection parameters is null!"); } IList <ObjectGroupingItemData> result = new List <ObjectGroupingItemData>(); using (SqlConnection conn = new SqlConnection(_connParams.ConnectionString)) { string cmdText = global::PragmaSQL.Scripts.Properties.Resources.spPragmaSQL_ObjectGroup_List; SqlCommand cmd = new SqlCommand(cmdText, conn); cmd.Parameters.Add("@ParentID", System.Data.SqlDbType.Int); cmd.Parameters["@ParentID"].Value = parentID; conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); string name = String.Empty; int? type = null; int? id = null; string tableName = String.Empty; string createdBy = String.Empty; ObjectGroupingItemData data = null; try { while (reader.Read()) { name = reader["Name"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["Name"]; type = reader["ObjType"].GetType() == typeof(DBNull) ? null : (int?)reader["ObjType"]; id = reader["ObjectID"].GetType() == typeof(DBNull) ? null : (int?)reader["ObjectID"]; tableName = reader["TableName"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["TableName"]; createdBy = reader["CreatedBy"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["CreatedBy"]; data = ObjectGroupingItemDataFactory.Create(name, type, id, tableName, parentID, createdBy); result.Add(data); } } finally { reader.Close(); } } return(result); }
public void AddFolder(TreeNode parentNode) { string name = String.Empty; int? parentID = null; ObjectGroupingItemData parentData = ObjectGroupingItemDataFactory.GetNodeData(parentNode); if (parentData != null) { parentID = parentData.ID; } DialogResult dlgRes = InputDialog.ShowDialog("New Folder", "Folder Name", ref name); if (dlgRes != DialogResult.OK || String.IsNullOrEmpty(name)) { return; } try { tv.BeginUpdate(); ObjectGroupingItemData newFolderData = ObjectGroupingItemDataFactory.Create(name, DBObjectType.GroupingFolderY, null, String.Empty, parentID, _connParams.CurrentUsername); newFolderData.ParentID = parentID; try { _grpFacade.AddItem(newFolderData); TreeNode newFolder = AddNode(parentNode, newFolderData); AddEmptyNode(newFolder); if (parentNode != null && !parentNode.IsExpanded) { parentNode.Expand(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { UpdateSelectedItemInfo(); tv.EndUpdate(); } }
public void AddObjectFromObjectExplorer(TreeNode source, TreeNode dropNode) { if (source == null) { return; } NodeData sourceData = NodeDataFactory.GetNodeData(source); if (sourceData == null) { return; } try { tv.BeginUpdate(); ObjectGroupingItemData dropData = ObjectGroupingItemDataFactory.GetNodeData(dropNode); int? parentID = null; TreeNode parentNode = null; if (dropNode != null && dropData != null) { if (dropData.Type == DBObjectType.GroupingFolderY) { parentID = dropData.ID; parentNode = dropNode; } else { parentID = dropData.ParentID; parentNode = dropNode.Parent; } } string tableName = String.Empty; if (sourceData.Type == DBObjectType.Trigger) { tableName = sourceData.ParentName; } ObjectGroupingItemData data = ObjectGroupingItemDataFactory.Create(sourceData.Name, sourceData.Type, null, tableName, parentID, _connParams.CurrentUsername); try { _grpFacade.AddItem(data); AddNode(parentNode, data); if (parentNode != null && !parentNode.IsExpanded) { parentNode.Expand(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { tv.EndUpdate(); UpdateSelectedItemInfo(); } }