private void dgLopHoc_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } string Ma_LopHoc = dgLopHoc.Rows[e.RowIndex].Cells["Ma_LopHoc"].Value.ToString(); Ma_LopHoc_2 = Ma_LopHoc; EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(Ma_LopHoc); EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(LopHoc.Ma_MonHoc); EC_GiaoVien GiaoVien = new BUS_GiaoVien().Select_ByPrimaryKey(LopHoc.Ma_GiaoVien); txbMa_LopHoc.Text = LopHoc.Ma_LopHoc; cbTrinhDo.SelectedItem = LopHoc.TrinhDo; dtNgayBatdau.Value = LopHoc.Ngay_BatDau; txbTongHP.Text = LopHoc.TongHocPhi_KhoaHoc.ToString(); txbSoBuoi.Text = LopHoc.SoBuoi.ToString(); txbMa_MonHoc.Text = MonHoc.Ma_MonHoc; cbLop.SelectedItem = MonHoc.Lop.ToString(); cbTenMon.SelectedItem = MonHoc.Ten_MonHoc; txbMaGV.Text = GiaoVien.Ma_GiaoVien; dgGiaoVien.Rows.Clear(); string GioiTinh = GiaoVien.GioiTinh == true ? "Nam" : "Nữ"; dgGiaoVien.Rows.Add(GiaoVien.Ma_GiaoVien, GiaoVien.Ten_GiaoVien, GiaoVien.NgaySinh.ToShortDateString(), GioiTinh, true); }
void LoadForm() { if (Quyen == 0) { } dgLichHoc.Rows.Clear(); List <EC_LichHoc> listBuoiHoc = new BUS_LichHoc().SelectByFields("Ma_LopHoc", Ma_LopHoc); int stt = 1; foreach (EC_LichHoc BuoiHoc in listBuoiHoc) { string TrangThai = BuoiHoc.TrangThai == true ? "Đã học" : "Chưa học"; dgLichHoc.Rows.Add(stt, BuoiHoc.Ma_BuoiHoc, BuoiHoc.NgayHoc, BuoiHoc.KipHoc, BuoiHoc.PhongHoc, BuoiHoc.TongHocPhi_Buoi, TrangThai); stt++; } txbMa_LopHoc.Text = Ma_LopHoc; EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(Ma_LopHoc); EC_GiaoVien GiaoVien = new BUS_GiaoVien().Select_ByPrimaryKey(LopHoc.Ma_GiaoVien); txbTen_Giaoien.Text = GiaoVien.Ten_GiaoVien; EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(LopHoc.Ma_MonHoc); txbTen_MonHoc.Text = MonHoc.Ten_MonHoc + " " + MonHoc.Lop.ToString(); }
string TaoMa_LopHoc() { string result = ""; List <EC_LopHoc> listLopHoc = new BUS_LopHoc().SelectAll(); if (listLopHoc.Count == 0) { return("LH00001"); } string Ma_LopHoc_Cu = listLopHoc[0].Ma_LopHoc; foreach (EC_LopHoc LopHoc in listLopHoc) { if (Convert.ToInt32(LopHoc.Ma_LopHoc.Substring(2)) > Convert.ToInt32(Ma_LopHoc_Cu.Substring(2))) { Ma_LopHoc_Cu = LopHoc.Ma_LopHoc; } } string Ma_1 = Ma_LopHoc_Cu.Substring(0, 2); result += Ma_1; string Ma_2 = Ma_LopHoc_Cu.Substring(2); int int_Ma_2 = Convert.ToInt32(Ma_2); int int_Ma_2_Moi = int_Ma_2 + 1; int x = Ma_1.Length + int_Ma_2_Moi.ToString().Length; int y = 7 - x; for (int i = 0; i < y; i++) { result += "0"; } result += int_Ma_2_Moi.ToString(); return(result); }
void Load() { EC_HocSinh HocSinh = new BUS_HocSinh().Select_ByPrimaryKey(Ma_HocSinh); if (HocSinh.Anh != null) { picAvt.Image = HinhAnh.ByteToImage(HocSinh.Anh); } txbMa_HocSinh.Text = HocSinh.Ma_HocSinh; txbTen_HocSinh.Text = HocSinh.Ten_HocSinh; txbDiaChi.Text = HocSinh.DiaChi; txbEmail.Text = HocSinh.Email; txbSDT.Text = HocSinh.SDT; dtNgaySinh.Value = HocSinh.NgaySinh; cbGioiTinh.SelectedItem = HocSinh.GioiTinh == true ? "Nam" : "Nữ"; cbLop.SelectedItem = HocSinh.Lop.ToString(); function ft = new function(); DataTable LopHoc_DangHoc = ft.LopHoc_DangHoc(Ma_HocSinh); DataTable LopHoc_DaHoc = ft.LopHoc_DaHoc(Ma_HocSinh); int index1 = 1; foreach (DataRow row in LopHoc_DangHoc.Rows) { string Ma_LopHoc = row[0].ToString(); EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(Ma_LopHoc); EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(LopHoc.Ma_MonHoc); dgLopHoc.Rows.Add(index1.ToString(), Ma_LopHoc, MonHoc.Ten_MonHoc, MonHoc.Lop, LopHoc.SoBuoi, "Đang học"); index1++; } foreach (DataRow row in LopHoc_DaHoc.Rows) { string Ma_LopHoc = row[0].ToString(); EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(Ma_LopHoc); EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(LopHoc.Ma_MonHoc); dgLopHoc.Rows.Add(index1.ToString(), Ma_LopHoc, MonHoc.Ten_MonHoc, MonHoc.Lop, LopHoc.SoBuoi, "Đã học"); index1++; } DataTable HocPhi_Thang = ft.TongTien_Thang(Ma_HocSinh); dgHocPhi.Rows.Clear(); foreach (DataRow row in HocPhi_Thang.Rows) { string ChuaDong = row["TongTien_ChuaDong"].ToString(); int TongTien_ChuaDong = 0; if (ChuaDong == "" || ChuaDong == null) { TongTien_ChuaDong = 0; } else { TongTien_ChuaDong = (int)row["TongTien_ChuaDong"]; } dgHocPhi.Rows.Add(row["Thang"].ToString() + "/" + row["Nam"].ToString(), row["TongTien"].ToString(), (int)row["TongTien"] - TongTien_ChuaDong, TongTien_ChuaDong); } }
private void button5_Click(object sender, EventArgs e) { string text = txbSearch.Text; if (text == "") { return; } dgSearchResult.Rows.Clear(); if (comboBox1.SelectedIndex == 0) { EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(text); if (LopHoc != null) { List <EC_LichHoc> listBuoiHoc = new BUS_LichHoc().SelectByFields("Ma_LopHoc", LopHoc.Ma_LopHoc); if (listBuoiHoc.Count == 0) { dgSearchResult.Rows.Clear(); return; } List <EC_BuoiHoc_HocSinh> listBHHS = new BUS_BuoiHoc_HocSinh().SelectByFields("Ma_BuoiHoc", listBuoiHoc[0].Ma_BuoiHoc); foreach (EC_BuoiHoc_HocSinh ec in listBHHS) { EC_HocSinh hs = new BUS_HocSinh().Select_ByPrimaryKey(ec.Ma_HocSinh); dgSearchResult.Rows.Add(hs.Ma_HocSinh, hs.Ten_HocSinh, "Học sinh", hs.Email, null); } } EC_HocSinh HocSinh = new BUS_HocSinh().Select_ByPrimaryKey(text); if (HocSinh != null) { dgSearchResult.Rows.Add(HocSinh.Ma_HocSinh, HocSinh.Ten_HocSinh, "Học sinh", HocSinh.Email, null); return; } EC_GiaoVien GiaoVien = new BUS_GiaoVien().Select_ByPrimaryKey(text); if (GiaoVien != null) { dgSearchResult.Rows.Add(GiaoVien.Ma_GiaoVien, GiaoVien.Ten_GiaoVien, "Giáo viên", GiaoVien.Email, null); return; } } else { List <EC_HocSinh> listHocSinh = new BUS_HocSinh().SelectByFields("Ten_HocSinh", text); foreach (EC_HocSinh HocSinh in listHocSinh) { dgSearchResult.Rows.Add(HocSinh.Ma_HocSinh, HocSinh.Ten_HocSinh, "Học sinh", HocSinh.Email, null); } List <EC_GiaoVien> listGiaoVien = new BUS_GiaoVien().SelectByFields("Ten_GiaoVien", text); foreach (EC_GiaoVien GiaoVien in listGiaoVien) { dgSearchResult.Rows.Add(GiaoVien.Ma_GiaoVien, GiaoVien.Ten_GiaoVien, "Giáo viên", GiaoVien.Email, null); } } }
void LayDuLieu() { List <EC_LopHoc> listLopHoc = new BUS_LopHoc().SelectAll(); int i = 1; foreach (EC_LopHoc ec in listLopHoc) { EC_GiaoVien GiaoVien = new BUS_GiaoVien().Select_ByPrimaryKey(ec.Ma_GiaoVien); EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(ec.Ma_MonHoc); dgLopHoc.Rows.Add(i.ToString(), ec.Ma_LopHoc, ec.Ma_GiaoVien, GiaoVien.Ten_GiaoVien, MonHoc.Ten_MonHoc, MonHoc.Lop); i++; } }
private void dgDanhSach_LopHoc_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } string Ma_LopHoc = dgDanhSach_LopHoc.Rows[e.RowIndex].Cells["Ma_LopHoc"].Value.ToString(); List <EC_LichHoc> listLichHoc = new BUS_LichHoc().SelectByFields("Ma_LopHoc", Ma_LopHoc); foreach (EC_LichHoc i in listLichHoc) { EC_BuoiHoc_HocSinh BuoiHoc_HS = new BUS_BuoiHoc_HocSinh().SelectByMa(i.Ma_BuoiHoc, Ma_HocSinh); if (BuoiHoc_HS == null) { continue; } string TrangThai = i.TrangThai == true ? "Đã học" : "Chưa học"; string DiemDanh = BuoiHoc_HS.DiemDanh == true ? "Học" : "Nghỉ"; dgDanhSach_BuoiHoc.Rows.Add(i.STT_Buoi, i.NgayHoc.ToShortDateString(), i.KipHoc, i.PhongHoc, TrangThai, DiemDanh); } EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(Ma_LopHoc); txbTen_GiaoVien.Text = new BUS_GiaoVien().Select_ByPrimaryKey(LopHoc.Ma_GiaoVien).Ten_GiaoVien; txbSoBuoi.Text = LopHoc.SoBuoi.ToString(); EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(LopHoc.Ma_MonHoc); txbLop.Text = MonHoc.Lop.ToString(); txbTen_MonHoc.Text = MonHoc.Ten_MonHoc; txbTongHP.Text = LopHoc.TongHocPhi_KhoaHoc.ToString(); txbTrinhDo.Text = LopHoc.TrinhDo; dtNgayBatdau.Value = LopHoc.Ngay_BatDau; dgDanhSach_HocSinh.Rows.Clear(); List <EC_LichHoc> listBuoiHoc = new BUS_LichHoc().SelectByFields("Ma_LopHoc", Ma_LopHoc); List <EC_BuoiHoc_HocSinh> listBuoiHoc_HocSinh = new BUS_BuoiHoc_HocSinh().SelectByFields("Ma_BuoiHoc", listBuoiHoc[0].Ma_BuoiHoc); List <EC_HocSinh> listHocSinh = new List <EC_HocSinh>(); foreach (EC_BuoiHoc_HocSinh i in listBuoiHoc_HocSinh) { EC_HocSinh hocsinh = new BUS_HocSinh().Select_ByPrimaryKey(i.Ma_HocSinh); listHocSinh.Add(hocsinh); } foreach (EC_HocSinh i in listHocSinh) { string GioiTinh = i.GioiTinh == true ? "Nam" : "Nữ"; dgDanhSach_HocSinh.Rows.Add(i.Ten_HocSinh, i.NgaySinh.ToShortDateString(), GioiTinh, i.DiaChi); } txbSoHocSinh.Text = listHocSinh.Count.ToString(); }
void LoadForm() { txbMa_LopHoc.Text = Ma_Lop; EC_LopHoc Lop = new BUS_LopHoc().Select_ByPrimaryKey(Ma_Lop); string Ten_GiaoVien = new BUS_GiaoVien().Select_ByPrimaryKey(Lop.Ma_GiaoVien).Ten_GiaoVien; txbTen_GiaoVien.Text = Ten_GiaoVien; txbTongSoBuoi.Text = Lop.SoBuoi.ToString(); txbTongHocPhi.Text = Lop.TongHocPhi_KhoaHoc.ToString(); BUS_LichHoc busLH = new BUS_LichHoc(); listBuoiHoc = busLH.SelectByFields("Ma_LopHoc", Ma_Lop); LayDuLieu(Stt); }
private void dgChiTiet_CellClick(object sender, DataGridViewCellEventArgs e) { string Ma_LopHoc = dgChiTiet.Rows[e.RowIndex].Cells["Ma_LopHoc"].Value.ToString(); string Ma_BuoiHoc = dgChiTiet.Rows[e.RowIndex].Cells["Ma_BuoiHoc"].Value.ToString(); EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(Ma_LopHoc); EC_LichHoc LichHoc = new BUS_LichHoc().Select_ByPrimaryKey(Ma_BuoiHoc); EC_BuoiHoc_HocSinh BHHS = new BUS_BuoiHoc_HocSinh().SelectByMa(Ma_BuoiHoc, Ma_HocSinh); txbMa_LopHoc.Text = LopHoc.Ma_LopHoc; txbMa_BuoiHoc.Text = LichHoc.Ma_BuoiHoc; txbGiaoVien.Text = new BUS_GiaoVien().Select_ByPrimaryKey(LopHoc.Ma_GiaoVien).Ten_GiaoVien; txbMonHoc.Text = new BUS_MonHoc().Select_ByPrimaryKey(LopHoc.Ma_MonHoc).Ten_MonHoc; txbSoTien_Buoi.Text = BHHS.SoTien_Buoi.ToString(); dtNgayHoc.Value = LichHoc.NgayHoc; }
void Load() { EC_GiaoVien GiaoVien = new BUS_GiaoVien().Select_ByPrimaryKey(Ma_GiaoVien); if (GiaoVien.Anh != null) { picAvt.Image = HinhAnh.ByteToImage(GiaoVien.Anh); } txbMa_GiaoVien.Text = GiaoVien.Ma_GiaoVien; txbTen_GiaoVien.Text = GiaoVien.Ten_GiaoVien; txbDiaChi.Text = GiaoVien.DiaChi; txbEmail.Text = GiaoVien.Email; txbSDT.Text = GiaoVien.SDT; dtNgaySinh.Value = GiaoVien.NgaySinh; cbGioiTinh.SelectedItem = GiaoVien.GioiTinh == true ? "Nam" : "Nữ"; cbTrinhDo.SelectedItem = GiaoVien.TrinhDo; List <EC_PhanCong_Day> listPhanCong_Day = new BUS_PhanCong_Day().SelectByFields("Ma_GiaoVien", Ma_GiaoVien); BUS_MonHoc busMonHoc = new BUS_MonHoc(); int index = 1; foreach (EC_PhanCong_Day ec in listPhanCong_Day) { EC_MonHoc MonHoc = busMonHoc.Select_ByPrimaryKey(ec.Ma_MonHoc); dgPhanCong_Day.Rows.Add(index.ToString(), MonHoc.Ma_MonHoc, MonHoc.Ten_MonHoc, MonHoc.Lop.ToString()); index++; } index = 1; List <EC_LopHoc> listLopHoc = new BUS_LopHoc().SelectByFields("Ma_GiaoVien", Ma_GiaoVien); foreach (EC_LopHoc ec in listLopHoc) { List <EC_LichHoc> listBuoiHoc = new BUS_LichHoc().SelectByFields("Ma_LopHoc", ec.Ma_LopHoc); if (listBuoiHoc.Count == 0) { continue; } List <EC_BuoiHoc_HocSinh> listBHHS = new BUS_BuoiHoc_HocSinh().SelectByFields("Ma_BuoiHoc", listBuoiHoc[0].Ma_BuoiHoc); EC_MonHoc MonHoc = busMonHoc.Select_ByPrimaryKey(ec.Ma_MonHoc); dgLopDay.Rows.Add(index.ToString(), ec.Ma_LopHoc, MonHoc.Ten_MonHoc, MonHoc.Lop, ec.SoBuoi, listBHHS.Count); index++; } }
void Load() { List <EC_LopHoc> listDanhSachLop = new BUS_LopHoc().SelectByFields("Ma_GiaoVien", Ma_GiaoVien); dgLopHoc.DataSource = listDanhSachLop; cbTenMon.Items.Clear(); List <EC_MonHoc> listtMonHoc = new BUS_MonHoc().SelectAll(); string TenMon = listtMonHoc[0].Ten_MonHoc; cbTenMon.Items.Add(TenMon); foreach (EC_MonHoc MonHoc in listtMonHoc) { if (MonHoc.Ten_MonHoc != TenMon) { cbTenMon.Items.Add(MonHoc.Ten_MonHoc); TenMon = MonHoc.Ten_MonHoc; } } }
private void dgLopHoc_CellClick(object sender, DataGridViewCellEventArgs e) { string Ma_LopHoc = dgLopHoc.Rows[e.RowIndex].Cells["Ma_LopHoc"].Value.ToString(); if (Ma_LopHoc == "") { return; } EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(Ma_LopHoc); EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(LopHoc.Ma_MonHoc); EC_GiaoVien GiaoVien = new BUS_GiaoVien().Select_ByPrimaryKey(LopHoc.Ma_GiaoVien); txbMa_LopHoc.Text = Ma_LopHoc; txbTen.Text = GiaoVien.Ten_GiaoVien; txbTen_MonHoc.Text = MonHoc.Ten_MonHoc; txbLop.Text = MonHoc.Lop.ToString(); txbMucDo.Text = LopHoc.TrinhDo; txbTongHP.Text = LopHoc.TongHocPhi_KhoaHoc.ToString(); txbSoBuoi.Text = LopHoc.SoBuoi.ToString(); }
void Load() { if (select == 1) { DataTable LopHoc_DangHoc = ft.LopHoc_DangHoc(Ma_HocSinh); if (LopHoc_DangHoc.Rows.Count == 0) { return; } int i = 1; foreach (DataRow row in LopHoc_DangHoc.Rows) { string Ma_LopHoc = row["Ma_LopHoc"].ToString(); EC_LopHoc LopHoc = new BUS_LopHoc().Select_ByPrimaryKey(Ma_LopHoc); dgDanhSach_LopHoc.Rows.Add(i.ToString(), LopHoc.Ma_LopHoc, new BUS_MonHoc().Select_ByPrimaryKey(LopHoc.Ma_MonHoc).Ten_MonHoc, new BUS_GiaoVien().Select_ByPrimaryKey(LopHoc.Ma_GiaoVien).Ten_GiaoVien); i++; } } }
string TaoMa_LopHoc() { List <EC_LopHoc> listLopHoc = new BUS_LopHoc().SelectAll(); if (listLopHoc.Count == 0) { return("LH00001"); } string Ma_LopHoc_Cu = listLopHoc[0].Ma_LopHoc; foreach (EC_LopHoc LopHoc in listLopHoc) { if (Convert.ToInt32(LopHoc.Ma_LopHoc.Substring(2)) > Convert.ToInt32(Ma_LopHoc_Cu.Substring(2))) { Ma_LopHoc_Cu = LopHoc.Ma_LopHoc; } } string Ma_1 = Ma_LopHoc_Cu.Substring(0, 2); string Ma_2 = Ma_LopHoc_Cu.Substring(2); int int_Ma_2 = Convert.ToInt32(Ma_2); int int_Ma_2_Moi = int_Ma_2 + 1; return(Ma_1 + int_Ma_2_Moi.ToString()); }
private void btXoa_Click(object sender, EventArgs e) { string Ma_BuoiHoc = txbMa_BuoiHoc.Text; if (Ma_BuoiHoc == "") { return; } try { BUS_LichHoc busLichHoc = new BUS_LichHoc(); BUS_LopHoc busLopHoc = new BUS_LopHoc(); EC_LichHoc LichHoc = busLichHoc.Select_ByPrimaryKey(Ma_BuoiHoc); EC_LopHoc LopHoc = busLopHoc.Select_ByPrimaryKey(LichHoc.Ma_LopHoc); if (LichHoc.TrangThai == true) { MessageBox.Show("Buổi học không thể xóa do đã học rồi", "Thông báo"); return; } LopHoc.SoBuoi -= 1; busLopHoc.SuaDuLieu(LopHoc); busLichHoc.XoaDuLieu_Ma_BuoiHoc(LichHoc.Ma_BuoiHoc); List <EC_LichHoc> listBuoiHoc = busLichHoc.SelectByFields("Ma_LopHoc", LichHoc.Ma_LopHoc); int SoBuoi_ChuaHoc = 0; int TongTien_DaHoc = 0; foreach (EC_LichHoc ec in listBuoiHoc) { if (ec.TrangThai == false) { SoBuoi_ChuaHoc++; } else { TongTien_DaHoc += ec.TongHocPhi_Buoi; } } int TongHocPhi_Buoi = (LopHoc.TongHocPhi_KhoaHoc - TongTien_DaHoc) / SoBuoi_ChuaHoc; foreach (EC_LichHoc ec in listBuoiHoc) { if (ec.TrangThai == false) { if (ec.STT_Buoi > LichHoc.STT_Buoi) { ec.STT_Buoi -= 1; } ec.TongHocPhi_Buoi = TongHocPhi_Buoi; } } foreach (EC_LichHoc ec in listBuoiHoc) { busLichHoc.SuaDuLieu(ec); } MessageBox.Show("Xóa thành công buổi học", "Thông báo"); } catch { MessageBox.Show("Xóa không thành công buổi học", "Thông báo"); } LoadForm(); }