public bool verifivarLogin(string objLogin, string objSenha) { clsConnect conexao = new clsConnect(); conexao.conectar(); string query = "SELECT USERNAME, PASSWORD FROM USUARIO WHERE USERNAME=@LOGIN AND PASSWORD=@SENHA"; MySqlCommand cmd = new MySqlCommand(query, conexao.objConexao); cmd.Parameters.AddWithValue("@LOGIN", objLogin.ToString()); cmd.Parameters.AddWithValue("@SENHA", objSenha); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { dr["username"].ToString(); dr["password"].ToString(); dr.Close(); conexao.desconectar(); return(true); } else { dr.Close(); conexao.desconectar(); return(false); } }
public void editar(int pId) { DialogResult iResposta; iResposta = MessageBox.Show("Deseja editar este Cliente?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (iResposta.ToString() == "Yes") { clsConnect conexao = new clsConnect(); conexao.conectar(); MySqlCommand cmd = new MySqlCommand("UPDATE TBPRODUTO SET nmProduto = 'Inativo' WHERE IDPRODUTO=@ID", conexao.objConexao); cmd.Parameters.AddWithValue("@ID", pId); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); } }
public void carregarList(ListView lst, string query) { clsConnect conexao = new clsConnect(); conexao.conectar(); lst.Items.Clear(); MySqlCommand cmd = new MySqlCommand(query, conexao.objConexao); MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.Default); while (dr.Read()) { ListViewItem lista = new ListViewItem(dr[("NMPRODUTO")].ToString()); lstProduto.Items.Add(lista); } dr.Close(); conexao.desconectar(); }
public string verifivartipo(string objLogin) { clsConnect conexao = new clsConnect(); conexao.conectar(); string query = "SELECT TYPE FROM USUARIO WHERE USERNAME=@LOGIN"; MySqlCommand cmd = new MySqlCommand(query, conexao.objConexao); cmd.Parameters.AddWithValue("@LOGIN", objLogin.ToString()); MySqlDataReader dr = cmd.ExecuteReader(); dr.Read(); dr["username"].ToString(); string type = dr["type"].ToString(); dr.Close(); conexao.desconectar(); return(type); }
public void cadastrarCliente(string pNome, int pcategoria) { clsConnect conexao = new clsConnect(); conexao.conectar(); MySqlCommand cmd; try { cmd = new MySqlCommand("INSERT INTO tbproduto (nmProduto, idCategoria) VALUES(PNOME,pcategoria);", conexao.objConexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PNOME", pNome); cmd.Parameters.AddWithValue("@pcategoria", Convert.ToInt32(pcategoria)); cmd.ExecuteReader(CommandBehavior.SingleRow); } catch (Exception ex) { MessageBox.Show("ERRO: " + ex.Message); } finally { conexao.desconectar(); } }