private void Deletebutton_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count > 0) { db = new BMSDETAILSDBDataContext(); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); BMSDETAIL bms = db.BMSDETAILs.FirstOrDefault(s => s.Id == id); db.BMSDETAILs.DeleteOnSubmit(bms); db.SubmitChanges(); MessageBox.Show("Employee Infromation Deleted Successfully Done!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearTextBoxes(); BindGridView(); } else { MessageBox.Show("Please Select for Delete"); } }
private void updatebutton_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count > 0) { db = new BMSDETAILSDBDataContext(); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); BMSDETAIL bms = db.BMSDETAILs.FirstOrDefault(s => s.Id == id); bms.name = NametextBox.Text; bms.phoneno = int.Parse(PhonenotextBox.Text); bms.emailid = EmailidtextBox.Text; bms.location = locationcomboBox.Text; db.SubmitChanges(); MessageBox.Show("Employee Infromation updated Successfully Done!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearTextBoxes(); BindGridView(); } else { MessageBox.Show("Please Select for update"); } }
private void Insertbutton_Click(object sender, EventArgs e) { if (NametextBox.Text == "" || EmailidtextBox.Text == "" || locationcomboBox.Text == "" || PhonenotextBox.Text == "") { MessageBox.Show("All fields are Mandatory"); } else { db = new BMSDETAILSDBDataContext(); BMSDETAIL b = new BMSDETAIL(); b.name = NametextBox.Text; b.phoneno = int.Parse(PhonenotextBox.Text); b.emailid = EmailidtextBox.Text; b.location = locationcomboBox.Text; db.BMSDETAILs.InsertOnSubmit(b); // data save on linq db.SubmitChanges(); // from permently infromation save to use Submitchanges MessageBox.Show("Employee Infromation inserted Successfully Done!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearTextBoxes(); BindGridView(); } }
partial void DeleteBMSDETAIL(BMSDETAIL instance);
partial void UpdateBMSDETAIL(BMSDETAIL instance);
partial void InsertBMSDETAIL(BMSDETAIL instance);