コード例 #1
0
        public int ThemNhiemVu(ThemNhiemVuMoel model)
        {
            var iMaNguoiDangCode = CurrentContext.GetUser().iMaThanhVienCode;
            var task             = new Models.NhiemVu();

            task.dNgayLap             = DateTime.Now;
            task.dNgayBD              = model.dNgayBD;
            task.dNgayKT              = model.dNgayKT;
            task.iMaNguoiDuocGiaoCode = 14;
            task.vTenNhiemVu          = model.vTenNhiemVu;
            task.vMoTa            = model.vMoTa;
            task.iMaNguoiDangCode = iMaNguoiDangCode;
            task.iMaTrangThaiCode = 1;
            task.iMaModuleCode    = model.iMaModuleCode;
            try
            {
                using (var db = new dbnhiemvuEntities())
                {
                    db.NhiemVus.Add(task);
                    db.SaveChanges();
                }
                return(task.iMaNhiemVuCode);
            }
            catch
            {
                return(0);
            }
        }
コード例 #2
0
 public ActionResult GetChiTietLoi(int iMaNhiemVuCode)
 {
     using (var db = new dbnhiemvuEntities()) {
         var result = db.ChiTietLois.Where(m => m.iMaNhiemVuCode == iMaNhiemVuCode).ToList();
         return(PartialView("_ChiTietLoiPartial", result));
     }
 }
コード例 #3
0
        public ActionResult LayDanhSachNhiemVuduocGiao(int id)
        {
            dbnhiemvuEntities     db = new dbnhiemvuEntities();
            List <LayDanhSachLoi> danhsachnhiemvuduocgiao = new List <LayDanhSachLoi>();

            try
            {
                danhsachnhiemvuduocgiao = (from nv in db.NhiemVus
                                           join tv in db.ThanhViens on nv.iMaNguoiDangCode equals tv.iMaThanhVienCode
                                           join tv1 in db.ThanhViens on nv.iMaNguoiDuocGiaoCode equals tv1.iMaThanhVienCode
                                           where nv.iMaTrangThaiCode == 1 && nv.iMaNguoiDuocGiaoCode == id
                                           select new LayDanhSachLoi
                {
                    iMaNhiemVuCode = nv.iMaNhiemVuCode,
                    vNguoiDang = tv.vTenDangNhap,
                    vNguoiDuocGiaoCode = tv1.vTenDangNhap,
                    vMoTa = nv.vMoTa,
                    vTenNhiemVu = nv.vTenNhiemVu,
                    iMaTrangThaiCode = nv.iMaTrangThaiCode
                }).ToList();
            }
            catch (DbEntityValidationException e)
            {
                throw e;
            }
            return(Json(danhsachnhiemvuduocgiao));
        }
コード例 #4
0
        public ActionResult ThanhVien()
        {
            dbnhiemvuEntities db = new dbnhiemvuEntities();

            ViewBag.ListNguoiDuocGiaoTask = db.ThanhViens.ToList();
            return(View());
        }
コード例 #5
0
        public ActionResult LayNhiemVuCanSua()
        {
            dbnhiemvuEntities db      = new dbnhiemvuEntities();
            List <LayNhiemVu> nhiemvu = new List <LayNhiemVu>();

            try
            {
                nhiemvu = (from nv in db.NhiemVus
                           join tv in db.ThanhViens on nv.iMaNguoiDangCode equals tv.iMaThanhVienCode
                           join tv1 in db.ThanhViens on nv.iMaNguoiDuocGiaoCode equals tv1.iMaThanhVienCode
                           where nv.iMaTrangThaiCode == 5
                           select new LayNhiemVu
                {
                    iMaNhiemVuCode = nv.iMaNhiemVuCode,
                    vNguoiDang = tv.vTenDangNhap,
                    vNguoiDuocGiaoCode = tv1.vTenDangNhap,
                    vMoTa = nv.vMoTa,
                    vTenNhiemVu = nv.vTenNhiemVu,
                    dNgayBD = nv.dNgayBD,
                    dNgayKT = nv.dNgayKT,
                    iMaTrangThaiCode = nv.iMaTrangThaiCode
                }).ToList();
            }
            catch (DbEntityValidationException e)
            {
                throw e;
            }
            return(Json(nhiemvu));
        }
