private void btMonHoc_Search_Click(object sender, EventArgs e) { string text = txbSearch.Text; if (text == "") { return; } BUS_MonHoc busMonHoc = new BUS_MonHoc(); EC_MonHoc MonHoc1 = busMonHoc.Select_ByPrimaryKey(text); List <EC_MonHoc> listResult = new List <EC_MonHoc>(); if (MonHoc1 != null) { listResult.Add(MonHoc1); } List <EC_MonHoc> listMonHoc2 = busMonHoc.SelectByFields("Ten_MonHoc", text); foreach (EC_MonHoc ec in listMonHoc2) { listResult.Add(ec); } dgSearchResult.Rows.Clear(); foreach (EC_MonHoc ec in listResult) { dgSearchResult.Rows.Add(ec.Ma_MonHoc, ec.Ten_MonHoc, ec.Lop, null); } }
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(); }
void LoadForm() { cbTenMon.Items.Clear(); cbLop.Items.Clear(); cbLop.Items.Add("Tất cả"); for (int j = 1; j <= 12; j++) { cbLop.Items.Add(j.ToString()); } EC_LopHoc ecLop = new EC_LopHoc(); EC_MonHoc ecMon = new EC_MonHoc(); dgLopHoc.DataSource = ft.LopHoc_Select_Manager(ecLop, ecMon); List <EC_MonHoc> listMonHoc = new BUS_MonHoc().SelectAll(); List <string> listTen_MonHoc = new List <string>(); listTen_MonHoc.Add(listMonHoc[0].Ten_MonHoc); cbTenMon.Items.Add(listTen_MonHoc[0]); foreach (EC_MonHoc MonHoc in listMonHoc) { if (listTen_MonHoc.IndexOf(MonHoc.Ten_MonHoc) == -1) { cbTenMon.Items.Add(MonHoc.Ten_MonHoc); } listTen_MonHoc.Add(MonHoc.Ten_MonHoc); } dtNgayBatdau.Value = DateTime.Now; cbLop.SelectedIndex = 12; cbTenMon.SelectedIndex = 0; cbTrinhDo.SelectedIndex = 0; }
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 NapDuLieu() { DataTable dt = new DataTable(); bus = new BUS_MonHoc(); dt = bus.selectdata(); dgv.DataSource = dt; if (dgv.ColumnCount > 0) { dgv.Columns[0].Visible = false; dgv.Columns[1].HeaderText = "Tên MH"; dgv.Columns[2].HeaderText = "Số Tín Chỉ"; dgv.Columns[3].HeaderText = "Biểu Phí"; dgv.Columns[4].HeaderText = "Dơn Vị"; dgv.Columns[5].HeaderText = "Trạng Thái"; dgv.Columns[6].HeaderText = "Ngày Tạo"; dgv.Columns[7].HeaderText = "Ngày Cập Nhật"; } for (int i = 0; i <= dgv.Columns.Count - 1; i++) { int colw = dgv.Columns[i].Width; dgv.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.None; dgv.Columns[i].Width = colw; } dgv.RowsDefaultCellStyle.BackColor = Color.White; dgv.RowsDefaultCellStyle.SelectionBackColor = Color.CornflowerBlue; dgv.RowsDefaultCellStyle.SelectionForeColor = Color.White; dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.Plum; }
private void btThem_MonHoc_Click(object sender, EventArgs e) { if (dgSearchResult.Rows.Count == 0) { return; } int count_Check = 0; List <EC_MonHoc> listChecked = new List <EC_MonHoc>(); foreach (DataGridViewRow row in dgSearchResult.Rows) { if (row.Cells[3].Value != null) { if (Convert.ToBoolean(row.Cells[3].Value.ToString()) == true) { count_Check++; EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(row.Cells[0].Value.ToString()); listChecked.Add(MonHoc); } } } if (count_Check == 0) { MessageBox.Show("Chọn môn học để thêm!", "Thông báo"); return; } List <EC_PhanCong_Day> listPhanCong_Day = new BUS_PhanCong_Day().SelectByFields("Ma_GiaoVien", Ma_GiaoVien); int count_Success = 0; foreach (EC_MonHoc i in listChecked) { bool check = true; foreach (EC_PhanCong_Day ec in listPhanCong_Day) { if (ec.Ma_MonHoc == i.Ma_MonHoc) { check = false; } } if (check == true) { new BUS_PhanCong_Day().ThemDuLieu(new EC_PhanCong_Day(Ma_GiaoVien, i.Ma_MonHoc)); count_Success++; } } MessageBox.Show("Thêm thành công " + count_Success.ToString() + " môn học", "Thông báo"); dgPhanCong_Day.Rows.Clear(); List <EC_PhanCong_Day> list = 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++; } }
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); } }
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(); }
string getMa_MonHoc(string TenMon, string Lop) { string Ma_MonHoc = ""; List <EC_MonHoc> list1 = new BUS_MonHoc().SelectByFields("Ten_MonHoc", TenMon); List <EC_MonHoc> list2 = new BUS_MonHoc().SelectByFields("Lop", Lop); foreach (EC_MonHoc i in list1) { if (list2.IndexOf(i) != -1) { Ma_MonHoc = i.Ma_MonHoc; } } return(Ma_MonHoc); }
private void btThem_Click(object sender, EventArgs e) { string Ma_LopHoc = TaoMa_LopHoc(); string Ten_MonHoc = cbTenMon.SelectedItem.ToString(); string Ma_MonHoc = ""; List <EC_MonHoc> list1 = new BUS_MonHoc().SelectByFields("Ten_MonHoc", Ten_MonHoc); List <EC_MonHoc> list2 = new BUS_MonHoc().SelectByFields("Lop", cbLop.SelectedItem.ToString()); foreach (EC_MonHoc ec1 in list1) { foreach (EC_MonHoc ec2 in list2) { if (ec1.Ma_MonHoc == ec2.Ma_MonHoc) { Ma_MonHoc = ec1.Ma_MonHoc; } } } EC_LopHoc ecLop = new EC_LopHoc(Ma_LopHoc, txbMaGV.Text, Ma_MonHoc, cbTrinhDo.SelectedItem.ToString(), Convert.ToInt32(txbTongHP.Text) , Convert.ToInt32(txbSoBuoi.Text), dtNgayBatdau.Value); new BUS_LopHoc().ThemDuLieu(ecLop); int HocPhi_Buoi = Convert.ToInt32(txbTongHP.Text) / Convert.ToInt32(txbSoBuoi.Text); string Ma_BuoiHoc_Cu = LayMa_BuoiHoc_Cu(new BUS_LichHoc().SelectAll()); for (int i = 0; i < Convert.ToInt32(txbSoBuoi.Text); i++) { string Ma_BuoiHoc = TaoMa_BuoiHoc(Ma_BuoiHoc_Cu); EC_LichHoc ecLich = new EC_LichHoc(Ma_LopHoc, DateTime.Now, 1, Ma_BuoiHoc, "", i + 1, HocPhi_Buoi, false); new BUS_LichHoc().ThemDuLieu(ecLich); Ma_BuoiHoc_Cu = Ma_BuoiHoc; } DialogResult result = MessageBox.Show("Thêm thành công lớp học!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { txbMaGV.Text = ""; txbSoBuoi.Text = ""; txbTongHP.Text = ""; } }
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(); }
private void dgDanhsach_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } txbMa_GiaoVien.Text = txbTen_GiaoVien.Text = txbSDT.Text = txbDiaChi.Text = txbEmail.Text = txbSDT.Text = txbTenDangNhap.Text = txbID.Text = ""; dtNgaySinh.Value = DateTime.Now; cbGioiTinh.Text = cbTrinhDo.Text = ""; DataGridViewRow row = dgDanhsach.Rows[e.RowIndex]; txbMa_GiaoVien.Text = row.Cells["Ma_GiaoVien"].Value.ToString(); txbTen_GiaoVien.Text = row.Cells["Ten_GiaoVien"].Value.ToString(); txbDiaChi.Text = row.Cells["DiaChi"].Value.ToString(); txbEmail.Text = row.Cells["Email"].Value.ToString(); txbSDT.Text = row.Cells["SDT"].Value.ToString(); cbGioiTinh.SelectedIndex = row.Cells["GioiTinh"].Value.ToString() == "Nam" ? 0 : 1; dtNgaySinh.Value = Convert.ToDateTime(row.Cells["NgaySinh"].Value.ToString()); foreach (string i in cbTrinhDo.Items) { if (i == row.Cells["TrinhDo"].Value.ToString()) { cbTrinhDo.SelectedItem = i; } } string Ma_GiaoVien = row.Cells["Ma_GiaoVien"].Value.ToString(); dgDayHoc.Rows.Clear(); List <EC_PhanCong_Day> listPhanCongDay = new BUS_PhanCong_Day().SelectByFields("Ma_GiaoVien", Ma_GiaoVien); int j = 1; foreach (EC_PhanCong_Day i in listPhanCongDay) { EC_MonHoc MonHoc = new BUS_MonHoc().Select_ByPrimaryKey(i.Ma_MonHoc); dgDayHoc.Rows.Add(j.ToString(), MonHoc.Ten_MonHoc, MonHoc.Lop.ToString()); } string ID = new BUS_GiaoVien().Select_ByPrimaryKey(Ma_GiaoVien).ID; if (ID == "") { txbID.Enabled = txbTenDangNhap.Enabled = true; txbMatKhau.Visible = true; } else { EC_TaiKhoan TaiKhoan = new BUS_TaiKhoan().SelectByMa(ID); txbID.Text = ID; if (TaiKhoan == null) { txbID.Enabled = false; txbTenDangNhap.Enabled = true; txbMatKhau.Visible = true; } else { txbID.Enabled = txbTenDangNhap.Enabled = false; txbMatKhau.Visible = false; txbTenDangNhap.Text = TaiKhoan.TenDangNhap; } } }