private void ControlsToData() { if (_item == null) { _item = new SwitchPort(); } base.ControlsToData(); SwitchPort switchPort = RepeatedItem as SwitchPort; if (dataGridView.Rows.Count == 0) { switchPort.Pin = null; } else { switchPort.Pin = new List <SwitchPortPin>(); foreach (DataGridViewRow row in dataGridView.Rows) { int iLine = 0; String line = row.Cells["line"].Value as String; String name = row.Cells["name"].Value as String; if (!String.IsNullOrEmpty(name) && line != null && int.TryParse(line, out iLine)) { SwitchPortPin pin = new SwitchPortPin(); pin.line = iLine; pin.name = name; switchPort.Pin.Add(pin); } } } }
private void AddListViewItem(SwitchPort port, lists.ATMLListControl listView) { ListViewItem lvi = new ListViewItem(port.name); lvi.SubItems.Add(port.Description); lvi.SubItems.Add(port.baseIndexSpecified ? "" + port.baseIndex : ""); lvi.SubItems.Add(port.countSpecified ? "" + port.count : ""); lvi.SubItems.Add(port.incrementBySpecified ? "" + port.incrementBy : ""); lvi.SubItems.Add(port.replacementCharacter); lvi.Tag = port; listView.Items.Add(lvi); }
private void DeleteSwitchPort(lists.ATMLListControl listView) { if (listView.SelectedItems.Count > 0) { SwitchPort port = (SwitchPort)listView.SelectedItems[0].Tag; String prompt = String.Format(MessageManager.getMessage("Generic.delete.prompt"), "switch port", port.name); String title = MessageManager.getMessage("Generic.title.verification"); if (DialogResult.Yes == MessageBox.Show(prompt, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { listView.SelectedItems[0].Remove(); } } }
private void AddSwitchPort(lists.ATMLListControl listView) { SwitchPortForm form = new SwitchPortForm(); form.SwitchPort = new SwitchPort(); if (DialogResult.OK == form.ShowDialog()) { SwitchPort port = form.SwitchPort; ListViewItem lvi = new ListViewItem(port.name); lvi.SubItems.Add(port.Description); lvi.SubItems.Add(port.baseIndexSpecified ? "" + port.baseIndex : ""); lvi.SubItems.Add(port.countSpecified ? "" + port.count : ""); lvi.SubItems.Add(port.incrementBySpecified ? "" + port.incrementBy : ""); lvi.SubItems.Add(port.replacementCharacter); lvi.Tag = port; listView.Items.Add(lvi); } }
private void DataToControls() { SwitchPort switchPort = RepeatedItem as SwitchPort; if (switchPort != null) { if (switchPort.Pin != null) { foreach (SwitchPortPin pin in switchPort.Pin) { //pin.line int idx = dataGridView.Rows.Add(); DataGridViewRow row = dataGridView.Rows[idx]; row.Cells["line"].Value = "" + pin.line; row.Cells["name"].Value = pin.name; } } } }
private void EditSwitchPort(lists.ATMLListControl listView) { if (lvColumns.SelectedItems.Count > 0) { ListViewItem lvi = listView.SelectedItems[0]; SwitchPortForm form = new SwitchPortForm(); form.SwitchPort = (SwitchPort)lvi.Tag; if (DialogResult.OK == form.ShowDialog()) { SwitchPort port = form.SwitchPort; lvi.SubItems[0].Text = port.name; lvi.SubItems[1].Text = port.Description; lvi.SubItems[2].Text = port.baseIndexSpecified ? "" + port.baseIndex : ""; lvi.SubItems[3].Text = port.countSpecified ? "" + port.count : ""; lvi.SubItems[4].Text = port.incrementBySpecified ? "" + port.incrementBy : ""; lvi.SubItems[5].Text = port.replacementCharacter; lvi.Tag = port; } } }
private void refreshPortLists() { string ppPortQuery = "SELECT PatchPanelPort.PatchPanelPortID, PatchPanelPort.PatchPanelPortNum, PatchPanelPort.PatchPanelID FROM [PatchPanelPort] WHERE PatchPanelPort.SwitchPortID IS NULL;"; string switchPortQuery = "SELECT SwitchPort.SwitchPortID, SwitchPort.SwitchPortNum, SwitchPort.SwitchID FROM [SwitchPort] WHERE SwitchPort.PatchPanelPortID IS NULL;"; DataSet swpDS = getDataSet(switchPortQuery); DataSet pppDS = getDataSet(ppPortQuery); List<SwitchPort> newSwitchPortList = new List<SwitchPort>(); List<PatchPanelPort> newPatchPanelPortList = new List<PatchPanelPort>(); try { foreach (DataRow dr in swpDS.Tables[0].Rows) { SwitchPort swp = new SwitchPort(); swp.switchPortID = (int)dr.ItemArray.GetValue(0); swp.switchPortNum = (int)dr.ItemArray.GetValue(1); swp.switchID = (int)dr.ItemArray.GetValue(2); newSwitchPortList.Add(swp); } foreach (DataRow dr in pppDS.Tables[0].Rows) { PatchPanelPort ppp = new PatchPanelPort(); ppp.patchPanelPortID = (int)dr.ItemArray.GetValue(0); ppp.patchPanelPortNum = (int)dr.ItemArray.GetValue(1); ppp.patchPanelID = (int)dr.ItemArray.GetValue(2); newPatchPanelPortList.Add(ppp); } switchPortList = newSwitchPortList; PPPList = newPatchPanelPortList; } catch (OleDbException exp) { MessageBox.Show("Database Error:" + exp.Message.ToString()); } }
//load venues into combobox private void Form2_Load(object sender, EventArgs e) { string venueQuery = "SELECT Venue.VenueID, Venue.VenueName FROM [Venue];"; string venueSpaceQuery = "SELECT VenueSpace.VenueSpaceID, VenueSpace.VenueSpaceName, VenueSpace.VenueID FROM [VenueSpace];"; string idfQuery = "SELECT IDF.IDFID, IDF.IDFName, IDF.VenueSpaceID FROM [IDF];"; string ppQuery = "SELECT PatchPanel.PatchPanelID, PatchPanel.PatchPanelName, PatchPanel.IDFID FROM [PatchPanel];"; string switchQuery = "SELECT Switch.SwitchID, Switch.DNSName, Switch.IDFID FROM [Switch];"; string ppPortQuery = "SELECT PatchPanelPort.PatchPanelPortID, PatchPanelPort.PatchPanelPortNum, PatchPanelPort.PatchPanelID FROM [PatchPanelPort] WHERE PatchPanelPort.SwitchPortID IS NULL;"; string switchPortQuery = "SELECT SwitchPort.SwitchPortID, SwitchPort.SwitchPortNum, SwitchPort.SwitchID FROM [SwitchPort] WHERE SwitchPort.PatchPanelPortID IS NULL;"; DataSet venDS = getDataSet(venueQuery); DataSet vsDS = getDataSet(venueSpaceQuery); DataSet idfDS = getDataSet(idfQuery); DataSet swDS = getDataSet(switchQuery); DataSet ppDS = getDataSet(ppQuery); DataSet swpDS = getDataSet(switchPortQuery); DataSet pppDS = getDataSet(ppPortQuery); try { foreach (DataRow dr in venDS.Tables[0].Rows) { Venue venue = new Venue(); venue.venueID = (int)dr.ItemArray.GetValue(0); venue.venueName = dr.ItemArray.GetValue(1).ToString(); venueList.Add(venue); } foreach (DataRow dr in vsDS.Tables[0].Rows) { VenueSpace venueSpace = new VenueSpace(); venueSpace.venueSpaceID = (int)dr.ItemArray.GetValue(0); venueSpace.venueSpaceName = dr.ItemArray.GetValue(1).ToString(); venueSpace.venueID = (int)dr.ItemArray.GetValue(2); venueSpaceList.Add(venueSpace); } foreach (DataRow dr in idfDS.Tables[0].Rows) { IDF idf = new IDF(); idf.idfID = (int)dr.ItemArray.GetValue(0); idf.idfName = dr.ItemArray.GetValue(1).ToString(); idf.venueSpaceID = (int)dr.ItemArray.GetValue(2); idfList.Add(idf); } foreach (DataRow dr in swDS.Tables[0].Rows) { Switch sw = new Switch(); sw.switchID = (int)dr.ItemArray.GetValue(0); sw.switchNameDNS = dr.ItemArray.GetValue(1).ToString(); sw.idfID = (int)dr.ItemArray.GetValue(2); switchList.Add(sw); } foreach (DataRow dr in ppDS.Tables[0].Rows) { PatchPanel pp = new PatchPanel(); pp.patchPanelID = (int)dr.ItemArray.GetValue(0); pp.patchPanelName = dr.ItemArray.GetValue(1).ToString(); pp.idfID = (int)dr.ItemArray.GetValue(2); PPList.Add(pp); } foreach (DataRow dr in swpDS.Tables[0].Rows) { SwitchPort swp = new SwitchPort(); swp.switchPortID = (int)dr.ItemArray.GetValue(0); swp.switchPortNum = (int)dr.ItemArray.GetValue(1); swp.switchID = (int)dr.ItemArray.GetValue(2); switchPortList.Add(swp); } foreach (DataRow dr in pppDS.Tables[0].Rows) { PatchPanelPort ppp = new PatchPanelPort(); ppp.patchPanelPortID = (int)dr.ItemArray.GetValue(0); ppp.patchPanelPortNum = (int)dr.ItemArray.GetValue(1); ppp.patchPanelID = (int)dr.ItemArray.GetValue(2); PPPList.Add(ppp); } } catch (OleDbException exp) { MessageBox.Show("Database Error:" + exp.Message.ToString()); } updateVenueBoxList(venueList); updateDataGridView(); }
/// <summary> /// 构造方法初始化 /// </summary> /// <param name="port"></param> /// <param name="status"></param> public SwitchModel(SwitchPort port, SwitchStatus status) { Port = port; Status = status; }