Ejemplo n.º 1
0
        /**  Reads a provider from data base  **/
        public bool ReadProvider(ENProvider provider)
        {
            SqlConnection con     = new SqlConnection(constring);
            bool          correct = true;


            try
            {
                con.Open();
                using (SqlCommand cmd = new SqlCommand("", con))
                {
                    cmd.CommandText = "SELECT empresa FROM Users where email='" + provider.email + "';";
                    SqlDataReader auxLectura = cmd.ExecuteReader();

                    while (auxLectura.Read())
                    {
                        provider.empresa = Convert.ToString(auxLectura[0]);
                    }
                    auxLectura.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("User operation has failed. Error: {0}", ex.Message);
                correct = false;
            }
            finally
            {
                con.Close();
            }

            return(correct);
        }
Ejemplo n.º 2
0
        /**  Adds a new provider to data base  **/
        public bool CreateProvider(ENProvider provider)
        {
            SqlConnection con     = new SqlConnection(constring);
            bool          correct = true;

            try
            {
                con.Open();
                using (SqlCommand cmd = new SqlCommand("", con))
                {
                    cmd.CommandText = "INSERT INTO Users (name, password, email, birthdate, urlImage, empresa, address) values ('" + provider.name + "', '" + provider.pass + "', '" + provider.email + "', '" + provider.birth.ToString("yyyy-MM-dd") + "', '" + provider.url + "', '" + provider.company + "', '" + provider.address + "');";
                    cmd.ExecuteNonQuery();
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("User operation has failed. Error: {0}", ex.Message);
                correct = false;
            }
            finally
            {
                con.Close();
            }

            return(correct);
        }
Ejemplo n.º 3
0
 /**  Deletes a provider from data base  **/
 public bool DeleteProvider(ENProvider provider)
 {
     return(false);
 }
Ejemplo n.º 4
0
 /** Updates a provider from data base **/
 public bool UpdateProvider(ENProvider provider)
 {
     return(false);
 }