示例#1
0
        private ProfileEntitlementView OpenProfileEntitlement(ProfileEntitlementModel pe)
        {
            var form = new Form();
            var view = (ProfileEntitlementForm)DBViewsFactory.GetView(MODELS.ProfileEntitlement);

            pe.ProfileId = Model.Id;
            view.SetModel(pe);
            view.Dock = DockStyle.Fill;
            form.Controls.Add(view);
            form.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.Size            = new System.Drawing.Size(430, 430);
            view.SetNewButtonEnabled(false);
            view.SetDeleteButtonEnabled(false);
            view.DisableChangeProfile();
            bool isnew = pe.Id == 0;

            view.AfterSave += (b) => {
                pe.EntitlementId = view.Model.EntitlementId;
                pe.ProfileId     = view.Model.ProfileId;
                var model = DBControllersFactory.ProfileEntitlement().Find(pe, "ProfileId", "EntitlementId");
                if (isnew)
                {
                    profileEntitlements.Add(model);
                }
                else
                {
                    profileEntitlements[profileEntitlements.IndexOf(profileEntitlements.Where(x => x.Id == pe.Id).First())] = model;
                }
                RequeryEntitlements();
                form.Close();
            };
            form.Show();
            return(view);
        }
示例#2
0
        private void BtnEditPE_Click(object sender, EventArgs e)
        {
            var model = new ProfileEntitlementModel {
                Id = lstProfileEntitlements.SelectedValue.ToInteger()
            };

            OpenProfileEntitlement(model).SetModel(DBControllersFactory.ProfileEntitlement().Find(model, "Id"));
        }