private void Form_Load(object sender, EventArgs e) { DataTable dt = new LayIpAddressDAO().SelectAllTcpIp(); foreach (DataRow row in dt.Rows) { UltraListViewItem item = tcpipListView.Items.Add(row[0].ToString(), row[0].ToString()); item.SubItems[0].Value = row[1].ToString(); item.CheckState = (Convert.ToBoolean(row[2])) ? CheckState.Checked : CheckState.Unchecked; } }
private void SaveChanges() { LayIpAddressDAO ipAddressDAO = new LayIpAddressDAO(); // delete all existing before adding new ones ipAddressDAO.DeleteAllTcpIp(); foreach (UltraListViewItem item in tcpipListView.Items) { IPAddressRange ipAddressRange = new IPAddressRange(item.Text, item.SubItems[0].Text, item.CheckState == CheckState.Checked, IPAddressRange.IPType.Tcpip); ipAddressDAO.Add(ipAddressRange); } }
private void Form_Load(object sender, EventArgs e) { string snmpCommunityStrings = new SettingsDAO().GetSettingAsString("SNMPRead", String.Empty); foreach (string communityString in snmpCommunityStrings.Split(',')) { if (communityString != String.Empty) { lbReadStrings.Items.Add(communityString); } } DataTable dt = new LayIpAddressDAO().SelectAllSnmp(); foreach (DataRow row in dt.Rows) { UltraListViewItem item = tcpipListView.Items.Add(row[0].ToString(), row[0].ToString()); item.SubItems[0].Value = row[1].ToString(); item.CheckState = (Convert.ToBoolean(row[2])) ? CheckState.Checked : CheckState.Unchecked; } }
private void SaveChanges() { SettingsDAO settingsDAO = new SettingsDAO(); LayIpAddressDAO ipAddressDao = new LayIpAddressDAO(); StringBuilder sb = new StringBuilder(); // delete all existing before adding new ones ipAddressDao.DeleteAllSnmp(); foreach (UltraListViewItem item in tcpipListView.Items) { IPAddressRange ipAddressRange = new IPAddressRange(item.Text, item.SubItems[0].Text, item.CheckState == CheckState.Checked, IPAddressRange.IPType.Snmp); ipAddressDao.Add(ipAddressRange); } foreach (string communityString in lbReadStrings.Items) { sb.Append(communityString + ","); } settingsDAO.SetSetting("SNMPRead", sb.ToString().TrimEnd(','), false); }