Exemplo n.º 1
0
        private bool VerificaLogin()
        {
            Boolean result = false;

            try
            {
                SecurityString SecurityS    = new SecurityString();
                string         SENHAUSUARIO = SecurityS.encrypt(txtSenha.Text);

                USUARIOProvider USUARIOP = new USUARIOProvider();

                RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();
                RowRelatorio.Add(new RowsFiltro("NOMEUSUARIO", "System.String", "=", txtNome.Text, "and"));
                RowRelatorio.Add(new RowsFiltro("SENHAUSUARIO", "System.String", "=", SENHAUSUARIO, "and"));
                RowRelatorio.Add(new RowsFiltro("FLAGATIVO", "System.String", "=", "S"));

                USUARIOCollection USUARIOColl = new USUARIOCollection();
                USUARIOColl = USUARIOP.ReadCollectionByParameter(RowRelatorio);

                if (USUARIOColl.Count > 0)
                {
                    _IdUsuario = USUARIOColl[0].IDUSUARIO;
                    _IdNivel   = Convert.ToInt32(USUARIOColl[0].IDNIVELUSUARIO);
                    result     = true;
                }
                else
                {
                    result = false;
                }

                return(result);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não foi possível acessar o Banco de Dados!",
                                "IMEX Sistemas",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);

                MessageBox.Show("Erro técnico: " + ex.Message);

                RestaurarConfig();

                result = false;

                return(result);
            }
        }
Exemplo n.º 2
0
        private Boolean VerificaPlanos()
        {
            Boolean result = true;

            try
            {
                if (BmsSoftware.ConfigSistema1.Default.FlagPlanos.Trim() == "S")
                {
                    USUARIOCollection USUARIOColl_Total = new USUARIOCollection();
                    USUARIOColl_Total = USUARIOP.ReadCollectionByParameter(null);

                    RECURSOSPLANOProvider RECURSOSPLANOP  = new RECURSOSPLANOProvider();
                    PLANOSProvider        PLANOSP         = new PLANOSProvider();
                    RECURSOSPLANOEntity   RECURSOSPLANOTy = new RECURSOSPLANOEntity();
                    RECURSOSPLANOTy = RECURSOSPLANOP.Read(Convert.ToInt32(BmsSoftware.ConfigSistema1.Default.IdPlanos));

                    if (RECURSOSPLANOTy != null)
                    {
                        int QuantUsuarios = Convert.ToInt32(RECURSOSPLANOTy.USUARIOS);

                        if (USUARIOColl_Total.Count < QuantUsuarios)
                        {
                            result = true;
                        }
                        else
                        {
                            MessageBox.Show("Limite de usuários atingido pelo plano: " + PLANOSP.Read(Convert.ToInt32(RECURSOSPLANOTy.IDPLANO)).NOME,
                                            ConfigSistema1.Default.NomeEmpresa,
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error,
                                            MessageBoxDefaultButton.Button1);

                            result = false;
                        }
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
                return(result);
            }
        }