private void artistTable_BeginEditing(object sender, XPTable.Events.CellEditEventArgs e) { switch (e.Column) { case 2: ((XPTable.Editors.ComboBoxCellEditor)e.Editor).Items.Clear(); ((XPTable.Editors.ComboBoxCellEditor)e.Editor).Items.AddRange(DataBase.GetAvailablePersonGroupTypes()); break; case 3: ((XPTable.Editors.ComboBoxCellEditor)e.Editor).Items.Clear(); ((XPTable.Editors.ComboBoxCellEditor)e.Editor).Items.AddRange(DataBase.GetAvailablePersonGroupSex()); break; case 4: ((XPTable.Editors.ComboBoxCellEditor)e.Editor).Items.Clear(); ((XPTable.Editors.ComboBoxCellEditor)e.Editor).DropDownStyle = XPTable.Editors.DropDownStyle.DropDown; List <String> countries = DataBase.GetAvailableCountries(personGroup.PersonGroup); ((XPTable.Editors.ComboBoxCellEditor)e.Editor).Items.AddRange(countries.ToArray()); break; default: break; } PersonGroupDataSet.PersonGroupRow personGroupRow = (PersonGroupDataSet.PersonGroupRow)personGroupTable.TableModel.Rows[e.Row].Tag; personGroupRow.BeginEdit(); }
public FormDeleteExistingArtist(DataBase db, PersonGroupDataSet.PersonGroupRow personGroup) { InitializeComponent(); dataBase = db; personGroupToDelete = personGroup; FormThemeManager.SetTheme(this); buttonOK.Enabled = false; }
private void Delete() { PersonGroupDataSet.PersonGroupRow selPersonGroup = GetSelectedRow(); int selectedIndex = GetSelectedIndex(); if (selPersonGroup == null) { return; } if (MessageBox.Show(String.Format(StringTable.DeleteArtist, selPersonGroup.Name), Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } // Prüfen, ob es noch Tracks oder CDs mit diesem Interpreten gibt. bool artistFound = IsPersonGroupUsed(selPersonGroup.PersonGroupID); if (artistFound) { FormDeleteExistingArtist formExisting = new FormDeleteExistingArtist(dataBase, selPersonGroup); if (formExisting.ShowDialog() == DialogResult.OK) { string personGroupName = (string)formExisting.comboBoxArtists.SelectedItem; PersonGroupDataSet.PersonGroupRow newPersonGroup = dataBase.GetPersonGroupRowByName(personGroupName, false); PersonGroupHelper.UpdateSoundfiles(this.dataBase, selPersonGroup.PersonGroupID, selPersonGroup.Name, personGroupName, delegate { dataBase.ExecuteNonQuery(string.Format("UPDATE CD SET ArtistID={0} WHERE ArtistID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID)); dataBase.ExecuteNonQuery(string.Format("UPDATE Track SET ArtistID={0} WHERE ArtistID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID)); dataBase.ExecuteNonQuery(string.Format("UPDATE CD SET ComposerID={0} WHERE ComposerID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID)); dataBase.ExecuteNonQuery(string.Format("UPDATE Track SET ComposerID={0} WHERE ComposerID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID)); dataBase.ExecuteNonQuery(string.Format("UPDATE Participant SET PersonGroupID={0} WHERE PersonGroupID={1}", newPersonGroup.PersonGroupID, selPersonGroup.PersonGroupID)); dataBase.ExecuteNonQuery(string.Format("DELETE FROM PersonGroup WHERE PersonGroupID={0}", selPersonGroup.PersonGroupID)); personGroupListBox.Items.Remove(selPersonGroup); personGroupTable.TableModel.Rows.RemoveAt(selectedIndex); }); } } else { dataBase.ExecuteNonQuery(string.Format("DELETE FROM PersonGroup WHERE PersonGroupID={0}", selPersonGroup.PersonGroupID)); personGroupListBox.Items.Remove(selPersonGroup); personGroupTable.TableModel.Rows.RemoveAt(selectedIndex); } }
private void buttonComposerTrack_Click(object sender, EventArgs e) { PersonGroupDataSet.PersonGroupRow row = DataBase.GetPersonGroupByName(textBoxComposerTrack.Text, true); FormArtistProperties formComposerProperties = new FormArtistProperties(DataBase, PersonType.Composer, row); if (formComposerProperties.ShowDialog(this) == DialogResult.OK) { try { Big3.Hitbase.DataBaseEngine.PersonGroupDataSetTableAdapters.PersonGroupTableAdapter personGroupAdapter = new Big3.Hitbase.DataBaseEngine.PersonGroupDataSetTableAdapters.PersonGroupTableAdapter(this.DataBase); personGroupAdapter.Update(row); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void ArtistListBoxWithImage_MouseDown(object sender, MouseEventArgs e) { int index = this.IndexFromPoint(e.X, e.Y); if (index < 0) { return; } PersonGroupDataSet.PersonGroupRow item = (PersonGroupDataSet.PersonGroupRow)Items[index]; if (index > -1) { if (PointInURL(index, e.Location)) { Process.Start(item.URL); } } }
private void artistTable_CellPropertyChanged(object sender, XPTable.Events.CellEventArgs e) { try { PersonGroupDataSet.PersonGroupRow personGroupRow = (PersonGroupDataSet.PersonGroupRow)personGroupTable.TableModel.Rows[e.Row].Tag; switch (e.Column) { case 0: personGroupRow.Name = e.Cell.Text; break; case 1: personGroupRow.SaveAs = e.Cell.Text; break; case 4: personGroupRow.Country = e.Cell.Text; break; case 7: personGroupRow.URL = e.Cell.Text; break; case 8: personGroupRow.ImageFilename = e.Cell.Text; break; case 9: personGroupRow.Comment = e.Cell.Text; break; } personGroupRow.EndEdit(); personGroupAdapter.Update(personGroupRow); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void CheckArtist(int row) { PersonGroupDataSet.PersonGroupRow personGroupRow = (PersonGroupDataSet.PersonGroupRow)personGroupTable.TableModel.Rows[row].Tag; Color textColor; if (IsPersonGroupUsed(personGroupRow.PersonGroupID)) { personGroupTable.TableModel.Rows[row].Cells[10].Text = StringTable.Yes; textColor = Color.Black; } else { personGroupTable.TableModel.Rows[row].Cells[10].Text = StringTable.No; textColor = Color.LightGray; } for (int i = 0; i < personGroupTable.TableModel.Rows[row].Cells.Count; i++) { personGroupTable.TableModel.Rows[row].Cells[i].ForeColor = textColor; } }
private bool PointInURL(int index, Point pt) { Rectangle rect = this.GetItemRectangle(index); PersonGroupDataSet.PersonGroupRow item = (PersonGroupDataSet.PersonGroupRow)Items[index]; int xpos = rect.Left + ItemHeight + Border * 2; string url = item.URL; if (pt.X > xpos + (Width - xpos) / 2 && pt.X < xpos + (Width - xpos) / 2 + CreateGraphics().MeasureString(url, fontSmall).Width&& pt.Y > rect.Top + 10 && pt.Y < rect.Top + 10 + CreateGraphics().MeasureString(url, fontSmall).Height) { return(true); } else { return(false); } }
private void buttonOK_Click(object sender, EventArgs e) { if (String.Compare(originalArtistName, textBoxName.Text, true) != 0) { // JUS 16.10.2004: Prüfen, ob Interpret schon vorhanden PersonGroupDataSet.PersonGroupRow row = dataBase.GetPersonGroupRowByName(textBoxName.Text, false); if (row != null) { String str; if (personType == PersonType.Artist) { str = String.Format(StringTable.ArtistAlreadyExists, textBoxName.Text); } else { str = String.Format(StringTable.ComposerAlreadyExists, textBoxName.Text); } MessageBox.Show(str, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.None; return; } } DialogResult = DialogResult.OK; thePersonGroupRow.EndEdit(); if (!string.IsNullOrEmpty(choosePictureButton.ImageFilename)) { thePersonGroupRow.ImageFilename = choosePictureButton.ImageFilename; } else { thePersonGroupRow.SetImageFilenameNull(); } }
private void Edit() { PersonGroupDataSet.PersonGroupRow personGroupRow = GetSelectedRow(); if (personGroupRow == null) { return; } PersonGroup personGroup = dataBase.GetPersonGroupById(personGroupRow.PersonGroupID); PersonGroupWindow personGroupWindow = new PersonGroupWindow(dataBase, PersonType.Unknown, personGroup); personGroupWindow.ChangeAllSoundFiles = true; int oldPersonGroupId = personGroup.ID; string oldPersonGroup = personGroup.Name; if (personGroupWindow.ShowDialog() == true) { personGroupListBox.ClearImageCache(); personGroupListBox.Invalidate(false); } }
void printDocument_PrintPage(object sender, PrintPageEventArgs e) { // Zuerst die Gesamtbreite aller Spalten ermitteln int totalWidth = 0; foreach (XPTable.Models.Column column in personGroupTable.ColumnModel.Columns) { if (column.Visible) { totalWidth += column.Width; } } // Jetzt den Prozentanteil jeder einzelnen Spalte errechnen und auf die Seite hochrechnen int[] columnWidth = new int[personGroupTable.ColumnModel.Columns.Count]; int nr = 0; foreach (XPTable.Models.Column column in personGroupTable.ColumnModel.Columns) { if (column.Visible) { columnWidth[nr] = (int)((double)e.MarginBounds.Width / (double)totalWidth * (double)column.Width); nr++; } } bool printThisPage = (e.PageSettings.PrinterSettings.PrintRange == PrintRange.AllPages || currentPage >= e.PageSettings.PrinterSettings.FromPage && currentPage <= e.PageSettings.PrinterSettings.ToPage); int yPosition = e.MarginBounds.Top; // Spaltenüberschrift drucken if (printThisPage) { PrintHeader(e.Graphics, e.MarginBounds, columnWidth, personGroupTable, ref yPosition); } int startYPosition = yPosition; if (personGroupTable.Visible) { for (int i = currentPrintRecord; i < personGroupTable.TableModel.Rows.Count; i++) { if (yPosition + printFont.Height > e.MarginBounds.Bottom) { currentPrintRecord = i; yPosition = e.MarginBounds.Top; if (e.PageSettings.PrinterSettings.PrintRange == PrintRange.SomePages && currentPage >= e.PageSettings.PrinterSettings.ToPage) { e.HasMorePages = false; break; } if (printThisPage) { currentPage++; e.HasMorePages = true; break; } currentPage++; printThisPage = (e.PageSettings.PrinterSettings.PrintRange == PrintRange.AllPages || currentPage >= e.PageSettings.PrinterSettings.FromPage && currentPage <= e.PageSettings.PrinterSettings.ToPage); if (printThisPage) { PrintHeader(e.Graphics, e.MarginBounds, columnWidth, personGroupTable, ref yPosition); } } if (printThisPage) { int colNr = 0; int xPosition = e.MarginBounds.Left; foreach (XPTable.Models.Cell cell in personGroupTable.TableModel.Rows[i].Cells) { if (personGroupTable.ColumnModel.Columns[cell.Index].Visible) { //e.Graphics.DrawString(cell.Text, printFont, Brushes.Black, new PointF(xPosition, yPosition)); StringFormat sf = new StringFormat(); sf.Trimming = StringTrimming.EllipsisCharacter; e.Graphics.DrawString(cell.Text, printFont, Brushes.Black, new RectangleF(xPosition, yPosition, columnWidth[colNr], printFont.Height), sf); xPosition += columnWidth[colNr]; colNr++; } } } yPosition += printFont.Height; } } else { int column = 0; for (int i = currentPrintRecord; i < personGroup.PersonGroup.Count; i++) { int xPosition; PersonGroupDataSet.PersonGroupRow personGroupRow = personGroup.PersonGroup[i]; if (yPosition + printFont.Height * 7 > e.MarginBounds.Bottom) { if (column < 1) { column++; yPosition = startYPosition; } else { currentPrintRecord = i; yPosition = e.MarginBounds.Top; if (e.PageSettings.PrinterSettings.PrintRange == PrintRange.SomePages && currentPage >= e.PageSettings.PrinterSettings.ToPage) { e.HasMorePages = false; break; } if (printThisPage) { currentPage++; e.HasMorePages = true; break; } currentPage++; printThisPage = (e.PageSettings.PrinterSettings.PrintRange == PrintRange.AllPages || currentPage >= e.PageSettings.PrinterSettings.FromPage && currentPage <= e.PageSettings.PrinterSettings.ToPage); if (printThisPage) { PrintHeader(e.Graphics, e.MarginBounds, columnWidth, personGroupTable, ref yPosition); } column = 0; } } if (column == 0) { xPosition = e.MarginBounds.Left; } else { xPosition = e.MarginBounds.Left + e.MarginBounds.Width / 2; } int imageWidth = printFont.Height * 7; if (printThisPage) { if (!personGroupRow.IsImageFilenameNull() && personGroupRow.ImageFilename.Length > 0) { try { Image img = Image.FromFile(Misc.FindCover(personGroupRow.ImageFilename)); SizeF imageBoundingBox = new SizeF(imageWidth, imageWidth); SizeF bestSize = GetBestFitSize(img, imageBoundingBox); RectangleF imageRect = new RectangleF( new PointF( xPosition + (imageBoundingBox.Width - bestSize.Width) / 2, yPosition + (imageBoundingBox.Height - bestSize.Height) / 2), bestSize); e.Graphics.DrawImage(img, imageRect); } catch // Fehler ignorieren { } } } xPosition += imageWidth + 20; StringFormat sf = new StringFormat(); sf.Trimming = StringTrimming.EllipsisCharacter; int artistWidth = e.MarginBounds.Width / 2 - imageWidth - 30; Rectangle artistRect = new Rectangle(xPosition, yPosition, artistWidth, printFont.Height); if (printThisPage) { e.Graphics.DrawString(personGroupRow.Name, printFontBold, Brushes.Black, artistRect, sf); } string artistType = DataBase.GetNameOfPersonGroupType((PersonGroupType)(personGroupRow.IsTypeNull() ? 0 : personGroupRow.Type)); string artistSex = DataBase.GetNameOfPersonGroupSex((SexType)(personGroupRow.IsSexNull() ? 0 : personGroupRow.Sex)); int yOffset = (int)((double)printFontBold.Height * 1.5); if (printThisPage) { e.Graphics.DrawString(artistType + ", " + artistSex, printFont, Brushes.Black, new PointF(xPosition, yPosition + yOffset)); } yOffset += printFont.Height; if (!personGroupRow.IsCountryNull() && personGroupRow.Country.Length > 0) { if (printThisPage) { e.Graphics.DrawString(StringTable.Country + ": " + personGroupRow.Country, printFont, Brushes.Black, new PointF(xPosition, yPosition + yOffset)); } yOffset += printFont.Height; } if (!personGroupRow.IsBirthDayNull()) { if (printThisPage) { if ((PersonGroupType)personGroupRow.Type == PersonGroupType.Single) { e.Graphics.DrawString(StringTable.Born + ": " + personGroupRow.BirthDay, printFont, Brushes.Black, new PointF(xPosition, yPosition + yOffset)); } else { e.Graphics.DrawString(StringTable.Founded + ": " + personGroupRow.BirthDay, printFont, Brushes.Black, new PointF(xPosition, yPosition + yOffset)); } } yOffset += printFont.Height; } if (!personGroupRow.IsDayOfDeathNull()) { if (printThisPage) { if ((PersonGroupType)personGroupRow.Type == PersonGroupType.Single) { e.Graphics.DrawString(StringTable.Died + ": " + personGroupRow.DayOfDeath, printFont, Brushes.Black, new PointF(xPosition, yPosition + yOffset)); } else { e.Graphics.DrawString(StringTable.BreakAway + ": " + personGroupRow.DayOfDeath, printFont, Brushes.Black, new PointF(xPosition, yPosition + yOffset)); } } yOffset += printFont.Height; } if (!personGroupRow.IsURLNull()) { if (printThisPage) { e.Graphics.DrawString(personGroupRow.URL, printFont, Brushes.Black, new PointF(xPosition, yPosition + yOffset)); } yOffset += printFont.Height; } yPosition += printFont.Height * 8; } } }
private void artistTable_EditingStopped(object sender, XPTable.Events.CellEditEventArgs e) { PersonGroupDataSet.PersonGroupRow personGroupRow = (PersonGroupDataSet.PersonGroupRow)personGroupTable.TableModel.Rows[e.Row].Tag; switch (e.Column) { case 2: personGroupRow.Type = ((XPTable.Editors.ComboBoxCellEditor)e.Editor).SelectedIndex; personGroupRow.EndEdit(); personGroupAdapter.Update(personGroupRow); break; case 3: personGroupRow.Sex = ((XPTable.Editors.ComboBoxCellEditor)e.Editor).SelectedIndex; personGroupRow.EndEdit(); personGroupAdapter.Update(personGroupRow); break; case 5: { string newValue = ((XPTable.Editors.TextCellEditor)e.Editor).TextBox.Text; try { if (newValue.Length > 0) { personGroupRow.BirthDay = Misc.ParseDate(newValue); // Das richtig formatierte Datum anzeigen ((XPTable.Editors.TextCellEditor)e.Editor).TextBox.Text = Misc.FormatDate(personGroupRow.BirthDay); e.Cell.Data = personGroupRow.BirthDay; } else { personGroupRow.SetBirthDayNull(); e.Cell.Data = null; } } catch { MessageBox.Show(StringTable.InvalidDateValue, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); e.Cancel = true; } break; } case 6: { string newValue = ((XPTable.Editors.TextCellEditor)e.Editor).TextBox.Text; try { if (newValue.Length > 0) { personGroupRow.DayOfDeath = Misc.ParseDate(newValue); // Das richtig formatierte Datum anzeigen ((XPTable.Editors.TextCellEditor)e.Editor).TextBox.Text = Misc.FormatDate(personGroupRow.DayOfDeath); e.Cell.Data = personGroupRow.DayOfDeath; } else { personGroupRow.SetDayOfDeathNull(); e.Cell.Data = null; } } catch { MessageBox.Show(StringTable.InvalidDateValue, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); e.Cancel = true; } break; } } }
private void artistTable_EditingCancelled(object sender, XPTable.Events.CellEditEventArgs e) { PersonGroupDataSet.PersonGroupRow personGroupRow = (PersonGroupDataSet.PersonGroupRow)personGroupTable.TableModel.Rows[e.Row].Tag; personGroupRow.CancelEdit(); }
protected override void OnDrawItem(DrawItemEventArgs e) { //base.OnDrawItem(e); if (e.Index >= Items.Count || e.Index < 0) { return; } Graphics g = e.Graphics; if ((e.State & DrawItemState.Selected) != 0) { g.FillRectangle(new SolidBrush(ColorTable.MenuItemSelected), e.Bounds); Rectangle rect = Rectangle.FromLTRB(e.Bounds.Left, e.Bounds.Top, e.Bounds.Right - 1, e.Bounds.Bottom - 1); g.DrawRectangle(new Pen(ColorTable.MenuItemBorder), rect); } else { LinearGradientBrush b = new LinearGradientBrush(e.Bounds, ProfessionalColors.ToolStripGradientBegin, ProfessionalColors.ToolStripGradientEnd, LinearGradientMode.Vertical); g.FillRectangle(b, e.Bounds); } int xpos = e.Bounds.Left + ItemHeight + Border * 2; PersonGroupDataSet.PersonGroupRow item = (PersonGroupDataSet.PersonGroupRow)Items[e.Index]; g.DrawString(item.Name, fontBold, Brushes.Black, new PointF(xpos, e.Bounds.Top + Border)); string artistType = DataBase.GetNameOfPersonGroupType((PersonGroupType)(item.IsTypeNull() ? 0 : item.Type)); string artistSex = DataBase.GetNameOfPersonGroupSex((SexType)(item.IsSexNull() ? 0 : item.Sex)); g.DrawString(artistType + ", " + artistSex, fontNormal, Brushes.Black, new PointF(xpos, e.Bounds.Top + 18)); int yOffset = 36; if (!item.IsCountryNull() && item.Country.Length > 0) { g.DrawString(StringTable.Country + ": " + item.Country, fontNormal, Brushes.Black, new PointF(xpos, e.Bounds.Top + yOffset)); yOffset = 54; } if (!item.IsBirthDayNull()) { if ((PersonGroupType)item.Type == PersonGroupType.Single) { g.DrawString(StringTable.Born + ": " + Misc.FormatDate(item.BirthDay), fontNormal, Brushes.Black, new PointF(xpos, e.Bounds.Top + yOffset)); } else { g.DrawString(StringTable.Founded + ": " + Misc.FormatDate(item.BirthDay), fontNormal, Brushes.Black, new PointF(xpos, e.Bounds.Top + yOffset)); } // yOffset += 16; } if (!item.IsDayOfDeathNull()) { if ((PersonGroupType)item.Type == PersonGroupType.Single) { g.DrawString(StringTable.Died + ": " + Misc.FormatDate(item.DayOfDeath), fontNormal, Brushes.Black, new PointF(xpos + (Width - xpos) / 2, e.Bounds.Top + yOffset)); } else { g.DrawString(StringTable.BreakAway + ": " + Misc.FormatDate(item.DayOfDeath), fontNormal, Brushes.Black, new PointF(xpos + (Width - xpos) / 2, e.Bounds.Top + yOffset)); } yOffset += 16; } if (!item.IsImageFilenameNull() && item.ImageFilename.Length > 0) { if (!imageCache.ContainsKey(item.ImageFilename)) { try { byte[] imageBytes = File.ReadAllBytes(Misc.FindCover(item.ImageFilename)); MemoryStream m = new MemoryStream(imageBytes); Image img = Image.FromStream(m); m.Close(); imageCache.Add(item.ImageFilename, img); } catch (Exception ex) { } } if (imageCache.ContainsKey(item.ImageFilename)) { Size origSize = new Size(ItemHeight - Border * 2, ItemHeight - Border * 2); Size imageBestFitSize = GetBestFitSize(imageCache[item.ImageFilename], origSize); Rectangle imageRect = new Rectangle( new Point(e.Bounds.Left + Border + (origSize.Width - imageBestFitSize.Width) / 2, e.Bounds.Top + Border + (origSize.Height - imageBestFitSize.Height) / 2), imageBestFitSize); g.DrawImage(imageCache[item.ImageFilename], imageRect); } } else { Size origSize = new Size(ItemHeight - Border * 2, ItemHeight - Border * 2); Size imageBestFitSize = GetBestFitSize(Images.MissingPersonImage, origSize); Rectangle imageRect = new Rectangle( new Point(e.Bounds.Left + Border + (origSize.Width - imageBestFitSize.Width) / 2, e.Bounds.Top + Border + (origSize.Height - imageBestFitSize.Height) / 2), imageBestFitSize); g.DrawImage(Images.MissingPersonImage, imageRect); } if (!item.IsURLNull()) { g.DrawString(item.URL, fontSmall, Brushes.Blue, new PointF(xpos + (Width - xpos) / 2, e.Bounds.Top + 10)); } }
/// <summary> /// Speichert die Person/Gruppe. /// </summary> /// <param name="db"></param> public void Save(DataBase dataBase) { SqlCeTransaction trans = dataBase.Connection.BeginTransaction(IsolationLevel.ReadCommitted); Big3.Hitbase.DataBaseEngine.PersonGroupDataSetTableAdapters.PersonGroupTableAdapter pgta = new Big3.Hitbase.DataBaseEngine.PersonGroupDataSetTableAdapters.PersonGroupTableAdapter(dataBase); pgta.Transaction = trans; PersonGroupDataSet.PersonGroupDataTable dt = pgta.GetDataById(id); PersonGroupDataSet.PersonGroupRow row = null; bool isNew = false; int personGroupId = 0; if (dt.Rows.Count == 1) { row = dt[0]; personGroupId = dt[0].PersonGroupID; } else { row = dt.NewPersonGroupRow(); isNew = true; } row.Name = Name; row.SaveAs = SaveAs; row.Type = (int)Type; row.Sex = (int)Sex; row.Country = Country; row.BirthDay = Birthday; row.DayOfDeath = DayOfDeath; row.ImageFilename = ImageFilename; row.URL = Homepage; row.Comment = Comment; if (isNew) { dt.AddPersonGroupRow(row); } pgta.Update(dt); if (isNew) { personGroupId = (int)(decimal)dataBase.ExecuteScalar("SELECT @@IDENTITY", trans); } // Urls speichern string sql = string.Format("DELETE FROM Url Where ReferenceID = {0}", personGroupId); dataBase.ExecuteScalar(sql); UrlDataSetTableAdapters.UrlTableAdapter urlta = new UrlDataSetTableAdapters.UrlTableAdapter(dataBase); urlta.Transaction = trans; UrlDataSet.UrlDataTable urlDataTable = new UrlDataSet.UrlDataTable(); foreach (Url url in Urls) { urlDataTable.AddUrlRow(personGroupId, 0, url.UrlType, url.Link); } urlta.Update(urlDataTable); // Jetzt noch die Mitwirkenden der Gruppe sql = string.Format("DELETE FROM GroupParticipant Where PersonGroupID = {0}", personGroupId); dataBase.ExecuteScalar(sql); GroupParticipantDataSetTableAdapters.GroupParticipantTableAdapter participantTableAdapter = new GroupParticipantDataSetTableAdapters.GroupParticipantTableAdapter(dataBase); participantTableAdapter.Transaction = trans; GroupParticipantDataSet.GroupParticipantDataTable participantsDataTable = new GroupParticipantDataSet.GroupParticipantDataTable(); foreach (GroupParticipant gp in this.Participants) { if (!string.IsNullOrEmpty(gp.Name)) { int participantId = dataBase.GetPersonGroupByName(gp.Name, true).ID; int roleId = dataBase.GetRoleByName(gp.Role, true).RoleID; participantsDataTable.AddGroupParticipantRow(personGroupId, participantId, roleId, gp.Begin == null ? "" : gp.Begin, gp.End == null ? "" : gp.End); } } participantTableAdapter.Update(participantsDataTable); trans.Commit(); }
public FormArtistProperties(DataBase db, PersonType persontype, PersonGroupDataSet.PersonGroupRow personGroupRow) { InitializeComponent(); switch (persontype) { case PersonType.Composer: Text = StringTable.Composer; groupBox.Text = StringTable.Composer; break; case PersonType.Artist: Text = StringTable.Artist; groupBox.Text = StringTable.Artist; break; case PersonType.Unknown: default: Text = StringTable.PersonOrGroup; groupBox.Text = StringTable.PersonOrGroup; break; } dataBase = db; originalArtistName = personGroupRow.Name; personType = persontype; thePersonGroupRow = personGroupRow; thePersonGroupRow.BeginEdit(); comboBoxArtistType.DataSource = DataBase.GetAvailablePersonGroupTypes(); comboBoxSex.DataSource = DataBase.GetAvailablePersonGroupSex(); textBoxName.DataBindings.Add("Text", personGroupRow, "Name"); textBoxSaveAs.DataBindings.Add("Text", personGroupRow, "SaveAs"); textBoxComment.DataBindings.Add("Text", personGroupRow, "Comment"); textBoxHomepage.DataBindings.Add("Text", personGroupRow, "URL"); comboBoxArtistType.DataBindings.Add("SelectedIndex", personGroupRow, "Type", true); comboBoxSex.DataBindings.Add("SelectedIndex", personGroupRow, "Sex", true); comboBoxCountry.DataBindings.Add("Text", personGroupRow, "Country"); // Vorhandene Länder ermitteln String[] distinctValues = dataBase.GetAvailableCountries(); comboBoxCountry.DataSource = distinctValues; if (!personGroupRow.IsImageFilenameNull() && personGroupRow.ImageFilename.Length > 0) { choosePictureButton.ImageFilename = personGroupRow.ImageFilename; } if (!personGroupRow.IsBirthDayNull()) { textBoxBirthday.Text = Misc.FormatDate(personGroupRow.BirthDay); } if (!personGroupRow.IsDayOfDeathNull()) { textBoxDayOfDeath.Text = Misc.FormatDate(personGroupRow.DayOfDeath); } UpdateWindowState(); choosePictureButton.CoverType = CoverType.PersonGroup; choosePictureButton.PersonGroup = personGroupRow; }