private void buttonOK_Click(object sender, RoutedEventArgs e) { CDItemResult selectedItem = DataGridResult.SelectedItem as CDItemResult; CD selectedCD = dataBase.GetCDById(selectedItem.CDID); if (selectedCD.ID == cdInDrive.ID) { MessageBox.Show(StringTable.CDAlreadyLinkedToThisCD, System.Windows.Forms.Application.ProductName, MessageBoxButton.OK, MessageBoxImage.Information); return; } string sql = string.Format("UPDATE CD Set [Identity]='' WHERE [Identity]='{0}'", cdInDrive.Identity); int count = dataBase.ExecuteNonQuery(sql); selectedCD.TotalLength = cdInDrive.TotalLength; selectedCD.NumberOfTracks = cdInDrive.NumberOfTracks; selectedCD.InitTracks(cdInDrive.Tracks.Count); selectedCD.Identity = cdInDrive.Identity; // Jus 10-Apr-98: Liedlängen werden auch von der eingelegten CD übernommen! for (int i = 0; i < cdInDrive.Tracks.Count; i++) { selectedCD.Tracks[i].Length = cdInDrive.Tracks[i].Length; } selectedCD.Save(dataBase); DialogResult = true; Close(); }
private void ShowDetails() { CDItemResult selectedItem = DataGridResult.SelectedItem as CDItemResult; CD selectedCD = dataBase.GetCDById(selectedItem.CDID); WindowAlbum windowAlbum = new WindowAlbum(selectedCD, dataBase); windowAlbum.ShowDialog(); }
private void ShowDetails() { CD cd = new CD(); int error = 0; int canceled = 0; CDItemResult selItem = ((CDItemResult)this.DataGridResult.SelectedItem); if (selItem == null) { return; } CDArchiveConfig cdArchiveConfig = ((ComboBoxArchiveItem)ComboBoxCDArchives.SelectedItem).ArchiveConfig; if (cdArchiveConfig.Type == CDArchiveType.BIG3) { cd.Identity = selItem.Identity; CCDArchive cdarchive = new CCDArchive(); cdarchive.SearchCDInInternetBig3(cdArchiveConfig, cd, ref canceled, ref error); } if (cdArchiveConfig.Type == CDArchiveType.CDArchiveLocal) { cd.Identity = selItem.Identity; CCDArchive cdarchive = new CCDArchive(); CDArchiveLocalFile.SearchCDInCDArchiveLocalFile(cdArchiveConfig.ArchiveName, cd); } WindowAlbum windowAlbum = new WindowAlbum(cd, dataBase); windowAlbum.SaveAlbumOnOK = false; windowAlbum.ShowDialog(); }
private void Search() { Big3.Hitbase.DataBaseEngine.Condition sel = new Big3.Hitbase.DataBaseEngine.Condition(); // Diese Sachen direkt speichern, wenn einmal gesucht wurde. Settings.SetValue("LinkSameNumber", checkBoxSameTrackCount.IsChecked == true ? (int)1 : (int)0); Settings.SetValue("LinkNotLinked", checkBoxNotAssigned.IsChecked == true ? (int)1 : (int)0); // Nur CDs. sel.Add(Field.AlbumType, Operator.Equal, 0); if (this.checkBoxNotAssigned.IsChecked == true) { sel.Add(Field.Identity, Operator.Empty, 0); } if (this.checkBoxSameTrackCount.IsChecked == true) { sel.Add(Field.NumberOfTracks, Operator.Equal, cdInDrive.NumberOfTracks); } if (textBoxArtist.Text != "") { sel.Add(Field.ArtistCDName, Operator.Contains, textBoxArtist.Text); } if (textBoxTitle.Text != "") { sel.Add(Field.Title, Operator.Contains, textBoxTitle.Text); } SortFieldCollection sortKeys = new SortFieldCollection(); sortKeys.Add(Field.ArtistCDName); sortKeys.Add(Field.Title); FieldCollection fc = new FieldCollection(); fc.Add(Field.ArtistCDName); fc.Add(Field.Title); fc.Add(Field.TotalLength); fc.Add(Field.NumberOfTracks); List <CDItemResult> items = new List <CDItemResult>(); using (DataBaseView albumView = AlbumView.CreateView(dataBase, fc, sortKeys, 0, sel)) { object[] values; while ((values = albumView.Read()) != null) { CDItemResult newItem = new CDItemResult(); newItem.CDID = (int)values[0]; newItem.Artist = (string)values[1]; newItem.Title = values[2] is DBNull ? "" : (string)values[2]; newItem.Length = (int)values[3]; newItem.NumberOfTracks = (int)values[4]; items.Add(newItem); } } DataGridResult.ItemsSource = items; return; }
void SearchCDArchive(CDArchiveConfig cdArchiveConfig) { String sURL = ""; int iMaxCount = 100; // Z.zt. fest Dispatcher.Invoke((Action)(() => { if (Misc.Atoi(TextBoxNumberOfTracks.Text) > 0) { sURL = string.Format("cdquery_browse.asp?User=hitbase&Password=hitbase2k&Artist={0}&Title={1}&UPC={2}&NumberOfTracks={3}&MaxCount={4}", TextBoxArtist.Text, TextBoxTitle.Text, TextBoxUPC.Text, Misc.Atoi(TextBoxNumberOfTracks.Text), iMaxCount); } else { sURL = string.Format("cdquery_browse.asp?User=hitbase&Password=hitbase2k&Artist={0}&Title={1}&UPC={2}&MaxCount={3}", TextBoxArtist.Text, TextBoxTitle.Text, TextBoxUPC.Text, iMaxCount); } })); WebClient wc = new WebClient(); wc.UseDefaultCredentials = true; wc.Proxy.Credentials = CredentialCache.DefaultCredentials; wc.Encoding = Encoding.UTF8; string content = wc.DownloadString("http://" + cdArchiveConfig.ArchiveName + "/" + sURL); content = content.Replace("\r", ""); string[] saLines; saLines = content.Split('\n'); //!!!!!!!!! Versionsnummer abfragen List <CDItemResult> cdList = new List <CDItemResult>(); bool bError = false; int iLine = 1; int iCount = 0; while (iLine < saLines.Length) { String sValueID = ""; String sValueArtist = ""; String sValueTitle = ""; String sValueTotalLength = ""; String sValueNumberOfTracks = ""; if (iLine >= saLines.Length || !GetValue(saLines[iLine++], "ID", ref sValueID)) { bError = true; break; } if (iLine >= saLines.Length || !GetValue(saLines[iLine++], "Artist", ref sValueArtist)) { bError = true; break; } if (iLine >= saLines.Length || !GetValue(saLines[iLine++], "Title", ref sValueTitle)) { bError = true; break; } if (iLine >= saLines.Length || !GetValue(saLines[iLine++], "TotalLength", ref sValueTotalLength)) { bError = true; break; } if (iLine >= saLines.Length || !GetValue(saLines[iLine++], "NumberOfTracks", ref sValueNumberOfTracks)) { bError = true; break; } CDItemResult newItem = new CDItemResult(); newItem.Identity = sValueID; newItem.Artist = sValueArtist; newItem.Title = sValueTitle; newItem.Length = Misc.Atoi(sValueTotalLength); newItem.NumberOfTracks = Misc.Atoi(sValueNumberOfTracks); cdList.Add(newItem); iCount++; } Dispatcher.Invoke((Action)(() => { DataGridResult.ItemsSource = cdList; String strResult; strResult = string.Format("{0} {1}", iCount, StringTable.CDsFound); TextBlockStatus.Text = strResult; })); }
void SearchCDArchiveLocal(CDArchiveConfig cdArchiveConfig) { int maxCount = 100; // Z.zt. fest String filename = cdArchiveConfig.ArchiveName; if (string.IsNullOrEmpty(filename)) { MessageBox.Show(StringTable.NoCDArchiveDefined, System.Windows.Forms.Application.ProductName, MessageBoxButton.OK, MessageBoxImage.Information); return; } String filter = ""; string artist = ""; string title = ""; string upc = ""; string numberOfTracks = ""; Dispatcher.Invoke((Action)(() => { artist = this.TextBoxArtist.Text; title = this.TextBoxTitle.Text; upc = this.TextBoxUPC.Text; numberOfTracks = this.TextBoxNumberOfTracks.Text; })); if (!string.IsNullOrEmpty(artist)) { filter += "sArtist like '%" + artist + "%'"; } if (!string.IsNullOrEmpty(title)) { if (!string.IsNullOrEmpty(filter)) { filter += " AND "; } filter += "sTitle like '%" + title + "%'"; } if (!string.IsNullOrEmpty(upc)) { if (!string.IsNullOrEmpty(filter)) { filter += " AND "; } filter += "sUPC='" + upc + "'"; } if (Misc.Atoi(numberOfTracks) != 0) { if (!string.IsNullOrEmpty(filter)) { filter += " AND "; } filter += string.Format("CD.cNumberOfTracks={0}", Misc.Atoi(numberOfTracks)); } if (string.IsNullOrEmpty(filter)) { return; } string sql; sql = string.Format("SELECT * FROM CD INNER JOIN Artist ON CD.IDArtist = Artist.ID WHERE {0} ORDER BY Artist.sArtist, CD.sTitle", filter); List <CDItemResult> cdList = new List <CDItemResult>(); int iCount = 0; using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + filename + "'")) { conn.Open(); System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(sql, conn); using (System.Data.OleDb.OleDbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { CDItemResult newItem = new CDItemResult(); newItem.Identity = (string)reader["sIdentity"]; newItem.Artist = (string)reader["sArtist"]; newItem.Title = (string)reader["sTitle"]; newItem.Length = (int)reader["dwTotalLength"]; newItem.NumberOfTracks = (int)(byte)reader["cNumberOfTracks"]; cdList.Add(newItem); iCount++; } } } Dispatcher.Invoke((Action)(() => { DataGridResult.ItemsSource = cdList; String strResult; strResult = string.Format("{0} {1}", iCount, StringTable.CDsFound); TextBlockStatus.Text = strResult; })); }