public bool Add(TieuDoan item) { try { db.TieuDoans.Add(item); db.SaveChanges(); return(true); } catch { return(false); } }
public bool Edit(TieuDoan item) { try { TieuDoan temp = db.TieuDoans.Find(item.ID); temp.Ten = item.Ten; temp.GhiChu = item.GhiChu; db.SaveChanges(); return(true); } catch { return(false); } }
private async void btnXemTkbLop_ItemClick(object sender, ItemClickEventArgs e) { string choosed = cbxXemTheo.EditValue.ToString(); string str = txtTkbHocKy.EditValue == null ? "" : txtTkbHocKy.EditValue.ToString(); if (choosed == "Lớp") { Lop lop = await apis.GetLop(HocKy, str); if (lop != null) { TkbHocKyLopForm tKB_HK = new TkbHocKyLopForm(this, lop); tKB_HK.tietHocs = await apis.GetTietHocs(HocKy, lop, ""); tKB_HK.MdiParent = this; tKB_HK.Show(); } else { DialogResult dal = MessageBox.Show("Lớp không tồn tại", "Lỗi", MessageBoxButtons.OK); } } else { TieuDoan td = await apis.GetTieuDoan(str); if (td != null) { TkbHocKyTieuDoanForm frm = new TkbHocKyTieuDoanForm(this, str); frm.lops = await apis.GetLopsByTieuDoan(HocKy, str); frm.MdiParent = this; frm.Show(); } else { DialogResult dal = MessageBox.Show("Tiểu đoàn không tồn tại", "Lỗi", MessageBoxButtons.OK); } } }
private void btn_Them_Click(object sender, EventArgs e) { if (Common.Acc_type == "Root" || Common.Acc_type == "Admin") { if (btn_Them.Text == "Thêm") { btn_Sua.Enabled = false; btn_Them.Text = "Lưu"; btn_Xoa.Text = "Hủy"; UnLockControl(); Empty(); } else { TieuDoan item = new TieuDoan(); item.Ten = txbTen.Text; item.GhiChu = txbGhiChu.Text; if (new TieuDoanDAO().Add(item)) { LoadTieuDoan(); MessageBox.Show("Thêm thành công"); } else { MessageBox.Show("Không thành công"); } LockControl(); } } else { MessageBox.Show("Bạn không có quyền thực hiện tác vụ này"); } }