public bool Update(SinhVienModel model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_SinhVien_update", "@masv", model.masv, "@tensv", model.tensv, "@gioitinh", model.gioitinh, "@ngaysinh", model.ngaysinh, "@quequan", model.quequan, "@malop", model.malop, "@magv", model.magv, "@namhoc", model.namhoc, "@sdt", model.sdt, "@avata", model.avata, "@ngaysua", model.ngaysua, "@ngaytao", model.ngaytao, "@trangthai", model.trangthai); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
public bool CapNhatThongTin(SinhVienModel sv) { string message = ""; var data = Execute("sp_CapNhatThongTinCaNhanSinhVien", out message, new Dictionary <string, object> { { "MaSinhVien", sv.MaSinhVien.Trim() }, { "TenSinhVien", sv.TenSinhVien }, { "NgaySinh", sv.NgaySinh }, { "ThangSinh", sv.ThangSinh }, { "NamSinh", sv.NamSinh }, { "GioiTinh", sv.GioiTinh }, { "DiaChi", sv.DiaChi }, { "MaDanToc", sv.MaDanToc }, { "TonGiao", sv.TonGiao }, { "DienThoai", sv.DienThoai }, { "Email", sv.Email.Trim() }, { "CMND", sv.CMND }, { "MaChiDoan", sv.MaChiDoan.Trim() }, { "MaTinhThanhPho", sv.MaTinhThanhPho }, { "MaQuanHuyen", sv.MaQuanHuyen }, { "MaPhuongXa", sv.MaPhuongXa }, { "Hinh", sv.Hinh.Trim() }, { "TinhTrangHD", sv.TinhTrangHD } }); return(data); }
public ActionResult Create(SinhVienModel sinhvien) { try { sinhvienCollection.InsertOne(sinhvien); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(string id, SinhVienModel sinhvien) { try { sinhvienCollection.DeleteOne(Builders <SinhVienModel> .Filter.Eq("_id", ObjectId.Parse(id))); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(string id, SinhVienModel sinhvien) { try { var filter = Builders <SinhVienModel> .Filter.Eq("_id", ObjectId.Parse(id)); var update = Builders <SinhVienModel> .Update .Set("HoTen", sinhvien.HoTen) .Set("QueQuan", sinhvien.QueQuan) .Set("SDT", sinhvien.SDT); var result = sinhvienCollection.UpdateOne(filter, update); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Login(LoginModel user) { if (user == null) { ViewBag.ErrorMessage = "User null"; return(View(user)); } if (string.IsNullOrEmpty(user.UserName)) { return(View(user)); } if (string.IsNullOrEmpty(user.Password)) { return(View(user)); } var userLogin = UserDAL.Login(user); if (userLogin == null) { ModelState.AddModelError("", "UserName/Password is incorrect!"); return(View("")); } SinhVienModel student = new SinhVienModel(); student = UserDAL.LoadProfile(userLogin.MaSinhVien); var userSession = new UserLogin(); userSession.UserName = userLogin.UserName; userSession.Password = userLogin.Password; userSession.MaSinhVien = userLogin.MaSinhVien; userSession.MaKhoa = userLogin.MaKhoa; userSession.MaChiDoan = userLogin.MaChiDoan; userSession.TenSinhVien = student.TenSinhVien; Session.Add(CommonConstants.USER_SESSION, userSession); // return(RedirectToAction("Index", "Home")); }
public IHttpActionResult TaoMoi(TaoHSModel model) { IHttpActionResult httpActionResult; if (string.IsNullOrEmpty(model.MaSV)) { err.Add("Mã sinh viên là trường bắt buộc"); } if (string.IsNullOrEmpty(model.HoTen)) { err.Add("Họ tên là trường bắt buộc"); } Lop lop = db.Lops.FirstOrDefault(x => x.Id == model.Lop); if (lop == null) { err.Add("Lớp không tồn tại"); } if (err.errors.Count == 0) { SinhVien sv = new SinhVien(); sv.MaSV = model.MaSV; sv.HoTen = model.HoTen; sv.Lop = lop; sv.NTNS = model.NTNS; sv = db.SinhViens.Add(sv); db.SaveChanges(); SinhVienModel viewmodel = new SinhVienModel(sv); httpActionResult = Ok(viewmodel); } else { httpActionResult = new ErrorActionResult(Request, System.Net.HttpStatusCode.BadRequest, err); } return(httpActionResult); }
public ActionResult CapNhatThongTinSinhVien(SinhVienModel sinhvien) { if (string.IsNullOrEmpty(sinhvien.Hinh)) { sinhvien.Hinh = "s"; } ThongTinSinhVienDAL sv = new ThongTinSinhVienDAL(); try { sv.CapNhatThongTin(sinhvien); ViewBag.Message = "Cập Nhật Thành Công"; }catch (Exception ex) { ViewBag.Message = string.Format(ex.Message); } ThongTinSinhVienDAL tt = new ThongTinSinhVienDAL(); ModelState.Clear(); var model = Session["USER_SESSION"]; ViewBag.User = model; return(View("ThongTinCaNhanSinhVien", tt.ThongTinSinhVien(ViewBag.User.MaSinhVien))); }
public SinhVienModel UpdateSinhVien([FromBody] SinhVienModel model) { _SinhVienBusiness.Update(model); return(model); }
public bool Update(SinhVienModel model) { return(_res.Update(model)); }
public bool Create(SinhVienModel model) { return(_res.Create(model)); }