コード例 #6
0
        public ActionResult NopNhiemVu(int id, int trangthai)
        {
            dbnhiemvuEntities db = new dbnhiemvuEntities();

            Models.NhiemVu nhiemvu = new Models.NhiemVu();
            try
            {
                if (trangthai == 2)
                {
                    nhiemvu = db.NhiemVus.Find(id);
                    nhiemvu.iMaTrangThaiCode = 3;
                    db.SaveChanges();
                }
                else if (trangthai == 3)
                {
                    nhiemvu = db.NhiemVus.Find(id);
                    nhiemvu.iMaTrangThaiCode = 5;
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(true));
        }
コード例 #7
0
        public ActionResult LuuLoiCanSua(string noidungloi, int id)
        {
            dbnhiemvuEntities db         = new dbnhiemvuEntities();
            ChiTietLoi        chitietloi = new ChiTietLoi();

            Models.NhiemVu nhiemvu = new Models.NhiemVu();
            try
            {
                nhiemvu = db.NhiemVus.Find(id);
                nhiemvu.iMaTrangThaiCode  = 5;
                chitietloi.iMaNhiemVuCode = id;
                chitietloi.vChiTietLoi    = noidungloi;
                chitietloi.iTrangThai     = 1;
                db.ChiTietLois.Add(chitietloi);
                db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            return(Json(chitietloi));
        }
コード例 #8
0
 public ActionResult GetNhiemVuTrangThai(int?iMaNguoiDuocGiaoCode, int?iMaTrangThaiCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var list = db.NhiemVus.ToList();
         if (iMaNguoiDuocGiaoCode.HasValue && iMaNguoiDuocGiaoCode != 0)
         {
             list = list.Where(m => m.iMaNguoiDuocGiaoCode == iMaNguoiDuocGiaoCode).ToList();
         }
         if (iMaTrangThaiCode.HasValue && iMaTrangThaiCode != 0)
         {
             list = list.Where(m => m.iMaTrangThaiCode == iMaTrangThaiCode).ToList();
         }
         var result = (from nv in list
                       join tv in db.ThanhViens on nv.iMaNguoiDangCode equals tv.iMaThanhVienCode
                       join tv1 in db.ThanhViens on nv.iMaNguoiDuocGiaoCode equals tv1.iMaThanhVienCode
                       select new LayNhiemVu
         {
             iMaNhiemVuCode = nv.iMaNhiemVuCode,
             vNguoiDang = tv.vTenDangNhap,
             vNguoiDuocGiaoCode = tv1.vTenDangNhap,
             vMoTa = nv.vMoTa,
             vTenNhiemVu = nv.vTenNhiemVu,
             iMaTrangThaiCode = nv.iMaTrangThaiCode,
             dNgayBD = nv.dNgayBD,
             dNgayKT = nv.dNgayKT,
         }).ToList();
         return(Json(result));
     }
 }
コード例 #9
0
 public ActionResult ChiTietNhiemVu(int?iMaNhiemVuCode)
 {
     if (!iMaNhiemVuCode.HasValue)
     {
         return(RedirectToAction("Index", "Project"));
     }
     using (var db = new dbnhiemvuEntities())
     {
         var result = (from t in db.NhiemVus
                       join s in db.ThanhViens on t.iMaNguoiDangCode equals s.iMaThanhVienCode
                       join r in db.ThanhViens on t.iMaNguoiDuocGiaoCode equals r.iMaThanhVienCode
                       join tt in db.TrangThais on t.iMaTrangThaiCode equals tt.iMaTrangThaiCode
                       where t.iMaNhiemVuCode == iMaNhiemVuCode
                       select new ChiTietNhiemVuViewModel
         {
             iMaNguoiDangCode = t.iMaNguoiDangCode,
             iMaNguoiDuocGiaoCode = t.iMaNguoiDuocGiaoCode,
             iMaNhiemVuCode = t.iMaNhiemVuCode,
             iMaTrangThaiCode = t.iMaTrangThaiCode,
             dNgayBD = t.dNgayBD,
             dNgayKT = t.dNgayKT,
             dNgayLap = t.dNgayLap,
             vMoTa = t.vMoTa,
             vTenNguoiDang = s.vTenDangNhap,
             vTenNguoiDuocGiao = r.vTenDangNhap,
             vTenNhiemVu = t.vTenNhiemVu,
             vTenTrangThai = tt.vTenTrangThai
         }).FirstOrDefault();
         return(View(result));
     }
 }
コード例 #10
0
        public int BaoCaoNhiemVu(BaoCaoNhiemVuViewModel model)
        {
            try
            {
                using (var db = new dbnhiemvuEntities())
                {
                    var baocao = new BaoCao();
                    baocao.iMaNhiemVuCode  = model.iMaNhiemVuCode;
                    baocao.vMoTa           = model.vMoTa;
                    baocao.vDuongDanTapTin = model.vDuongDanTapTin;
                    db.BaoCaos.Add(baocao);
                    db.SaveChanges();
                    if (model.iMaChiTietLoiCode != 0)
                    {
                        var loi = db.ChiTietLois.Find(model.iMaChiTietLoiCode);
                        loi.iTrangThai = 2;
                        db.SaveChanges();
                    }

                    return(baocao.iMaBaoCaoCode);
                }
            }
            catch
            {
                return(0);
            }
        }
コード例 #11
0
        public bool ThayDoiTrangThai(int iMaNhiemVuCode, int iMaTrangThaiCode)
        {
            try
            {
                using (var db = new dbnhiemvuEntities())
                {
                    var task = db.NhiemVus.Find(iMaNhiemVuCode);
                    if (task.iMaTrangThaiCode == 5)
                    {
                        var loi = db.ChiTietLois.Where(m => m.iMaNhiemVuCode == iMaNhiemVuCode && m.iTrangThai == 1).ToList();
                        if (loi.Count == 0)
                        {
                            task.iMaTrangThaiCode = iMaTrangThaiCode;
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        task.iMaTrangThaiCode = iMaTrangThaiCode;
                    }

                    db.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
コード例 #12
0
        public static bool IsLogged()
        {
            var flag = HttpContext.Current.Session["isLogin"];

            if (flag == null || (int)flag == 0)
            {
                // Kiểm tra trong cookie
                // nếu có cookie , dùng thông tin trong cookie
                // để tái tạo lại session
                if (HttpContext.Current.Request.Cookies["userID"] != null)
                {
                    int userIdCookie = Convert.ToInt32(HttpContext.Current.Request.Cookies["userID"].Value);
                    using (var db = new dbnhiemvuEntities())
                    {
                        var user = db.ThanhViens.Where(u => u.iMaThanhVienCode == userIdCookie).FirstOrDefault();
                        HttpContext.Current.Session["isLogin"] = 1;
                        HttpContext.Current.Session["user"]    = user;
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
コード例 #13
0
 public ActionResult GetNhiemVuModule(int iMaModuleCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var result = (from nv in db.NhiemVus
                       join tv in db.ThanhViens on nv.iMaNguoiDangCode equals tv.iMaThanhVienCode
                       join tv1 in db.ThanhViens on nv.iMaNguoiDuocGiaoCode equals tv1.iMaThanhVienCode
                       join tt in db.TrangThais on nv.iMaTrangThaiCode equals tt.iMaTrangThaiCode
                       where nv.iMaModuleCode == iMaModuleCode
                       select new LayNhiemVu
         {
             iMaNhiemVuCode = nv.iMaNhiemVuCode,
             vNguoiDang = tv.vTenDangNhap,
             vNguoiDuocGiaoCode = tv1.vTenDangNhap,
             vMoTa = nv.vMoTa,
             vTenNhiemVu = nv.vTenNhiemVu,
             iMaTrangThaiCode = nv.iMaTrangThaiCode,
             dNgayLap = nv.dNgayLap,
             dNgayBD = nv.dNgayBD,
             dNgayKT = nv.dNgayKT,
             vTenTrangThai = tt.vTenTrangThai
         }).OrderByDescending(m => m.dNgayLap).ToList();
         return(Json(result));
     }
 }
コード例 #14
0
        public ActionResult Login(LoginViewModel model)

        {
            string encPWD = StringUtils.MD5(model.vMatKhau);

            using (var db = new dbnhiemvuEntities())
            {
                var user = db.ThanhViens.Where(m => m.vTenDangNhap == model.vTenDangNhap && m.vMatKhau == encPWD).FirstOrDefault();
                if (user != null)
                {
                    Session["isLogin"] = 1;
                    Session["user"]    = user;

                    if (Request.Form.GetValues("bGhiNho") != null)
                    {
                        Response.Cookies["userID"].Value   = user.iMaThanhVienCode.ToString();
                        Response.Cookies["userID"].Expires = DateTime.Now.AddDays(7);
                    }
                    return(RedirectToAction("Index", "Project"));
                    //return RedirectToAction("Index", "Home");
                }
                else
                {
                    ViewBag.Msg = "Tên đăng nhập hoặc tài khoản không đúng !";
                    return(View());
                }
            }
        }
コード例 #15
0
 public ActionResult GetInfoModule(int iMaModuleCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var result = db.Modules.Find(iMaModuleCode);
         return(Json(result));
     }
 }
コード例 #16
0
 public ActionResult GetTapTinNhiemVu(int iMaNhiemVuCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var result = db.TapTins.Where(m => m.iMaNhiemVuCode == iMaNhiemVuCode).ToList();
         return(Json(result));
     }
 }
コード例 #17
0
 public ActionResult GetHinhLoiChinhSua(int iMaChiTietLoiCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var result = db.HinhLois.Where(m => m.iMaChiTietLoiCode == iMaChiTietLoiCode && m.iTrangThai == 1).ToList();
         return(Json(result));
     }
 }
コード例 #18
0
 public ActionResult GetInfoChiTietLoi(int iMaChiTietLoiCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var result = db.ChiTietLois.Find(iMaChiTietLoiCode);
         return(Json(result));
     }
 }
コード例 #19
0
 public ActionResult HinhNhiemVuPartial(int iMaNhiemVuCode)
 {
     using (var db = new dbnhiemvuEntities()) {
         var result = db.Hinhs.Where(m => m.iMaNhiemVuCode == iMaNhiemVuCode).ToList();
         return(PartialView("HinhNhiemVuPartial", result));
         //return Json(result);
     }
 }
コード例 #20
0
 public ActionResult GetInfoProject(int iMaProjectCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var result = db.Projects.Find(iMaProjectCode);
         return(Json(result));
     }
 }
コード例 #21
0
 public ActionResult HinhLoiPartial(int iMaChiTietLoiCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var result = db.HinhLois.Where(m => m.iMaChiTietLoiCode == iMaChiTietLoiCode && m.iTrangThai == 1).ToList();
         //return PartialView("_HinhLoiPartial", result);
         return(Json(result));
     }
 }
コード例 #22
0
 public ActionResult TapTinBaoCaoPartial(int iMaBaoCaoCode)
 {
     using (var db = new dbnhiemvuEntities())
     {
         var result = db.TapTinBaoCaos.Where(m => m.iMaBaoCaoCode == iMaBaoCaoCode).ToList();
         //return PartialView("_TapTinBaoCaoPartial", result);
         return(Json(result));
     }
 }
コード例 #23
0
        public ActionResult TrangCaNhan()
        {
            var iMaNguoiDuocGiaoCode = CurrentContext.GetUser().iMaThanhVienCode;

            using (var db = new dbnhiemvuEntities())
            {
                ViewBag.TrangThai = db.TrangThais.ToList();
                var list = db.NhiemVus.Where(m => m.iMaNguoiDuocGiaoCode == iMaNguoiDuocGiaoCode).ToList();
                return(View(list));
            }
        }
コード例 #24
0
 public ActionResult Index()
 {
     using (var db = new dbnhiemvuEntities())
     {
         ViewBag.ThanhVien = (from t in db.ThanhViens
                              select new GetThanhVienViewModel
         {
             iMaThanhVienCode = t.iMaThanhVienCode,
             vTenDangNhap = t.vTenDangNhap
         }).ToList();
         ViewBag.TrangThai = db.TrangThais.ToList();
         return(View());
     }
 }
コード例 #25
0
 public ActionResult GetBaoCao(int iMaNhiemVuCode, int?index = 0)
 {
     if (!index.HasValue)
     {
         index = 0;
     }
     using (var db = new dbnhiemvuEntities())
     {
         var result = db.BaoCaos.Where(m => m.iMaNhiemVuCode == iMaNhiemVuCode).ToList();
         var item   = 1;
         result = result.OrderByDescending(m => m.iMaBaoCaoCode).Skip(item * index.Value).Take(item).ToList();
         return(Json(result));
     }
 }
コード例 #26
0
 // GET: Module
 public ActionResult ByProject(int?iMaProjectCode)
 {
     if (!iMaProjectCode.HasValue)
     {
         return(RedirectToAction("Index", "Project"));
     }
     ViewBag.iMaProjectCode = iMaProjectCode;
     using (var db = new dbnhiemvuEntities())
     {
         var p = db.Projects.Find(iMaProjectCode);
         ViewBag.vTenProject = p.vTenProject;
         return(View());
     }
 }
コード例 #27
0
        public ActionResult LayFileCanTai(int id, int idmafile)
        {
            dbnhiemvuEntities db     = new dbnhiemvuEntities();
            List <TapTin>     taptin = new List <TapTin>();

            try
            {
                taptin = db.TapTins.Where(x => x.iMaNhiemVuCode == id && x.iMaTapTinCode == idmafile).ToList();
            }
            catch (DbEntityValidationException e)
            {
                throw e;
            }
            return(Json(taptin));
        }
コード例 #28
0
        public ActionResult ChiTietLoi(int id)
        {
            dbnhiemvuEntities db         = new dbnhiemvuEntities();
            List <ChiTietLoi> chitietloi = new List <ChiTietLoi>();

            try
            {
                chitietloi = db.ChiTietLois.Where(x => x.iMaNhiemVuCode == id).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(chitietloi));
        }
コード例 #29
0
 public bool GiaoNhiemVu(int iMaNhiemVuCode, int iMaThanhVienCode)
 {
     try {
         using (var db = new dbnhiemvuEntities())
         {
             var n = db.NhiemVus.Find(iMaNhiemVuCode);
             n.iMaNguoiDuocGiaoCode = iMaThanhVienCode;
             n.iMaTrangThaiCode     = 1;
             db.SaveChanges();
             return(true);
         }
     } catch {
         return(false);
     }
 }
コード例 #30
0
 public bool ThayDoiTrangThai(int iMaNhiemVuCode, int iMaTrangThaiCode)
 {
     try
     {
         using (var db = new dbnhiemvuEntities())
         {
             var task = db.NhiemVus.Find(iMaNhiemVuCode);
             task.iMaTrangThaiCode = iMaTrangThaiCode;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }