public void UpdateUI(DEBusinessItem item, DEMetaClassEx meta, Guid uOid, bool readOnly) { this.Item = item; if (meta != null) { this.meta = meta; } this.uOid = uOid; this.Text = "编辑对象" + item.Master.Id; int y = 20; int x = 20; int num3 = 150; int num4 = 50; int height = 30; int width = 100; int num7 = 150; this.pnlProperty.Controls.Clear(); foreach (DEMetaAttribute attribute in this.meta.Attributes) { if (attribute.IsViewable) { Label label = new Label { Location = new Point(x, y + 5), Size = new Size(width, height), Text = attribute.Label + ":" }; TextBox box = null; ResCombo combo = null; if (!readOnly) { if (attribute.LinkedResClass != Guid.Empty) { combo = new ResCombo(ModelContext.MetaModel.GetClass(attribute.LinkedResClass).Name, attribute); } else { box = new TextBox(); } } else { box = new TextBox(); } if (!attribute.IsEditable || (PLGrantPerm.CanDoClassAttribute(ClientData.LogonUser.Oid, item.Master.ClassName, attribute.Name, item) == 1)) { if (box != null) { box.ReadOnly = true; } else if (combo != null) { combo.readOnly = true; } } if (readOnly) { if (box != null) { box.ReadOnly = true; } else if (combo != null) { combo.readOnly = true; } } if (box != null) { box.Location = new Point(num3, y); box.Size = new Size(num7, height); box.Tag = attribute; } else if (combo != null) { combo.Location = new Point(num3, y); combo.Size = new Size(num7, height); combo.Tag = attribute; } object attrValue = this.Item.Iteration.GetAttrValue(attribute.Name); if (box != null) { if (attrValue is Guid) { box.Text = PrincipalRepository.GetPrincipalName((Guid)attrValue); } else { box.Text = PSConvert.Attribute2String(attrValue, attribute); } } else if (combo != null) { if ((attribute.LinkType == 0) && (attribute.DataType == 8)) { if (attrValue == null) { combo.ResValue = ""; } else { combo.ResValue = combo.GetResourceID(new Guid((byte[])attrValue), ModelContext.MetaModel.GetClass(attribute.LinkedResClass).Name); } } else { combo.ResValue = PSConvert.Attribute2String(attrValue, attribute); } } this.pnlProperty.Controls.Add(label); if (box != null) { this.pnlProperty.Controls.Add(box); } else if (combo != null) { this.pnlProperty.Controls.Add(combo); } y += num4; } } }
public PropertyPanel(DEBusinessItem item, DEMetaClassEx meta, Guid uOid, bool readOnly) { this.InitializeComponent(); this.UpdateUI(item, meta, uOid, readOnly); }