Ejemplo n.º 1
0
        public void init(ListItem temp)
        {
            /**
             * 创建表
             * */
            using (var statement = conn.Prepare(SQL_CREATE_TABLE))
            {
                statement.Step();
            }

            /**
             * 遍历数据库中的item
             */
            using (var statement = conn.Prepare(SQL_SELECT_ALL))
            {
                while (statement.Step() != SQLiteResult.DONE)
                {
                    if ((string)statement[4] == "like")
                    {
                        temp.AddItem((string)statement[0], (string)statement[1], (string)statement[2], (string)statement[3], true, 0);
                    }
                    else if ((string)statement[4] == "unlike")
                    {
                        temp.AddItem((string)statement[0], (string)statement[1], (string)statement[2], (string)statement[3], false, 0);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void PopulateMainFlowlayout()
        {
            progressBar1.Visible = true;
            progressBar1.Value   = 0;
            progressBar1.Maximum = itemlist.Count();

            foreach (ItemModel item in itemlist)
            {
                ListItem listItem = new ListItem(this);
                listItem.AddItem(item);
                fpListItemPanel.Controls.Add(listItem);
                progressBar1.PerformStep();
            }

            progressBar1.Visible = false;
        }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Button       btn  = (Button)sender;
        DataListItem item = (DataListItem)btn.NamingContainer;

        Label lbl_ID     = (Label)item.FindControl("prodID");
        Label lbl_Amount = (Label)item.FindControl("prodAmount");

        DropDownList ddlist = (DropDownList)item.FindControl("ddlist");

        string numUD = Request.Form["prodQuantity"];

        if (int.Parse(lbl_Amount.Text) <= 0)
        {
            Response.Write("Out of stock !");
        }
        else if (int.Parse(numUD) > int.Parse(lbl_Amount.Text))
        {
            Response.Write("Not enough !");
        }
        else if (int.Parse(numUD) < 1)
        {
            Response.Write("<script>alert(' Quanity must larger than 0');</script>");
        }
        else
        {
            if (Session["myCart"] == null)
            {
                ds = new ListItem();
                Session["myCart"] = ds;
            }
            ds = (ListItem)Session["myCart"];

            string    id    = Request.QueryString["ID"];
            string    query = "select * from ShoesStorage where id = " + id;
            DataTable data  = CSDL.Instance.ExecuteQuery(query);
            DataRow   dtrow = data.Rows[0];
            ds.AddItem(new cartItem(int.Parse(id), dtrow["shoesName"].ToString(), dtrow["shoesImage"].ToString(), int.Parse(dtrow["shoesPrice"].ToString()), int.Parse(dtrow["shoesAmount"].ToString()), dtrow["shoesStatus"].ToString(), dtrow["shoesType"].ToString(), int.Parse(numUD), ddlist.Text));
        }


        //Response.Write(numUD);

        //string thisID = lbl_ID.Text;

        //Response.Write(thisID);
    }
Ejemplo n.º 4
0
        private async void OpenFile_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new FileOpenPicker();

            picker.ViewMode = PickerViewMode.List;
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".mp3");
            try
            {
                StorageFile file = await picker.PickSingleFileAsync();

                mediaSource = MediaSource.CreateFromStorageFile(file);
                if (file != null)
                {
                    using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read))
                    {
                        MusicProperties songProperties = await file.Properties.GetMusicPropertiesAsync();

                        StorageItemThumbnail currentThumb = await file.GetThumbnailAsync(ThumbnailMode.MusicView, 200, ThumbnailOptions.UseCurrentScale);

                        var albumCover = new BitmapImage();
                        albumCover.SetSource(currentThumb);
                        //修改此处将所得歌曲文件添加到歌曲列表(list)中

                        Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                        string      tempFilename = Guid.NewGuid().ToString();
                        string      musicSource  = tempFilename + ".mp3";
                        StorageFile musicfile    = await localFolder.CreateFileAsync(musicSource, CreationCollisionOption.ReplaceExisting);

                        var buffer = await FileIO.ReadBufferAsync(file);

                        await FileIO.WriteBufferAsync(musicfile, buffer);

                        list.AddItem(songProperties.Title, songProperties.Artist, songProperties.Album, albumCover, songProperties.Title, musicSource, 0);
                        Store.insert(songProperties.Title + " - " + songProperties.Artist, songProperties.Artist, songProperties.Album, musicSource, false);
                        int count = list.getItems.Count;
                        index = count - 1;
                    }
                }
                updatetile();
            }
            catch
            {
                var i = new MessageDialog("Open file error!");
            }
        }
Ejemplo n.º 5
0
        //
        private async void searchOnline(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            if (InputSearchBox.Text == "")
            {
                return;
            }
            Uri requestUri = new Uri(@"http://s.music.163.com/search/get/?type=1&limit=25&s=" + InputSearchBox.Text.ToString());

            try
            {
                Windows.Web.Http.HttpClient httpclient = new Windows.Web.Http.HttpClient();
                var httpResponse = await httpclient.GetAsync(requestUri);

                httpResponse.EnsureSuccessStatusCode();
                var httpResponseBody = await httpResponse.Content.ReadAsStringAsync();

                int start = httpResponseBody.IndexOf('['), end = httpResponseBody.LastIndexOf(']');
                httpResponseBody = httpResponseBody.Substring(start, end - start + 1);

                JArray jarr = JArray.Parse(httpResponseBody.ToString());

                string      name, artist, album, imagname, url;
                ImageSource imag;
                //清空上一次的查询列表
                searchlist.clearItems();

                for (int i = 0; i < jarr.Count; i++)
                {
                    name     = jarr[i]["name"].ToString();
                    artist   = jarr[i]["artists"][0]["name"].ToString();
                    album    = jarr[i]["album"]["name"].ToString();
                    url      = jarr[i]["audio"].ToString();
                    imagname = jarr[i]["album"]["picUrl"].ToString();
                    imag     = new BitmapImage(new Uri(imagname));
                    searchlist.AddItem(name, artist, album, imag, imagname, url, 1);
                }
                PlayList.Visibility         = Visibility.Collapsed;
                SearchOnlineList.Visibility = Visibility.Visible;
            }
            catch (Exception e)
            {
                var i = new MessageDialog("can't find the song");

                return;
            }
        }