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 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; } } }
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; }
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"); } } }
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++; } }
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"); } } }
private void dgDanhsach_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } pictureBox1.Image = null; txbMa_GiaoVien.Text = txbTen_GiaoVien.Text = txbSDT.Text = txbDiaChi.Text = txbEmail.Text = txbSDT.Text = txbTenDangNhap.Text = txbID.Text = txbMatKhau.Text = ""; dtNgaySinh.Value = DateTime.Now; cbGioiTinh.SelectedIndex = cbTrinhDo.SelectedIndex = 0; DataGridViewRow row = dgDanhsach.Rows[e.RowIndex]; txbMa_GiaoVien.Text = row.Cells["Ma_GiaoVien"].Value.ToString(); EC_GiaoVien GiaoVien = new BUS_GiaoVien().Select_ByPrimaryKey(txbMa_GiaoVien.Text); txbTen_GiaoVien.Text = row.Cells["Ten_GiaoVien"].Value.ToString(); txbDiaChi.Text = GiaoVien.DiaChi; txbEmail.Text = GiaoVien.Email; txbSDT.Text = GiaoVien.SDT; cbGioiTinh.SelectedIndex = GiaoVien.GioiTinh == true ? 0 : 1; dtNgaySinh.Value = Convert.ToDateTime(row.Cells["NgaySinh"].Value.ToString()); if (GiaoVien.Anh != null) { pictureBox1.Image = HinhAnh.ByteToImage(GiaoVien.Anh); } 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()); j++; } 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; } } }