private void dgvDeAn_CellClick(object sender, DataGridViewCellEventArgs e) { if (dgvDeAn.CurrentRow.Index >= 0) { int IDDA = Int32.Parse(dgvDeAn.CurrentRow.Cells[0].Value.ToString()); DeAn da = DeAnController.GetDeAn(IDDA); currentIDDeAn = da.IDDeAn; txtTenDeAn.Text = da.TenDeAn.Trim(); cbLoaiDeAn.SelectedIndex = cbLoaiDeAn.FindStringExact(da.LoaiDeAn.Trim()); rtbNoiDung.Text = da.NoiDung.Trim(); foreach (Nhom nhom in cbNhom.Items) { if (nhom.IDNhom == da.IDNhom) { cbNhom.SelectedIndex = cbNhom.Items.IndexOf(nhom); } } foreach (GiaoVien gv in cbGiaoVien.Items) { if (gv.IDGiaoVien == da.IDGiaoVien) { cbGiaoVien.SelectedIndex = cbGiaoVien.Items.IndexOf(gv); return; } } } }
private void btnXoa_Click_1(object sender, EventArgs e) { if (currentIDDeAn == -1) { MessageBox.Show("Vui long chon Sinh vien"); return; } DeAn da = new DeAn(); da.IDDeAn = currentIDDeAn; da.TenDeAn = txtTenDeAn.Text.Trim(); da.NoiDung = rtbNoiDung.Text.Trim(); da.LoaiDeAn = cbLoaiDeAn.SelectedItem.ToString(); Nhom nhom = cbNhom.SelectedItem as Nhom; da.IDNhom = nhom.IDNhom; GiaoVien gv = cbGiaoVien.SelectedItem as GiaoVien; da.IDGiaoVien = gv.IDGiaoVien; da.status = 0; if (DeAnController.CapNhatDeAn(da) == false) { MessageBox.Show("Khong xoa De an duoc"); return; } currentIDDeAn = -1; showDSDeAn(); }
public static bool CapNhatDeAn(DeAn dean) { try { using (var _context = new DBQuanLyDeAnEntities()) { var da = (from s in _context.DeAns where s.IDDeAn == dean.IDDeAn select s) .Include("TienDoes") .SingleOrDefault(); da.IDDeAn = dean.IDDeAn; da.TenDeAn = dean.TenDeAn; da.NoiDung = dean.NoiDung; da.IDNhom = dean.IDNhom; da.IDGiaoVien = dean.IDGiaoVien; da.LoaiDeAn = dean.LoaiDeAn; da.status = dean.status; _context.SaveChanges(); return(true); } } catch { return(false); } }
private void btnTienDo_Click(object sender, EventArgs e) { if (dgvDeAn.CurrentRow.Index >= 0) { int IDDA = Int32.Parse(dgvDeAn.CurrentRow.Cells[0].Value.ToString()); DeAn da = DeAnController.GetDeAn(IDDA); frmTienDo ftd = new frmTienDo((int)da.IDNhom, IDDA); ftd.Show(); } }
private void btnThem_Click_1(object sender, EventArgs e) { errorDeAn.Clear(); if (txtTenDeAn.Text.Trim().Length <= 0) { errorDeAn.SetError(txtTenDeAn, "Thêm tên đề án"); return; } if (rtbNoiDung.Text.Trim().Length <= 5) { errorDeAn.SetError(rtbNoiDung, "Thêm nội dung đề án"); return; } if (cbLoaiDeAn.SelectedItem == null) { errorDeAn.SetError(cbLoaiDeAn, "Chọn loại đề án"); return; } if (cbNhom.SelectedItem as Nhom == null) { errorDeAn.SetError(cbNhom, "Chọn nhóm"); return; } if (cbGiaoVien.SelectedItem as GiaoVien == null) { errorDeAn.SetError(cbGiaoVien, "Chọn Giáo viên"); return; } GiaoVien giaovien = cbGiaoVien.SelectedItem as GiaoVien; Nhom nhom = cbNhom.SelectedItem as Nhom; DeAn da = new DeAn(); da.TenDeAn = txtTenDeAn.Text.Trim(); da.LoaiDeAn = cbLoaiDeAn.SelectedItem.ToString(); da.NoiDung = rtbNoiDung.Text.Trim(); da.IDNhom = nhom.IDNhom; da.IDGiaoVien = giaovien.IDGiaoVien; da.status = 1; if (DeAnController.ThemDeAn(da) == false) { MessageBox.Show("Khong them duoc"); return; } showDSDeAn(); this.txtTenDeAn.Clear(); this.cbLoaiDeAn.Text = ""; this.rtbNoiDung.Clear(); this.cbNhom.Text = ""; this.cbGiaoVien.Text = ""; }
public static bool ThemDeAn(DeAn dean) { try { using (var _context = new DBQuanLyDeAnEntities()) { _context.DeAns.Add(dean); _context.SaveChanges(); return(true); } } catch { return(false); } }
public bool Sua(DeAn da) { try { string query = @" UPDATE dbo.DeAn set TenDA = N'" + da.Ten + "',maphong = '" + da.MaPhong + "', sogio = '" + da.SoGio + "' where mada ='" + da.Ma + "'"; OpenConection(); ExecuteQueries(query); CloseConnection(); return(true); } catch (Exception ex) { SetEx(ex); return(false); } }
public bool Them(DeAn da) { try { string query = @"INSERT INTO dbo.DeAn( MaDA, TenDa, SoGio, MaPhong) VALUES ( '" + da.Ma + "',N'" + da.Ten + "', '" + da.SoGio + "','" + da.MaPhong + "')"; OpenConection(); ExecuteQueries(query); CloseConnection(); return(true); } catch (Exception ex) { SetEx(ex); return(false); } }
public bool Sua(DeAn da) { return(dal_da.Sua(da)); }
public bool Them(DeAn da) { return(dal_da.Them(da)); }
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 } }