public void LoadEvents(Int32 statelid) { while ((cntEvents < dtEvents.Rows.Count) && ((Int32)dtEvents.Rows[cntEvents][1] == statelid)) { StatelEvent e = new StatelEvent(); e.EventNumber = (Int32)dtEvents.Rows[cntEvents][2]; e.LoadFunctions((Int32)dtEvents.Rows[cntEvents][0], statelid); this.Events.Add(e); cntEvents++; } }
private void but_RemoveEvent_Click(object sender, EventArgs e) { if (EventBox.SelectedIndex == -1) { return; } if (MessageBox.Show("Delete this event and all of its functions?", "Delete event?", MessageBoxButtons.YesNo) == DialogResult.Yes) { StatelEvent te = events.ElementAt(EventBox.SelectedIndex); foreach (StatelFunction f in functions) { common.execSQL("DELETE FROM statel_function_reqs WHERE function_id=" + f.functionid); common.execSQL("DELETE FROM statel_function_arguments WHERE function_id=" + f.functionid); } common.execSQL("DELETE FROM statel_functions WHERE event_id=" + te.eventid); common.execSQL("DELETE FROM statel_events WHERE eventid=" + te.eventid); ChangeStatelSelection(); } }
private void EventBox_DragDrop(object sender, DragEventArgs e) { if (dragsource != sender) { ChangeStatelSelection(); return; } Point p = new Point(e.X, e.Y); p = ((ListBox)sender).PointToClient(p); int indexOfItem = EventBox.IndexFromPoint(p.X, p.Y); if ((indexOfItem >= 0) && (indexOfItem < EventBox.Items.Count)) { StatelEvent se = events.ElementAt(indexOfItem); se.changeid(selectedstatel, evdrag.eventid); ChangeStatelSelection(); } Setline(null, false, null); }
public void ChangeStatelSelection() { this.Cursor = Cursors.WaitCursor; DataSet ds = common.readSQL("SELECT * FROM statels where instance=" + strBefore(strAfter(StatelBox.SelectedItem.ToString(), ":"), " ") + " AND type=" + strBefore(StatelBox.SelectedItem.ToString(), ":") + " ORDER BY id ASC"); DataTable dt = ds.Tables[0]; EventBox.Items.Clear(); FunctionBox.Items.Clear(); ArgumentBox.Items.Clear(); args.Clear(); RequirementBox.Items.Clear(); reqs.Clear(); if (dt.Rows.Count > 0) { selectedstatel = (Int32)dt.Rows[0]["id"]; foreach (DataRow dr in dt.Rows) { DataSet ds2 = common.readSQL("SELECT * from statel_events where statel_id=" + dr["id"].ToString() + " ORDER BY eventid, statel_id ASC"); DataTable dt2 = ds2.Tables[0]; events.Clear(); foreach (DataRow dr2 in dt2.Rows) { StatelEvent f = new StatelEvent(); f.eventid = (Int32)dr2[0]; f.eventnum = (Int32)dr2[2]; events.Add(f); EventBox.Items.Add(NamesandNumbers.Events[Int32.Parse(dr2[2].ToString())] + " (" + Int32.Parse(dr2[2].ToString()) + ")"); } if (EventBox.Items.Count > 0) { EventBox.SelectedIndex = 0; } } } else { selectedstatel = -1; } this.Cursor = Cursors.Default; }