You are on page 1of 15

public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.Hide(); Form2 o= new Form2(); o.

Show(); } private void button2_Click(object sender, EventArgs e) { this.Hide(); Form3 o1 = new Form3(); o1.Show(); } public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "nand" && textBox2.Text == "ni") { MessageBox.Show("LOGIN VALID"); Form4 o2 = new Form4(); o2.Show(); } else { MessageBox.Show("ENTER CORRECT NAME & PASSWORD"); } } private void button2_Click(object sender, EventArgs e) { this.Hide(); Form1 A = new Form1(); A.Show(); } } } public partial class Form3 : Form { DataSet ds = new DataSet(); SqlConnection cs = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\students\\My Documents\\Visual Studio 2005\\Projects\\PETROL DB\\PETROL DB\\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); SqlDataAdapter da = new SqlDataAdapter();

BindingSource bs = new BindingSource(); public Form3() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { da.InsertCommand = new SqlCommand("INSERT INTO VALUES(@USER_NAME,@CREDIT_NO)", cs); da.InsertCommand.Parameters.Add("@USER_NAME", SqlDbType.VarChar).Value = textBox1.Text; da.InsertCommand.Parameters.Add("@CREDIT_NO", SqlDbType.VarChar).Value = textBox2.Text; cs.Open(); da.InsertCommand.ExecuteNonQuery(); MessageBox.Show("Record(s) has been Added"); textBox1.Clear(); textBox2.Clear(); cs.Close(); Form5 O4 = new Form5(); O4.Show(); } private void button2_Click(object sender, EventArgs e) { this.Hide(); Form1 B = new Form1(); B.Show(); } } } namespace petrol { public partial class Form4 : Form { public Form4() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.Hide(); Form6 o5 = new Form6(); o5.Show(); } private void button2_Click(object sender, EventArgs e) Table1

this.Hide(); Form7 o6 = new Form7(); o6.Show();

} private void button3_Click(object sender, EventArgs e) { this.Hide(); Form1 E = new Form1(); E.Show(); } } } namespace petrol { public partial class Form5 : Form { public Form5() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.Hide(); Form8 o7 = new Form8(); o7.Show(); } private void button2_Click(object sender, EventArgs e) { this.Hide(); Form9 o8 = new Form9(); o8.Show(); } private void button3_Click(object sender, EventArgs e) { this.Hide(); Form10 o9 = new Form10(); o9.Show(); } private void button4_Click(object sender, EventArgs e) { this.Hide(); Form1 F = new Form1(); F.Show(); }

} } namespace petrol {

public partial class Form6 : Form { DataSet ds1 = new DataSet(); SqlConnection cs = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\students\\My Documents\\Visual Studio 2005\\Projects\\PETROL DB\\PETROL DB\\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); SqlDataAdapter da1 = new SqlDataAdapter(); BindingSource bs1 = new BindingSource(); public Form6() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { cs.Open(); SqlCommand myCommand = new SqlCommand("SELECT * FROM Table2",cs); SqlDataReader myReader = myCommand.ExecuteReader(); while (myReader.Read()) { if (textBox2.Text == "" && textBox5.Text == "" && textBox8.Text == "") { textBox2.Text = myReader.GetString(0); textBox5.Text = myReader.GetString(1); textBox8.Text = myReader.GetString(2); } } cs.Close(); int a; a=int.Parse(textBox1.Text) + int.Parse(textBox2.Text); textBox3.Text=a.ToString(); int b; b=int.Parse(textBox4.Text) + int.Parse(textBox5.Text); textBox6.Text=b.ToString(); int c; c = int.Parse(textBox7.Text) + int.Parse(textBox8.Text); textBox9.Text=c.ToString(); da1.UpdateCommand = new SqlCommand("UPDATE Table2 SET petrol=@petrol,diesel=@diesel,lubricant=@lubricant", cs); da1.UpdateCommand.Parameters.Add("@petrol", SqlDbType.VarChar).Value = textBox3.Text; da1.UpdateCommand.Parameters.Add("@diesel", SqlDbType.VarChar).Value = textBox6.Text; da1.UpdateCommand.Parameters.Add("@lubricant", SqlDbType.VarChar).Value = textBox9.Text;

cs.Open();

da1.UpdateCommand.ExecuteNonQuery(); MessageBox.Show("Record(s) has been Updated"); cs.Close();

} private void button2_Click(object sender, EventArgs e) { this.Hide(); Form4 C = new Form4(); C.Show(); }

} } namespace petrol { public partial class Form7 : Form { DataSet ds = new DataSet(); SqlConnection cs = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\students\\My Documents\\Visual Studio 2005\\Projects\\PETROL DB\\PETROL DB\\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); SqlDataAdapter da = new SqlDataAdapter(); BindingSource bs = new BindingSource(); public Form7() { InitializeComponent(); } private void label2_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { this.Hide(); Form4 o11 = new Form4(); o11.Show(); } private void button2_Click(object sender, EventArgs e) { cs.Open(); SqlCommand myCommand = new SqlCommand("SELECT * FROM Table3", cs); SqlDataReader myReader1 = myCommand.ExecuteReader(); while (myReader1.Read()) {

if (textBox1.Text textBox3.Text == "") { textBox1.Text textBox2.Text textBox3.Text } } cs.Close(); cs.Open();

== "" && textBox2.Text == "" && = myReader1.GetString(0); = myReader1.GetString(1); = myReader1.GetString(2);

SqlCommand myCommand1 = new SqlCommand("SELECT * FROM Table2", cs); SqlDataReader myReader = myCommand1.ExecuteReader(); while (myReader.Read()) { if (textBox4.Text == "" && textBox5.Text == "" && textBox6.Text == "") { textBox4.Text = myReader.GetString(0); textBox5.Text = myReader.GetString(1); textBox6.Text = myReader.GetString(2); } } cs.Close(); } } } namespace petrol { public partial class Form8 : Form { DataSet ds = new DataSet(); SqlConnection cs = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\students\\My Documents\\Visual Studio 2005\\Projects\\PETROL DB\\PETROL DB\\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); SqlDataAdapter da = new SqlDataAdapter(); BindingSource bs = new BindingSource(); public Form8() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.Hide(); Form5 o10 = new Form5(); o10.Show(); } private void button2_Click(object sender, EventArgs e) { cs.Open();

SqlCommand myCommand = new SqlCommand("SELECT * FROM Table3", cs); SqlDataReader myReader1 = myCommand.ExecuteReader(); while (myReader1.Read()) { if (textBox1.Text textBox3.Text == "") { textBox1.Text textBox2.Text textBox3.Text } } cs.Close(); cs.Open(); == "" && textBox2.Text == "" && = myReader1.GetString(0); = myReader1.GetString(1); = myReader1.GetString(2);

SqlCommand myCommand1 = new SqlCommand("SELECT * FROM Table2", cs); SqlDataReader myReader = myCommand1.ExecuteReader(); while (myReader.Read()) { if (textBox4.Text == "" && textBox5.Text == "" && textBox6.Text == "") { textBox4.Text = myReader.GetString(0); textBox5.Text = myReader.GetString(1); textBox6.Text = myReader.GetString(2); } } cs.Close(); } } }namespace petrol { public partial class Form9 : Form { DataSet ds1 = new DataSet(); SqlConnection cs = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\students\\My Documents\\Visual Studio 2005\\Projects\\PETROL DB\\PETROL DB\\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); SqlDataAdapter da1 = new SqlDataAdapter(); BindingSource bs1 = new BindingSource(); public Form9() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) {

da1.UpdateCommand = new SqlCommand("UPDATE Table4 SET PET_BUY=@PET_BUY,DIE_BUY=@DIE_BUY,LUB_BUY=@LUB_BUY", cs); da1.UpdateCommand.Parameters.Add("@PET_BUY", SqlDbType.VarChar).Value = textBox1.Text; da1.UpdateCommand.Parameters.Add("@DIE_BUY", SqlDbType.VarChar).Value = textBox4.Text; da1.UpdateCommand.Parameters.Add("@LUB_BUY", SqlDbType.VarChar).Value = textBox7.Text;

cs.Open(); da1.UpdateCommand.ExecuteNonQuery(); cs.Close(); cs.Open(); SqlCommand myCommand = new SqlCommand("SELECT * FROM Table2", cs); SqlDataReader myReader = myCommand.ExecuteReader(); while (myReader.Read()) { if (textBox2.Text == "" && textBox5.Text == "" && textBox8.Text == "") { textBox2.Text = myReader.GetString(0); textBox5.Text = myReader.GetString(1); textBox8.Text = myReader.GetString(2); } } cs.Close(); int a; a = int.Parse(textBox1.Text) - int.Parse(textBox2.Text); textBox3.Text = a.ToString(); int b; b = int.Parse(textBox4.Text) - int.Parse(textBox5.Text); textBox6.Text = b.ToString(); int c; c = int.Parse(textBox7.Text) - int.Parse(textBox8.Text); textBox9.Text = c.ToString(); da1.UpdateCommand = new SqlCommand("UPDATE Table2 SET petrol=@petrol,diesel=@diesel,lubricant=@lubricant", cs); da1.UpdateCommand.Parameters.Add("@petrol", SqlDbType.VarChar).Value = textBox3.Text; da1.UpdateCommand.Parameters.Add("@diesel", SqlDbType.VarChar).Value = textBox6.Text; da1.UpdateCommand.Parameters.Add("@lubricant", SqlDbType.VarChar).Value = textBox9.Text;

cs.Open(); da1.UpdateCommand.ExecuteNonQuery();

MessageBox.Show("Record(s) has been Updated"); cs.Close(); } private void button2_Click(object sender, EventArgs e) { this.Hide(); Form5 o11 = new Form5(); o11.Show(); }

} } namespace petrol { public partial class Form10 : Form { DataSet ds1 = new DataSet(); SqlConnection cs = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\students\\My Documents\\Visual Studio 2005\\Projects\\PETROL DB\\PETROL DB\\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"); SqlDataAdapter da1 = new SqlDataAdapter(); BindingSource bs1 = new BindingSource(); public Form10() { InitializeComponent(); } private void textBox4_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { cs.Open(); SqlCommand myCommand = new SqlCommand("SELECT * FROM Table3", cs); SqlDataReader myReader1 = myCommand.ExecuteReader(); while (myReader1.Read()) { if (textBox2.Text textBox8.Text == "") { textBox2.Text textBox5.Text textBox8.Text } } cs.Close(); == "" && textBox5.Text == "" && = myReader1.GetString(0); = myReader1.GetString(1); = myReader1.GetString(2);

cs.Open(); SqlCommand myCommand1 = new SqlCommand("SELECT * FROM Table4", cs); SqlDataReader myReader = myCommand1.ExecuteReader(); while (myReader.Read()) { if (textBox1.Text == "" && textBox4.Text == "" && textBox7.Text == "") { textBox1.Text = myReader.GetString(0); textBox4.Text = myReader.GetString(1); textBox7.Text = myReader.GetString(2); } } cs.Close(); int a; a = int.Parse(textBox1.Text) * int.Parse(textBox2.Text); textBox3.Text = a.ToString(); int b; b = int.Parse(textBox4.Text) * int.Parse(textBox5.Text); textBox6.Text = b.ToString(); int c; c = int.Parse(textBox7.Text) * int.Parse(textBox8.Text); textBox9.Text = c.ToString(); int d; d = int.Parse(textBox3.Text) + int.Parse(textBox6.Text) +int.Parse(textBox9.Text); textBox10.Text = d.ToString();

} private void button2_Click(object sender, EventArgs e) { this.Hide(); Form5 D = new Form5(); D.Show(); }

You might also like