/// <summary> /// 设置字段的值 /// </summary> /// <param name="type"></param> /// <param name="obj"></param> public void SetItemValue(SystemType type, string obj) { comboBox1.SelectedIndex = GetIndexByType(type, comboBox1); switch (type) { case SystemType.附件: PermissionForm owner = null; Form f = this.FindForm(); if (f != null && f is PermissionForm) { owner = f as PermissionForm; } Attachment a = Commons.GetAttachment(obj, owner); List <Attachment> atta = new List <Attachment>(); if (a != null) { atta.Add(a); } uc.Attachments = atta; break; case SystemType.时间: dtp.Value = Convert.ToDateTime(obj); break; case SystemType.数字: nud.Value = Convert.ToDecimal(obj); break; case SystemType.字符: default: tb.Text = Convert.ToString(obj); break; } }
/// <summary> /// 设置字段的值(注意:只能自己上传附件,无法修改别人上传的附件,其他字段类型的值就能修改) /// </summary> /// <param name="type"></param> /// <param name="obj"></param> public void SetItemValue(SystemType type, string obj) { panel1.Controls.Clear(); Control c = null; switch (type) { case SystemType.附件: PermissionForm owner = null; Form f = this.FindForm(); if (f != null && f is PermissionForm) { owner = f as PermissionForm; } Attachment a = Commons.GetAttachment(obj, owner); List <Attachment> atta = new List <Attachment>(); if (a != null) { atta.Add(a); } uc.Attachments = atta; c = uc; break; case SystemType.时间: dtp.Value = Convert.ToDateTime(obj); c = dtp; break; case SystemType.数字: nud.Value = Convert.ToDecimal(obj); c = nud; break; case SystemType.字符: default: tb.Text = Convert.ToString(obj); c = tb; break; } if (c != null) { panel1.Controls.Add(c); } }