public async Task <ActionResult> Create(ChamCong chamCong, KyLuat kyLuat) { var model = new ViewModelCC(); model.ListNhanVien = database.NhanViens.ToArray(); model.ListloaiKyLuat = database.LoaiKyLuats.ToArray(); if (ModelState.IsValid) { chamCong.Idnv = int.Parse(HttpContext.Session.GetString("IDNV")); chamCong.Ngay = DateTime.Now; chamCong.TrangThai = true; database.Add(chamCong); await database.SaveChangesAsync(); if (chamCong.Ngay.Hour > 7 || chamCong.Ngay.Hour == 7 && chamCong.Ngay.Minute >= 1) { kyLuat.Idnv = int.Parse(HttpContext.Session.GetString("IDNV")); kyLuat.IdloaiKl = 2; kyLuat.Ngay = DateTime.Now; database.Add(kyLuat); await database.SaveChangesAsync(); } return(RedirectToAction("Index", "ChamCong")); } return(View(model)); }
public ActionResult Create(ChucVu chucVu) { if (ModelState.IsValid) { database.Add(chucVu); database.SaveChanges(); return(RedirectToAction("Index")); } return(View(chucVu)); }
public ActionResult Create(LoaiKhenThuong loaiKhenThuong) { if (ModelState.IsValid) { database.Add(loaiKhenThuong); database.SaveChanges(); return(RedirectToAction("Index", "DanhGia")); } return(View(loaiKhenThuong)); }
public async Task <ActionResult> Create(NhanVien nhanVien, HopDongLaoDong hopDongLaoDong, TaiKhoan taiKhoan) { var model = new ViewModelNV(); model.ListPhongBan = database.PhongBans.ToArray(); model.ListChucVu = database.ChucVus.ToArray(); //model.ListHopDongLaoDong = database.HopDongLaoDongs.ToArray(); if (ModelState.IsValid) { #region Save Image from wwwroot/img string wwwRootPath = hostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(nhanVien.UploadHinh.FileName); string extension = Path.GetExtension(nhanVien.UploadHinh.FileName); 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 nhanVien.TinhTrang = true; database.Add(nhanVien); await database.SaveChangesAsync(); hopDongLaoDong.Idnv = nhanVien.Idnv; database.Add(hopDongLaoDong); await database.SaveChangesAsync(); taiKhoan.Idnv = nhanVien.Idnv; taiKhoan.Pass = "******" + nhanVien.Idnv; database.Add(taiKhoan); await database.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(PhongBan phongBan) { if (ModelState.IsValid) { database.Add(phongBan); database.SaveChanges(); return(RedirectToAction("Index")); } return(View(phongBan)); }
public async Task <ActionResult> Create(KhenThuong khenThuong) { var model = new ViewModelDG(); model.ListNhanVien = database.NhanViens.ToArray(); model.ListLoaikhenThuong = database.LoaiKhenThuongs.ToArray(); if (ModelState.IsValid) { database.Add(khenThuong); await database.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); }