private string TaoMa_HocSinh() { string result = "HS"; List <EC_HocSinh> listHocSinh = new BUS_HocSinh().SelectAll(); if (listHocSinh.Count == 0) { result = "HS00001"; return(result); } string Ma_Cu = listHocSinh[0].Ma_HocSinh; foreach (EC_HocSinh ec in listHocSinh) { int Int_MaCu = Convert.ToInt32(Ma_Cu.Substring(2)); int Int_Ma = Convert.ToInt32(ec.Ma_HocSinh.Substring(2)); if (Int_Ma > Int_MaCu) { Ma_Cu = ec.Ma_HocSinh; } } int Int_MaMoi = Convert.ToInt32(Ma_Cu.Substring(2)) + 1; int length = 7 - 2 - Int_MaMoi.ToString().Length; for (int i = 0; i < length; i++) { result += "0"; } result += Int_MaMoi.ToString(); return(result); }
private void btDangNhap_Click(object sender, EventArgs e) { BUS_TaiKhoan busTK = new BUS_TaiKhoan(); List <EC_TaiKhoan> list1 = busTK.SelectByFields("TenDangNhap", txbTenDangNhap.Text); List <EC_TaiKhoan> list2 = busTK.SelectByFields("MatKhau", txbMatKhau.Text); EC_TaiKhoan TaiKhoan = new EC_TaiKhoan(); foreach (EC_TaiKhoan tk1 in list1) { foreach (EC_TaiKhoan tk2 in list2) { if (tk1.ID == tk2.ID) { TaiKhoan = tk1; } } } if (TaiKhoan.ID == "") { DialogResult result = MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); if (result == DialogResult.OK) { txbMatKhau.Text = ""; } return; } ID = TaiKhoan.ID; BUS_QuanLyTrungTam busQL = new BUS_QuanLyTrungTam(); BUS_GiaoVien busGV = new BUS_GiaoVien(); BUS_HocSinh busHS = new BUS_HocSinh(); if (busQL.TaoBang("where ID='" + ID + "'").Rows.Count != 0) { PhanQuyen = 1; // admin co quyen la 1 } else if (busGV.SelectByFields("ID", ID).Count != 0) { PhanQuyen = 2; //Giao vien co quyen la 2 } else if (busHS.SelectByFields("ID", ID).Count != 0) { PhanQuyen = 3; } else { PhanQuyen = 0; } MessageBox.Show("Đăng nhập thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Thread thr = new Thread(NewForm); thr.Start(); this.Close(); }
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 LoadForm() { BUS_HocSinh busHs = new BUS_HocSinh(); dgDanhsach.DataSource = busHs.SelectAll(); cbLop.SelectedIndex = 0; cbGioiTinh.SelectedIndex = 0; dateTimePicker1.Value = DateTime.Now; }
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 btLuu_Click(object sender, EventArgs e) { if (XacNhan == false) { lbThongBao.Visible = true; pnXacNhan.Visible = true; return; } if (btLuu.Text == "Thêm") { txbMatKhau.Enabled = true; btLuu.Text = "Lưu"; } else if (btLuu.Text == "Lưu") { string ID = TaoID(); string MatKhau = txbMatKhau.Text; if (MatKhau == "") { return; } EC_TaiKhoan ecTK = new EC_TaiKhoan(ID, txbTenDN.Text, Hash.getHashString(MatKhau)); new BUS_TaiKhoan().ThemDuLieu(ecTK); if (cbLoai.SelectedIndex == 0) { EC_QuanLyTrungTam ecQl = new EC_QuanLyTrungTam(); ecQl.ID = ID; new BUS_QuanLyTrungTam().ThemDuLieu(ecQl); } else if (cbLoai.SelectedIndex == 1) { BUS_GiaoVien busGv = new BUS_GiaoVien(); if (busGv.Select_ByPrimaryKey(txbMa.Text) == null) { MessageBox.Show("Không tồn tại giáo viên"); return; } busGv.ThemID(txbMa.Text, ID); } else if (cbLoai.SelectedIndex == 2) { BUS_HocSinh busHS = new BUS_HocSinh(); if (busHS.Select_ByPrimaryKey(txbMa.Text) == null) { MessageBox.Show("Không tồn tại học sinh"); return; } busHS.ThemID(txbMa.Text, ID); } btLuu.Text = "Thêm"; } else { } LoadForm(); }
private void dgDanhsach_CellClick_1(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } pictureBox1.Image = null; txbMa_HocSinh.Text = txbTen_HocSinh.Text = txbSDT.Text = txbDiaChi.Text = txbEmail.Text = txbSDT.Text = txbTenDangNhap.Text = txbID.Text = txbMatKhau.Text = ""; dtNgaySinh.Value = DateTime.Now; cbGioiTinh.SelectedIndex = cbLop.SelectedIndex = 0; DataGridViewRow row = dgDanhsach.Rows[e.RowIndex]; txbMa_HocSinh.Text = row.Cells["Ma_HocSinh"].Value.ToString(); EC_HocSinh HocSinh = new BUS_HocSinh().Select_ByPrimaryKey(txbMa_HocSinh.Text); txbTen_HocSinh.Text = row.Cells["Ten_HocSinh"].Value.ToString(); txbDiaChi.Text = HocSinh.DiaChi; txbEmail.Text = HocSinh.Email; txbSDT.Text = row.Cells["SDT"].Value.ToString(); cbGioiTinh.SelectedIndex = HocSinh.GioiTinh == true ? 0 : 1; dtNgaySinh.Value = HocSinh.NgaySinh; if (HocSinh.Anh != null) { pictureBox1.Image = HinhAnh.ByteToImage(HocSinh.Anh); } cbLop.SelectedIndex = HocSinh.Lop - 1; string Ma_HocSinh = row.Cells["Ma_HocSinh"].Value.ToString(); string ID = new BUS_HocSinh().Select_ByPrimaryKey(Ma_HocSinh).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; } } }
private void dgDanhsach_CellClick_1(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } txbMa_HocSinh.Text = txbTen_HocSinh.Text = txbSDT.Text = txbDiaChi.Text = txbEmail.Text = txbSDT.Text = txbTenDangNhap.Text = txbID.Text = ""; dtNgaySinh.Value = DateTime.Now; cbGioiTinh.Text = cbLop.Text = ""; DataGridViewRow row = dgDanhsach.Rows[e.RowIndex]; txbMa_HocSinh.Text = row.Cells["Ma_HocSinh"].Value.ToString(); txbTen_HocSinh.Text = row.Cells["Ten_HocSinh"].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 cbLop.Items) { if (i == row.Cells["LopHoc"].Value.ToString()) { cbLop.SelectedItem = i; } } string Ma_HocSinh = row.Cells["Ma_HocSinh"].Value.ToString(); string ID = new BUS_HocSinh().Select_ByPrimaryKey(Ma_HocSinh).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; } } }
private void btReset_Click(object sender, EventArgs e) { txbMa_HocSinh.Text = txbTen_HocSinh.Text = txbSDT.Text = txbDiaChi.Text = txbEmail.Text = txbSDT.Text = txbTenDangNhap.Text = txbID.Text = txbMatKhau.Text = ""; dtNgaySinh.Value = DateTime.Now; cbGioiTinh.Text = cbLop.Text = ""; pictureBox1.Image = null; ArrByte_Anh = null; List <EC_HocSinh> listHocSinh = new BUS_HocSinh().SelectAll(); LoadForm(listHocSinh); }
public QuanLyHocSinh() { InitializeComponent(); List <EC_HocSinh> listGiaoVien = new BUS_HocSinh().SelectAll(); LoadForm(listGiaoVien); cbLop.SelectedIndex = 0; cbGioiTinh.SelectedIndex = 0; cbLop_Search.SelectedIndex = 0; cbGioiTinh_Search.SelectedIndex = 0; dtNgaySinh.Value = DateTime.Now; }
void LayDuLieu() { DataTable tb = new DataTable(); if (Quyen == 2) { EC_GiaoVien GiaoVien = new BUS_GiaoVien().SelectByFields("ID", ID)[0]; txbTrinhDo.Text = GiaoVien.TrinhDo; lbTrinhDo.Text = "Trình độ"; txbHoTen.Text = GiaoVien.Ten_GiaoVien; txbMa.Text = GiaoVien.Ma_GiaoVien; txbNgaySinh.Text = GiaoVien.NgaySinh.ToString(); txbDiaChi.Text = GiaoVien.DiaChi; txbEmail.Text = GiaoVien.Email; txbSDT.Text = GiaoVien.SDT; comboBox1.SelectedIndex = GiaoVien.GioiTinh == true ? 0 : 1; cbLoaiTaiKhoan.SelectedIndex = 1; if (GiaoVien.Anh != null) { picAvt.Image = HinhAnh.ByteToImage(GiaoVien.Anh); } } else if (Quyen == 3) { EC_HocSinh hs = new BUS_HocSinh().SelectByFields("ID", ID)[0]; txbTrinhDo.Text = hs.Lop.ToString(); lbTrinhDo.Text = "Lớp"; txbHoTen.Text = hs.Ten_HocSinh; txbMa.Text = hs.Ma_HocSinh; txbNgaySinh.Text = hs.NgaySinh.ToString(); txbDiaChi.Text = hs.DiaChi; txbEmail.Text = hs.Email; txbSDT.Text = hs.SDT; comboBox1.SelectedIndex = hs.GioiTinh == true ? 0 : 1; cbLoaiTaiKhoan.SelectedItem = "Học sinh"; if (hs.Anh != null) { picAvt.Image = HinhAnh.ByteToImage(hs.Anh); } } BUS_TaiKhoan busTK = new BUS_TaiKhoan(); EC_TaiKhoan TaiKhoan = busTK.SelectByMa(ID); txbID.Text = ID; txbTenDN.Text = TaiKhoan.TenDangNhap; txbMatKhau.UseSystemPasswordChar = false; txbMatKhau.PasswordChar = '*'; txbMatKhau.Text = TaiKhoan.MatKhau; }
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(); }
private void btTimKiem_Click(object sender, EventArgs e) { dgSearch.Rows.Clear(); string Ma_HocSinh = txbMa_HocSinh.Text; string Ten_HocSinh = txbTen_HocSinh.Text; int Lop = 0; if (txbLop.Text != "") { Lop = Int32.Parse(txbLop.Text); } listSearch = new List <EC_HocSinh>(); if (Ma_HocSinh != "") { EC_HocSinh hocsinh = new BUS_HocSinh().Select_ByPrimaryKey(Ma_HocSinh); listSearch.Add(hocsinh); } if (Ten_HocSinh != "") { List <EC_HocSinh> list = new BUS_HocSinh().SelectByFields("Ten_HocSinh", Ten_HocSinh); foreach (EC_HocSinh i in list) { if (listSearch.IndexOf(i) == -1) { listSearch.Add(i); } } } if (Lop > 0 && Lop <= 12) { List <EC_HocSinh> list = new BUS_HocSinh().SelectByFields("Lop", Lop); foreach (EC_HocSinh i in list) { if (listSearch.IndexOf(i) == -1) { listSearch.Add(i); } } } foreach (EC_HocSinh i in listSearch) { string GioiTinh = i.GioiTinh == true ? "Nam" : "Nữ"; dgSearch.Rows.Add(i.Ma_HocSinh, i.Ten_HocSinh, i.NgaySinh.ToShortDateString(), GioiTinh, i.SDT, false); } }
private void btDangNhap_Click(object sender, EventArgs e) { BUS_TaiKhoan busTK = new BUS_TaiKhoan(); List <EC_TaiKhoan> ListTaiKhoan = busTK.SelectByFields(txbTenDangNhap.Text, Hash.getHashString(txbMatKhau.Text)); EC_TaiKhoan TaiKhoan = new EC_TaiKhoan(); if (ListTaiKhoan.Count == 0) { DialogResult result = MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); if (result == DialogResult.OK) { txbMatKhau.Text = ""; } return; } TaiKhoan = ListTaiKhoan[0]; ID = TaiKhoan.ID; BUS_QuanLyTrungTam busQL = new BUS_QuanLyTrungTam(); BUS_GiaoVien busGV = new BUS_GiaoVien(); BUS_HocSinh busHS = new BUS_HocSinh(); if (busQL.Select_BYPrimaryKey(ID).Count > 0) { PhanQuyen = 1; // admin co quyen la 1 } else if (busGV.SelectByFields("ID", ID).Count != 0) { PhanQuyen = 2; //Giao vien co quyen la 2 } else if (busHS.SelectByFields("ID", ID).Count != 0) { PhanQuyen = 3; } else { PhanQuyen = 0; } MessageBox.Show("Đăng nhập thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Thread thr = new Thread(NewForm); thr.Start(); this.Close(); }
void PhanQuyen() { if (Quyen == 1) { btDaHocXong.Visible = btDangHoc.Visible = btHocPhi.Visible = btLichHoc.Visible = btLopHoc.Visible = btLichDay.Visible = btLopDangDay.Visible = false; btGmail.Visible = true; QlLopHoc = new QuanLyLopHoc(); QlLopHoc.btChiTiet.Click += BtChiTiet_Click2; } else if (Quyen == 2) { btDaHocXong.Visible = btDangHoc.Visible = btHocPhi.Visible = btLichHoc.Visible = btLopHoc.Visible = btQl_ThuHocPhi.Visible = btQuanLyGiaoVien.Visible = btQuanLyHocSinh.Visible = btQuanLyLopHoc.Visible = btQuanLyTaiKhoan.Visible = false; btGmail.Visible = true; EC_GiaoVien GiaoVien = new BUS_GiaoVien().SelectByFields("ID", ID)[0]; btAcc.Text = GiaoVien.Ten_GiaoVien; if (GiaoVien.Anh != null) { picAvt.Image = HinhAnh.ByteToImage(GiaoVien.Anh); } Ma_GiaoVien = GiaoVien.Ma_GiaoVien; usLopDay = new LopDay(Ma_GiaoVien); usLopDay.dgLopHoc.CellClick += DgLopHoc_CellClick; } else if (Quyen == 3) { btLichDay.Visible = btLopDangDay.Visible = btQuanLyGiaoVien.Visible = btQuanLyHocSinh.Visible = btQl_ThuHocPhi.Visible = btQuanLyLopHoc.Visible = btQuanLyTaiKhoan.Visible = false; btGmail.Visible = false; EC_HocSinh HocSinh = new BUS_HocSinh().SelectByFields("ID", ID)[0]; btAcc.Text = HocSinh.Ten_HocSinh; if (HocSinh.Anh != null) { picAvt.Image = HinhAnh.ByteToImage(HocSinh.Anh); } LH_Tuan = new LichHoc_Tuan(ID); } else { btDaHocXong.Visible = btDangHoc.Visible = btHocPhi.Visible = btLichHoc.Visible = btLopHoc.Visible = btQuanLyGiaoVien.Visible = btQuanLyHocSinh.Visible = btQuanLyLopHoc.Visible = btQuanLyTaiKhoan.Visible = btLichDay.Visible = btLopDangDay.Visible = false; } }
private void pictureBox1_DoubleClick(object sender, EventArgs e) { string filename = ""; Thread thr = new Thread((ThreadStart)(() => { OpenFileDialog open = new OpenFileDialog(); open.Multiselect = false; if (open.ShowDialog() == DialogResult.OK) { filename = open.FileName.ToString(); } })); thr.SetApartmentState(ApartmentState.STA); thr.Start(); thr.Join(); if (filename == "") { return; } byte[] arrByte = HinhAnh.StringToByte(filename); ArrByte_Anh = arrByte; pictureBox1.Image = HinhAnh.ByteToImage(arrByte); if (txbMa_HocSinh.Text == "") { } else { EC_HocSinh hs = new BUS_HocSinh().Select_ByPrimaryKey(txbMa_HocSinh.Text); hs.Anh = arrByte; try { new BUS_HocSinh().SuaDuLieu(hs); MessageBox.Show("Lưu ảnh thành công", "Thông báo"); textBox1.Text = ArrByte_Anh.Clone().ToString(); } catch { MessageBox.Show("Lưu ảnh không thành công", "Thông báo"); } } }
private void dgDanhsach_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { DialogResult result = MessageBox.Show("Bạn có muốn xóa học sinh này đi không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { EC_HocSinh HocSinh = new EC_HocSinh(); HocSinh.Ma_HocSinh = dgDanhsach.Rows[e.RowIndex].Cells["Ma_HocSinh"].Value.ToString(); BUS_HocSinh busHS = new BUS_HocSinh(); busHS.XoaDuLieu(HocSinh); MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { return; } }
void Load() { dgDanhSachLop.Rows.Clear(); List <EC_LichHoc> listLichHoc = new BUS_LichHoc().SelectByFields("Ma_LopHoc", Ma_LopHoc); List <EC_BuoiHoc_HocSinh> listBuoiHoc_HocSinh = new BUS_BuoiHoc_HocSinh().SelectByFields("Ma_BuoiHoc", listLichHoc[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) { dgDanhSachLop.Rows.Add(i.Ma_HocSinh, i.Ten_HocSinh, i.NgaySinh, i.GioiTinh, i.SDT); } }
private void btLuu_Click(object sender, EventArgs e) { if (btLuu.Text == "Lưu") { EC_TaiKhoan ecTK = new EC_TaiKhoan(txbID.Text, txbTenDN.Text, txbMatKhau.Text); busTK.SuaDuLieu(ecTK); btLuu.Text = "Thêm"; txbID.Enabled = txbMa.Enabled = txbTenDN.Enabled = cbLoai.Enabled = true; } else if (btLuu.Text == "Thêm") { string ID = TaoID(); EC_TaiKhoan ecTK = new EC_TaiKhoan(ID, txbTenDN.Text, txbMatKhau.Text); if (cbLoai.SelectedIndex == 0) { EC_QuanLyTrungTam ecQl = new EC_QuanLyTrungTam(); ecQl.ID = ID; } else if (cbLoai.SelectedIndex == 1) { BUS_GiaoVien busGv = new BUS_GiaoVien(); if (busGv.Select_ByPrimaryKey(txbMa.Text) == null) { MessageBox.Show("Không tồn tại giáo viên"); return; } busGv.ThemID(txbMa.Text, ID); } else if (cbLoai.SelectedIndex == 2) { BUS_HocSinh busHS = new BUS_HocSinh(); if (busHS.Select_ByPrimaryKey(txbMa.Text) == null) { MessageBox.Show("Không tồn tại học sinh"); return; } busHS.ThemID(txbMa.Text, ID); } } else { } LoadForm(); }
void Load() { EC_HocSinh HocSinh = new BUS_HocSinh().Select_ByPrimaryKey(Ma_HocSinh); txbMa_HocSinh.Text = HocSinh.Ma_HocSinh; txbTenHocSinh.Text = HocSinh.Ten_HocSinh; txbNgayThu.Text = DateTime.Now.ToShortDateString(); txbThang.Text = ThoiGian.Month.ToString() + "/" + ThoiGian.Year.ToString(); DataTable data = new function().Select_HocPhi_Thang(ThoiGian); foreach (DataRow row in data.Rows) { if (row["Ma_HocSinh"].ToString() == HocSinh.Ma_HocSinh) { txbTongHocPhi.Text = row["TongSoTien"].ToString(); } } }
private void dgDanhsach_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } string ID = dgDanhsach.Rows[e.RowIndex].Cells["ID"].Value.ToString(); string TenDangNhap = dgDanhsach.Rows[e.RowIndex].Cells["TenDangNhap"].Value.ToString(); string MatKhau = dgDanhsach.Rows[e.RowIndex].Cells["MatKhau"].Value.ToString(); txbID.Text = ID; txbTenDN.Text = TenDangNhap; txbMatKhau.Text = MatKhau; btLuu.Text = "Lưu"; BUS_GiaoVien busGv = new BUS_GiaoVien(); BUS_HocSinh busHs = new BUS_HocSinh(); BUS_QuanLyTrungTam busQl = new BUS_QuanLyTrungTam(); if (busQl.TaoBang("where ID='" + ID + "'").Rows.Count != 0) { cbLoai.SelectedIndex = 0; txbMa.Text = ""; } else if (busHs.SelectByFields("ID", ID).Count != 0) { cbLoai.SelectedIndex = 2; txbMa.Text = busHs.SelectByFields("ID", ID)[0].Ma_HocSinh; } else if (busGv.SelectByFields("ID", ID).Count != 0) { cbLoai.SelectedIndex = 1; txbMa.Text = busGv.SelectByFields("ID", ID)[0].Ma_GiaoVien; } else { return; } txbID.Enabled = txbMa.Enabled = txbTenDN.Enabled = cbLoai.Enabled = false; }
private void btThem_TaiKhoan_Click(object sender, EventArgs e) { string Ma_HocSinh = txbMa_HocSinh.Text; if (Ma_HocSinh == "") { return; } EC_HocSinh HocSinh = new BUS_HocSinh().Select_ByPrimaryKey(Ma_HocSinh); if (HocSinh.ID == "") { try { string MatKhau = Hash.getHashString(txbMatKhau.Text); string ID = Tao_ID(); EC_TaiKhoan TaiKhoan = new EC_TaiKhoan(ID, txbTenDangNhap.Text, MatKhau); new BUS_TaiKhoan().ThemDuLieu(TaiKhoan); HocSinh.ID = ID; new BUS_HocSinh().SuaDuLieu(HocSinh); MessageBox.Show("Tạo tài khoản thành công", "Thông báo"); } catch { MessageBox.Show("Xem lại các thông tin đã tạo", "Thông báo"); } } else { try { string MatKhau = Hash.getHashString(txbMatKhau.Text); EC_TaiKhoan TaiKhoan = new EC_TaiKhoan(HocSinh.ID, txbTenDangNhap.Text, MatKhau); new BUS_TaiKhoan().ThemDuLieu(TaiKhoan); } catch { MessageBox.Show("Xem lại các thông tin đã tạo", "Thông báo"); } } }
private void btThem_Click_1(object sender, EventArgs e) { bool gt; if (cbGioiTinh.SelectedIndex == 0) { MessageBox.Show("Giới tính không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { gt = cbGioiTinh.SelectedIndex == 1 ? true : false; } int Lop; if (cbLop.SelectedIndex == 0) { MessageBox.Show("Trình độ không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { Lop = cbLop.SelectedIndex + 1; } if (dtNgaySinh.Value > DateTime.Now) { MessageBox.Show("Ngày sinh không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { EC_HocSinh HocSinh = new EC_HocSinh(txbMa_HocSinh.Text, txbTen_HocSinh.Text, dtNgaySinh.Value, gt, txbDiaChi.Text, txbSDT.Text, txbEmail.Text, Lop, "", null); BUS_HocSinh busHS = new BUS_HocSinh(); busHS.ThemDuLieu(HocSinh); MessageBox.Show("Thêm học sinh thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("Thêm học sinh thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void Load() { dgDanhSachLop.Rows.Clear(); List <EC_LichHoc> listLichHoc = new BUS_LichHoc().SelectByFields("Ma_LopHoc", Ma_LopHoc); List <EC_BuoiHoc_HocSinh> listBuoiHoc_HocSinh = new BUS_BuoiHoc_HocSinh().SelectByFields("Ma_BuoiHoc", listLichHoc[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); } int index = 1; foreach (EC_HocSinh i in listHocSinh) { string GioiTinh = i.GioiTinh == true ? "Nam" : "Nữ"; dgDanhSachLop.Rows.Add(index.ToString(), i.Ma_HocSinh, i.Ten_HocSinh, i.NgaySinh.ToShortDateString(), GioiTinh, i.SDT); index++; } }
private void btThem_Click_1(object sender, EventArgs e) { bool gt = cbGioiTinh.SelectedIndex == 0 ? true : false; int Lop; if (cbLop.SelectedIndex == 0) { MessageBox.Show("Trình độ không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { Lop = cbLop.SelectedIndex + 1; } if (dtNgaySinh.Value > DateTime.Now) { MessageBox.Show("Ngày sinh không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (pictureBox1.Image == null) { MessageBox.Show("Bạn hãy thêm ảnh bằng cách nhấn đúp vào khung hình ảnh nhé!", "Thông báo"); return; } try { EC_HocSinh HocSinh = new EC_HocSinh(TaoMa_HocSinh(), txbTen_HocSinh.Text, dtNgaySinh.Value, gt, txbDiaChi.Text, txbSDT.Text, txbEmail.Text, Lop, "", ArrByte_Anh); BUS_HocSinh busHS = new BUS_HocSinh(); busHS.ThemDuLieu(HocSinh); MessageBox.Show("Thêm học sinh thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); List <EC_HocSinh> listHocSinh = new BUS_HocSinh().SelectAll(); LoadForm(listHocSinh); } catch { MessageBox.Show("Thêm học sinh thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dgLichHoc_CellClick(object sender, DataGridViewCellEventArgs e) { if (data == null) { return; } if (e.RowIndex == -1) { return; } string Ma_HocSinh = dgHocPhi.Rows[e.RowIndex].Cells["Ma"].Value.ToString(); EC_HocSinh HocSinh = new BUS_HocSinh().Select_ByPrimaryKey(Ma_HocSinh); txbMa_HocSinh.Text = Ma_HocSinh; txbTen_HocSinh.Text = HocSinh.Ten_HocSinh; txbSDT.Text = HocSinh.SDT; txbEmail.Text = HocSinh.Email; DateTime ThoiGian = dtThang.Value; function ft = new function(); DataTable SoBuoiHoc_Thang = ft.SoBuoiHoc_Thang(Ma_HocSinh, dtThang.Value.Year); foreach (DataRow row in SoBuoiHoc_Thang.Rows) { if ((int)row["Thang"] == ThoiGian.Month) { txbTongSoBuoi.Text = row["TongSoBuoi"].ToString(); txbDiHoc.Text = row["SoBuoi_DiHoc"].ToString(); txbVang.Text = row["SoBuoi_Vang"].ToString(); if (txbVang.Text == "") { txbVang.Text = "0"; } } } DataTable HocPhi_Thang = ft.Select_HocPhi_Thang(dtThang.Value); foreach (DataRow row in HocPhi_Thang.Rows) { if (row["Ma_HocSinh"].ToString() == Ma_HocSinh) { txbTongHocPhi.Text = row["TongSoTien"].ToString(); if (txbTongHocPhi.Text == "") { txbTongHocPhi.Text = "0"; } txbDaDong.Text = row["DaDong"].ToString(); int DaDong = 0; if (txbDaDong.Text == "") { txbDaDong.Text = "0"; } else { DaDong = Int32.Parse(txbTongHocPhi.Text) - Int32.Parse(txbDaDong.Text); } txbChuaDong.Text = DaDong.ToString(); } } dgChiTiet.Rows.Clear(); int Stt = 1; DataTable BuoiHoc_Thang = ft.BuoiHoc_Thang(Ma_HocSinh, dtThang.Value); foreach (DataRow row in BuoiHoc_Thang.Rows) { string TrangThai = (bool)row["TrangThai"] == true ? "Đã học" : "Chưa học"; string DiemDanh = (bool)row["DiemDanh"] == true ? "Đi học" : "Vắng"; dgChiTiet.Rows.Add(Stt, row["Ma_LopHoc"].ToString(), row["Ma_BuoiHoc"].ToString(), TrangThai, DiemDanh); Stt++; } }
private void btTimKiem_Click(object sender, EventArgs e) { string Ma_HocSinh = txbMa_HocSinh_Search.Text; string Ten_HocSinh = txbTen_HocSinh_Search.Text; string GioiTinh = cbGioiTinh_Search.SelectedItem.ToString(); int Lop = cbLop_Search.SelectedIndex; List <EC_HocSinh> listResult = new List <EC_HocSinh>(); if (Ma_HocSinh != "") { EC_HocSinh GV = new BUS_HocSinh().Select_ByPrimaryKey(Ma_HocSinh); if (GV != null) { listResult.Add(GV); } } else if (Ten_HocSinh != "") { List <EC_HocSinh> list1 = new BUS_HocSinh().SelectByFields("Ten_HocSinh", Ten_HocSinh); foreach (EC_HocSinh i in list1) { if (listResult.IndexOf(i) == -1) { listResult.Add(i); } } } else if (GioiTinh != " ") { List <EC_HocSinh> list1 = new BUS_HocSinh().SelectByFields("GioiTinh", GioiTinh); foreach (EC_HocSinh i in list1) { if (listResult.IndexOf(i) == -1) { listResult.Add(i); } } } else if (Lop != 0) { List <EC_HocSinh> list1 = new BUS_HocSinh().SelectByFields("Lop", Lop); foreach (EC_HocSinh i in list1) { if (listResult.IndexOf(i) == -1) { listResult.Add(i); } } } else { } if (listResult.Count > 0) { LoadForm(listResult); } else { List <EC_HocSinh> listGiaoVien = new BUS_HocSinh().SelectAll(); LoadForm(listGiaoVien); } }
private void btTatCa_Click(object sender, EventArgs e) { List <EC_HocSinh> listGiaoVien = new BUS_HocSinh().SelectAll(); LoadForm(listGiaoVien); }
void LayDuLieu(int SttBuoi) { int SoHS_DiHoc = 0; EC_LichHoc ecLichHoc = new EC_LichHoc(); DanhSachLop = new List <EC_HocSinh>(); dgLopHoc.Rows.Clear(); foreach (EC_LichHoc ec in listBuoiHoc) { if (ec.STT_Buoi == (SttBuoi + 1)) { ecLichHoc = ec; } } if (ecLichHoc == null) { return; } List <EC_BuoiHoc_HocSinh> listBH_HS = new BUS_BuoiHoc_HocSinh().SelectByFields("Ma_BuoiHoc", ecLichHoc.Ma_BuoiHoc); if (listBH_HS.Count == 0) { return; } foreach (EC_BuoiHoc_HocSinh bhhs in listBH_HS) { EC_HocSinh hs = new BUS_HocSinh().Select_ByPrimaryKey(bhhs.Ma_HocSinh); DanhSachLop.Add(hs); if (bhhs.DiemDanh == true) { SoHS_DiHoc++; } } int i = 1; foreach (EC_HocSinh HocSinh in DanhSachLop) { string gioitinh = HocSinh.GioiTinh == true ? "Nam" : "Nữ"; bool DiemDanh = false; foreach (EC_BuoiHoc_HocSinh bhhs in listBH_HS) { if (bhhs.Ma_HocSinh == HocSinh.Ma_HocSinh) { DiemDanh = bhhs.DiemDanh; } } dgLopHoc.Rows.Add(i.ToString(), HocSinh.Ten_HocSinh, HocSinh.NgaySinh, gioitinh, HocSinh.SDT, DiemDanh); i++; } DateTime NgayHoc = ecLichHoc.NgayHoc; if (NgayHoc.Day == DateTime.Now.Day && NgayHoc.Month == DateTime.Now.Month && NgayHoc.Year == DateTime.Now.Year) { btDiemDanh.Visible = true; } else { btDiemDanh.Visible = false; } dateTimePicker1.Value = NgayHoc; txbKip.Text = ecLichHoc.KipHoc.ToString(); txbSoHocSinh.Text = DanhSachLop.Count.ToString(); int SoHS_Vang = DanhSachLop.Count - SoHS_DiHoc; txbDiHoc.Text = SoHS_DiHoc.ToString(); txbVang.Text = SoHS_Vang.ToString(); txbTrangThai.Text = ecLichHoc.TrangThai == true ? "Đã học" : "Chưa học"; txbHocPhi_Buoi.Text = ecLichHoc.TongHocPhi_Buoi.ToString(); txbMa_BuoiHoc.Text = ecLichHoc.Ma_BuoiHoc; }
private void picAvt_DoubleClick(object sender, EventArgs e) { string filename = ""; Thread thr = new Thread((ThreadStart)(() => { OpenFileDialog open = new OpenFileDialog(); open.Multiselect = false; if (open.ShowDialog() == DialogResult.OK) { filename = open.FileName.ToString(); } })); thr.SetApartmentState(ApartmentState.STA); thr.Start(); thr.Join(); if (filename == "") { return; } byte[] arrByte = HinhAnh.StringToByte(filename); picAvt.Image = HinhAnh.ByteToImage(arrByte); if (Quyen == 1) { EC_QuanLyTrungTam ql = new BUS_QuanLyTrungTam().Select_BYPrimaryKey(ID)[0]; ql.Anh = arrByte; try { new BUS_QuanLyTrungTam().SuaDuLieu(ql); MessageBox.Show("Lưu ảnh thành công", "Thông báo"); } catch { MessageBox.Show("Lưu ảnh không thành công", "Thông báo"); } } else if (Quyen == 2) { EC_GiaoVien hs = new BUS_GiaoVien().SelectByFields("ID", ID)[0]; hs.Anh = arrByte; try { new BUS_GiaoVien().SuaDuLieu(hs); MessageBox.Show("Lưu ảnh thành công", "Thông báo"); } catch { MessageBox.Show("Lưu ảnh không thành công", "Thông báo"); } } else if (Quyen == 3) { EC_HocSinh hs = new BUS_HocSinh().SelectByFields("ID", ID)[0]; hs.Anh = arrByte; try { new BUS_HocSinh().SuaDuLieu(hs); MessageBox.Show("Lưu ảnh thành công", "Thông báo"); } catch { MessageBox.Show("Lưu ảnh không thành công", "Thông báo"); } } }