private void QueueControl_Load(object sender, EventArgs e) { dataGridViewQueue.EnableHeadersVisualStyles = true; defaultstyle = new DataGridViewCellStyle(); defaultstyle.ForeColor = Color.Black; addstyle = new DataGridViewCellStyle(); addstyle.ForeColor = Color.DarkGreen; changestyle = new DataGridViewCellStyle(); changestyle.ForeColor = Color.DarkBlue; stateDefault = new DataGridViewCellStyle(); stateDefault.BackColor = Color.Green; stateStyleFinished = new DataGridViewCellStyle(); stateStyleFinished.BackColor = Color.DarkBlue; stateStyleGoneHome = new DataGridViewCellStyle(); stateStyleGoneHome.BackColor = Color.Black; _queuerForm = Tag as QueuerForm; dataGridViewQueue.AutoGenerateColumns = false; SetSingers(); if (_queuerForm != null) { _scc = _queuerForm.scc; string xml = ""; string ix = Name.Substring(Name.Length - 1, 1); switch (ix) { case "1": (Tag as QueuerForm).controlTag.queueControl1 = this; _round = 1; break; case "2": (Tag as QueuerForm).controlTag.queueControl2 = this; _round = 2; break; case "3": (Tag as QueuerForm).controlTag.queueControl3 = this; _round = 3; break; case "4": (Tag as QueuerForm).controlTag.queueControl4 = this; _round = 4; break; case "5": (Tag as QueuerForm).controlTag.queueControl5 = this; _round = 5; break; case "6": (Tag as QueuerForm).controlTag.queueControl6 = this; _round = 6; break; } xml = GetQueue(_round); LoadTSCQueue(xml); if (_round != 1 && _queuerForm != null) { _queuerForm.controlTag.queueControl1.MasterRefresh(); } if (_queuerForm != null) { _queuerForm.SetNext(); } } else { _scc = new SingerDatabase(); } }
public void Save() { int recordsadded = 0; int recordschanged = 0; int recordsremoved = 0; if (IsValid()) { foreach (TSCQueue queue in gd_tscqueue) { SetState(queue, db_tscqueue); } foreach (TSCQueue queue in db_tscqueue) { SetState(queue, gd_tscqueue); } foreach (TSCQueue queue in gd_tscqueue) { if (queue.state == 'I') { string xml = queue.GetDataXml(); string result = _scc.GeneralStore("TSCQueue", "INSERT", xml); if (!(result != null && IsNumber(result) && int.Parse(result) > 0)) { MessageBox.Show("Save error: " + QueueKey(queue) + " - " + result); } else { recordsadded++; } } else if (queue.state == 'U') { string xml = queue.GetDataXml(); string result = _scc.GeneralStore("TSCQueue", "UPDATE", xml); if (!(result != null && IsNumber(result) && int.Parse(result) > 0)) { MessageBox.Show("Save error: " + QueueKey(queue) + " - " + result); } else { recordschanged++; } } } foreach (TSCQueue queue in db_tscqueue) { if (queue.state == 'D') { string xml = queue.GetDataXml(); string result = _scc.GeneralStore("TSCQueue", "DELETE", xml); if (!(result != null && IsNumber(result) && int.Parse(result) > 0)) { MessageBox.Show("Delete error: " + QueueKey(queue) + " - " + result); } else { recordsremoved++; } } } if (_queuerForm != null && (recordsadded > 0 || recordschanged > 0 || recordsremoved > 0)) { db_tscqueue.Clear(); gd_tscqueue.Clear(); TSCQueue templateQueue = new TSCQueue(); templateQueue.EventKey = _queuerForm.cmb_events.Text; templateQueue.QueueRound = _round; switch (_round) { case 1: _queuerForm.controlTag.queue1Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml()); LoadTSCQueue(_queuerForm.controlTag.queue1Xml); break; case 2: _queuerForm.controlTag.queue2Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml()); LoadTSCQueue(_queuerForm.controlTag.queue2Xml); break; case 3: _queuerForm.controlTag.queue3Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml()); LoadTSCQueue(_queuerForm.controlTag.queue3Xml); break; case 4: _queuerForm.controlTag.queue4Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml()); LoadTSCQueue(_queuerForm.controlTag.queue4Xml); break; case 5: _queuerForm.controlTag.queue5Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml()); LoadTSCQueue(_queuerForm.controlTag.queue5Xml); break; case 6: _queuerForm.controlTag.queue6Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml()); LoadTSCQueue(_queuerForm.controlTag.queue6Xml); break; } RefreshGrid(); if (_queuerForm != null) { _queuerForm.controlTag.RefreshQueue(gd_tscqueue); if (_queuerForm.controlTag != null) { _queuerForm.controlTag.SetNext(); } _queuerForm.SetNext(); } } } }