private void AddControl(LayoutControlItem layout, object targetObject, string memberName, string caption) { layout.Text = caption; Type type = targetObject.GetType(); BaseEdit control; if (security.CanRead(targetObject, memberName)) { control = GetControl(type, memberName); if (control != null) { control.DataBindings.Add(new Binding(nameof(BaseEdit.EditValue), targetObject, memberName, true, DataSourceUpdateMode.OnPropertyChanged)); control.Enabled = security.CanWrite(targetObject, memberName); } } else { control = new ProtectedContentEdit(); } dataLayoutControl1.Controls.Add(control); layout.Control = control; }
private void AddControl(LayoutControlItem layout, object targetObject, string memberName) { layout.Text = memberName; Type type = targetObject.GetType(); BaseEdit control; if (security.IsGranted(new PermissionRequest(securedObjectSpace, type, SecurityOperations.Read, targetObject, memberName))) { control = GetControl(type, memberName); if (control != null) { control.DataBindings.Add(new Binding("EditValue", employeeBindingSource, memberName, true, DataSourceUpdateMode.OnPropertyChanged)); control.Enabled = security.IsGranted(new PermissionRequest(securedObjectSpace, type, SecurityOperations.Write, targetObject, memberName)); } } else { control = new ProtectedContentEdit(); control.Enabled = false; } dataLayoutControl1.Controls.Add(control); layout.Control = control; }