Esempio n. 1
0
        public Stack <Restoran> SearchRest(string Restoran)
        {
            Stack <Restoran> restorans        = new Stack <Restoran>();
            string           procedure        = "Search_rest";
            string           connectionString = @"Data Source=.\CHUPRIS; Initial Catalog=RESTORATOR; User Id=Admin; Password=P@$$word";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(procedure, connection);
                // указываем, что команда представляет хранимую процедуру
                command.CommandType = System.Data.CommandType.StoredProcedure;
                // параметр для ввода имени
                SqlParameter nameParam = new SqlParameter
                {
                    ParameterName = "@name",
                    Value         = Restoran
                };
                // добавляем параметр
                command.Parameters.Add(nameParam);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    string   Filename  = reader.GetString(1);
                    byte[]   data      = (byte[])reader.GetValue(2);
                    string   name_Rest = reader.GetString(3);
                    string   Type      = reader.GetString(4);
                    string   Work_time = reader.GetString(5);
                    string   Sity      = reader.GetString(6);
                    string   Street    = reader.GetString(7);
                    string   Price     = reader.GetString(8);
                    string   Disk      = reader.GetString(9);
                    string   Cord      = reader.GetString(10);
                    Restoran restoran  = new Restoran(Filename, data, name_Rest, Type, Work_time, Sity, Street, Price, Disk, Cord);
                    restorans.Push(restoran);
                }
                ;
                return(restorans);
            }
        }
Esempio n. 2
0
        public async void PushRest(Restoran restoran)
        {
            string sql = string.Format("Insert Into Rest" +
                                       "(FileNama,ImageData,Name,Type,WorkTime,Sity,Street,Price,[Disk],Cord) Values(@FileNama,@ImageData,@Name,@Type,@WorkTime,@Sity,@Street,@Price,@Disk,@Cord)");

            using (SqlCommand cmd = new SqlCommand(sql, this.connect))
            {
                // Добавить параметры
                cmd.Parameters.AddWithValue("@FileNama", restoran.Filename);
                cmd.Parameters.AddWithValue("@ImageData", restoran.imagedata);
                cmd.Parameters.AddWithValue("@Name", restoran.Name);
                cmd.Parameters.AddWithValue("@Type", restoran.Type);
                cmd.Parameters.AddWithValue("@WorkTime", restoran.WorkTime);
                cmd.Parameters.AddWithValue("@Sity", restoran.Sity);
                cmd.Parameters.AddWithValue("@Street", restoran.Street);
                cmd.Parameters.AddWithValue("@Price", restoran.Price);
                cmd.Parameters.AddWithValue("@Disk", restoran.Disk);
                cmd.Parameters.AddWithValue("@Cord", restoran.Cord);
                await cmd.ExecuteNonQueryAsync();
            }
        }