public ActionResult Edit(LoaiKhenThuong loaiKhenThuong) { var model = loaiKhenThuong; if (ModelState.IsValid) { database.Update(model); database.SaveChanges(); return(RedirectToAction("Index", "DanhGia")); } return(View(model)); }
public ActionResult Edit(ChucVu chucVu) { var model = chucVu; if (ModelState.IsValid) { database.Update(model); database.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Edit(PhongBan phongBan) { var model = phongBan; if (ModelState.IsValid) { database.Update(model); database.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Edit(HopDongLaoDong hopDongLaoDong) { var model = new ViewModelNV(); model.ListNhanVien = database.NhanViens.ToArray(); //model.hopDongLaoDong = database.HopDongLaoDongs.Where(x => x.Idnv == id).FirstOrDefault(); if (ModelState.IsValid) { database.Update(hopDongLaoDong); database.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <IActionResult> Edit(int id, KhenThuong khenThuong) { var model = new ViewModelDG(); model.ListNhanVien = database.NhanViens.ToArray(); model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray(); model.khenThuong = database.KhenThuongs.Where(x => x.Idkt == id).FirstOrDefault(); if (ModelState.IsValid) { model.khenThuong.Idnv = khenThuong.Idnv; model.khenThuong.IdloaiKt = khenThuong.IdloaiKt; model.khenThuong.Ngay = khenThuong.Ngay; database.Update(model.khenThuong); await database.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <IActionResult> Edit(int id, KyLuat kyLuat) { var model = new ViewModelDG(); model.ListNhanVien = database.NhanViens.ToArray(); model.ListloaiKyLuat = database.LoaiKyLuats.ToArray(); model.kyLuat = database.KyLuats.Where(x => x.Idkl == id).FirstOrDefault(); if (ModelState.IsValid) { model.kyLuat.Idnv = kyLuat.Idnv; model.kyLuat.IdloaiKl = kyLuat.IdloaiKl; model.kyLuat.Ngay = kyLuat.Ngay; database.Update(model.kyLuat); await database.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <IActionResult> Edit(int id, NhanVien nhanVien, HopDongLaoDong hopDongLaoDong) { var model = new ViewModelNV(); model.ListPhongBan = database.PhongBans.ToArray(); model.ListChucVu = database.ChucVus.ToArray(); model.ListHopDongLaoDong = database.HopDongLaoDongs.ToArray(); model.nhanVien = database.NhanViens.Where(x => x.Idnv == id).FirstOrDefault(); model.hopDongLaoDong = database.HopDongLaoDongs.Where(x => x.Idnv == id).FirstOrDefault(); if (nhanVien.TenNv != null && nhanVien.DienThoai.Length <= 12 && nhanVien.DiaChi != null && nhanVien.Cmnd >= 100000000 && nhanVien.Cmnd < 999999999 && nhanVien.NgaySinh.Value.Year <= (DateTime.Now.Year - 18)) { model.nhanVien.TenNv = nhanVien.TenNv; model.nhanVien.Idpb = nhanVien.Idpb; model.nhanVien.Idcv = nhanVien.Idcv; model.nhanVien.GioiTinh = nhanVien.GioiTinh; model.nhanVien.Cmnd = nhanVien.Cmnd; model.nhanVien.DiaChi = nhanVien.DiaChi; model.nhanVien.DienThoai = nhanVien.DienThoai; model.nhanVien.Email = nhanVien.Email; model.nhanVien.TinhTrang = nhanVien.TinhTrang; model.nhanVien.NgaySinh = nhanVien.NgaySinh; model.hopDongLaoDong.NgayKy = hopDongLaoDong.NgayKy; model.hopDongLaoDong.LuongCb = hopDongLaoDong.LuongCb; #region Save Image from wwwroot/img string wwwRootPath = hostEnvironment.WebRootPath; string fileName; string extension; if (nhanVien.UploadHinh != null) { fileName = Path.GetFileNameWithoutExtension(nhanVien.UploadHinh.FileName); extension = Path.GetExtension(nhanVien.UploadHinh.FileName); model.nhanVien.HinhAnh = fileName += extension; string path = Path.Combine(wwwRootPath + "/img/", fileName); using (var fileStream = new FileStream(path, FileMode.Create)) { await nhanVien.UploadHinh.CopyToAsync(fileStream); } } #endregion //string wwwRootPath = hostEnvironment.WebRootPath; //string fileName1; //string extension1; //if (nhanVien.UploadHinh != null) //{ // fileName1 = Path.GetFileNameWithoutExtension(nhanVien.UploadHinh.FileName); // extension1 = Path.GetExtension(nhanVien.UploadHinh.FileName); // model.nhanVien.HinhAnh = "/img/" + fileName1 + extension1; // string path1 = Path.Combine(wwwRootPath + "/img/", fileName1); // using (var fileStream = new FileStream(path1, FileMode.Create)) // { // await nhanVien.UploadHinh.CopyToAsync(fileStream); // } //} database.Update(model.nhanVien); database.Update(model.hopDongLaoDong); await database.SaveChangesAsync(); return(RedirectToAction("Index", "NhanVien")); } return(View(model)); }