Example #1
0
 private void UpdateAutomaticNumering()
 {
     GlobalUser.AutomaticNumberings = AutomaticNumberingApp.Search().ToList();
 }
Example #2
0
        public FLogin(SplashScreen splash)
        {
            _splashScreen = splash;
            var ri   = new RepositoryInjection();
            var conn = ri.GetClass <IFactoryConnection>();

            _userApp               = new UserApp(conn);
            _companyApp            = new CompanyApp(conn);
            _translateApp          = new TranslateApp(conn);
            _tableApp              = new TableApp(conn);
            _dbTableApp            = new DbTableApp(conn);
            _automaticNumberingApp = new AutomaticNumberingApp(conn);

            _userController = new UserController(conn);

            GlobalUser.Forms               = _tableApp.Search().ToList();
            GlobalUser.Translates          = _translateApp.Search().ToList();
            GlobalUser.Tables              = _dbTableApp.Search().ToList();
            GlobalUser.AutomaticNumberings = _automaticNumberingApp.Search().ToList();

            InitializeComponent();

            Unidade.ObjetoApp     = new InvokeMethod(typeof(CompanyController), TypeExecute.SearchAll, "ListCompany", typeof(Company));
            Unidade.DisplayMember = "PersonName";
            Unidade.ValueMember   = "Id";
            Unidade.Enabled       = false;
            Unidade.Refresh();
            Unidade.SComponent.DropDown += SComponentOnDropDown;
            Unidade.Caption              = "Unidade";

            EntrarButton.SComponent.BackColor = Color.DarkSlateGray;
            EntrarButton.SComponent.ForeColor = Color.White;
            EntrarButton.SComponent.Text      = @"Entrar";
            EntrarButton.SComponent.Click    += EntrarButton_Click;
            EntrarButton.Enabled = false;

            SenhaTextBox.SComponent.PasswordChar = '*';
            SenhaTextBox.Caption = "Senha";
            SenhaTextBox.SComponent.TextChanged += SenhaComponentOnTextChanged;

            UsuarioTextBox.SComponent.TextChanged += UsuarioComponentOnTextChanged;
            UsuarioTextBox.Caption = "Login";

            var cont = false;

            if (_companyApp.Search().Any())
            {
                if (!_userApp.Search().Any())
                {
                    MessageBox.Show(@"Necessário cadastrar um usuário",
                                    @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);
                    var fuser = new FUser
                    {
                        StateForm       = StateForm.Inserting,
                        ClosedAfterSave = true
                    };
                    fuser.RefreshControls();
                    ((User)fuser.CurrentControl).IsAdministrator = true;
                    _splashScreen.Close();
                    fuser.ShowDialog();
                }
                return;
            }
            ;
            MessageBox.Show(@"Este é o seu primeiro acesso ao sistema, por favor, cadastre sua empresa.",
                            @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);

            do
            {
                var fcompany = new FCompany()
                {
                    StateForm       = StateForm.Inserting,
                    ClosedAfterSave = true
                };
                fcompany.RefreshControls();
                _splashScreen.Close();
                fcompany.ShowDialog();
                if (!_companyApp.Search().Any())
                {
                    cont = MessageBox.Show(@"Necessário cadastrar uma empresa, deseja continuar ?",
                                           @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                           DialogResult.Yes;
                }
            } while (cont);

            if (!_companyApp.Search().Any())
            {
                Close();
            }
            else
            {
                if (_userApp.Search().Any())
                {
                    return;
                }
                MessageBox.Show(@"Necessário cadastrar um usuário",
                                @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK);
                var fuser = new FUser
                {
                    ClosedAfterSave = true,
                    StateForm       = StateForm.Inserting,
                };
                ((User)fuser.CurrentControl).IsAdministrator = true;
                _splashScreen.Close();
                fuser.ShowDialog();
            }
        }
 public bool Remove(Expression <Func <AutomaticNumbering, bool> > expression)
 {
     _automaticNumberingApp.Remove(_automaticNumberingApp.Search(expression).ToList());
     return(_connection.Save());
 }
Example #4
0
 /// <summary>
 /// Força atualização de todos os objetos da tela.
 /// </summary>
 public void RefreshControls()
 {
     try
     {
         var fieldsForm = GetListControls().OrderBy(c => c.Index);
         foreach (var fieldInfo in fieldsForm)
         {
             if (StateForm != StateForm.Waiting)
             {
                 if (GlobalUser.User != null)
                 {
                     foreach (var groupUser in GlobalUser.User.GroupUsers)
                     {
                         foreach (var groupPermission in groupUser.GroupAccess.GroupPermissions)
                         {
                             if (groupPermission.Permission.TypeComponent != TypeComponent.Field)
                             {
                                 continue;
                             }
                             if (groupPermission.Permission.NamePermission != fieldInfo.Name)
                             {
                                 continue;
                             }
                             if (groupPermission.Permission.Delete)
                             {
                                 fieldInfo.Disable = false;
                             }
                             else if (groupPermission.Permission.Insert)
                             {
                                 fieldInfo.Disable = false;
                             }
                             else if (groupPermission.Permission.Update)
                             {
                                 fieldInfo.Disable = false;
                             }
                             else if (groupPermission.Permission.Visible)
                             {
                                 fieldInfo.Visible = false;
                             }
                         }
                     }
                 }
             }
             fieldInfo.Refresh();
             if (StateForm == StateForm.Inserting && !fieldInfo.DisabledAutomaticNumbering)
             {
                 var fieldConf = GlobalUser.AutomaticNumberings.FirstOrDefault(c => c.DbTable.TableName == InvokeMethod.TypeModel.Name && c.FieldName == fieldInfo.Name);
                 if (fieldConf != null)
                 {
                     var sequencia = AutomaticNumberingApp.GerarSequencia(fieldConf.DbTableId, fieldConf.FieldName);
                     if (sequencia.HasValue)
                     {
                         var reflection      = new SReflection();
                         var valueConvertido = reflection.ConvertValue(sequencia, fieldInfo.PropertyControl);
                         fieldInfo.ValueControl         = valueConvertido;
                         GlobalUser.AutomaticNumberings = AutomaticNumberingApp.Search().ToList();
                     }
                     fieldInfo.Disable = false;
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }