Esempio n. 1
0
 //               //
 //  FRM_LOGIN    //
 //               //
 private void frmLogin_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && MainConfig.GetFocusedControl(this) != cbUsuario)
     {
         this.SelectNextControl(this.ActiveControl, !e.Shift, true, true, true);
     }
 }
Esempio n. 2
0
 //               //
 //   TXT_SENHA   //
 //               //
 private void txtSenha_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Enter)
     {
         MainConfig.GetFocusedControl(this);
         this.validarComboUsuario(new KeyEventArgs(Keys.Enter));
     }
 }
Esempio n. 3
0
        private void Logar()
        {
            try
            {
                if (cbUsuario.SelectedItem != null && txtSenha.Text.Trim() != "")
                {
                    if (cbUsuario.SelectedItem != null)
                    {
                        var objUsuario = new Usuario((Usuario)cbUsuario.SelectedItem);

                        if (objUsuario.validaUsuario(cbUsuario.SelectedItem, cbUsuario.Text, txtSenha.Text))
                        {
                            MainConfig.UserOn = objUsuario;
                            MainConfig.UserOn.definePermissoes();
                            MainConfig.UserOn.registrarAcesso(Usuario.statusLogin.LOGADO);
                            this.cbUsuario.Text = "";
                            this.txtSenha.Text  = "";
                            FrmAcao frmAcao = new FrmAcao();

                            frmAcao.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show(" A senha digitada \n é inválida!!", "Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                            txtSenha.Text = "";
                            txtSenha.Focus();
                        }
                    }
                }
                else
                {
                    if (cbUsuario.SelectedItem != null && txtSenha.Text.Trim() == "")
                    {
                        txtSenha.Text = "";
                        txtSenha.Focus();
                    }
                    else
                    {
                        cbUsuario.Text = "";
                        cbUsuario.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MainConfig.errorMessage("Não foi possível acessar o sistema! \nMotivo" + ex.Message, "Login");
            }
        }
Esempio n. 4
0
        public frmLogin()
        {
            try
            {
                daoUsuario = new DaoUsuario();

                //Configurações de criação do form
                InitializeComponent();
                //Seta as configurações principais a serem usadas na classe MainConfig
                MainConfig.setMainConfigurations();
                //Configura a string de conexão para conexão com o servidor.
                SqlServerConn.configuraStrConnection(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase), "strConn.txt");
                //Configura string de conexão E/OU cria a base mobile e todas as suas tabelas.
                BaseMobile.configurarBaseMobile();
                //Recupera Permissões a serem usadas no sistema mobile
                MainConfig.recuperaPermissoes();
                //Configura Layout
                this.configControls();
                //Preenche o combo de Usuários para que seja validado o Login
                this.preencheComboBoxUsuario(cbUsuario, daoUsuario.retornaListUsuarios(), Usuario.usuarioProperty.NOME, false);
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                StringBuilder bdMsg = new StringBuilder();
                bdMsg.Append("\nOcorreu um problema durante a tentativa de conexão com a base de dados!");
                bdMsg.Append("\nA aplicação não poderá ser iniciada.");
                bdMsg.Append("\nDescription :" + sqlEx.Message);
                bdMsg.Append("\nSource :" + sqlEx.Source);
                MainConfig.errorMessage(bdMsg.ToString(), "Connection error");

                Application.Exit();
            }
            catch (Exception ex)
            {
                StringBuilder bdMsg = new StringBuilder();
                bdMsg.Append("\nO sistema não pode ser iniciado.");
                bdMsg.Append("\nFavor contate o administrador do sitema.");
                bdMsg.Append("\nDescription :" + ex.Message);
                MainConfig.errorMessage(bdMsg.ToString(), "Application Error.");

                Application.Exit();
            }
            finally
            {
                daoUsuario = null;
            }
        }
        private void configControls()
        {
            this.SuspendLayout();
            this.Size = new System.Drawing.Size(MainConfig.ScreenSize.Width, MainConfig.ScreenSize.Height);

            //
            //pboxFrmLogin
            //
            this.pboxFrmLogin.Location = new System.Drawing.Point(0, 0);
            this.pboxFrmLogin.Size     = new System.Drawing.Size(this.Size.Width, 90);
            //Tamanho da Imagem a ser mostrada no Picture Box
            this.ImgLogin.ImageSize     = new Size((int)(this.Size.Width), 89);
            this.pboxFrmLogin.BackColor = Color.Black;
            this.pboxFrmLogin.Image     = ImgLogin.Images[1];
            this.FormBorderStyle        = FormBorderStyle.None;
            //
            //pnFrmLogin
            //
            this.panelFrmLogin.Size      = new System.Drawing.Size(this.Size.Width, this.Size.Height - 20);
            this.panelFrmLogin.BackColor = System.Drawing.SystemColors.AppWorkspace;
            //
            // Label Descrição
            //
            this.lbDescricao.Font      = MainConfig.FontMuitoGrandeBold;
            this.lbDescricao.Text      = "Login";
            sizeString                 = MainConfig.sizeStringEmPixel(this.lbDescricao.Text, MainConfig.FontMuitoGrandeBold);
            this.lbDescricao.Size      = new System.Drawing.Size((int)sizeString.Width, (int)sizeString.Height);
            this.lbDescricao.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            sizeString                 = MainConfig.sizeStringEmPixel(this.lbDescricao.Text, MainConfig.FontGrandeRegular);
            this.lbDescricao.Location  = new System.Drawing.Point((int)(MainConfig.ScreenSize.Width / 2 - lbDescricao.Width / 2),
                                                                  this.panelFrmLogin.Location.Y + pboxFrmLogin.Size.Height);
            //
            //Label Usuário
            //
            this.lbUsuario.Font      = MainConfig.FontMediaBold;
            this.lbUsuario.Size      = new System.Drawing.Size(90, 35);
            this.lbUsuario.Text      = "Usuário :";
            this.lbUsuario.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            sizeString = MainConfig.sizeStringEmPixel(this.lbUsuario.Text, MainConfig.FontGrandeRegular);
            this.lbUsuario.Location = new System.Drawing.Point((int)(MainConfig.intPositionX + 20),
                                                               this.lbDescricao.Location.Y + 80);
            //
            //Label Senha
            //
            this.lbSenha.Font      = MainConfig.FontMediaBold;
            this.lbSenha.Text      = "Senha :";
            this.lbSenha.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            sizeString             = MainConfig.sizeStringEmPixel(this.lbSenha.Text, MainConfig.FontGrandeRegular);
            this.lbSenha.Size      = new System.Drawing.Size((int)sizeString.Width, (int)sizeString.Height);
            this.lbSenha.Location  = new System.Drawing.Point((int)(this.lbUsuario.Location.X + 3),
                                                              this.lbUsuario.Location.Y + 30);

            //
            //ComboBox Usuário
            //
            this.cbUsuario.Font     = MainConfig.FontPequenaBold;
            sizeString              = MainConfig.sizeStringEmPixel(this.lbSenha.Text, MainConfig.FontGrandeRegular);
            this.cbUsuario.Visible  = true;
            this.cbUsuario.Size     = new System.Drawing.Size(120, 27);
            this.cbUsuario.Location = new System.Drawing.Point((int)(this.lbUsuario.Location.X + this.lbUsuario.Size.Width),
                                                               this.lbUsuario.Location.Y - 3);
            this.cbUsuario.DropDownStyle = ComboBoxStyle.DropDown;

            //
            // TextBox Senha
            //
            this.txtSenha.Font         = MainConfig.FontMediaBold;
            this.txtSenha.Text         = "";
            this.txtSenha.MaxLength    = 12;
            this.txtSenha.PasswordChar = MainConfig.PasswordChar;
            this.txtSenha.Visible      = true;
            this.txtSenha.Size         = new System.Drawing.Size(cbUsuario.Size.Width, 23);
            this.txtSenha.Location     = new System.Drawing.Point((int)(this.cbUsuario.Location.X),
                                                                  this.lbSenha.Location.Y - 3);
            this.txtSenha.Enabled = false;

            //
            //Button Login
            //
            this.btLogin.Font     = MainConfig.FontMediaBold;
            this.btLogin.Visible  = true;
            this.btLogin.Size     = new System.Drawing.Size(72, 30);
            this.btLogin.Location = new System.Drawing.Point((int)(MainConfig.ScreenSize.Width / 2 - btLogin.Size.Width - 3),
                                                             this.lbSenha.Location.Y + 40);

            //
            //Button Sair
            //
            this.btSair.Font     = MainConfig.FontMediaBold;
            this.btSair.Visible  = true;
            this.btSair.Size     = new System.Drawing.Size(72, 30);
            this.btSair.Location = new System.Drawing.Point((int)(MainConfig.ScreenSize.Width / 2 + 3),
                                                            this.lbSenha.Location.Y + 40);

            //
            //FrmLogin
            //
            Size size = new Size(this.ClientSize.Width, this.ClientSize.Height);

            MainConfig.defineClienteSize(size);
            this.cbUsuario.Focus();
            this.ResumeLayout();
        }