public bool ThemSinhVien(string MSSV, string HoVaTen, string GioiTinh, string QueQuan, string NgaySinh, string CMND, string DiaChi, string NienKhoa, string maLop, ref string err) { string sqlString = "Select SinhVien.MSSV From SinhVien Where SinhVien.MSSV='" + MSSV + "'"; SqlDataReader sdr = dbMain.ExecuteReader(sqlString, CommandType.Text); if (sdr.Read()) { err = "Không thêm được, mã số sinh viên đã tồn tại !"; return(false); } sqlString = "Insert Into SinhVien Values('" + MSSV + "',N'" + HoVaTen + "',N'" + QueQuan + "','" + NgaySinh + "','" + CMND + "',N'" + GioiTinh + "',N'" + DiaChi + "','" + NienKhoa + "','" + maLop + "')"; return(dbMain.ExecuteNonQuery(sqlString, CommandType.Text, ref err)); }
public bool KiemTraTrungLap(string MSSV, string maMon) { string sqlString = "Select Diem.MSSV, Diem.MaMon From Diem"; sdr = dbMain.ExecuteReader(sqlString, CommandType.Text); while (sdr.Read()) { string maSV = (string)sdr["MSSV"]; string mamon = (string)sdr["MaMon"]; if (maSV.Trim() == MSSV && mamon.Trim() == maMon) { return(true); } } return(false); }
public bool CapNhatKhoa(string maKhoa, string tenKhoa, ref string err) { string sqlString = "Select Khoa.TenKhoa From Khoa"; SqlDataReader sdr = dbMain.ExecuteReader(sqlString, CommandType.Text); while (sdr.Read()) { if (sdr.GetString(0).ToLower().Trim() == tenKhoa.ToLower().Trim()) { err = "Tên khoa đã tồn tại !"; return(false); } } sqlString = "Update Khoa Set TenKhoa=N'" + tenKhoa + "' Where MaKhoa='" + maKhoa + "'"; return(dbMain.ExecuteNonQuery(sqlString, CommandType.Text, ref err)); }
public bool ktrathem(string MaLop, string TenLop) { string sqlString = "select Lop.MaLop,Lop.TenLop from Lop"; sdr = dbMain.ExecuteReader(sqlString, CommandType.Text); while (sdr.Read()) { string malop = (string)sdr["MaLop"].ToString(); string tenlop = (string)sdr["TenLop"].ToString(); if (malop.Trim() == MaLop && tenlop.Trim() == TenLop) { return(true); } } return(false); }
public bool ktrathem(string MaChuyenNganh, string TenChuyenNganh) { string sqlString = "select ChuyenNganh.MaChuyenNganh,ChuyenNganh.TenChuyenNganh from ChuyenNganh"; sdr = dbMain.ExecuteReader(sqlString, CommandType.Text); while (sdr.Read()) { string machuyennganh = (string)sdr["MaChuyenNganh"]; string tenchuyennganh = (string)sdr["TenChuyenNganh"]; if (machuyennganh.Trim().ToUpper() == MaChuyenNganh.Trim().ToUpper() || tenchuyennganh.Trim().ToUpper() == TenChuyenNganh.Trim().ToUpper()) { return(true); } } return(false); }
public bool KiemTraTrungLap(string maMon, string tenMon) { string sqlString = "Select MaMon, TenMon From MonHoc"; sdr = dbMain.ExecuteReader(sqlString, CommandType.Text); while (sdr.Read()) { string mamon = (string)sdr["MaMon"]; string tenmon = (string)sdr["TenMon"]; if (mamon.Trim().ToLower() == maMon.Trim().ToLower() || tenmon.Trim().ToLower() == tenMon.Trim().ToLower()) { return(true); } } return(false); }
public bool ktra(string Mssv, string Tennt) { string sqlString = "select ThanNhan.MSSV,ThanNhan.HoVaTen from ThanNhan"; sdr = dbMain.ExecuteReader(sqlString, CommandType.Text); while (sdr.Read()) { string mssv = (string)sdr["MSSV"]; string tennt = (string)sdr["HoVaTen"]; if (mssv.Trim() == Mssv && tennt.Trim() == Tennt) { return(true); } } return(false); }
public bool Reader(out string message) { bool result = false; string str = "Select MaHD from HoaDon group by MaHD having MaHD=max(MaHD)"; int max; result = main.ExecuteReader(str, out max, out message); Max = max; return(result); }
public bool Reader(out string message) { bool result = false; string str = "Select MaNV from NhanVien group by MaNV having MaNV=max(MaNV)"; int max; result = dbNV.ExecuteReader(str, out max, out message); Max = max; return(result); }
//public DataSet LayTaiKhoan() //{ // string sqlString = "select * from TaiKhoan"; // return dbMain.ExecuteQueryDataSet(sqlString, CommandType.Text); //} //public bool ThemTaiKhoan(string maUser, string tenDangNhap, string matkhau, string hovaten, string quyen, string gioitinh, ref string err) //{ // string sqlString = "Insert Into UserLogin Values(" + "'" + maUser + "','" + tenDangNhap + "','" + matkhau + "',N'" + hovaten + "',N'" + gioitinh + "',N'" + quyen + "')"; // return dbMain.ExecuteNonQuery(sqlString, CommandType.Text, ref err); //} //public bool XoaTaiKhoan(string maUser, ref string err) //{ // string sqlString = "Delete From UserLogin Where maUser='******'"; // return dbMain.ExecuteNonQuery(sqlString, CommandType.Text, ref err); //} //public bool CapNhatTaiKhoan(string maUser, string matkhau, string hovaten, string quyen, string gioitinh, ref string err) //{ // string sqlString = "Update UserLogin Set MatKhau='" + // matkhau + "',HoVaTen=N'" + hovaten + "',Quyen=N'" + quyen + "',GioiTinh=N'" + gioitinh + "' Where MaUser='******'"; // return dbMain.ExecuteNonQuery(sqlString, CommandType.Text, ref err); //} public bool KiemTraDangNhap(string TenDangNhap, string MatKhau, ref string err) { string sqlString = "select * from TaiKhoan left join DanhSachKhongDuocDangKy " + "on TaiKhoan.tenDangNhap = DanhSachKhongDuocDangKy.maSV"; sdr = dbMain.ExecuteReader(sqlString, CommandType.Text); try { while (sdr.Read()) { string username = (string)sdr["tenDangNhap"].ToString().Trim(); string password = (string)sdr["matkhau"].ToString().Trim(); string bannedID = (string)sdr["maSV"].ToString().Trim(); string message = (string)sdr["ghiChu"].ToString().Trim(); if (bannedID.ToLower() == TenDangNhap.ToLower()) { err = "Tài khoản hiện không thể đăng ký học phần!" + "\nLý do: " + message; return(false); } else if (username.ToLower() == TenDangNhap.ToLower() && password.ToLower() == MatKhau.ToLower()) { PropertiesCls.tenDangNhap = sdr["tenDangNhap"].ToString().Trim(); PropertiesCls.matkhau = sdr["matKhau"].ToString().Trim(); PropertiesCls.quyenDangNhap = sdr["quyenDangNhap"].ToString().Trim(); return(true); } } throw new Exception(); } catch { err = "Tên đăng nhập hoặc mật khẩu không chính xác, vui lòng nhập lại !"; return(false); } }