private bool sSaveStudents(int sCheck) { hocvien = new HOCVIEN(); boHv = new BO_HOCVIEN(); hocvien.HOV_Code = txtStudentCode.Text; hocvien.HOV_FirstName = txtFirstName.Text.Trim(); hocvien.HOV_LastName = txtLastName.Text.Trim(); hocvien.HOV_FullName = txtFirstName.Text.Trim() + " " + txtLastName.Text.Trim(); hocvien.HOV_BirthDay = txtBirthDay.Text; hocvien.HOV_Address = txtAddress.Text; hocvien.HOV_Phone = txtPhone.Text; hocvien.HOV_GhiChu = memoRemarks.Text.Trim(); hocvien.HOV_QuocTich = txtQuocTich.Text.Trim(); if (lookUpBirthPlace.ItemIndex < 0) { MessageBox.Show("Chưa chọn nơi sinh", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } else { hocvien.HOV_NoiSinh = lookUpBirthPlace.GetColumnValue("TIN_ID").ToString(); } if (lookUpDonvi.ItemIndex < 0) { MessageBox.Show("Chưa chọn đơn vị", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } else { hocvien.HOV_DonVi = lookUpDonvi.GetColumnValue("DON_ID").ToString(); } if (sCheck == 1) { gIDHocVien = boHv.insert(hocvien); flagSave = true; } else if (sCheck == 2) { hocvien.HOV_ID = gIDHocVien; boHv.update(hocvien); loadDataToGrid(); } return(flagSave); }
private bool updateData() { hocvien = new HOCVIEN(); boHv = new BO_HOCVIEN(); hocvien.HOV_Code = txtCode.Text; hocvien.HOV_FirstName = txtNameF.Text.Trim(); hocvien.HOV_LastName = txtNameL.Text.Trim(); hocvien.HOV_FullName = txtNameF.Text.Trim() + " " + txtNameL.Text.Trim(); hocvien.HOV_BirthDay = txtBirthDay.Text; hocvien.HOV_Address = txtAddress.Text; hocvien.HOV_Phone = txtFone.Text; if (lookUpBirthPlace.ItemIndex < 0) { //sQueQuan = " "; MessageBox.Show("Chưa chọn nơi sinh", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(vFlagSave);; } else { hocvien.HOV_NoiSinh = lookUpBirthPlace.GetColumnValue("TIN_ID").ToString(); } if (lookUpDonvi.ItemIndex < 0) { MessageBox.Show("Chưa chọn đơn vị", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(vFlagSave); } else { hocvien.HOV_DonVi = lookUpDonvi.GetColumnValue("DON_ID").ToString(); } hocvien.HOV_GhiChu = txtGhiChu.Text.Trim(); hocvien.HOV_QuocTich = txtQuocTich.Text.Trim(); hocvien.HOV_ID = sId; try { boHv.update(hocvien); vFlagSave = true; } catch (Exception ex) { MessageBox.Show(ex.Message); vFlagSave = false; } return(vFlagSave); }