Example #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            passwordInserita = textBox1.Text;

            if (passwordInserita == checkPassword)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                FormsHelper.Error("Password Errata!", this.Text);
            }
        }
Example #2
0
        public void LoadForm()
        {
            tsddbLanguage.DropDownItems.Clear();
            foreach (var l in CntrlLG.Select(new LanguageModel {
            }, "Id,LanguageName").Concat(new[] { new LanguageModel {
                                                     LanguageName = "English"
                                                 } }))
            {
                tsddbLanguage.DropDownItems.Add(l.LanguageName).Click += (s, e) => {
                    //new Thread(delegate () {
                    if (WordController.CurrentLanguage == LanguageState.Translation)
                    {
                        CntrlWD.SetToDefault();
                        FormsHelper.ApplyLanguageLocalization(this);
                    }
                    CntrlWD.ReadDictionary(l.Id);
                    tsddbLanguage.Text = l.LanguageName;
                    //BeginInvoke((Action)delegate () {
                    FormsHelper.ApplyLanguageLocalization(this);
                    //});
                    //}).Start();
                };
            }

            tsProgressBar.Value = 0;

            //FormsHelper.ApplyLanguageLocalization(this);

            tssLabelStatus.Text = "Loading Menus";
            //LogOutToolStripMenuItemClick(sender, e);
            //LogInToolStripMenuItemClick(sender, e);
            tsProgressBar.Value = 100;
            var login = new UsersLoginView();

            login.GoClicked += delegate(UserModel um) {
                um = CntrlUS.Autheniticate(um);
                if (um == null)
                {
                    FormsHelper.Error("Login denied");
                    return;
                }
                login.Visible = false;
                WhenAuthenticated(um);
            };
            ShowView(login, "Main");
        }
Example #3
0
        private void MainViewLoad(object sender, EventArgs e)
        {
            if (DesignMode || (Site != null && Site.DesignMode))
            {
                return;
            }
            //tsDateTime.Alignment = ToolStripItemAlignment.Right;
            //try {
            //this.StartPosition = FormStartPosition.CenterScreen;
            SetBounds(100, 50, 1200, 680);

            LoadForm();

            try{}
            catch (Exception ex) {
                FormsHelper.Error(ex.Message);
            }
        }
Example #4
0
        public PermissionsHelper(BaseView <M, C> view)
        {
            if (view == null)
            {
                throw new ArgumentException("view cannot be null");
            }
            //if(model==default) throw new ArgumentException("model cannot be null");
            var CntrlEN = DBControllersFactory.Entitlement();
            var CntrlPE = DBControllersFactory.ProfileEntitlement();
            var CntrlPR = DBControllersFactory.Profile();
            var CntrlET = DBControllersFactory.Entity();

            var usr = MVCHISSession.Instance.CurrentUser;

            if (usr == null)
            {
                return;
            }
            //var mdl = view?.GetType().GetCustomAttributes().OfType<ForModelAttribute>().FirstOrDefault();
            //if (mdl == null) return;

            var entity = CntrlET.Find(new EntityModel()
            {
                EntityName = $"{typeof(M).Name}".Replace("Model", "")
            }, "EntityName");

            var ent = CntrlEN.Find(new EntitlementModel()
            {
                EntityId = entity.Id
            }, "EntityId");

            if (ent == null)
            {
                return;
            }

            var pen = CntrlPE.Find(new ProfileEntitlementModel()
            {
                ProfileId     = usr.ProfileId,
                EntitlementId = ent.Id
            }, "ProfileId", "EntitlementId");

            if (view.NewButton != null)
            {
                view.SetNewButtonEnabled(view.NewButton.Enabled && pen.AllowCreate);
            }
            if (view.SaveButton != null)
            {
                view.SetSaveButtonEnabled(view.SaveButton.Enabled && pen.AllowUpdate);
            }
            if (view.DeleteButton != null)
            {
                view.SetDeleteButtonEnabled(view.DeleteButton.Enabled && pen.AllowDelete);
            }

            if (!pen.AllowRead)
            {
                FormsHelper.Error($"You don't have enough permissions to open {view}.");
                view.GotFocus += (x, y) => {
                    view.Enabled = false;
                    view.BeginInvoke(new MethodInvoker(view.Hide));
                };
            }
        }
Example #5
0
        public BaseBinder() : base()
        {
            Controllers = new Dictionary <string, IDBController>();
            Mapper      = new Dictionary <string, Control>();
            Prop        = new Func <string, PropertyInfo>(x => typeof(M).GetProperty(x));
            isBoolean   = new Func <string, bool>(x => Mapper[x].GetType() == typeof(CheckBox) &&
                                                  Prop(x).PropertyType == typeof(bool));
            isDateTime = new Func <string, bool>(x => Prop(x).PropertyType == typeof(DateTime) ||
                                                 Prop(x).PropertyType == typeof(DateTime?));
            isInt64 = new Func <string, bool>(x => Prop(x).PropertyType == typeof(Int64));
            isInt32 = new Func <string, bool>(x => Prop(x).PropertyType == typeof(Int32) ||
                                              Prop(x).PropertyType == typeof(int));
            isDouble = new Func <string, bool>(x => Prop(x).PropertyType == typeof(double) ||
                                               Prop(x).PropertyType == typeof(Double));

            //Load += (s, e) => {
            //    if (DesignMode || (Site != null && Site.DesignMode)) return;
            new PermissionsHelper <M>(this);
            foreach (var control in Mapper.Values.OrderBy(x => x.TabIndex))
            {
                if (DefaultControl == null && control.TabStop)
                {
                    DefaultControl = control;
                }
                control.KeyDown += delegate(object sender, KeyEventArgs ea) {
                    if (ea.KeyCode == Keys.Enter)
                    {
                        ea.SuppressKeyPress = true;
                        ea.Handled          = true;
                        SendKeys.Send("\t");
                    }
                };
            }
            DefaultControl?.Focus();
            if (SaveButton != null)
            {
                SaveButton.Enabled = SaveButtonEnabled;
                SaveButton.Click  += (bs, be) => {
                    try {
                        Controller.Save(Model);
                        Model = Controller.Find(Model, Controller.GetMetaData().UniqueKeyFields.ToArray());
                        AfterSave?.Invoke();
                        DefaultControl.Focus();
                        DefaultControl.Select();
                    }catch (Exception ex) {
                        FormsHelper.Error(ex.Message);
                    }
                };
            }
            if (DeleteButton != null)
            {
                DeleteButton.Enabled = DeleteButtonEnabled;
                DeleteButton.Click  += (bs, be) => { Controller.Delete(Model); NewButton?.PerformClick(); };
            }
            if (NewButton != null)
            {
                NewButton.Enabled = NewButtonEnabled;
                NewButton.Click  += (bs, be) => { Model = Controller.NewModel <M>(); };
            }
            //};
        }