void bwAlbumView_DoWork(object sender, DoWorkEventArgs e) { List <PersonGroupViewItem> items = new List <PersonGroupViewItem>(); PersonGroupCatalogViewDataSet personGroupsDataSet = new PersonGroupCatalogViewDataSet(); PersonGroupTableAdapter ta = new PersonGroupTableAdapter(DataBase); ta.Fill(personGroupsDataSet.PersonGroup); foreach (PersonGroupCatalogViewDataSet.PersonGroupRow row in personGroupsDataSet.PersonGroup) { // Leeren Interpreten nicht anzeigen. Kann schon mal angelegt werden. if (string.IsNullOrEmpty(row.Name)) { continue; } PersonGroupViewItem newItem = new PersonGroupViewItem(); newItem.ID = row.PersonGroupID; newItem.Name = row.Name; newItem.ImageFilename = row.ImageFilename; newItem.URL = row.URL; newItem.NumberOfTracks = row.NumberOfTracks; newItem.PersonGroupType = DataBaseEngine.DataBase.GetNameOfPersonGroupType(row.IsTypeNull() ? PersonGroupType.Unknown : (PersonGroupType)row.Type); newItem.Sex = DataBaseEngine.DataBase.GetNameOfPersonGroupSex(row.IsSexNull() ? SexType.Unknown : (SexType)row.Sex); newItem.LandOfOrigin = row.Country; newItem.DayOfBirth = Misc.FormatDate(row.BirthDay); newItem.DayOfDeath = Misc.FormatDate(row.DayOfDeath); items.Add(newItem); } e.Result = items; }
private void FormDeleteExistingArtist_Load(object sender, EventArgs e) { PersonGroupTableAdapter ta = new PersonGroupTableAdapter(dataBase); PersonGroupDataSet.PersonGroupDataTable personGroups = new PersonGroupDataSet.PersonGroupDataTable(); ta.Fill(personGroups); foreach (PersonGroupDataSet.PersonGroupRow personGroup in personGroups) { if (personGroup.Name != personGroupToDelete.Name) { comboBoxArtists.Items.Add(personGroup.Name); } } label1.Text = string.Format(label1.Text, personGroupToDelete.Name); }
void bwAlbumView_DoWork(object sender, DoWorkEventArgs e) { PersonGroupCatalogViewDataSet personGroupsDataSet = new PersonGroupCatalogViewDataSet(); PersonGroupTableAdapter ta = new PersonGroupTableAdapter(DataBase); ta.Fill(personGroupsDataSet.PersonGroup); foreach (PersonGroupCatalogViewDataSet.PersonGroupRow row in personGroupsDataSet.PersonGroup) { // Leeren Interpreten nicht anzeigen. Kann schon mal angelegt werden. if (string.IsNullOrEmpty(row.Name)) { continue; } PersonGroupViewItem newItem = new PersonGroupViewItem(); FillPersonGroupItem(row, newItem); items.AddItemFromThread(newItem); } e.Result = items; }
private void Convert() { string sql; formConvertProgress.MaximumValue = 15; formConvertProgress.CurrentTable = "Master"; ConvertMasterTable(); #region CD formConvertProgress.CurrentTable = "CD"; formConvertProgress.Value++; List <FieldConvert> fieldsCD = new List <FieldConvert>(); fieldsCD.Add(new FieldConvert("IDCD", "CDID")); fieldsCD.Add(new FieldConvert("dwGesamtlaenge", "Length")); fieldsCD.Add(new FieldConvert("cAnzahlLieder", "NumberOfTracks")); fieldsCD.Add(new FieldConvert("bCDSampler", "IsSampler")); fieldsCD.Add(new FieldConvert("wNummerImSet", "SetNumber")); fieldsCD.Add(new FieldConvert("IDCDSet", "SetID")); fieldsCD.Add(new FieldConvert("IDArtist", "ArtistID")); fieldsCD.Add(new FieldConvert("IDKategorie", "CategoryID")); fieldsCD.Add(new FieldConvert("IDMedium", "MediumID")); fieldsCD.Add(new FieldConvert("szTitel", "Title")); fieldsCD.Add(new FieldConvert("szDatum", "Date")); fieldsCD.Add(new FieldConvert("szArchivNummer", "ArchiveNumber")); fieldsCD.Add(new FieldConvert("szPfadBitmap", "FrontCover")); fieldsCD.Add(new FieldConvert("szKennzeichen", "Codes")); fieldsCD.Add(new FieldConvert("szKommentar", "Comment")); fieldsCD.Add(new FieldConvert("szFeld1", "User1")); fieldsCD.Add(new FieldConvert("szFeld2", "User2")); fieldsCD.Add(new FieldConvert("szFeld3", "User3")); fieldsCD.Add(new FieldConvert("szFeld4", "User4")); fieldsCD.Add(new FieldConvert("szFeld5", "User5")); fieldsCD.Add(new FieldConvert("C_Type", "Type")); fieldsCD.Add(new FieldConvert("C_YearRecorded", "YearRecorded")); fieldsCD.Add(new FieldConvert("C_Copyright", "Copyright")); fieldsCD.Add(new FieldConvert("C_BackCoverBitmap", "BackCover")); fieldsCD.Add(new FieldConvert("C_CDLabelBitmap", "CDLabelCover")); fieldsCD.Add(new FieldConvert("C_Rating", "Rating")); fieldsCD.Add(new FieldConvert("C_Label", "Label")); fieldsCD.Add(new FieldConvert("C_URL", "URL")); fieldsCD.Add(new FieldConvert("C_Price", "Price")); fieldsCD.Add(new FieldConvert("C_UPC", "UPC")); fieldsCD.Add(new FieldConvert("C_Original", "IsOriginal")); fieldsCD.Add(new FieldConvert("C_IDComposer", "ComposerID")); fieldsCD.Add(new FieldConvert("C_Location", "Location")); fieldsCD.Add(new FieldConvert("C_Language", "Language")); CDTableAdapter cdAdap = new CDTableAdapter(sdfDatabase); ConvertDataSet.CDDataTable cd = new ConvertDataSet.CDDataTable(); cdAdap.Fill(cd); // Alle Identities einlesen Dictionary <int, string> identites = ReadIdentities(); CopyData("CD", fieldsCD, cd, identites); SqlCeCommand cmd = new SqlCeCommand("SET IDENTITY_INSERT CD ON", sdfDatabase.Connection); cmd.ExecuteNonQuery(); int count = 0; foreach (DataRow row in cd.Rows) { try { cdAdap.Update(row); } catch (Exception e) { FormUnhandledException formUnhandledException = new FormUnhandledException(e); formUnhandledException.ShowDialog(); } if ((count % 100) == 0) { formConvertProgress.CurrentTable = string.Format("{0} ({1} Einträge)", "Track", count); formConvertProgress.Refresh(); Application.DoEvents(); } count++; } cmd = new SqlCeCommand("SET IDENTITY_INSERT CD OFF", sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(CDID) FROM CD", sdfDatabase.Connection); int maxId = (int)cmd.ExecuteScalar() + 1; cmd = new SqlCeCommand(string.Format("ALTER TABLE CD ALTER COLUMN CDID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion #region Track formConvertProgress.CurrentTable = "Track"; formConvertProgress.Value++; List <FieldConvert> fieldsTrack = new List <FieldConvert>(); fieldsTrack.Add(new FieldConvert("IDLied", "TrackID")); fieldsTrack.Add(new FieldConvert("IDCD", "CDID")); fieldsTrack.Add(new FieldConvert("IDArtist", "ArtistID")); fieldsTrack.Add(new FieldConvert("wLiedNummer", "TrackNumber")); fieldsTrack.Add(new FieldConvert("szTitel", "Title")); fieldsTrack.Add(new FieldConvert("dwLaenge", "Length")); fieldsTrack.Add(new FieldConvert("wBpm", "Bpm")); fieldsTrack.Add(new FieldConvert("szNameRecDatei", "SoundFile")); fieldsTrack.Add(new FieldConvert("szKennzeichen", "Codes")); fieldsTrack.Add(new FieldConvert("szKommentar", "Comment")); fieldsTrack.Add(new FieldConvert("szLiedtext", "Lyrics")); fieldsTrack.Add(new FieldConvert("szFeld1", "User1")); fieldsTrack.Add(new FieldConvert("szFeld2", "User2")); fieldsTrack.Add(new FieldConvert("szFeld3", "User3")); fieldsTrack.Add(new FieldConvert("szFeld4", "User4")); fieldsTrack.Add(new FieldConvert("szFeld5", "User5")); fieldsTrack.Add(new FieldConvert("L_TrackFormat", "TrackFormat")); fieldsTrack.Add(new FieldConvert("L_BitRate", "BitRate")); fieldsTrack.Add(new FieldConvert("L_SampleRate", "SampleRate")); fieldsTrack.Add(new FieldConvert("L_Channels", "Channels")); fieldsTrack.Add(new FieldConvert("L_YearRecorded", "YearRecorded")); fieldsTrack.Add(new FieldConvert("L_Checksum", "Checksum")); fieldsTrack.Add(new FieldConvert("L_Rating", "Rating")); fieldsTrack.Add(new FieldConvert("L_IDCategory", "CategoryID")); fieldsTrack.Add(new FieldConvert("L_IDComposer", "ComposerID")); fieldsTrack.Add(new FieldConvert("L_Language", "Language")); TrackTableAdapter trackAdap = new TrackTableAdapter(sdfDatabase); ConvertDataSet.TrackDataTable track = new ConvertDataSet.TrackDataTable(); trackAdap.Fill(track); CopyData("Lied", fieldsTrack, track); sql = string.Format("SET IDENTITY_INSERT Track ON"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); count = 0; foreach (DataRow row in track.Rows) { try { trackAdap.Update(row); } catch (Exception e) { FormUnhandledException formUnhandledException = new FormUnhandledException(e); formUnhandledException.ShowDialog(); } if ((count % 100) == 0) { formConvertProgress.CurrentTable = string.Format("{0} ({1} Einträge)", "Track", count); formConvertProgress.Refresh(); Application.DoEvents(); } count++; } sql = string.Format("SET IDENTITY_INSERT Track OFF"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(TrackID) FROM Track", sdfDatabase.Connection); maxId = (int)cmd.ExecuteScalar() + 1; cmd = new SqlCeCommand(string.Format("ALTER TABLE Track ALTER COLUMN TrackID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion #region Artist formConvertProgress.CurrentTable = "Artist"; formConvertProgress.Value++; List <FieldConvert> fieldsPersonGroup = new List <FieldConvert>(); fieldsPersonGroup.Add(new FieldConvert("IDArtist", "PersonGroupID")); fieldsPersonGroup.Add(new FieldConvert("szArtistName", "Name")); fieldsPersonGroup.Add(new FieldConvert("sSortKey", "SaveAs")); fieldsPersonGroup.Add(new FieldConvert("nGroup", "Type")); fieldsPersonGroup.Add(new FieldConvert("nSex", "Sex")); fieldsPersonGroup.Add(new FieldConvert("sComment", "Comment")); fieldsPersonGroup.Add(new FieldConvert("A_URL", "URL")); fieldsPersonGroup.Add(new FieldConvert("A_Country", "Country")); fieldsPersonGroup.Add(new FieldConvert("A_BirthDay", "BirthDay", true)); fieldsPersonGroup.Add(new FieldConvert("A_DayOfDeath", "DayOfDeath", true)); fieldsPersonGroup.Add(new FieldConvert("A_ImageFilename", "ImageFilename")); PersonGroupTableAdapter personGroupAdap = new PersonGroupTableAdapter(sdfDatabase); ConvertDataSet.PersonGroupDataTable personGroup = new ConvertDataSet.PersonGroupDataTable(); personGroupAdap.Fill(personGroup); CopyData("Artist", fieldsPersonGroup, personGroup); sql = string.Format("SET IDENTITY_INSERT PersonGroup ON"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); count = 0; foreach (DataRow row in personGroup.Rows) { try { personGroupAdap.Update(row); } catch (Exception e) { FormUnhandledException formUnhandledException = new FormUnhandledException(e); formUnhandledException.ShowDialog(); } if ((count % 100) == 0) { formConvertProgress.CurrentTable = string.Format("{0} ({1} Einträge)", "Artist", count); formConvertProgress.Refresh(); Application.DoEvents(); } count++; } sql = string.Format("SET IDENTITY_INSERT PersonGroup OFF"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(PersonGroupID) FROM PersonGroup", sdfDatabase.Connection); maxId = (int)cmd.ExecuteScalar() + 1; cmd = new SqlCeCommand(string.Format("ALTER TABLE PersonGroup ALTER COLUMN PersonGroupID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion #region Category formConvertProgress.CurrentTable = "Category"; formConvertProgress.Value++; List <FieldConvert> fieldsCategory = new List <FieldConvert>(); fieldsCategory.Add(new FieldConvert("IDKategorie", "CategoryID")); fieldsCategory.Add(new FieldConvert("szKategorieName", "Name")); fieldsCategory.Add(new FieldConvert("wOrder", "Order")); CategoryTableAdapter categoryAdap = new CategoryTableAdapter(sdfDatabase); ConvertDataSet.CategoryDataTable categories = new ConvertDataSet.CategoryDataTable(); categoryAdap.Fill(categories); CopyData("Kategorie", fieldsCategory, categories); sql = string.Format("SET IDENTITY_INSERT Category ON"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); categoryAdap.Update(categories); sql = string.Format("SET IDENTITY_INSERT Category OFF"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(CategoryID) FROM Category", sdfDatabase.Connection); maxId = (int)cmd.ExecuteScalar() + 1; cmd = new SqlCeCommand(string.Format("ALTER TABLE Category ALTER COLUMN CategoryID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion #region Medium formConvertProgress.CurrentTable = "Medium"; formConvertProgress.Value++; List <FieldConvert> fieldsMedium = new List <FieldConvert>(); fieldsMedium.Add(new FieldConvert("IDMedium", "MediumID")); fieldsMedium.Add(new FieldConvert("szMedium", "Name")); fieldsMedium.Add(new FieldConvert("wOrder", "Order")); MediumTableAdapter mediumAdap = new MediumTableAdapter(sdfDatabase); ConvertDataSet.MediumDataTable mediums = new ConvertDataSet.MediumDataTable(); mediumAdap.Fill(mediums); CopyData("Medium", fieldsMedium, mediums); sql = string.Format("SET IDENTITY_INSERT Medium ON"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); mediumAdap.Update(mediums); sql = string.Format("SET IDENTITY_INSERT Medium OFF"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(MediumID) FROM Medium", sdfDatabase.Connection); maxId = (int)cmd.ExecuteScalar() + 1; cmd = new SqlCeCommand(string.Format("ALTER TABLE Medium ALTER COLUMN MediumID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion #region CDSet formConvertProgress.CurrentTable = "CDSet"; formConvertProgress.Value++; List <FieldConvert> fieldsSet = new List <FieldConvert>(); fieldsSet.Add(new FieldConvert("IDCDSet", "SetID")); fieldsSet.Add(new FieldConvert("szCDSetName", "Name")); SetTableAdapter setAdap = new SetTableAdapter(sdfDatabase); ConvertDataSet.SetDataTable sets = new ConvertDataSet.SetDataTable(); setAdap.Fill(sets); CopyData("CDSet", fieldsSet, sets); sql = string.Format("SET IDENTITY_INSERT [Set] ON"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); setAdap.Update(sets); sql = string.Format("SET IDENTITY_INSERT [Set] OFF"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(SetID) FROM [Set]", sdfDatabase.Connection); object maxSetID = cmd.ExecuteScalar(); if (maxSetID is DBNull) { maxId = 1; } else { maxId = (int)maxSetID + 1; } cmd = new SqlCeCommand(string.Format("ALTER TABLE [Set] ALTER COLUMN SetID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion #region Program formConvertProgress.CurrentTable = "Program"; formConvertProgress.Value++; List <FieldConvert> fieldsProgram = new List <FieldConvert>(); fieldsProgram.Add(new FieldConvert("IDCD", "CDID")); fieldsProgram.Add(new FieldConvert("szName", "Name")); fieldsProgram.Add(new FieldConvert("szLieder", "Tracks")); fieldsProgram.Add(new FieldConvert("bStandard", "IsStandard")); ProgramTableAdapter programAdap = new ProgramTableAdapter(sdfDatabase); ConvertDataSet.ProgramDataTable programs = new ConvertDataSet.ProgramDataTable(); programAdap.Fill(programs); CopyData("Programme", fieldsProgram, programs); programAdap.Update(programs); #endregion #region Index formConvertProgress.CurrentTable = "Index"; formConvertProgress.Value++; List <FieldConvert> fieldsIndex = new List <FieldConvert>(); fieldsIndex.Add(new FieldConvert("IDCD", "CDID")); fieldsIndex.Add(new FieldConvert("szIndexName", "Name")); fieldsIndex.Add(new FieldConvert("dwPosition", "Position")); IndexTableAdapter indexAdap = new IndexTableAdapter(sdfDatabase); ConvertDataSet.IndexDataTable indexes = new ConvertDataSet.IndexDataTable(); indexAdap.Fill(indexes); CopyData("Index", fieldsIndex, indexes); indexAdap.Update(indexes); #endregion #region Codes formConvertProgress.CurrentTable = "Codes"; formConvertProgress.Value++; List <FieldConvert> fieldsCode = new List <FieldConvert>(); fieldsCode.Add(new FieldConvert("cBuchstabe", "Letter")); fieldsCode.Add(new FieldConvert("szBedeutung", "Description")); CodeTableAdapter codeAdap = new CodeTableAdapter(sdfDatabase); ConvertDataSet.CodeDataTable codes = new ConvertDataSet.CodeDataTable(); codeAdap.Fill(codes); CopyData("Kennzeichen", fieldsCode, codes); codeAdap.Update(codes); #endregion #region Queue formConvertProgress.CurrentTable = "Queue"; formConvertProgress.Value++; List <FieldConvert> fieldsQueue = new List <FieldConvert>(); fieldsQueue.Add(new FieldConvert("Q_lIDCD", "CDID")); fieldsQueue.Add(new FieldConvert("Q_lAction", "Action")); fieldsQueue.Add(new FieldConvert("Q_sIdentity", "Identity")); fieldsQueue.Add(new FieldConvert("Q_sIdentityCDDB", "IdentityCDDB")); QueueTableAdapter queueAdap = new QueueTableAdapter(sdfDatabase); ConvertDataSet.QueueDataTable queues = new ConvertDataSet.QueueDataTable(); queueAdap.Fill(queues); CopyData("Queue", fieldsQueue, queues); queueAdap.Update(queues); #endregion #region LoanedCDs formConvertProgress.CurrentTable = "LoanedCDs"; formConvertProgress.Value++; List <FieldConvert> fieldsLoanedCD = new List <FieldConvert>(); fieldsLoanedCD.Add(new FieldConvert("IDCD", "CDID")); fieldsLoanedCD.Add(new FieldConvert("Kommentar", "Comment")); fieldsLoanedCD.Add(new FieldConvert("VerliehenAm", "LoanedDate")); fieldsLoanedCD.Add(new FieldConvert("VerliehenAn", "LoanedTo")); fieldsLoanedCD.Add(new FieldConvert("RueckgabeTermin", "ReturnDate")); LoanedCDTableAdapter loanedCDAdap = new LoanedCDTableAdapter(sdfDatabase); ConvertDataSet.LoanedCDDataTable loanedCDs = new ConvertDataSet.LoanedCDDataTable(); loanedCDAdap.Fill(loanedCDs); CopyData("VerlieheneCDs", fieldsLoanedCD, loanedCDs); loanedCDAdap.Update(loanedCDs); #endregion #region Dialog formConvertProgress.CurrentTable = "Dialog"; formConvertProgress.Value++; List <FieldConvert> fieldsDialog = new List <FieldConvert>(); fieldsDialog.Add(new FieldConvert("D_IDDialog", "DialogID")); fieldsDialog.Add(new FieldConvert("D_IDCategory", "CategoryID")); fieldsDialog.Add(new FieldConvert("D_DialogXML", "DialogXML")); DialogTableAdapter dialogAdap = new DialogTableAdapter(sdfDatabase); ConvertDataSet.DialogDataTable dialogs = new ConvertDataSet.DialogDataTable(); dialogAdap.Fill(dialogs); CopyData("Dialog", fieldsDialog, dialogs); sql = string.Format("SET IDENTITY_INSERT [Dialog] ON"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); dialogAdap.Update(dialogs); sql = string.Format("SET IDENTITY_INSERT [Dialog] OFF"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(DialogID) FROM [Dialog]", sdfDatabase.Connection); maxSetID = cmd.ExecuteScalar(); if (maxSetID is DBNull) { maxId = 1; } else { maxId = (int)maxSetID + 1; } cmd = new SqlCeCommand(string.Format("ALTER TABLE [Dialog] ALTER COLUMN DialogID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion #region Role formConvertProgress.CurrentTable = "Role"; formConvertProgress.Value++; List <FieldConvert> fieldsRole = new List <FieldConvert>(); fieldsRole.Add(new FieldConvert("R_ID", "RoleID")); fieldsRole.Add(new FieldConvert("R_Role", "Name")); RoleTableAdapter roleAdap = new RoleTableAdapter(sdfDatabase); ConvertDataSet.RoleDataTable roles = new ConvertDataSet.RoleDataTable(); roleAdap.Fill(roles); CopyData("Role", fieldsRole, roles); sql = string.Format("SET IDENTITY_INSERT [Role] ON"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); roleAdap.Update(roles); sql = string.Format("SET IDENTITY_INSERT [Role] OFF"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(RoleID) FROM [Role]", sdfDatabase.Connection); maxSetID = cmd.ExecuteScalar(); if (maxSetID is DBNull) { maxId = 1; } else { maxId = (int)maxSetID + 1; } cmd = new SqlCeCommand(string.Format("ALTER TABLE [Role] ALTER COLUMN RoleID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion #region Participant formConvertProgress.CurrentTable = "Participant"; formConvertProgress.Value++; List <FieldConvert> fieldsParticipant = new List <FieldConvert>(); fieldsParticipant.Add(new FieldConvert("P_ID", "ParticipantID")); fieldsParticipant.Add(new FieldConvert("P_IDArtist", "PersonGroupID")); fieldsParticipant.Add(new FieldConvert("P_IDRole", "RoleID")); fieldsParticipant.Add(new FieldConvert("P_IDCD", "CDID")); fieldsParticipant.Add(new FieldConvert("P_TrackNumber", "TrackNumber")); fieldsParticipant.Add(new FieldConvert("P_Comment", "Comment")); ParticipantTableAdapter participantAdap = new ParticipantTableAdapter(sdfDatabase); ConvertDataSet.ParticipantDataTable participants = new ConvertDataSet.ParticipantDataTable(); participantAdap.Fill(participants); CopyData("Participant", fieldsParticipant, participants); sql = string.Format("SET IDENTITY_INSERT [Participant] ON"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); participantAdap.Update(participants); sql = string.Format("SET IDENTITY_INSERT [Participant] OFF"); cmd = new SqlCeCommand(sql, sdfDatabase.Connection); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT MAX(ParticipantID) FROM [Participant]", sdfDatabase.Connection); maxSetID = cmd.ExecuteScalar(); if (maxSetID is DBNull) { maxId = 1; } else { maxId = (int)maxSetID + 1; } cmd = new SqlCeCommand(string.Format("ALTER TABLE [Participant] ALTER COLUMN ParticipantID IDENTITY({0},1)", maxId), sdfDatabase.Connection); cmd.ExecuteNonQuery(); #endregion }
private void FillArtistList() { Cursor.Current = Cursors.WaitCursor; personGroup.PersonGroup.Clear(); personGroupAdapter.Fill(personGroup.PersonGroup); personGroupListBox.Items.Clear(); personGroupTable.TableModel.Rows.Clear(); foreach (PersonGroupDataSet.PersonGroupRow row in personGroup.PersonGroup) { // Leeren Interpreten nicht anzeigen. Kann schon mal angelegt werden. if (string.IsNullOrEmpty(row.Name)) { continue; } if (personGroupListBox.Visible) { try { personGroupListBox.Items.Add(row); } catch { } } else { XPTable.Models.Row newRow = new XPTable.Models.Row(); newRow.Cells.Add(new XPTable.Models.Cell(row.Name)); newRow.Cells.Add(new XPTable.Models.Cell(row.SaveAs)); newRow.Cells.Add(new XPTable.Models.Cell(DataBase.GetNameOfPersonGroupType((PersonGroupType)(row.IsTypeNull() ? 0 : row.Type)))); newRow.Cells.Add(new XPTable.Models.Cell(DataBase.GetNameOfPersonGroupSex((SexType)(row.IsSexNull() ? 0 : row.Sex)))); newRow.Cells.Add(new XPTable.Models.Cell(row.Country)); string date = row.IsBirthDayNull() ? "" : Misc.FormatDate(row.BirthDay); XPTable.Models.Cell cellBirthDay = new XPTable.Models.Cell(date); if (row.IsBirthDayNull()) { cellBirthDay.Data = null; } else { cellBirthDay.Data = Misc.Atoi(row.BirthDay); } newRow.Cells.Add(cellBirthDay); date = row.IsDayOfDeathNull() ? "" : Misc.FormatDate(row.DayOfDeath); XPTable.Models.Cell cellDayOfDeath = new XPTable.Models.Cell(date); if (row.IsDayOfDeathNull()) { cellDayOfDeath.Data = null; } else { cellDayOfDeath.Data = Misc.Atoi(row.DayOfDeath); } newRow.Cells.Add(cellDayOfDeath); newRow.Cells.Add(new XPTable.Models.Cell(row.URL)); XPTable.Models.Cell cellImageFilename = new XPTable.Models.Cell(row.IsImageFilenameNull() ? "" : row.ImageFilename); if (row.IsImageFilenameNull()) { cellImageFilename.Data = null; } else { cellImageFilename.Data = row.ImageFilename; } newRow.Cells.Add(cellImageFilename); newRow.Cells.Add(new XPTable.Models.Cell(row.Comment)); newRow.Cells.Add(new XPTable.Models.Cell("")); newRow.Tag = row; personGroupTable.TableModel.Rows.Add(newRow); } } toolStripLabelCount.Text = String.Format(StringTable.NumberOfPersonsGroups, personGroup.PersonGroup.Count); Cursor.Current = Cursors.Default; if (personGroupListBox.Visible) { //personGroupListBox.Sorted = false; //personGroupListBox.Sorted = true; } }