Exemplo n.º 1
0
        public ActionResult UpdateProject([Bind(Include = "Id,name,startDate,endDate,priority,taskNo,status,manager")] Project project)
        {
            project.status = "In-Process";

            if (ModelState.IsValid)
            {
                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("AddProject"));
            }
            return(View(project));
        }
Exemplo n.º 2
0
        public ActionResult Edit([Bind(Include = "TaiKhoanId,Username,HoTen,Password,LoaiTaiKhoanId")] TaiKhoan user)
        {
            ViewBag.AllowChangePass = (Request.Form["AllowChangePass"] == "on" ? true : false).ToString().ToLower();
            if (ModelState.IsValid)
            {
                bool valid = true;
                if (user.Username + "" == "")
                {
                    AddError("error", "Chưa Nhập Tên đăng nhập.");
                    valid = false;
                }
                if (user.Password + "" == "")
                {
                    AddError("error", "Chưa chọn Mật khẩu.");
                    valid = false;
                }
                if (user.HoTen + "" == "")
                {
                    AddError("error", "Chưa Nhập Họ tên.");
                    valid = false;
                }
                if (user.LoaiTaiKhoanId + "" == "")
                {
                    AddError("error", "Chưa chọn Vai trò.");
                    valid = false;
                }
                if (valid)
                {
                    db.Entry(user).State = EntityState.Modified;
                    if (Request.Form["AllowChangePass"] == "on" ? true : false)
                    {
                        string ps = Security.EncryptSha1(Security.EncryptMd5(user.Password).ToLower());
                        user.Password = ps;
                        db.Entry(user).Property("Password").IsModified = true;
                    }
                    else
                    {
                        db.Entry(user).Property("Password").IsModified = false;
                    }
                    ;
                    db.SaveChanges();

                    ViewBag.UserCreatedBy = db.TaiKhoans.ToList();

                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.LoaiTaiKhoanId = new SelectList(db.LoaiTaiKhoans, "LoaiTaiKhoanId", "TenLoaiTaiKhoan", user.LoaiTaiKhoanId);
            return(View(user));
        }
        public IHttpActionResult PutProject(int id, Project project)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != project.project_id)
            {
                return(BadRequest());
            }

            db.Entry(project).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "LichId,MocNgay")] QuanLyLich lich)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lich).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(lich));
 }
Exemplo n.º 5
0
 public ActionResult EditUser([Bind(Include = "Id,firstName,lastName,employeeId")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("AddUser"));
     }
     return(View(user));
 }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "DeTaiId,TenDeTai,MoTa,SoLuongThanhVien,NgayTao,NgayDangKy")] DeTai deTai)
 {
     if (ModelState.IsValid)
     {
         db.Entry(deTai).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(deTai));
 }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "SinhVienId,GioiTinh,HoTen,NgaySinh,SoTCHT,SoTCCL,TrangThai")] SinhVien sinhVien)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sinhVien).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sinhVien));
 }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "LoaiTaiKhoanId,TenLoaiTaiKhoan")] LoaiTaiKhoan loaiTaiKhoan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loaiTaiKhoan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(loaiTaiKhoan));
 }
Exemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "NhomSVId,TenNhom")] NhomSV nhomSV)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nhomSV).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(nhomSV));
 }
Exemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "KhoaHocID,TenKhoaHoc,NamHocHocKyId")] KhoaHoc khoaHoc)
 {
     if (ModelState.IsValid)
     {
         db.Entry(khoaHoc).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.NamHocHocKyId = new SelectList(db.NamHocs, "NamHocHocKyId", "TenKhoaHoc", khoaHoc.NamHocHocKyId);
     return(View(khoaHoc));
 }
Exemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "NamHocHocKyId,TenNamHocHocKy,TuNgay,DenNgay,NamHocHocKyIdRoot")] NamHoc namHoc)
 {
     if (ModelState.IsValid)
     {
         db.Entry(namHoc).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.NamHocHocKyIdRoot = new SelectList(db.NamHocs, "NamHocHocKyId", "TenNamHocHocKy", namHoc.NamHocHocKyIdRoot);
     return(View(namHoc));
 }
Exemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "GiangVienId,HoTen,GioiTinh")] GiangVien giangvien)
 {
     if (ModelState.IsValid)
     {
         db.Entry(giangvien).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.GiangVienId = new SelectList(db.GiangViens, "GiangVienId", "HoTen", giangvien.GiangVienId);
     return(View(giangvien));
 }
Exemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "TinTucId,TieuDe,NoiDung,NgayDang,TaiKhoanId")] TinTucThongBao tinTucThongBao)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tinTucThongBao).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TaiKhoanId = new SelectList(db.TaiKhoans, "TaiKhoanId", "Username", tinTucThongBao.TaiKhoanId);
     return(View(tinTucThongBao));
 }
Exemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "NganhId,TenNganh,KhoaId")] Nganh nganh)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nganh).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.KhoaId = new SelectList(db.Khoas, "KhoaId", "TenKhoa", nganh.KhoaId);
     return(View(nganh));
 }
 public ActionResult Edit([Bind(Include = "Khoa.TenKhoa,GiangVien.HoTen,TuNgay,DenNgay,KhoaId,GiangVienId")] GiangVienThuocKhoa giangVienThuocKhoa)
 {
     if (ModelState.IsValid)
     {
         db.Entry(giangVienThuocKhoa).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.GiangVienId = new SelectList(db.GiangViens, "GiangVienId", "HoTen", giangVienThuocKhoa.GiangVienId);
     ViewBag.KhoaId      = new SelectList(db.Khoas, "KhoaId", "TenKhoa", giangVienThuocKhoa.KhoaId);
     return(View(giangVienThuocKhoa));
 }
Exemplo n.º 16
0
 public ActionResult Edit([Bind(Include = "KhoaId,SinhVienId,TuNgay,DenNgay")] SinhVienThuocKhoa sinhVienThuocKhoa)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sinhVienThuocKhoa).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("DSSV", new { KId = sinhVienThuocKhoa.KhoaId }));
     }
     ViewBag.KhoaId     = new SelectList(db.Khoas, "KhoaId", "TenKhoa", sinhVienThuocKhoa.KhoaId);
     ViewBag.SinhVienId = new SelectList(db.SinhViens, "SinhVienId", "HoTen", sinhVienThuocKhoa.SinhVienId);
     return(View(sinhVienThuocKhoa));
 }
Exemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "NhomSVId,DeTaiId,NgayPhanDeTai,GhiChu")] PhanDeTaiChoNhomSV phanDeTaiChoNhomSV)
 {
     if (ModelState.IsValid)
     {
         db.Entry(phanDeTaiChoNhomSV).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DeTaiId  = new SelectList(db.DeTais, "DeTaiId", "TenDeTai", phanDeTaiChoNhomSV.DeTaiId);
     ViewBag.NhomSVId = new SelectList(db.NhomSVs, "NhomSVId", "TenNhom", phanDeTaiChoNhomSV.NhomSVId);
     return(View(phanDeTaiChoNhomSV));
 }
Exemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "SinhVienId,NganhId,TuNgay,DenNgay,KhoaHocID")] SinhVienNganhHoc sinhVienNganhHoc)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sinhVienNganhHoc).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("DSSV", new { NId = sinhVienNganhHoc.NganhId }));
     }
     ViewBag.NganhId    = new SelectList(db.Nganhs, "NganhId", "TenNganh", sinhVienNganhHoc.NganhId);
     ViewBag.SinhVienId = new SelectList(db.SinhViens, "SinhVienId", "HoTen", sinhVienNganhHoc.SinhVienId);
     return(View(sinhVienNganhHoc));
 }
Exemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "DotKhoaLuanId,TenDotKhoaLuan,NamHocHocKyId")] DotKhoaLuan dotKhoaLuan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dotKhoaLuan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.NamHocHocKyId = new SelectList(db.NamHocs, "NamHocHocKyId", "TenNamHocHocKy", dotKhoaLuan.NamHocHocKyId);
     ViewBag.DotKhoaLuanId = new SelectList(db.QuanLyLiches, "DotKhoaLuanId", "TieuDe", dotKhoaLuan.DotKhoaLuanId);
     return(View(dotKhoaLuan));
 }
Exemplo n.º 20
0
        public Step UpdateStep(Step _s, List <int> _workerIds)
        {
            try
            {
                var numberOfUpdated = 0;
                using (var context = new ProjectManagementEntities())
                {
                    var step = context.Step.FirstOrDefault(x => x.Id == _s.Id);

                    if (step != null)
                    {
                        step.AssigneeUser = _s.AssigneeUser;
                        step.Description  = _s.Description;
                        step.EndDate      = _s.EndDate;
                        step.MilestoneId  = _s.MilestoneId;
                        step.Name         = _s.Name;
                        step.SprintId     = _s.SprintId;
                        step.StartDate    = _s.StartDate;

                        numberOfUpdated = context.SaveChanges();

                        var stepPerson = context.StepPerson.Where(x => x.StepId == _s.Id).ToList();

                        if (stepPerson.Count() > 0)
                        {
                            foreach (var stepPersonItem in stepPerson)
                            {
                                var stepPersonDetail = context.StepPersonDetail.Where(x => x.StepPersonId == stepPersonItem.Id).ToList();

                                if (stepPersonDetail.Count() > 0)
                                {
                                    foreach (var stepPersonDetailItem in stepPersonDetail)
                                    {
                                        context.Entry(stepPersonDetailItem).State = EntityState.Deleted;
                                        context.SaveChanges();
                                    }
                                }

                                context.Entry(stepPersonItem).State = EntityState.Deleted;
                                context.SaveChanges();
                            }
                        }

                        foreach (var item in _workerIds)
                        {
                            var newStepPerson = new StepPerson()
                            {
                                PersonId = item,
                                StepId   = _s.Id
                            };

                            context.StepPerson.Add(newStepPerson);
                            context.SaveChanges();
                        }
                        return(numberOfUpdated > 0 ? _s : null);
                    }
                    return(null);
                }
            }
            catch (System.Exception exc)
            {
                throw exc;
            }
        }