private void SaveData(string FolderID) { string count = MSCE.ExecuteScalar("Select count(1) from userfile where userID=@1 and Fileid=@2 " , UserID.Replace("_Sync", "") , FileID); if (count.Equals("0")) { MSCE.ExecuteNonQuery("insert into userfile (folderid,Fileid,userid) values(@1,@2,@3)" , FolderID , FileID , UserID.Replace("_Sync", "")); } else { MSCE.ExecuteNonQuery("update userfile set folderid=@1 where fileid=@2 and userid=@3" , FolderID , FileID , UserID.Replace("_Sync", "")); } }
private void DelData(string FolderID) { MSCE.ExecuteScalar("delete from userfile where userID=@1 and Fileid=@2 " , UserID.Replace("_Sync", "") , FileID); }
private void InitUI() { try { this.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; this.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; this.Top = 0; //移動視窗到左上角 this.Left = 0; //移動視窗到左上角 this.WindowState = System.Windows.WindowState.Normal; this.WindowStyle = WindowStyle.None; this.ResizeMode = System.Windows.ResizeMode.NoResize; mediaPlayer.LoadedBehavior = MediaState.Manual; mediaPlayer.UnloadedBehavior = MediaState.Manual; //mediaPlayer.Source = new Uri(fileItem.UnZipFilePath + "\\" + fileItem.StorageFileName, UriKind.Absolute); mediaPlayer.Source = new Uri(FilePath, UriKind.Absolute); Home Home_Window = Application.Current.Windows.OfType <Home>().FirstOrDefault(); if (Home_Window != null) { IsInSync = Home_Window.IsInSync; IsSyncOwner = Home_Window.IsSyncOwner; if (pageJson.Equals("") == false) { IsInSync = true; IsSyncOwner = false; } if (IsInSync == true && IsSyncOwner == false) { cbBooks.Visibility = Visibility.Collapsed; } } btnSync.Source = ButtonTool.GetSyncButtonImage(IsInSync, IsSyncOwner); btnLight.Source = ButtonTool.GetSyncButtonImage(IsInSync, IsSyncOwner); cbBooks.ItemsSource = cbBooksData; cbBooks.DisplayMemberPath = "Key"; cbBooks.SelectedValuePath = "Value"; cbBooks.SelectedIndex = 0; int i = 0; if (cbBooksData != null) { foreach (KeyValuePair <string, BookVM> item in cbBooksData) { if (item.Value.FileID.Equals(this.FileID) == true) { cbBooks.SelectedIndex = i; break; } i++; } } else { cbBooks.Visibility = Visibility.Collapsed; } string count = MSCE.ExecuteScalar("Select count(1) from userfile where userID=@1 and Fileid=@2 " , UserID.Replace("_Sync", "") , FileID); if (count.Equals("0") == false) { var dt = MSCE.GetDataTable("select FolderID from userfile where userid =@1 and fileid=@2" , UserID.Replace("_Sync", "") , FileID); if (dt.Rows.Count > 0) { FolderID = dt.Rows[0]["FolderID"].ToString(); if (FolderID.Length == 0) { HasJoin2Folder = false; imgJoin.Source = new BitmapImage(new Uri("image/[email protected]", UriKind.Relative)); } else { HasJoin2Folder = true; imgJoin.Source = new BitmapImage(new Uri("image/[email protected]", UriKind.Relative)); } } } if (this.FolderID == null || this.FolderID.Equals("")) { HasJoin2Folder = false; imgJoin.Source = new BitmapImage(new Uri("image/[email protected]", UriKind.Relative)); } else { HasJoin2Folder = true; imgJoin.Source = new BitmapImage(new Uri("image/[email protected]", UriKind.Relative)); } if (CanNotCollect) { imgJoin.Source = new BitmapImage(new Uri("image/[email protected]", UriKind.Relative)); } if (cloud && !today) { DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += (sender, e) => { btnSync.Visibility = Visibility.Collapsed; btnSync.Width = 0; btnSync.Height = 0; timer.Stop(); }; timer.Start(); } else { btnSync.Visibility = Visibility.Visible; } } catch (Exception ex) { } }