private void btnLogin_Click(object sender, EventArgs e)
        {
            bool found = false;
            Operador usuario = new Operador();

            if ((txbId.TextLength > 0) && (txbSenha.TextLength > 0))
            {

                using (SqlConnection sqlConn = new SqlConnection(@"Data Source=(localdb)\Av2DotNet;Initial Catalog=estoque;Integrated Security=True"))
                {
                    using (SqlCommand sqlCommand = new SqlCommand())
                    {
                        sqlCommand.CommandText = "SELECT id, senha, nome, tipo FROM operador";
                        sqlCommand.Connection = sqlConn;
                        sqlConn.Open();
                        SqlDataReader dataReader;
                        dataReader = sqlCommand.ExecuteReader(); //para caso que retorna registros
                        while ((found == false) && (dataReader.Read())) //encontrou registro
                        {
                            usuario.Id = Int32.Parse(dataReader[0].ToString());
                            usuario.Senha = dataReader[1].ToString();
                            usuario.Nome = dataReader[2].ToString();
                            usuario.Tipo = int.Parse(dataReader[3].ToString());

                            if (usuario.Id == Int32.Parse(txbId.Text))
                            {
                                if (usuario.Senha == txbSenha.Text)
                                {
                                    found = true;
                                }
                            }
                        }
                        sqlConn.Close();
                    }
                }
                if (found == true)
                {
                    this.Hide();
                    FormPrincipal formPrincipal = new FormPrincipal(usuario, this);
                    formPrincipal.Show();
                }
                else
                    MessageBox.Show("Login inválido!", "Erro ao efetuar login", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string errorMessage = string.Empty;

                if (txbId.TextLength == 0)
                    errorMessage += "Id vazio!" + Environment.NewLine;

                if (txbSenha.TextLength == 0)
                    errorMessage += "Senha vazia!" + Environment.NewLine;

                MessageBox.Show(errorMessage, "Erro ao efetuar login", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public FormSelecaoProduto(FormPrincipal prevForm)
 {
     this.previousForm = prevForm;
     InitializeComponent();
     ListarProdutos();
 }
 public FormGerenciarOperadores(FormPrincipal fPrinc)
 {
     formPrincipal = fPrinc;
     InitializeComponent();
 }
 public FormGerenciarProdutos(FormPrincipal fPrinc)
 {
     formPrincipal = fPrinc;
     InitializeComponent();
 }