private void AddIpButton_Click(object sender, RoutedEventArgs e) { string AllIp = IpListBox.Text; AllIp = AllIp.Replace("\r", ""); string[] IpList = AllIp.Split('\n'); DatabaseDataSet.ipsDataTable ipsDt = new DatabaseDataSet.ipsDataTable(); foreach (string ip in IpList) { Regex rx = new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))"); if (rx.IsMatch(ip)) { DataRow row = ipsDt.NewRow(); row["ip"] = ip; row["country"] = GetstringIpAddress(ip); ipsDt.Rows.Add(row); } } DatabaseDataSetTableAdapters.ipsTableAdapter ipsTa = new DatabaseDataSetTableAdapters.ipsTableAdapter(); try { ipsTa.Update(ipsDt); ipsTa.Fill(PublicClass.ipsDataTable); } catch (Exception ex) { } this.Close(); }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { while (IplistView.SelectedItems.Count>0) { DataRowView rowveiw = (DataRowView)IplistView.SelectedItems[0]; rowveiw.Delete(); } DatabaseDataSetTableAdapters.ipsTableAdapter ipsTa = new DatabaseDataSetTableAdapters.ipsTableAdapter(); ipsTa.Update(PublicClass.ipsDataTable); }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { while (IplistView.SelectedItems.Count > 0) { DataRowView rowveiw = (DataRowView)IplistView.SelectedItems[0]; rowveiw.Delete(); } DatabaseDataSetTableAdapters.ipsTableAdapter ipsTa = new DatabaseDataSetTableAdapters.ipsTableAdapter(); ipsTa.Update(PublicClass.ipsDataTable); }