private void buttonConfirm_Click(object sender, EventArgs e)
        {
            using (SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\Estoque;Initial Catalog=northwind;Integrated Security=True"))
            {
                using (SqlCommand sqlCommand = new SqlCommand())
                {
                    if ((textBoxLogin.Text != "") && (textBoxPass.Text != ""))
                    {
                        sqlCommand.Parameters.AddWithValue("Log", textBoxLogin.Text);
                        sqlCommand.Parameters.AddWithValue("Pass", textBoxPass.Text);
                        sqlCommand.CommandText = "SELECT ID, login, secret, tipo FROM Employees WHERE Login= @Log AND Secret= @Pass";
                        sqlCommand.Connection = sqlConn;
                        sqlConn.Open();
                        SqlDataReader dataReader;
                        dataReader = sqlCommand.ExecuteReader();

                        if (dataReader.Read())
                        {
                            login = new Operador();
                            login.Login = dataReader["Login"].ToString();
                            login.Id = Int32.Parse(dataReader["ID"].ToString());
                            login.Senha = Int32.Parse(dataReader["Secret"].ToString());
                            login.Tipo = Int32.Parse(dataReader["Tipo"].ToString());
                            FormMenu frm = new FormMenu();
                            frm.Show();
                            this.Visible = false;
                        }
                        else
                        {
                            MessageBox.Show("Login não encontrado");
                        }
                        sqlConn.Close();
                    }
                }
            }
        }
        private void buttonPesquisar_Click(object sender, EventArgs e)
        {
            using (SqlConnection sqlConn =
                    new SqlConnection("Data Source=(localdb)\\Estoque;Initial Catalog=northwind;Integrated Security=True"))
            {
                using (SqlCommand sqlCommand = new SqlCommand())
                {
                    sqlCommand.Parameters.AddWithValue("PId", comboBoxNome.SelectedValue);
                    sqlCommand.CommandText = "SELECT ID, FirstName,LastName," +
                    "Address, HomePhone, login, secret, tipo FROM Employees WHERE id= @PId";
                    sqlCommand.Connection = sqlConn;
                    sqlConn.Open();
                    SqlDataReader dataReader;
                    dataReader = sqlCommand.ExecuteReader(); //para caso que retorna registros
                    if (dataReader.Read()) //encontrou registro
                    {
                        operador = new Operador(Int32.Parse(dataReader[0].ToString()),
                                                dataReader[1].ToString(), dataReader[2].ToString(),
                                                dataReader[3].ToString(), dataReader[4].ToString(),
                                                dataReader[5].ToString(),
                                                Int32.Parse(dataReader[6].ToString()),
                                                Int32.Parse(dataReader[7].ToString()));

                        textBoxCod.Text = operador.Id.ToString();
                        textBoxNome.Text = operador.Nome;
                        textBoxSobreNome.Text = operador.Sobrenome;
                        textBoxEndereco.Text = operador.Endereco;
                        textBoxTelefone.Text = operador.Telefone;
                        textBoxLogin.Text = operador.Login;
                        textBoxSenha.Text = operador.Senha.ToString();
                        comboBoxTipo.Text = operador.Tipo.ToString();
                    }
                    else
                    {
                        limparForm();
                    }
                    sqlConn.Close();
                }
            }
        }
 private void buttonSalvar_Click(object sender, EventArgs e)
 {
     if (operadorNovo)
     {
         using (SqlConnection sqlConn =
             new SqlConnection("Data Source=(localdb)\\Estoque;Initial Catalog=northwind;Integrated Security=True"))
         {
             using (SqlCommand sqlCommand = new SqlCommand())
             {
                 operador = new Operador(Int32.Parse(textBoxCod.Text.ToString()),
                                             textBoxNome.Text.ToString(),
                                             textBoxSobreNome.Text.ToString(),
                                             textBoxEndereco.Text.ToString(),
                                             textBoxTelefone.Text.ToString(), textBoxLogin.Text.ToString(),
                                             Int32.Parse(textBoxSenha.Text.ToString()),
                                             Int32.Parse(comboBoxTipo.SelectedIndex.ToString()));
                 sqlCommand.CommandText = "INSERT into Employees (FirstName,LastName," +
                             "Address,HomePhone,Login,Secret,Tipo) values ('" + operador.Nome +
                             "','" + operador.Sobrenome + "', '" + operador.Endereco + "', '" + operador.Telefone + "','" +
                             operador.Login + "', '" + operador.Senha + "', '" + operador.Tipo + "')";
                 sqlCommand.Connection = sqlConn;
                 sqlConn.Open();
                 if (sqlCommand.ExecuteNonQuery() > 0)
                 {
                     comboBoxNome.Refresh();
                     bloquearTextBox();
                     MessageBox.Show("Operador adicionado com sucesso!");
                 }
                 else
                 {
                     MessageBox.Show("Operador nao adicionado");
                 }
                 sqlConn.Close();
             }
         }
     }
     else
     {
         using (SqlConnection sqlConn =
                 new SqlConnection("Data Source=(localdb)\\Estoque;Initial Catalog=northwind;Integrated Security=True"))
         {
             using (SqlCommand sqlCommand = new SqlCommand())
             {
                 sqlCommand.CommandText = "UPDATE Employees SET FirstName = '" + operador.Nome + "',LastName = '" + operador.Sobrenome + "',"+
                     "Address = '" + operador.Endereco + "'," +
                     "HomePhone = '" + operador.Telefone + "', Login = '******'," +
                      "Secret = '" + operador.Senha + "', Tipo = '" + operador.Tipo + "' where ID = '" + operador.Id + "'";
                 sqlCommand.Connection = sqlConn;
                 sqlConn.Open();
                 if (sqlCommand.ExecuteNonQuery() > 0)
                 {
                     MessageBox.Show("Oeprador atualizado com sucesso!");
                 }
                 else
                 {
                     MessageBox.Show("Falha ao atualizar");
                 }
                 sqlConn.Close();
                 bloquearTextBox();
             }
         }
     }
 }