private void gridView1_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) { //Insert, update row var row = (e.Row as System.Data.DataRowView).Row; bool result; if (gridView1.IsNewItemRow(e.RowHandle)) { //insert MedicineType MedicineType = new MedicineType() { MedicineTypeName = (string)row["MedicineTypeName"] }; int id = medicineTypeBusiness.Insert(MedicineType); if (id == 0) { result = false; } else { result = true; row["MedicineTypeID"] = id; } } else { //update MedicineType medicineType = new MedicineType() { MedicineTypeID = (int)row["MedicineTypeID"], MedicineTypeName = (string)row["MedicineTypeName"] }; result = medicineTypeBusiness.Update(medicineType); } if (result) { XtraMessageBox.Show(this, "Lưu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); gridView1.FocusedRowHandle = GridControl.NewItemRowHandle; } else { XtraMessageBox.Show(this, "Lưu thất bại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }