Example #1
0
        //  return List of restorents
        public List <Restorent> ToSelectRestorentDetails()
        {
            List <Restorent> rlist = new List <Restorent>();
            string           query = "select * from Restorent";

            try
            {
                using (SqlConnection connection = new SqlConnection(connection_string))
                {
                    connection.Open();
                    SqlCommand    command = new SqlCommand(query, connection);
                    SqlDataReader sdr     = command.ExecuteReader();



                    while (sdr.Read())
                    {
                        Restorent r = new Restorent();
                        r.Resto_name    = sdr.GetString(0);
                        r.Resto_Address = sdr.GetString(1);
                        r.Rating        = sdr.GetString(2);

                        rlist.Add(r);
                    }
                }
            }
            catch (Exception e) { Console.WriteLine(e.Message); }
            return(rlist);
        }
Example #2
0
        // insert data
        public void ToInsertRestorentDetails(Restorent r)
        {
            string query = "insert into Restorent values('" + r.Resto_name + "','" + r.Resto_Address + "','" + r.Rating + "')";

            try
            {
                using (SqlConnection connection = new SqlConnection(connection_string))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(query, connection);
                    Console.WriteLine("{0} Rows inserted", command.ExecuteNonQuery());
                }
            }
            catch (Exception e) { Console.WriteLine(e.Message); }
        }
Example #3
0
        // set restorent data
        public Restorent SetResrorentDetails()
        {
            Restorent rs = new Restorent();

            Console.WriteLine("Enter Id:");
            rs.Resto_name = Console.ReadLine();

            Console.WriteLine("Enter location:");
            rs.Resto_Address = Console.ReadLine();

            Console.WriteLine("Enter rating 1-5:");
            rs.Rating = Console.ReadLine();

            return(rs);
        }