private void button3_Click(object sender, EventArgs e) { //Add the Values to the data base Name = textBox1.Text; Address = textBox2.Text; if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Check your all inputs"); } else { try { using (DataClasses1DataContext dr = new DataClasses1DataContext()) { branch b = new branch(); b.BranchID = BID; b.Name = Name; b.Address = Address; dr.branches.InsertOnSubmit(b); dr.SubmitChanges(); MessageBox.Show("Data inserted Succcessfully"); } textBox1.Text = ""; textBox2.Text = ""; label2.Text = ""; constructors(); // TODO: This line of code loads data into the 'bank_SystemDataSet.branch' table. You can move, or remove it, as needed. this.branchTableAdapter.Fill(this.bank_SystemDataSet.branch); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
partial void Deletebranch(branch instance);
partial void Updatebranch(branch instance);
partial void Insertbranch(branch instance);
private void button5_Click(object sender, EventArgs e) { if (button5.Text == "Edit" && comboBox2.Text != "") { try { Name = textBox3.Text; Address = textBox4.Text; BID = comboBox2.Text; DataClasses1DataContext dr = new DataClasses1DataContext(); branch b = dr.branches.Single(id => id.BranchID == BID); b.Name = Name; b.Address = Address; dr.SubmitChanges(); MessageBox.Show("Data edited Succcessfully"); // TODO: This line of code loads data into the 'bank_SystemDataSet.branch' table. You can move, or remove it, as needed. this.branchTableAdapter.Fill(this.bank_SystemDataSet.branch); comboBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; comboBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; button5.Enabled = false; button6.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else if (button5.Text == "Delete" && comboBox2.Text != "") { Name = textBox3.Text; Address = textBox4.Text; BID = comboBox2.Text; DialogResult result = MessageBox.Show("Are You sure want to delete it ?", "Conformation", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { try { DataClasses1DataContext dr = new DataClasses1DataContext(); branch b = dr.branches.Single(id => id.BranchID == BID); dr.branches.DeleteOnSubmit(b); dr.SubmitChanges(); MessageBox.Show("Data deleted Succcessfully"); // TODO: This line of code loads data into the 'bank_SystemDataSet.branch' table. You can move, or remove it, as needed. this.branchTableAdapter.Fill(this.bank_SystemDataSet.branch); constructors(); comboBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; comboBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; button5.Enabled = false; button6.Enabled = false; } catch (Exception ex) { MessageBox.Show("First Delete the Account"); } } } else { MessageBox.Show("Select the Branch ID"); } }