public ActionResult updateLoaiChamDut(String json) { dynamic js = JObject.Parse(json); String tenLoaiChamDut = js.tenLoaiChamDut; String soQD = js.soQD; String ngayQD = js.ngayQD; String ngayCD = js.ngayCD; int soQD1 = Int32.Parse(soQD.Trim()); using (QUANGHANHABCEntities db = new QUANGHANHABCEntities()) { ChamDut_NhanVien nv = (from p in db.ChamDut_NhanVien where p.MaQuyetDinh == soQD1 select p).SingleOrDefault(); nv.LoaiChamDut = tenLoaiChamDut; if (isValidateDateTime(ngayCD)) { nv.NgayChamDut = Convert.ToDateTime(ngayCD); } QuyetDinh cd = (from p in db.QuyetDinhs where p.SoQuyetDinh == soQD select p).SingleOrDefault(); if (isValidateDateTime(ngayQD)) { cd.NgayQuyetDinh = Convert.ToDateTime(ngayQD); } db.SaveChanges(); ViewBag.nameDepartment = "quanlyhoso"; return(Json(new { success = true, draw = Request["draw"] }, JsonRequestBehavior.AllowGet)); } }
public ActionResult updateThongTinCoBan(String json) { dynamic js = JObject.Parse(json); String hoVaTen = js.hoVaTen; String sothe = js.sothe; String ngaythangnamsinh = js.ngaythangnamsinh; String donvicd = js.donvicd; String soBH = js.soBH; String sodt = js.sodt; String diachithuongtru = js.diachithuongtru; using (QUANGHANHABCEntities db = new QUANGHANHABCEntities()) { NhanVien nv = (from p in db.NhanViens where p.MaNV == sothe select p).SingleOrDefault(); nv.Ten = hoVaTen; nv.SoBHXH = soBH; nv.SoDienThoai = sodt; nv.NoiOHienTai = diachithuongtru; if (isValidateDateTime(ngaythangnamsinh)) { nv.NgaySinh = Convert.ToDateTime(ngaythangnamsinh); } ChamDut_NhanVien cd = (from p in db.ChamDut_NhanVien where p.MaNV == sothe select p).SingleOrDefault(); // cd.DonViKhiChamDut = donvicd; db.SaveChanges(); ViewBag.nameDepartment = "quanlyhoso"; return(Json(new { success = true, draw = Request["draw"] }, JsonRequestBehavior.AllowGet)); } }
public ActionResult TLHD(string id, string soQD, string lydo, string dateQD, string dateTLHD, string group1, string group2, string elseCase) { QUANGHANHABCEntities db = new QUANGHANHABCEntities(); using (DbContextTransaction dbct = db.Database.BeginTransaction()) { try { string dateQDFix = ""; if (dateQD != null && !dateQD.Equals("")) { string[] arr1 = dateQD.Split('/'); for (int i = 0; i < arr1.Length; i++) { dateQDFix = arr1[1] + "/" + arr1[0] + "/" + arr1[2]; } } string[] arr2 = dateTLHD.Split('/'); string dateTLHDFix = ""; for (int i = 0; i < arr2.Length; i++) { dateTLHDFix = arr2[1] + "/" + arr2[0] + "/" + arr2[2]; } var emp = db.NhanViens.Where(x => x.MaNV == id).FirstOrDefault(); emp.TrangThaiLamViec = "Đã chấm dứt"; db.Entry(emp).State = EntityState.Modified; QuyetDinh qd = new QuyetDinh(); qd.SoQuyetDinh = soQD; if (!dateQDFix.Equals("") && dateQDFix != null) { qd.NgayQuyetDinh = Convert.ToDateTime(dateQDFix); } db.QuyetDinhs.Add(qd); ChamDut_NhanVien tlhd = new ChamDut_NhanVien(); tlhd.MaNV = id; if (lydo.Equals("Đi đơn vị ngoài")) { tlhd.LoaiChamDut = group1; } else if (lydo.Equals("Các trường hợp khác")) { if (group2.Equals("on")) { tlhd.LoaiChamDut = elseCase; } else { tlhd.LoaiChamDut = group2; } } else { tlhd.LoaiChamDut = lydo; } tlhd.NgayChamDut = Convert.ToDateTime(dateTLHDFix); db.ChamDut_NhanVien.Add(tlhd); db.SaveChanges(); dbct.Commit(); return(RedirectToAction("Search")); } catch (Exception) { dbct.Rollback(); string output = ""; if (output == "") { output += "Vui lòng nhập ngày chấm dứt"; } Response.Write(output); return(new HttpStatusCodeResult(400)); } } }