private void HienThi_Nut() { LaySiSoLop(); DataTable dsTam = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select * from thamso where mathamso='TS3' "; dsTam = provider.LayDanhSach(sSql); int sohs_toida; sohs_toida = Convert.ToInt32(dsTam.DefaultView[0].Row["giatri"].ToString()); int so = sohs - 1; if (so >= sohs_toida) { btnTiepNhan.Enabled = false; btnXoa.Enabled = false; btnCapNhat.Enabled = false; } else { btnTiepNhan.Enabled = true; btnXoa.Enabled = false; btnCapNhat.Enabled = false; } }
private void dataDS_Click(object sender, System.EventArgs e) { btnXoa.Enabled = true; btnCapNhat.Enabled = true; btnTiepNhan.Enabled = false; khoitao_textbox(); txtMaso.Text = ""; cboGioiTinh.Text = ""; string sSql; string sMaHS = dataDS[dataDS.CurrentCell.RowNumber, 0].ToString(); sSql = "select * from hocsinh where MAHS='" + sMaHS + "'"; DataTable dsHS = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS = provider.LayDanhSach(sSql); //gan du lieu vao cac textbox txtMaso.Text = dsHS.Rows[0]["MAHS"].ToString(); txtDiaChi.Text = dsHS.Rows[0]["DIACHI"].ToString(); txtEmail.Text = dsHS.Rows[0]["EMAIL"].ToString(); txtHoTen.Text = dsHS.Rows[0]["HOTEN"].ToString(); cboGioiTinh.SelectedText = dsHS.Rows[0]["PHAI"].ToString(); dtpNgaySinh.Value = Convert.ToDateTime(dsHS.Rows[0]["NGAYSINH"].ToString()); HienThi_Nut(); btnCapNhat.Enabled = true; btnXoa.Enabled = true; btnTiepNhan.Enabled = false; //MessageBox.Show("'"+dataDS[dataDS.CurrentCell.RowNumber,0]+"'"); }
private int kiemtra_ngaysinh() { DataTable dsTam = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select * from thamso "; dsTam = provider.LayDanhSach(sSql); int tuoitoithieu = 0, tuoitoida = 0, giatri = 0; string mathamso; for (int i = 0; i < dsTam.DefaultView.Count; i++) { mathamso = dsTam.DefaultView[i].Row["mathamso"].ToString(); giatri = Convert.ToInt32(dsTam.DefaultView[i].Row["giatri"].ToString()); if (mathamso == "TS1") { tuoitoithieu = giatri; } if (mathamso == "TS2") { tuoitoida = giatri; } } int tuoi = DateTime.Now.Year - dtpNgaySinh.Value.Year; if (tuoi < tuoitoithieu || tuoi > tuoitoida) { MessageBox.Show("Học sinh " + tuoi + " tuổi . Không thoả qui định !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return(0); } return(1); }
private void LayBangDiem() { DataColumn cot; DataTable dsHS = new DataTable(); string sSql; sSql = "select MAHS from hocsinh where MALOP='" + cboLop.SelectedValue + "'"; //QUANLYHOCSINHCAP3.HOCSINH.HocSinhData HSData=new QUANLYHOCSINHCAP3.HOCSINH.HocSinhData(); //dsHS= HSData.GetDanhSachHocSinh(sSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS = provider.LayDanhSach(sSql); sohocsinh = dsHS.DefaultView.Count; //tao cot Điểm 15 phút cot = new DataColumn(); cot.ColumnName = "Điểm 15 phút"; cot.DataType = Type.GetType("System.Double"); dsHS.Columns.Add(cot); //tao cot Điểm 1tiet cot = new DataColumn(); cot.ColumnName = "Điểm 1 tiết"; cot.DataType = Type.GetType("System.Double"); dsHS.Columns.Add(cot); //tao cot Điểm 1tiet cot = new DataColumn(); cot.ColumnName = "Điểm cuối HK"; cot.DataType = Type.GetType("System.Double"); dsHS.Columns.Add(cot); dataBD.DataSource = dsHS; khoitao(); }
private void GetDanhSachMonHoc() { //string strSql="select * from monhoc where mamon not in(select mamonhoc from diemmon d,hocsinh h where h.mahs=d.mahocsinh and h.malop='"+cboLop.SelectedValue+"'and d.mahocky='"+cboHocky.SelectedValue+"' ) "; //QUANLYHOCSINHCAP3.MONHOC.MonHocData monhoc = new QUANLYHOCSINHCAP3.MONHOC.MonHocData(); //cboMon.DataSource = monhoc.GetDanhSachMonHoc(strSql); string strSql = "select * from monhoc "; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboMon.DataSource = provider.LayDanhSach(strSql); cboMon.DisplayMember = "TENMON"; cboMon.ValueMember = "MAMON"; /*if(cboMon.Text=="") * { * btnLuu.Enabled=false; * strSql="select * from monhoc"; * cboMon.DataSource=provider.LayDanhSach(strSql); * cboMon.DisplayMember = "TENMON"; * cboMon.ValueMember = "MAMON"; * btnCapNhat.Enabled=true; * btnXoa.Enabled=true; * } * else * { * btnLuu.Enabled=true; * btnCapNhat.Enabled=false; * btnXoa.Enabled=false; * }*/ }
private void btnThoat_Click(object sender, System.EventArgs e) { QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); //cboKhoi.DataSource=provider.LayDanhSach(strSql); provider.Disconnect(); this.Close(); }
private void Getdanhsachlop() { string strSql = "select * from lop "; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboLop.DataSource = provider.LayDanhSach(strSql); cboLop.DisplayMember = "TENLOP"; cboLop.ValueMember = "MALOP"; }
private void LaySiSoLop() { string strSql = "select Siso from lop where malop='" + cboLop.SelectedValue + "'"; DataTable dsHS = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS = provider.LayDanhSach(strSql); txtSiSo.Text = ""; txtSiSo.Text = dsHS.Rows[0]["Siso"].ToString(); }
private void GetDanhSachKhoi() { string strSql = "select * from KHOI"; //QUANLYHOCSINHCAP3.KHOI.KhoiData khoi=new QUANLYHOCSINHCAP3.KHOI.KhoiData(); //cboKhoi.DataSource=khoi.GetDanhSachKhoi(strSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboKhoi.DataSource = provider.LayDanhSach(strSql); cboKhoi.ValueMember = "MAKHOI"; cboKhoi.DisplayMember = "TENKHOI "; }
private void GetDanhSachHocSinh() { DataTable dsHS = new DataTable(); string sSql; sSql = "select MAHS , HOTEN from hocsinh where MALOP='" + cboLop.SelectedValue + "'"; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS = provider.LayDanhSach(sSql); dataDS.DataSource = dsHS; sohs = dsHS.DefaultView.Count + 1; txtMaso.Text = Tao_MaHS(); }
private void GetDanhSachHocKi() { string strSql = "select * from hocki "; //QUANLYHOCSINHCAP3.HOCKY.HocKyData hocki = new QUANLYHOCSINHCAP3.HOCKY.HocKyData(); //cboHocky.DataSource = hocki.GetDanhSachHocKi(strSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboHocky.DataSource = provider.LayDanhSach(strSql); cboHocky.DisplayMember = "MAHOCKI"; cboHocky.ValueMember = "MAHOCKI"; //LayBaoCaoMon(); }
private void GetDanhSachMonHoc() { string strSql = "select * from monhoc "; //QUANLYHOCSINHCAP3.MONHOC.MonHocData monhoc = new QUANLYHOCSINHCAP3.MONHOC.MonHocData(); //cboMon.DataSource = monhoc.GetDanhSachMonHoc(strSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboMon.DataSource = provider.LayDanhSach(strSql); cboMon.DisplayMember = "TENMON"; cboMon.ValueMember = "MAMON"; }
private void GetDanhSachThamSo() { DataTable dsTS = new DataTable(); string sSql; sSql = "select mathamso as MATS,tenthamso AS TENTS from thamso"; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsTS = provider.LayDanhSach(sSql); dataDS.DataSource = dsTS; sots = dsTS.DefaultView.Count + 1; txtMaso.Text = "TS" + sots.ToString(); }
private void Tracuu() { string sSql; string sMaHS = txtMaHS.Text; sSql = "select * from hocsinh where MAHS='" + sMaHS + "'"; DataTable dsHS = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS = provider.LayDanhSach(sSql); dataThongTinHocSinh.DataSource = dsHS; LayBangDiem(); }
private void DangNhap() { QUANLYHOCSINHCAP3.KNCSDL.DataProvider.Username = txtUsername.Text; QUANLYHOCSINHCAP3.KNCSDL.DataProvider.Password = txtPasswd.Text; QUANLYHOCSINHCAP3.KNCSDL.DataProvider.Service = txtService.Text; QUANLYHOCSINHCAP3.KNCSDL.DataProvider _provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string path = "Provider=MSDAORA.1;Data Source= " + txtService.Text + ";User ID=" + txtUsername.Text + ";Password="******";Persist Security Info=True"; QUANLYHOCSINHCAP3.KNCSDL.DataProvider.ConnectionString = path; _provider.connect(); if (_provider.flag == 1) { ((Form1)MdiParent).ShowMenu(true); this.Close(); } else { MessageBox.Show("Không kết nối Oracle được !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUsername.Text = ""; txtUsername.Focus(); return; } /* if(txtMatKhau.Text=="") * { * * MessageBox.Show("Bạn phải nhập mật khẩu","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information); * txtMatKhau.Focus(); * return; * } * else * { * if(txtMatKhau.Text!="123") * { * MessageBox.Show("Bạn nhập sai mật khẩu","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Error); * txtMatKhau.Text=""; * txtMatKhau.Focus(); * return; * } * else * { * ((Form1)MdiParent).ShowMenu(true); * this.Close(); * } * }*/ }
private int Lay_MaDiemMon(string mahs, string mahocky, string mamon) { DataTable dsTam = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select madiemmon from diemmon where mahocsinh='" + mahs + "' and mahocky='" + mahocky + "' and mamonhoc='" + mamon + "'"; dsTam = provider.LayDanhSach(sSql); int madiemmon = 0; if (dsTam.DefaultView.Count != 0) { madiemmon = Convert.ToInt32(dsTam.DefaultView[0].Row["madiemmon"].ToString()); } return(madiemmon); }
private void dataDS_Click(object sender, System.EventArgs e) { btnCapnhat.Enabled = true; btnThem.Enabled = false; string sSql; string MaTS = dataDS[dataDS.CurrentCell.RowNumber, 0].ToString(); sSql = "select * from thamso where mathamso='" + MaTS + "'"; DataTable dsTS = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsTS = provider.LayDanhSach(sSql); //gan du lieu vao cac textbox txtMaso.Text = dsTS.Rows[0]["MATHAMSO"].ToString(); txtTenThamSo.Text = dsTS.Rows[0]["TENTHAMSO"].ToString(); txtGiaTri.Text = dsTS.Rows[0]["GIATRI"].ToString(); txtGhichu.Text = dsTS.Rows[0]["GHICHU"].ToString(); }
private void btnThoat_Click(object sender, System.EventArgs e) { DialogResult nut; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); if (Kiemtra_Thoat() == 1) { provider.Disconnect(); this.Close(); } else { nut = MessageBox.Show("Bạn có muốn lưu trước khi thoát không ? ", "Thông báo", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (nut == DialogResult.Yes) { if (btnTiepNhan.Enabled == false) { if (btnCapNhat.Enabled == true) { if (kiemtra() == 1) { CapNhat(); provider.Disconnect(); this.Close(); } } } else { if (kiemtra() == 1) { Luu(); provider.Disconnect(); this.Close(); } } } if (nut == DialogResult.No) { provider.Disconnect(); this.Close(); } } }
private void LayBangDiem() { DataColumn cot; DataTable dsBangDiem = new DataTable(); string sSql; sSql = "select * from monhoc "; //QUANLYHOCSINHCAP3.MONHOC.MonHocData Monhoc_Data=new QUANLYHOCSINHCAP3.MONHOC.MonHocData(); //dsBangDiem= Monhoc_Data.GetDanhSachMonHoc(sSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsBangDiem = provider.LayDanhSach(sSql); int soluongmon = dsBangDiem.DefaultView.Count; /*//tao cot HK * cot = new DataColumn(); * cot.ColumnName=" Học Kỳ"; * cot.DataType=Type.GetType("System.String"); * dsLop.Columns.Add(cot);*/ //tao cot TBHK1 cot = new DataColumn(); cot.ColumnName = "TBHK1"; cot.DataType = Type.GetType("System.String"); dsBangDiem.Columns.Add(cot); //tao cot TBHK2' cot = new DataColumn(); cot.ColumnName = "TBHK2"; cot.DataType = Type.GetType("System.String"); dsBangDiem.Columns.Add(cot); dataBDiem.DataSource = dsBangDiem; int i; string ma_mon, trungbinh; for (i = 0; i < soluongmon; i++) { ma_mon = dsBangDiem.Rows[i][0].ToString(); trungbinh = LayTrungBinhMon(ma_mon, "HK1"); dataBDiem[i, 2] = trungbinh.ToString(); trungbinh = LayTrungBinhMon(ma_mon, "HK2"); dataBDiem[i, 3] = trungbinh.ToString(); } }
private string Tao_MaHS() { DataTable dsTam = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select mahs from hocsinh where malop='" + cboLop.SelectedValue + "' order by mahs asc"; dsTam = provider.LayDanhSach(sSql); string mahs, s, tam; s = cboLop.SelectedValue.ToString(); tam = s; int j = 1, i; for (i = 0; i < dsTam.DefaultView.Count; i++) { mahs = dsTam.DefaultView[i].Row["mahs"].ToString(); if (mahs == (tam + "_" + j.ToString())) { s = mahs; } else { s = tam + "_" + j.ToString(); //s=s+1; break; } j++; } i = j - 1; if (s == cboLop.SelectedValue.ToString()) { s = s + "_1"; } else if (s == tam + "_" + i.ToString()) { s = tam + "_" + j.ToString(); } return(s); }
private void btnBaoCao_Click(object sender, System.EventArgs e) { QUANLYHOCSINHCAP3.KNCSDL.DataProvider _provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); if (nflag == 1) { BANGDIEM.RptBangDiemHS rpt = new QUANLYHOCSINHCAP3.BANGDIEM.RptBangDiemHS(); rpt.SetDatabaseLogon(username, password); rpt.SetParameterValue("pMaHS", txtMaHS.Text); crystalReportViewer1.ReportSource = rpt; } if (nflag == 0) { BANGDIEM.RptDSHS rpt = new QUANLYHOCSINHCAP3.BANGDIEM.RptDSHS(); rpt.SetDatabaseLogon(username, password); rpt.SetParameterValue("pLop", (string)cboLop.SelectedValue); rpt.SetParameterValue("pMamon", (string)cboMon.SelectedValue); crystalReportViewer1.ReportSource = rpt; } if (nflag == 2) { string MaHK = (string)cboHocky.SelectedValue; RptBaocaoHocki rpt = new RptBaocaoHocki(); rpt.SetDatabaseLogon(username, password); rpt.SetParameterValue("pMaHK", MaHK); crystalReportViewer1.ReportSource = rpt; } if (nflag == 4) { BaoCaoTheoMon rpt = new BaoCaoTheoMon(); rpt.SetDatabaseLogon(username, password); rpt.SetParameterValue("pMaHK", (string)cboHocky.SelectedValue); rpt.SetParameterValue("pMaMon", (string)cboMon.SelectedValue); crystalReportViewer1.ReportSource = rpt; } //CACH EXPORT VO WORD /*SaveFileDialog dlg = new SaveFileDialog (); * if (dlg.ShowDialog()==DialogResult.OK) * rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows,dlg.FileName) ;*/ }
private int kiemtra() { DataTable dsTam = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select * from thamso "; dsTam = provider.LayDanhSach(sSql); int diemtoithieu = 0, diemtoida = 0, giatri = 0; string mathamso; int i, j; for (i = 0; i < dsTam.DefaultView.Count; i++) { mathamso = dsTam.DefaultView[i].Row["mathamso"].ToString(); giatri = Convert.ToInt32(dsTam.DefaultView[i].Row["giatri"].ToString()); if (mathamso == "TS4") { diemtoithieu = giatri; } if (mathamso == "TS5") { diemtoida = giatri; } } for (i = 0; i < sohocsinh; i++) { for (j = 1; j < 4; j++) { if (Convert.ToInt32(dataBD[i, j]) < diemtoithieu || Convert.ToInt32(dataBD[i, j]) > diemtoida) { return(0); } } } return(1); }
private int Tao_MaDiemMon() { DataTable dsTam = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select madiemmon from diemmon order by madiemmon asc"; dsTam = provider.LayDanhSach(sSql); int madiemmon = 0; int s = 0; for (int i = 0; i < dsTam.DefaultView.Count; i++) { madiemmon = Convert.ToInt32(dsTam.DefaultView[i].Row["madiemmon"].ToString()); if (madiemmon == (s + 1)) { s = madiemmon; } else { s = s + 1; break; } } if (s == 0) { s = s + 1; } else if (s == madiemmon) { s = s + 1; } return(s); }
private string LayTrungBinhMon(string mamon, string hocky) { /*dsBDiem=new DataTable(); * string sSql,trungbinh; * sSql = "select trungbinh from diemmon where mamonhoc='"+mamon+"' and mahocky='"+hocky+"' and mahocsinh='"+txtMaHS.Text+"'"; * QUANLYHOCSINHCAP3.BANGDIEM.BangDiemData BDiemData=new QUANLYHOCSINHCAP3.BANGDIEM.BangDiemData(); * dsBDiem= BDiemData.GetDanhSachDiemMon(sSql); * * trungbinh=dsBDiem.Rows[0][0].ToString();*/ DataTable dsTam = new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select trungbinh from diemmon where mamonhoc='" + mamon + "' and mahocky='" + hocky + "' and mahocsinh='" + txtMaHS.Text + "'"; dsTam = provider.LayDanhSach(sSql); string trungbinh = "0.0"; if (dsTam.DefaultView.Count != 0) { trungbinh = dsTam.DefaultView[0].Row["trungbinh"].ToString(); } return(trungbinh); }
private void GetDanhSachMonHoc() { string strSql="select * from monhoc "; //QUANLYHOCSINHCAP3.MONHOC.MonHocData monhoc = new QUANLYHOCSINHCAP3.MONHOC.MonHocData(); //cboMon.DataSource = monhoc.GetDanhSachMonHoc(strSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboMon.DataSource=provider.LayDanhSach(strSql); cboMon.DisplayMember = "TENMON"; cboMon.ValueMember = "MAMON"; }
private void GetDanhSachMonHoc() { //string strSql="select * from monhoc where mamon not in(select mamonhoc from diemmon d,hocsinh h where h.mahs=d.mahocsinh and h.malop='"+cboLop.SelectedValue+"'and d.mahocky='"+cboHocky.SelectedValue+"' ) "; //QUANLYHOCSINHCAP3.MONHOC.MonHocData monhoc = new QUANLYHOCSINHCAP3.MONHOC.MonHocData(); //cboMon.DataSource = monhoc.GetDanhSachMonHoc(strSql); string strSql="select * from monhoc "; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboMon.DataSource=provider.LayDanhSach(strSql); cboMon.DisplayMember = "TENMON"; cboMon.ValueMember = "MAMON"; /*if(cboMon.Text=="") { btnLuu.Enabled=false; strSql="select * from monhoc"; cboMon.DataSource=provider.LayDanhSach(strSql); cboMon.DisplayMember = "TENMON"; cboMon.ValueMember = "MAMON"; btnCapNhat.Enabled=true; btnXoa.Enabled=true; } else { btnLuu.Enabled=true; btnCapNhat.Enabled=false; btnXoa.Enabled=false; }*/ }
private int Lay_MaDiemMon(string mahs,string mahocky,string mamon) { DataTable dsTam=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select madiemmon from diemmon where mahocsinh='"+mahs+"' and mahocky='"+mahocky+"' and mamonhoc='"+mamon+"'"; dsTam=provider.LayDanhSach(sSql); int madiemmon =0; if(dsTam.DefaultView.Count!=0) madiemmon=Convert.ToInt32(dsTam.DefaultView[0].Row["madiemmon"].ToString()); return madiemmon; }
private void btnThoat_Click(object sender, System.EventArgs e) { QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider = new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); provider.Disconnect(); this.Close(); }
private void dataDS_Click(object sender, System.EventArgs e) { btnCapnhat.Enabled=true; btnThem.Enabled=false; string sSql; string MaTS=dataDS[dataDS.CurrentCell.RowNumber,0].ToString(); sSql = "select * from thamso where mathamso='"+MaTS+"'"; DataTable dsTS=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsTS=provider.LayDanhSach(sSql); //gan du lieu vao cac textbox txtMaso.Text=dsTS.Rows[0]["MATHAMSO"].ToString(); txtTenThamSo.Text=dsTS.Rows[0]["TENTHAMSO"].ToString(); txtGiaTri.Text=dsTS.Rows[0]["GIATRI"].ToString(); txtGhichu.Text=dsTS.Rows[0]["GHICHU"].ToString(); }
private void GetDanhSachHocKi() { string strSql="select * from hocki "; //QUANLYHOCSINHCAP3.HOCKY.HocKyData hocki = new QUANLYHOCSINHCAP3.HOCKY.HocKyData(); //cboHocky.DataSource = hocki.GetDanhSachHocKi(strSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboHocky.DataSource=provider.LayDanhSach(strSql); cboHocky.DisplayMember ="MAHOCKI"; cboHocky.ValueMember = "MAHOCKI"; //LayBaoCaoMon(); }
private void LayBangDiem() { DataColumn cot ; DataTable dsHS=new DataTable(); string sSql; sSql = "select MAHS from hocsinh where MALOP='" + cboLop.SelectedValue + "'"; //QUANLYHOCSINHCAP3.HOCSINH.HocSinhData HSData=new QUANLYHOCSINHCAP3.HOCSINH.HocSinhData(); //dsHS= HSData.GetDanhSachHocSinh(sSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS=provider.LayDanhSach(sSql); sohocsinh=dsHS.DefaultView.Count; //tao cot Điểm 15 phút cot = new DataColumn(); cot.ColumnName="Điểm 15 phút"; cot.DataType=Type.GetType("System.Double"); dsHS.Columns.Add(cot); //tao cot Điểm 1tiet cot = new DataColumn(); cot.ColumnName="Điểm 1 tiết"; cot.DataType=Type.GetType("System.Double"); dsHS.Columns.Add(cot); //tao cot Điểm 1tiet cot = new DataColumn(); cot.ColumnName="Điểm cuối HK"; cot.DataType=Type.GetType("System.Double"); dsHS.Columns.Add(cot); dataBD.DataSource =dsHS; khoitao(); }
private int kiemtra() { DataTable dsTam=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select * from thamso "; dsTam=provider.LayDanhSach(sSql); int diemtoithieu=0,diemtoida=0,giatri=0; string mathamso; int i,j; for(i=0;i<dsTam.DefaultView.Count;i++) { mathamso=dsTam.DefaultView[i].Row["mathamso"].ToString(); giatri=Convert.ToInt32(dsTam.DefaultView[i].Row["giatri"].ToString()); if(mathamso=="TS4") diemtoithieu=giatri; if(mathamso=="TS5") diemtoida=giatri; } for(i=0;i<sohocsinh;i++) { for(j=1;j<4;j++) if(Convert.ToInt32(dataBD[i,j])<diemtoithieu ||Convert.ToInt32(dataBD[i,j])>diemtoida) return 0; } return 1; }
private void GetDanhSachKhoi() { string strSql="select * from KHOI"; //QUANLYHOCSINHCAP3.KHOI.KhoiData khoi=new QUANLYHOCSINHCAP3.KHOI.KhoiData(); //cboKhoi.DataSource=khoi.GetDanhSachKhoi(strSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboKhoi.DataSource=provider.LayDanhSach(strSql); cboKhoi.ValueMember="MAKHOI"; cboKhoi.DisplayMember="TENKHOI "; }
private string LayTrungBinhMon(string mamon,string hocky) { /*dsBDiem=new DataTable(); string sSql,trungbinh; sSql = "select trungbinh from diemmon where mamonhoc='"+mamon+"' and mahocky='"+hocky+"' and mahocsinh='"+txtMaHS.Text+"'"; QUANLYHOCSINHCAP3.BANGDIEM.BangDiemData BDiemData=new QUANLYHOCSINHCAP3.BANGDIEM.BangDiemData(); dsBDiem= BDiemData.GetDanhSachDiemMon(sSql); trungbinh=dsBDiem.Rows[0][0].ToString();*/ DataTable dsTam=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select trungbinh from diemmon where mamonhoc='"+mamon+"' and mahocky='"+hocky+"' and mahocsinh='"+txtMaHS.Text+"'"; dsTam=provider.LayDanhSach(sSql); string trungbinh="0.0"; if(dsTam.DefaultView.Count!=0) trungbinh=dsTam.DefaultView[0].Row["trungbinh"].ToString(); return trungbinh; }
private void Tracuu() { string sSql; string sMaHS=txtMaHS.Text; sSql = "select * from hocsinh where MAHS='" + sMaHS + "'"; DataTable dsHS=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS=provider.LayDanhSach(sSql); dataThongTinHocSinh.DataSource = dsHS; LayBangDiem(); }
private string Tao_MaHS() { DataTable dsTam=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select mahs from hocsinh where malop='"+cboLop.SelectedValue+"' order by mahs asc"; dsTam=provider.LayDanhSach(sSql); string mahs ,s,tam; s=cboLop.SelectedValue.ToString(); tam=s; int j=1,i; for( i=0;i<dsTam.DefaultView.Count;i++) { mahs=dsTam.DefaultView[i].Row["mahs"].ToString(); if(mahs ==(tam+"_"+j.ToString())) { s=mahs; } else { s=tam+"_"+j.ToString(); //s=s+1; break; } j++; } i=j-1; if(s==cboLop.SelectedValue.ToString()) s=s+"_1"; else if(s==tam+"_"+i.ToString()) { s=tam+"_"+j.ToString(); } return s; }
private void HienThi_Nut() { LaySiSoLop(); DataTable dsTam=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select * from thamso where mathamso='TS3' "; dsTam=provider.LayDanhSach(sSql); int sohs_toida; sohs_toida=Convert.ToInt32(dsTam.DefaultView[0].Row["giatri"].ToString()); int so=sohs-1; if(so>=sohs_toida) { btnTiepNhan.Enabled=false; btnXoa.Enabled=false; btnCapNhat.Enabled=false; } else { btnTiepNhan.Enabled=true; btnXoa.Enabled=false; btnCapNhat.Enabled=false; } }
private int Tao_MaDiemMon() { DataTable dsTam=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select madiemmon from diemmon order by madiemmon asc"; dsTam=provider.LayDanhSach(sSql); int madiemmon =0; int s=0; for(int i=0;i<dsTam.DefaultView.Count;i++) { madiemmon=Convert.ToInt32(dsTam.DefaultView[i].Row["madiemmon"].ToString()); if(madiemmon ==(s+1)) s=madiemmon; else { s=s+1; break; } } if(s==0) s=s+1; else if(s == madiemmon) s=s+1; return s; }
private int kiemtra_ngaysinh() { DataTable dsTam=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string sSql; sSql = "select * from thamso "; dsTam=provider.LayDanhSach(sSql); int tuoitoithieu=0,tuoitoida=0,giatri=0; string mathamso; for(int i=0;i<dsTam.DefaultView.Count;i++) { mathamso=dsTam.DefaultView[i].Row["mathamso"].ToString(); giatri=Convert.ToInt32(dsTam.DefaultView[i].Row["giatri"].ToString()); if(mathamso=="TS1") tuoitoithieu=giatri; if(mathamso=="TS2") tuoitoida=giatri; } int tuoi=DateTime.Now.Year-dtpNgaySinh.Value.Year; if( tuoi<tuoitoithieu || tuoi>tuoitoida) { MessageBox.Show("Học sinh "+tuoi+" tuổi . Không thoả qui định !","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information); return 0; } return 1; }
private void btnThoat_Click(object sender, System.EventArgs e) { QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); provider.Disconnect(); this.Close(); }
private void dataDS_Click(object sender, System.EventArgs e) { btnXoa.Enabled=true; btnCapNhat.Enabled=true; btnTiepNhan.Enabled=false; khoitao_textbox(); txtMaso.Text=""; cboGioiTinh.Text=""; string sSql; string sMaHS=dataDS[dataDS.CurrentCell.RowNumber,0].ToString(); sSql = "select * from hocsinh where MAHS='" + sMaHS + "'"; DataTable dsHS=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS=provider.LayDanhSach(sSql); //gan du lieu vao cac textbox txtMaso.Text=dsHS.Rows[0]["MAHS"].ToString(); txtDiaChi.Text=dsHS.Rows[0]["DIACHI"].ToString(); txtEmail.Text=dsHS.Rows[0]["EMAIL"].ToString(); txtHoTen.Text=dsHS.Rows[0]["HOTEN"].ToString(); cboGioiTinh.SelectedText=dsHS.Rows[0]["PHAI"].ToString(); dtpNgaySinh.Value=Convert.ToDateTime(dsHS.Rows[0]["NGAYSINH"].ToString()); HienThi_Nut(); btnCapNhat.Enabled=true; btnXoa.Enabled=true; btnTiepNhan.Enabled=false; //MessageBox.Show("'"+dataDS[dataDS.CurrentCell.RowNumber,0]+"'"); }
private void Getdanhsachlop() { string strSql="select * from lop "; //QUANLYHOCSINHCAP3.LOPHOC.LopHocData lop = new QUANLYHOCSINHCAP3.LOPHOC.LopHocData(); //cboLop.DataSource = lop.Getdanhsachlop(strSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboLop.DataSource=provider.LayDanhSach(strSql); cboLop.DisplayMember = "TENLOP"; cboLop.ValueMember = "MALOP"; }
private void GetDanhSachThamSo() { DataTable dsTS=new DataTable(); string sSql; sSql = "select mathamso as MATS,tenthamso AS TENTS from thamso"; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsTS=provider.LayDanhSach(sSql); dataDS.DataSource =dsTS; sots=dsTS.DefaultView.Count+1; txtMaso.Text="TS"+ sots.ToString(); }
private void LaySiSoLop() { string strSql="select Siso from lop where malop='"+cboLop.SelectedValue+"'"; DataTable dsHS=new DataTable(); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS=provider.LayDanhSach(strSql); txtSiSo.Text=""; txtSiSo.Text=dsHS.Rows[0]["Siso"].ToString(); }
private void btnBaoCao_Click(object sender, System.EventArgs e) { QUANLYHOCSINHCAP3.KNCSDL.DataProvider _provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); if (nflag==1) { BANGDIEM.RptBangDiemHS rpt=new QUANLYHOCSINHCAP3.BANGDIEM.RptBangDiemHS (); rpt.SetDatabaseLogon(username , password); rpt.SetParameterValue("pMaHS",txtMaHS.Text); crystalReportViewer1.ReportSource = rpt; } if (nflag==0) { BANGDIEM.RptDSHS rpt=new QUANLYHOCSINHCAP3.BANGDIEM.RptDSHS(); rpt.SetDatabaseLogon(username , password); rpt.SetParameterValue("pLop",(string)cboLop.SelectedValue); rpt.SetParameterValue("pMamon",(string)cboMon.SelectedValue); crystalReportViewer1.ReportSource = rpt; } if (nflag==2) { string MaHK=(string)cboHocky.SelectedValue; RptBaocaoHocki rpt=new RptBaocaoHocki (); rpt.SetDatabaseLogon(username , password); rpt.SetParameterValue("pMaHK",MaHK); crystalReportViewer1.ReportSource = rpt; } if (nflag==4) { BaoCaoTheoMon rpt=new BaoCaoTheoMon(); rpt.SetDatabaseLogon(username , password); rpt.SetParameterValue("pMaHK",(string)cboHocky.SelectedValue); rpt.SetParameterValue("pMaMon",(string)cboMon.SelectedValue); crystalReportViewer1.ReportSource = rpt; } //CACH EXPORT VO WORD /*SaveFileDialog dlg = new SaveFileDialog (); if (dlg.ShowDialog()==DialogResult.OK) rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows,dlg.FileName) ;*/ }
private void Getdanhsachlop(string ma_khoi) { string strSql="select * from lop where makhoi='"+ma_khoi+"'"; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); cboLop.DataSource=provider.LayDanhSach(strSql); cboLop.DisplayMember = "TENLOP"; cboLop.ValueMember = "MALOP"; }
private void GetDanhSachHocSinh() { DataTable dsHS=new DataTable(); string sSql; sSql = "select MAHS , HOTEN from hocsinh where MALOP='" + cboLop.SelectedValue + "'"; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsHS=provider.LayDanhSach(sSql); dataDS.DataSource =dsHS; sohs=dsHS.DefaultView.Count+1; txtMaso.Text=Tao_MaHS(); }
private void LayBangDiem() { DataColumn cot ; DataTable dsBangDiem=new DataTable(); string sSql; sSql = "select * from monhoc "; //QUANLYHOCSINHCAP3.MONHOC.MonHocData Monhoc_Data=new QUANLYHOCSINHCAP3.MONHOC.MonHocData(); //dsBangDiem= Monhoc_Data.GetDanhSachMonHoc(sSql); QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); dsBangDiem=provider.LayDanhSach(sSql); int soluongmon=dsBangDiem.DefaultView.Count; /*//tao cot HK cot = new DataColumn(); cot.ColumnName=" Học Kỳ"; cot.DataType=Type.GetType("System.String"); dsLop.Columns.Add(cot);*/ //tao cot TBHK1 cot = new DataColumn(); cot.ColumnName="TBHK1"; cot.DataType=Type.GetType("System.String"); dsBangDiem.Columns.Add(cot); //tao cot TBHK2' cot = new DataColumn(); cot.ColumnName="TBHK2"; cot.DataType=Type.GetType("System.String"); dsBangDiem.Columns.Add(cot); dataBDiem.DataSource =dsBangDiem; int i; string ma_mon,trungbinh; for(i=0;i<soluongmon;i++) { ma_mon=dsBangDiem.Rows[i][0].ToString(); trungbinh=LayTrungBinhMon(ma_mon,"HK1"); dataBDiem[i,2]=trungbinh.ToString(); trungbinh=LayTrungBinhMon(ma_mon,"HK2"); dataBDiem[i,3]=trungbinh.ToString(); } }
private void btnThoat_Click(object sender, System.EventArgs e) { DialogResult nut; QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); if(Kiemtra_Thoat()==1) { provider.Disconnect(); this.Close(); } else { nut=MessageBox.Show("Bạn có muốn lưu trước khi thoát không ? ","Thông báo",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Information); if(nut==DialogResult.Yes) { if(btnTiepNhan.Enabled==false) { if(btnCapNhat.Enabled==true) { if(kiemtra()==1) { CapNhat(); provider.Disconnect(); this.Close(); } } } else { if(kiemtra()==1) { Luu(); provider.Disconnect(); this.Close(); } } } if(nut==DialogResult.No) { provider.Disconnect(); this.Close(); } } }
private void btnThoat_Click(object sender, System.EventArgs e) { QUANLYHOCSINHCAP3.KNCSDL.DataProvider provider=new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); //cboKhoi.DataSource=provider.LayDanhSach(strSql); provider.Disconnect(); this.Close(); }
private void DangNhap() { QUANLYHOCSINHCAP3.KNCSDL.DataProvider.Username=txtUsername.Text; QUANLYHOCSINHCAP3.KNCSDL.DataProvider.Password=txtPasswd.Text; QUANLYHOCSINHCAP3.KNCSDL.DataProvider.Service=txtService.Text; QUANLYHOCSINHCAP3.KNCSDL.DataProvider _provider= new QUANLYHOCSINHCAP3.KNCSDL.DataProvider(); string path = "Provider=MSDAORA.1;Data Source= "+txtService.Text+";User ID="+txtUsername.Text+";Password="******";Persist Security Info=True"; QUANLYHOCSINHCAP3.KNCSDL.DataProvider.ConnectionString=path; _provider.connect(); if(_provider.flag==1) { ((Form1)MdiParent).ShowMenu(true); this.Close(); } else { MessageBox.Show("Không kết nối Oracle được !!!","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Error); txtUsername.Text=""; txtUsername.Focus(); return; } /* if(txtMatKhau.Text=="") { MessageBox.Show("Bạn phải nhập mật khẩu","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information); txtMatKhau.Focus(); return; } else { if(txtMatKhau.Text!="123") { MessageBox.Show("Bạn nhập sai mật khẩu","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Error); txtMatKhau.Text=""; txtMatKhau.Focus(); return; } else { ((Form1)MdiParent).ShowMenu(true); this.Close(); } }*/ }