Пример #1
0
        private void cboPoolIp_EditValueChanged(object sender, EventArgs e)
        {
            Class.NW_Dhcp_Ip       cls    = new Class.NW_Dhcp_Ip();
            Class.NW_Dhcp_Customer clscus = new Class.NW_Dhcp_Customer();
            clscus.PoolIp = cboPoolIp.EditValue.ToString();
            DataTable dtcus = clscus.NW_Dhcp_Customer_GetbyPool_MySQL();

            cls.PoolIp = cboPoolIp.EditValue.ToString();
            DataTable dt    = cls.NW_Dhcp_Ip_GetIPbyPool_MySQL();
            string    ip    = "";
            bool      check = false;;

            if (dt.Rows.Count > 0)
            {
                string   range = dt.Rows[0]["RangeIP"].ToString();
                string[] cat   = range.Split(' ');
                if (cat.Length > 1)
                {
                    txtIpAddress.Properties.Items.Clear();
                    string[] temp  = cat[0].Split('.');
                    int      start = 0;
                    int      end   = 0;
                    if (temp.Length > 2)
                    {
                        start = int.Parse(temp[3]);
                    }
                    temp = cat[1].Split('.');
                    if (temp.Length > 2)
                    {
                        end = int.Parse(temp[3]);
                    }

                    for (int i = start; i < end; i++)
                    {
                        ip    = temp[0] + "." + temp[1] + "." + temp[2] + "." + i.ToString();
                        check = false;
                        for (int j = 0; j < dtcus.Rows.Count; j++)
                        {
                            if (ip == dtcus.Rows[j]["IpAddress"].ToString())
                            {
                                check = true;
                            }
                        }
                        if (check == false)
                        {
                            txtIpAddress.Properties.Items.Add(ip);
                        }
                    }
                }
            }
            if (txtIpAddress.Properties.Items.Count > 0)
            {
                txtIpAddress.Text = txtIpAddress.Properties.Items[0].ToString();
            }
            else
            {
                txtIpAddress.Text = "";
            }
        }
Пример #2
0
        private void cboPoolIp_EditValueChanged(object sender, EventArgs e)
        {
            Class.NW_Dhcp_Ip cls = new Class.NW_Dhcp_Ip();
            Class.NW_Dhcp_Customer clscus = new Class.NW_Dhcp_Customer();
            clscus.PoolIp = cboPoolIp.EditValue.ToString();
            DataTable dtcus = clscus.NW_Dhcp_Customer_GetbyPoolPublic_MySQL();
            cls.PoolIp = cboPoolIp.EditValue.ToString();
            DataTable dt = cls.NW_Dhcp_Ip_GetIPbyPool_MySQL();
            string ip = "";
            bool check = false; ;
            if (dt.Rows.Count > 0)
            {
                string range = dt.Rows[0]["RangeIP"].ToString();
                string[] cat = range.Split(' ');
                if (cat.Length > 1)
                {
                    txtIpAddress.Properties.Items.Clear();
                    string[] temp = cat[0].Split('.');
                    int start = 0;
                    int end = 0;
                    if (temp.Length > 2)
                    {
                        start = int.Parse(temp[3]);
                    }
                    temp = cat[1].Split('.');
                    if (temp.Length > 2)
                    {
                        end = int.Parse(temp[3]);
                    }

                    for (int i = start; i < end; i++)
                    {
                        ip = temp[0] + "." + temp[1] + "." + temp[2] + "." + i.ToString();
                        check = false;
                        for (int j = 0; j < dtcus.Rows.Count; j++)
                        {
                            if (ip == dtcus.Rows[j]["IpPublic"].ToString())
                            {
                                check = true;
                            }

                        }
                        if (check == false)
                        {
                            txtIpAddress.Properties.Items.Add(ip);
                        }

                    }
                }
            }
            if (txtIpAddress.Properties.Items.Count > 0)
            {
                txtIpAddress.Text = txtIpAddress.Properties.Items[0].ToString();
            }
            else
            {
                txtIpAddress.Text = "";
            }
        }