private void singerHistoryToolStripMenuItem_Click(object sender, EventArgs e) { if (_queuerForm != null && _rowIndex >= 0 && _rowIndex < dataGridViewQueue.Rows.Count) { string singerkey = dataGridViewQueue.Rows[_rowIndex].Cells["SingerKey"].Value.ToString(); if (singerkey != null && singerkey.Trim().Length > 0) { SingerHistory sh = new SingerHistory(); sh.SetUp(_queuerForm.scc, singerkey); sh.ShowDialog(); } } }
private void btnHistory_Click(object sender, EventArgs e) { /* * string xml = ""; * if (cmbEvent.SelectedItem != null) * { * TSCEvents tscevent = cmbEvent.SelectedItem as TSCEvents; * if (tscevent != null) * { * xml = scc.GetSingerHistoryForVenue(tscevent.VenueKey); * } * } * else * { * xml = scc.GetSingerHistoryForVenue(""); * } * if (xml.Trim().Length > 0) * { * Dictionary<string, SingerHistoryStore> history = new Dictionary<string, SingerHistoryStore>(); * XmlDataDocument doc = new XmlDataDocument(); * if (Utility.IsValidXml(xml) == true) * { * doc.LoadXml(xml); * XmlNodeList nodes = doc.SelectNodes("/Root/Data"); * * foreach (XmlNode node in nodes) * { * string singerKey = Utility.GetXmlString(node, "SingerKey").Trim(); * DateTime EventDate = Utility.GetXmlDateTime(node, "EventDate"); * string song = Utility.GetXmlString(node, "QueueSong").Trim(); * string artist = Utility.GetXmlString(node, "QueueArtist").Trim(); * if (singerKey.Length > 0 && song.Length > 0) * { * SingerHistoryRecord record = new SingerHistoryRecord(singerKey, song, artist, EventDate); * if (history.ContainsKey(singerKey) == true) * { * history[singerKey].history.Add(record); * } * else * { * SingerHistoryStore store = new SingerHistoryStore(); * store.history.Add(record); * history.Add(singerKey, store); * } * } * } * } * if (history != null && history.Count > 0) * { * Excel.Application app = null; * Excel.Workbook workbook = null; * Excel.Worksheet worksheet = null; * Excel.Range worksheet_range = null; * app = new Excel.Application(); * app.Visible = true; * workbook = app.Workbooks.Add(1); * worksheet = (Excel.Worksheet)workbook.Sheets[1]; * int row = 1; * foreach (KeyValuePair<string, SingerHistoryStore> pair in history) * { * foreach (SingerHistoryRecord record in pair.Value.history) * { * worksheet.Cells[row, 1] = record.SingerKey; * worksheet.Cells[row, 2] = record.date; * worksheet.Cells[row, 3] = record.Song; * worksheet.Cells[row, 4] = record.Artist; * row++; * } * } * Excel.Range startcell = worksheet.Cells[1, 1]; * Excel.Range endcell = worksheet.Cells[row, 4]; * worksheet.Range[startcell, endcell].Columns.AutoFit(); * } * } */ SingerHistory sh = new SingerHistory(); sh.SetUp(scc, ""); sh.ShowDialog(); }