コード例 #1
0
 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);
     }
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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);
     }
 }