Code for administrator login and exit :- using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace wids { public partial class Form2 : Form { data d = new data(); public Form2() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) //LOGIN { int a=d.scalar("select count(*) from login where username='"+textBox1.Text+"' and password='"+textBox2.Text+"'"); if(a>0) { main m=new main (); m.Show(); this.Hide(); } else{ MessageBox.Show("Invalid Login"); } } private void button2_Click(object sender, EventArgs e) //EXIT { Application.Exit(); } } } Code for adding rules in snort database:- using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace wids { public partial class Ruleadd : Form { data d = new data(); Ruleadd() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { int number = d.scalar("select count (*) from snortrule where actionname='" + comboBox1.SelectedItem + "'and type='"+ comboBox2.SelectedItem +"' and public scip='"+textBox1.Text+"'and deip='"+textBox3.Text+"'"); if (number > 0) { MessageBox.Show("Already exist"); textBox1.Clear(); textBox3.Clear(); textBox5.Clear(); return; } string[] p = textBox1.Text.Split('.'); if (p.Length > 4) { MessageBox.Show("Invalid"); return; } for (int i = 0; i < p.Length; i++) { if (p[i].Length > 3) { MessageBox.Show("Invalid"); return; } else if ((int.Parse(p[i].ToString())) > 255) { MessageBox.Show("Invalid"); return; } else { } } p = textBox3.Text.Split('.'); if (p.Length > 4) { MessageBox.Show("Invalid"); return; } for (int i = 0; i < p.Length; i++) { if (p[i].Length > 3) { MessageBox.Show("Invalid"); return; } else if ((int.Parse(p[i].ToString())) > 255) { MessageBox.Show("Invalid"); return; } else { } } string qry = "select count (*) from snortrule"; int no = d.scalar(qry); if (no == 0) no = 1; else no = no + 1; qry = "insert into snortrule values('" + no + "','" + comboBox1.SelectedItem.ToString() + "','" + comboBox2.SelectedItem.ToString() + "','" + textBox1.Text + "','" + textBox3.Text + "','" + textBox5.Text + "')"; if (d.execute(qry)) MessageBox.Show("Rule Is Created"); else MessageBox.Show("Error.........."); textBox1.Clear(); textBox3.Clear(); textBox5.Clear(); } catch (Exception ex) { } } private void Ruleadd_Load(object sender, EventArgs e) { } } }