public ActionResult Index(string mssv) { var sess = Session["taikhoan"]; if (sess == null) { return(RedirectToAction("dangnhap", "SinhVien")); } else { sinhvien sv = SinhvienDAO.Instance.GetSVByMSSV(mssv); return(View(sv)); } }
public ActionResult QuenMatKhau(string email) { sinhvien sv = db.sinhviens.SingleOrDefault(x => x.email == email); if (sv == null) { Session["ErrorMess"] = "Email này không tồn tại!"; return(RedirectToAction("dangnhap", "SinhVien")); } string newpass = RandomString(10, false); sv.matkhau = newpass; db.SaveChanges(); StringBuilder Body = new StringBuilder(); //Tạo body mail Body.Append("<table>"); Body.Append("<tr><td colspan='2'><h4>Lấy lại mật khẩu</h4></td></tr>"); Body.Append("<tr><td>Mật khẩu mới của bạn là:</td><td>" + newpass + "</td></tr>"); Body.Append("<tr><td>Vui lòng đăng nhập bằng tài khoản này để đổi lại mật khẩu</td></tr>"); Body.Append("</table>"); // //Cài đặt mail MailMessage mail = new MailMessage(); mail.To.Add(sv.email); mail.From = new MailAddress("*****@*****.**"); mail.Subject = "Trả lời về vấn đề quên mật khẩu của sinh viên"; mail.Body = Body.ToString();// phần thân của mail ở trên mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = true; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Smile123");// tài khoản Gmail của bạn smtp.EnableSsl = true; smtp.Send(mail); return(View()); // }
public ActionResult doimatkhau(string oldpass, string newpass, string newpass1, string mssv, string oldemail, string newemail) { sinhvien kiemtra = db.sinhviens.SingleOrDefault(x => x.mssv == mssv); if (newpass != newpass1) { ViewBag.ThongBao = "Nhập lại mật khẩu mới chưa đúng!!"; return(RedirectToAction("xemthongtin", new { mssv })); } else if (kiemtra.matkhau != oldpass) { ViewBag.ThongBao = " mật khẩu chưa đúng!!"; return(RedirectToAction("xemthongtin", new { mssv })); } else { if (kiemtra != null) { string checkemail = newemail.Replace(" ", ""); string checknewpass = newpass.Replace(" ", ""); if (checkemail.Length > 0) { if (checknewpass.Length > 0) { kiemtra.matkhau = newpass; kiemtra.email = newemail; db.SaveChanges(); return(RedirectToAction("Index", "Home", new { mssv })); } kiemtra.email = newemail; db.SaveChanges(); return(RedirectToAction("Index", "Home", new { mssv })); } else if (checknewpass.Length > 0) { kiemtra.matkhau = newpass; db.SaveChanges(); return(RedirectToAction("Index", "Home", new { mssv })); } return(RedirectToAction("xemthongtin", new { mssv })); } return(RedirectToAction("xemthongtin", new { mssv })); } }
public HttpResponseMessage Put(long id, [FromBody] sinhvien value) { StudentPersistance sp = new StudentPersistance(); bool recordExisted = false; recordExisted = sp.updateStudent(id, value); HttpResponseMessage response; if (recordExisted) { response = Request.CreateResponse(HttpStatusCode.NoContent); } else { response = Request.CreateResponse(HttpStatusCode.NotFound); } return(response); }
public bool deleteSinhVien(sinhvien sv) { string sqlDeleteSinhVien = "DELETE SinhVien WHERE id =@ID"; SqlConnection con = dc.getConnection(); cm = new SqlCommand(sqlDeleteSinhVien, con); try { con.Open(); cm.Parameters.Add("@ID", SqlDbType.Int).Value = sv.ID; cm.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public ActionResult Index(FormCollection collection) { Session["LoggedCNT"] = ""; Session["LoggedSV"] = ""; Session["LoggedAD"] = ""; chunhatro cnt = new chunhatro(); sinhvien sv = new sinhvien(); nguoidung admin = new nguoidung(); var tendn = collection["username"]; var matkhau = collection["password"]; if (String.IsNullOrEmpty(tendn)) { ViewData["Loi1"] = "Phải nhập tên đăng nhập"; } else if (String.IsNullOrEmpty(matkhau)) { ViewData["Loi2"] = "Phải nhập mật khẩu"; } else { cnt = Db.chunhatros.SingleOrDefault(n => n.Machunhatro == tendn && n.Pass == matkhau); sv = Db.sinhviens.SingleOrDefault(n => n.Masv == tendn && n.Pass == matkhau); if (cnt != null) { Session["LoggedCNT"] = cnt; Session["cnt"] = cnt.Tenchunhatro; return(RedirectToAction("Index", "ChuNT")); } else if (sv != null) { Session["LoggedSV"] = sv; return(RedirectToAction("Index")); } else { ViewBag.Thongbao = "Tên đăng nhập hoặc mật khẩu không đúng"; } } return(View()); }
private void btCapNhat_Click(object sender, EventArgs e) { dgvSinhVien.CurrentRow.Selected = true; sinhvien sv = new sinhvien { MSV = dgvSinhVien.SelectedCells[0].Value.ToString(), HoTen = dgvSinhVien.SelectedCells[1].Value.ToString(), GioiTinh = Boolean.Parse(dgvSinhVien.SelectedCells[2].Value.ToString()), NgaySinh = DateTime.Parse(dgvSinhVien.SelectedCells[3].Value.ToString()), TenKhoa = dgvSinhVien.SelectedCells[4].Value.ToString(), Diem1 = dgvSinhVien.SelectedCells[5].Value.ToString(), Diem2 = dgvSinhVien.SelectedCells[6].Value.ToString() }; if (sv != null) { var _f = new frmChinhSua(this, sv); _f.ShowDialog(); } }
public ActionResult DanhSachPhieu() { if (Session["LoggedSV"] == null || Session["LoggedSV"].ToString() == "") { TempData["Login"] = "******"; return(RedirectToAction("Index", "Home")); } sinhvien sv = (sinhvien)Session["LoggedSV"]; ViewBag.sinhvien = sv.Tensv; DanhSachPhieu dsp = new DanhSachPhieu(); dsp.dktpt = db.phieudangkitimphongtros.Where(m => m.Masv == sv.Masv).ToList(); dsp.tddc = db.phieuthaydoidiachis.Where(m => m.Masv == sv.Masv).ToList(); dsp.xnttnt = db.phieuxacnhanthongtinngoaitrus.Where(m => m.Masv == sv.Masv).ToList(); dsp.dknt = db.phieudangkingoaitrus.Where(m => m.Masv == sv.Masv).ToList(); dsp.gtsvnt = db.phieugioithieusinhvienngoaitrus.Where(m => m.Masv == sv.Masv).ToList(); ViewBag.danhsachphieu = dsp; return(View()); }
public bool UpdateSinhVien(sinhvien sv, string filePath, string folderpath) { string sqlUpdate = "UPDATE SinhVien SET Masv=@MASV,Tensv=@TENSV,Gioitinh=@GIOITINH,Malop=@MALOP,Diachi=@DIACHI,Image=@IMAGE WHERE id =@ID"; SqlConnection con = dc.getConnection(); cm = new SqlCommand(sqlUpdate, con); if (filePath == "") { cm.Parameters.Add("@ID", SqlDbType.Int).Value = sv.ID; cm.Parameters.Add("@MASV", SqlDbType.NVarChar).Value = sv.MASV; cm.Parameters.Add("@TENSV", SqlDbType.NVarChar).Value = sv.TENSV; cm.Parameters.Add("@GIOITINH", SqlDbType.Int).Value = sv.GIOITINH; cm.Parameters.Add("@MALOP", SqlDbType.NVarChar).Value = sv.MALOP; cm.Parameters.Add("@DIACHI", SqlDbType.NVarChar).Value = sv.DIACHI; cm.Parameters.AddWithValue("@IMAGE", ""); } else { cm.Parameters.Add("@ID", SqlDbType.Int).Value = sv.ID; cm.Parameters.Add("@MASV", SqlDbType.NVarChar).Value = sv.MASV; cm.Parameters.Add("@TENSV", SqlDbType.NVarChar).Value = sv.TENSV; cm.Parameters.Add("@GIOITINH", SqlDbType.Int).Value = sv.GIOITINH; cm.Parameters.Add("@MALOP", SqlDbType.NVarChar).Value = sv.MALOP; cm.Parameters.Add("@DIACHI", SqlDbType.NVarChar).Value = sv.DIACHI; cm.CommandType = CommandType.Text; cm.Parameters.AddWithValue("@IMAGE", folderpath + Path.GetFileName(filePath)); File.Copy(filePath, Path.Combine(folderpath, Path.GetFileName(filePath)), true); } try { con.Open(); cm.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
private void btBoSungThem_Click(object sender, EventArgs e) { sinhvien sv = new sinhvien { MSV = (sinhvien.GetSinhVien().Count + 1).ToString(), HoTen = txtThemHoTen.Text, GioiTinh = cbThemGioiTinh.Checked, NgaySinh = DateTime.Parse(datetimeThemTime.Value.ToString("dd/MM/yyyy")), Diem1 = txtDiem1.Text, Diem2 = txtDiem2.Text }; if (MessageBox.Show( "Bạn có thật sự muốn xóa không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) { sinhvien.Add(sv); this.Close(); } }
public sinhvien getSinhVien(int masv) { string sql = "select * from sinhvien where masv=@masv"; connection.Open(); SqlCommand cmd = new SqlCommand(sql, connection); cmd.Parameters.AddWithValue("masv", masv); SqlDataReader rd = cmd.ExecuteReader(); sinhvien sv = new sinhvien(); if (rd.Read()) { sv.MaSv = (int)rd["masv"]; sv.HoTen = (string)rd["hoten"]; sv.DiaChi = (string)rd["diachi"]; sv.DienThoai = (string)rd["dienthoai"]; sv.MaLop = (int)rd["malop"]; } connection.Close(); return(sv); }
public List <sinhvien> dsSinhVien() { List <sinhvien> sinhviens = new List <sinhvien>(); string sql = "select * from sinhvien"; connection.Open(); SqlCommand cmd = new SqlCommand(sql, connection); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { sinhvien sv = new sinhvien(); sv.MaSv = (int)rd["masv"]; sv.HoTen = (string)rd["hoten"]; sv.DiaChi = (string)rd["diachi"]; sv.DienThoai = (string)rd["dienthoai"]; sv.MaLop = (int)rd["malop"]; sinhviens.Add(sv); } connection.Close(); return(sinhviens); }
public bool insertSinhVien(sinhvien sv, string filePath, string folderpath) { SqlConnection con = dc.getConnection(); string sqlInsert = "INSERT INTO SinhVien(Masv,Tensv,Gioitinh,Malop,Diachi,Image) VALUES(@MASV,@TENSV,@GIOITINH,@MALOP,@DIACHI,@IMAGE)"; cm = new SqlCommand(sqlInsert, con); if (filePath == "") { cm.Parameters.Add("@MASV", SqlDbType.NVarChar).Value = sv.MASV; cm.Parameters.Add("@TENSV", SqlDbType.NVarChar).Value = sv.TENSV; cm.Parameters.Add("@GIOITINH", SqlDbType.Int).Value = sv.GIOITINH; cm.Parameters.Add("@MALOP", SqlDbType.NVarChar).Value = sv.MALOP; cm.Parameters.Add("@DIACHI", SqlDbType.NVarChar).Value = sv.DIACHI; cm.Parameters.AddWithValue("@IMAGE", ""); } else { cm.Parameters.Add("@MASV", SqlDbType.NVarChar).Value = sv.MASV; cm.Parameters.Add("@TENSV", SqlDbType.NVarChar).Value = sv.TENSV; cm.Parameters.Add("@GIOITINH", SqlDbType.Int).Value = sv.GIOITINH; cm.Parameters.Add("@MALOP", SqlDbType.NVarChar).Value = sv.MALOP; cm.Parameters.Add("@DIACHI", SqlDbType.NVarChar).Value = sv.DIACHI; cm.CommandType = CommandType.Text; cm.Parameters.AddWithValue("@IMAGE", folderpath + Path.GetFileName(filePath)); File.Copy(filePath, Path.Combine(folderpath, Path.GetFileName(filePath)), true); } try { con.Open(); cm.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public DataTable Layketquahoctaptheotunglopvasinhvien(sinhvien sv) { string Layketquahoctaptheotunglopvasinhvien = @"SELECT kq.id, kq.Masv , sv.Tensv , lp.Tenlop, kh.Tenkhoa, mh.Tenmh, mh.Kyhoc, kq.Diem FROM dbo.Ketquahoctap kq INNER JOIN dbo.SinhVien sv ON sv.Masv = kq.Masv INNER JOIN dbo.Lop lp ON lp.Malop = sv.Malop INNER JOIN dbo.Khoa kh ON kh.Makhoa = lp.Makhoa INNER JOIN dbo.Monhoc mh ON mh.Mamh = kq.Mamh WHERE sv.Malop ='" + sv.MALOP + "' AND sv.Masv='" + sv.MASV + "'"; SqlConnection con = dc.getConnection(); adt = new SqlDataAdapter(Layketquahoctaptheotunglopvasinhvien, con); DataTable dt = new DataTable(); adt.Fill(dt); return(dt); }
public ActionResult Detail(int id) { if (Session["LoggedSV"] != null) { sinhvien sv = (sinhvien)Session["LoggedSV"]; ViewBag.sinhvien = sv.Tensv; } else { ViewBag.sinhvien = "Chưa đăng nhập"; } ChiTietPhongTro co = new ChiTietPhongTro(); co.phongtro = Db.phongtros.SingleOrDefault(n => n.Maphongtro == id); co.chunhatro = Db.chunhatros.SingleOrDefault(n => n.Machunhatro == co.phongtro.Machunhatro); ViewBag.Maphongtro = co.phongtro.Maphongtro; if (co.phongtro == null) { Response.StatusCode = 404; return(null); } return(View(co)); }
public void Edit(sinhvien sv) { foreach (sinhvien sv1 in db.sinhviens.ToList()) { if (sv1.mssv == sv.mssv) { sv1.hoten = sv.hoten; sv1.gioitinh = sv.gioitinh; sv1.lop = sv.lop; sv1.madk = sv.madk; sv1.makhoa = sv.makhoa; sv1.matkhau = sv.matkhau; sv1.email = sv.email; sv1.diachi = sv.diachi; sv1.ngaysinh = sv.ngaysinh; sv1.sdt = sv.sdt; db.SaveChanges(); } } }
public ArrayList getStudent() { ArrayList studentArray = new ArrayList(); MySql.Data.MySqlClient.MySqlDataReader mySQLReader = null; String sqlString = "SELECT * FROM sinhvien INNER JOIN lop ON lop.idlop=sinhvien.idlop;"; MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn); mySQLReader = cmd.ExecuteReader(); while (mySQLReader.Read()) { sinhvien sv = new sinhvien(); sv.MSSV = mySQLReader.GetInt32(0); sv.hoten = mySQLReader.GetString(1); sv.ngaysinh = mySQLReader.GetDateTime(2); sv.diemtongket = mySQLReader.GetFloat(4); sv.lop = mySQLReader.GetString(6); studentArray.Add(sv); } return(studentArray); }
public DataTable Layketquahoctaptheotunglopvasinhvien(sinhvien sv) { return(kqht_dal.Layketquahoctaptheotunglopvasinhvien(sv)); }
public DataTable timkiemtheolop(sinhvien sv) { return(trinh.timkiemtheolop(sv)); }
public void Xoasinhvien(sinhvien sv) { trinh.Xoasinhvien(sv); }
public void Insert(sinhvien sv) { db.sinhviens.Add(sv); db.SaveChanges(); }
public bool update(sinhvien lop) { return(sinhvienController.update(lop)); }
public bool add(sinhvien lop) { return(sinhvienController.insert(lop)); }
public ActionResult UploadFileSinhvien(HttpPostedFileBase FileUpload) { if (FileUpload == null || FileUpload.ContentLength == 0) { Session["ErrorMess"] = "Please select a excel file<br>"; return(RedirectToAction("Score", "PDT")); } else { if (FileUpload.FileName.EndsWith("xls") || (FileUpload.FileName.EndsWith("xlsx"))) { string location = Server.MapPath("~/FileExcel/" + FileUpload.FileName); if (System.IO.File.Exists(location)) { System.IO.File.Delete(location); } FileUpload.SaveAs(location); //Read data from excel Excel.Application application = new Excel.Application(); Excel.Workbook workbook = application.Workbooks.Open(location); Excel.Worksheet worksheet = workbook.ActiveSheet; Excel.Range range = worksheet.UsedRange; for (int row = 2; row <= range.Rows.Count; row++) { DateTime dtDOB = new DateTime(); sinhvien sv = new sinhvien(); sv.mssv = ((Excel.Range)range.Cells[row, 1]).Text; sv.hoten = ((Excel.Range)range.Cells[row, 2]).Text; dtDOB = DateTime.ParseExact(((Excel.Range)range.Cells[row, 4]).Text, "d/M/yyyy", CultureInfo.InvariantCulture); sv.ngaysinh = dtDOB; sv.diachi = ((Excel.Range)range.Cells[row, 5]).Text; sv.sdt = ((Excel.Range)range.Cells[row, 6]).Text; sv.email = ((Excel.Range)range.Cells[row, 7]).Text; sv.matkhau = ((Excel.Range)range.Cells[row, 8]).Text; sv.lop = ((Excel.Range)range.Cells[row, 9]).Text; sv.makhoa = ((Excel.Range)range.Cells[row, 10]).Text; sv.gioitinh = Boolean.Parse(((Excel.Range)range.Cells[row, 11]).Text); var kiemtratrung = SinhvienDAO.Instance.GetSVByMSSV(sv.mssv); if (kiemtratrung != null) { Session["ErrorMess"] = "Đã có sv!"; return(RedirectToAction("Index", "PDT")); } else { db.sinhviens.Add(sv); db.SaveChanges(); } } application.Quit(); var lst = db.diems.ToList(); Session["ErrorMess"] = "Success!"; return(RedirectToAction("Index", "PDT")); } else { Session["ErrorMess"] = "File type is incorrect<br>"; return(RedirectToAction("Index", "PDT")); } } }
public ActionResult EditSV(string mssv) { sinhvien sv = SinhvienDAO.Instance.GetSVByMSSV(mssv); return(View(sv)); }
//Dếm số bản ghi public int TongBanGhi(sinhvien sv) { return(trinh.TongBanGhi(sv)); }
public bool delete(sinhvien lop) { return(sinhvienController.delete(lop)); }
//Thêm giang vien public void Themsinhvien(sinhvien sv) { trinh.Themsinhvien(sv); }
public FormEditStudent(sinhvien SinhVien) { InitializeComponent(); this.SinhVien = SinhVien; }
//Sửa giang vien public void Suasinhvien(sinhvien sv) { trinh.Suasinhvien(sv); }