private void barButtonItemActive_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ATINChamCongEntities context = new ATINChamCongEntities(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells.Count > 0) { if (row.Cells[0].Value == null) { continue; } if ((bool)row.Cells[0].Value == true) { var viewsapxeplichtrinh = row.DataBoundItem as ViewSapXepLichTrinh; if (comboBox1.SelectedValue == null) { context.spDeleteSapXepLichTrinh(viewsapxeplichtrinh.MaSapXep); } else { context.spDeleteSapXepLichTrinh(viewsapxeplichtrinh.MaSapXep); context.spInsertSapXepLichTrinh(viewsapxeplichtrinh.MaNguoi, comboBox1.SelectedValue.ToString().Trim()); } } } } DataGridView1Config(treeView1.SelectedNode); }
//Insert & update SapXepLichTrinh when changed combobox value private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.CurrentCell != null) { ATINChamCongEntities context = new ATINChamCongEntities(); if (dataGridView1.CurrentCell.GetType() == typeof(DataGridViewComboBoxCell)) { var viewsapxeplichtrinh = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].DataBoundItem as ViewSapXepLichTrinh; if (dataGridView1.CurrentCell.Value == null) { context.spDeleteSapXepLichTrinh(viewsapxeplichtrinh.MaSapXep); } else { context.spDeleteSapXepLichTrinh(viewsapxeplichtrinh.MaSapXep); context.spInsertSapXepLichTrinh(viewsapxeplichtrinh.MaNguoi, viewsapxeplichtrinh.MaLichTrinh); } } } }