private void btnSetDHCP_Click(object sender, EventArgs e) { try { NIC nic = (NIC)this.comboAdapterList.SelectedItem; nic.SetDHCP(); NIC.LoadNICs(this.comboAdapterList); nic.ReselectNIC(this.comboAdapterList); nic = (NIC)this.comboAdapterList.SelectedItem; FormHandler.UpdateNICText(nic, this.txtAdapterIPAddress, this.txtAdapterSubnetMask, this.txtAdapterDefaultGateway); } catch (Exception ex) { Logger.WriteMessage("Error in setting DHCP."); Logger.WriteException(ex); Logger.PromptLogReview("There was an error in setting DHCP."); } }
private void btnSetStatic_Click(object sender, EventArgs e) { if (this.treeSites.SelectedNode == null) { MessageBox.Show("Please select an NAE to set a static IP for."); return; } if (!(this.treeSites.SelectedNode.Tag is NAE)) { MessageBox.Show("Please select an NAE to set a static IP for."); return; } try { NAE nae = (NAE)this.treeSites.SelectedNode.Tag; NIC nic = (NIC)this.comboAdapterList.SelectedItem; if (!StaticIP.IsIPv4(nae.StaticIPAddress.Address) || !StaticIP.IsIPv4(nae.StaticIPAddress.SubnetMask) || !StaticIP.IsIPv4(nae.StaticIPAddress.DefaultGateway)) { MessageBox.Show("Please enter valid IP addresses for the NAE's static IP address, subnet mask, and gateway."); return; } nic.SetStaticIP(nae.StaticIPAddress.Address, nae.StaticIPAddress.SubnetMask, nae.StaticIPAddress.DefaultGateway); NIC.LoadNICs(this.comboAdapterList); nic.ReselectNIC(this.comboAdapterList); nic = (NIC)this.comboAdapterList.SelectedItem; FormHandler.UpdateNICText(nic, this.txtAdapterIPAddress, this.txtAdapterSubnetMask, this.txtAdapterDefaultGateway); } catch (Exception ex) { Logger.WriteMessage("Error in setting the static IP address."); Logger.WriteException(ex); Logger.PromptLogReview("There was an error in setting the static IP address."); } }