public bool deleteCliente(string id) { try { myQuery = "delete from Cliente where ClienteID = " + id; MySqlCommand query = new MySqlCommand(myQuery); query.Connection = con.abrirConexion(); query.ExecuteNonQuery(); query.Connection = con.cerrarConexion(); return(true); } catch (MySqlException) { return(false); } }
public int Login(string User, string Pass) { int res = -1; MySqlCommand query = new MySqlCommand(); try { query.CommandText = "sp_login"; query.CommandType = CommandType.StoredProcedure; query.Parameters.Add("userP", MySqlDbType.VarChar).Value = User; query.Parameters.Add("passP", MySqlDbType.VarChar).Value = Pass; query.Parameters.Add("@LoginR", MySqlDbType.Int16).Direction = ParameterDirection.Output; query.Connection = con.abrirConexion(); MySqlDataReader reader = query.ExecuteReader(); reader.Read(); res = Convert.ToInt32(reader["LoginR"]); TempObjects.usuarioActualVenta.Id = (int)reader["UsuarioID"]; TempObjects.usuarioActualVenta.Nombre = (string)reader["Nombre"]; query.Connection = con.cerrarConexion(); return(res); } catch (InvalidCastException) { return(res); } catch (InvalidOperationException) { return(res); } }
public bool updateCliente(Cliente c) { try { myQuery = "update Cliente set Nombre='" + c.Nombre + "' , Correo='" + c.Correo + "' , Telefono='" + c.Telefono + "', Direccion='" + c.Direccion + "' where ClienteID = " + c.Id; MySqlCommand query = new MySqlCommand(myQuery); query.Connection = con.abrirConexion(); query.ExecuteNonQuery(); query.Connection = con.cerrarConexion(); return(true); } catch (SqlException) { return(false); } }