/// <summary> /// attribute change /// </summary> /// <param name="ca"></param> /// <returns></returns> internal bool UpdateAttribute(ComponentAttribute ca, string serverid = "") { try { if (this.TableID != "") { if (serverid == "") { Tz.ClientManager.ClientServer c = new Tz.ClientManager.ClientServer(this.ClientID); Tz.ClientManager.Server s = c.GetServer(); serverid = s.ServerID; } DataManager dm = new DataManager(this.TableID, serverid, this.ClientID); dm.ChangeField(ca.FieldID, ca.AttributeName.Replace(" ", "_"), GetFieldType(ca), ca.Length, ca.IsNullable, ca.IsPrimaryKey, ca.AttributeName.Replace(" ", "_")); dm.AcceptChanges(); } var dataComponentAttr = new Data.Component.ComponentAttribute(ck.GetServer().Connection()); dataComponentAttr.Update(this.ClientID, this.ComponentID, ca.FieldID, ca.IsRequired, ca.IsCore, ca.IsUnique, ca.IsReadOnly, ca.IsSecured, ca.IsAuto, ca.LookUpID, ca.DefaultValue, ca.FileExtension, ca.RegExp, ca.AttributeName, ca.Length, ca.IsNullable, ca.IsPrimaryKey); return(true); } catch (Exception ex) { throw ex; } }
public bool ChangeAttribute(ComponentAttribute ca) { Component c = (Component)_component; return(c.UpdateAttribute(ca)); }
public bool AddAttribute(ComponentAttribute ca) { Component c = (Component)_component; return(c.AddAttribute(ca)); }
public void InsertAttribute(ComponentAttribute ca) { Component c = (Component)_component; c.Attributes.Add(ca); }
public static List <Component> GetComponentList(string clientID) { var ck = new ClientServer(clientID); var dataComponent = new Data.Component.Component(ck.GetServer().Connection()); var dtFields = new DataTable(); var dt = dataComponent.GetCompnents(clientID); var dttable = dt.DefaultView.ToTable(true, "ComponentID", "ComponentName", "ComponentType", "Title", "TableID", "PrimaryKeys", "TitleFormat", "Category", "IsGlobal" ); var clist = new List <Component>(); dtFields = dt.DefaultView.ToTable(true, "FieldID", "AttributeName", "ComponentID", "IsRequired", "IsUnique", "IsCore", "IsReadOnly", "IsSecured", "IsAuto", "DefaultValue", "FileExtension", "RegExp", "AttributeType" ); foreach (DataRow dr in dttable.Rows) { var c = new Component(clientID); c.ComponentID = dr.IsNull("ComponentID") ? "" : dr["ComponentID"].ToString(); c.ComponentName = dr.IsNull("ComponentName") ? "" : dr["ComponentName"].ToString(); c.ComponentType = dr.IsNull("ComponentType") ? Tz.Core.ComponentType.none : (Tz.Core.ComponentType)dr["ComponentType"]; c.Title = dr.IsNull("Title") ? "" : dr["Title"].ToString(); c.TableID = dr.IsNull("TableID") ? "" : dr["TableID"].ToString(); c.PrimaryKeys = dr.IsNull("PrimaryKeys") ? "" : dr["PrimaryKeys"].ToString(); c.TitleFormat = dr.IsNull("TitleFormat") ? "" : dr["TitleFormat"].ToString(); c.Category = dr.IsNull("Category") ? "" : dr["Category"].ToString(); c.IsGlobal = dr.IsNull("IsGlobal") ? false : Convert.ToBoolean(dr["IsGlobal"]); c.State = dr.IsNull("ComponentState") ? ComponentState.draft : (ComponentState)(dr["ComponentState"]); foreach (DataRow drow in dtFields.Rows) { string _fieldid = ""; _fieldid = drow.IsNull("FieldID") ? "" : drow["FieldID"].ToString(); ComponentAttribute ca = new ComponentAttribute(clientID, c.TableID, _fieldid); ca.AttributeName = drow.IsNull("AttributeName") ? "" : drow["AttributeName"].ToString(); // ca.FieldName = drow.IsNull("FieldName") ? "" : drow["FieldName"].ToString(); ca.IsRequired = drow.IsNull("IsRequired") ? false : Convert.ToBoolean(drow["IsRequired"]); ca.IsUnique = drow.IsNull("IsUnique") ? false : Convert.ToBoolean(drow["IsUnique"]); ca.IsCore = drow.IsNull("IsCore") ? false : Convert.ToBoolean(drow["IsCore"]); ca.IsReadOnly = drow.IsNull("IsReadOnly") ? false : Convert.ToBoolean(drow["IsReadOnly"]); ca.IsSecured = drow.IsNull("IsSecured") ? false : Convert.ToBoolean(drow["IsSecured"]); ca.IsAuto = drow.IsNull("IsAuto") ? false : Convert.ToBoolean(drow["IsAuto"]); ca.DefaultValue = drow.IsNull("DefaultValue") ? "" : drow["DefaultValue"].ToString(); ca.FileExtension = drow.IsNull("FileExtension") ? "" : drow["FileExtension"].ToString(); ca.RegExp = drow.IsNull("RegExp") ? "" : drow["RegExp"].ToString(); ca.LookUpID = dr.IsNull("LookUpID") ? "" : dr["LookUpID"].ToString(); ca.AttributeType = drow.IsNull("AttributeType") ? ComponentAttribute.ComoponentAttributeType._string : (ComponentAttribute.ComoponentAttributeType)drow["AttributeType"]; //ca.FieldType = drow.IsNull("FieldType") ? DbType.String : (DbType)drow["FieldType"]; ca.Length = drow.IsNull("length") ? -1 : (int)drow["length"]; ca.IsNullable = drow.IsNull("IsNullable") ? false : (bool)drow["IsNullable"]; ca.IsPrimaryKey = drow.IsNull("ISPrimaryKey") ? false : (bool)drow["ISPrimaryKey"]; c.Attributes.Add(ca); } clist.Add(c); } return(clist); }