public virtual void OnAddDeAnThanhCong(AddDeAnThanhCongEventArgs e) { EventHandler <AddDeAnThanhCongEventArgs> handler = AddDeAnThanhCong; if (handler != null) { handler(this, e); } }
private void FrmDeAn_AddDeAnThanhCong(object sender, AddDeAnThanhCongEventArgs e) { DoDuLieu(); }
private void btnDangKy_Click(object sender, EventArgs e) { SetErrorProvider(); if (txtIDNhom.Text != "" && txtTenDeAn.Text != "" && txtGVHD.Text != "" && txtMoTa.Text != "" && dtpDateStart.Value > DateTime.Now && dtpDateEnd.Value > dtpDateStart.Value) { string IDnhom = txtIDNhom.Text.Trim(); #region Tên nhóm hoặc giảng viên không tồn tại using (var _context = new DBLapTrinhWin()) { var nhom = from u in _context.NhomSinhViens where u.IDNhom == IDnhom select u; if (nhom.Count() == 0) { MessageBox.Show("Nhóm không tồn tại!"); this.ActiveControl = txtIDNhom; return; } string gvhd = txtGVHD.Text.Trim(); var gv = from u in _context.GiangViens where u.MSGV == gvhd select u; if (gv.Count() == 0) { MessageBox.Show("Giảng viên không tồn tại"); this.ActiveControl = txtGVHD; return; } } #endregion #region Xử lý lưu các thuộc tính vào database List <string> cacthuoctinh = new List <string>(); cacthuoctinh = DeAnController.TachIDNhom(IDnhom); string type = ""; if (cacthuoctinh[0] == "DAMH") { type = "1"; } else if (cacthuoctinh[0] == "TLCN") { type = "2"; } else if (cacthuoctinh[0] == "DATN") { type = "3"; } DeAn DeAnDangKy = new DeAn(); DeAnDangKy.IDDeAn = IDnhom; DeAnDangKy.TenDeAn = txtTenDeAn.Text.Trim(); DeAnDangKy.Type = type; DeAnDangKy.IDNhomSV = IDnhom; DeAnDangKy.GVHD = txtGVHD.Text.Trim(); DeAnDangKy.MoTa = txtMoTa.Text; if (type == "1") { DeAnDangKy.MonHoc = cacthuoctinh[1]; } else { DeAnDangKy.ChuyenNganh = cacthuoctinh[1]; } using (var _context = new DBLapTrinhWin()) { _context.DeAns.Add(DeAnDangKy); _context.SaveChanges(); } txtIDDeAn.Text = IDnhom; TienDo tienDo = new TienDo(); tienDo.IDDeAn = DeAnDangKy.IDDeAn; using (var _context = new DBLapTrinhWin()) { _context.TienDoes.Add(tienDo); _context.SaveChanges(); } MessageBox.Show("Thêm đề án thành công!"); AddDeAnThanhCongEventArgs arg = new AddDeAnThanhCongEventArgs(); OnAddDeAnThanhCong(arg); this.Close(); #endregion } }