Ejemplo n.º 1
0
        public async Task <ActionResult> DeleteConfirmed(int id, int mankh, int manhakhoahoc)
        {
            DSNguoiThamGiaBaiBao dSNguoiThamGiaBaiBao = await db.DSNguoiThamGiaBaiBaos.Where(p => p.MaBaiBao == id && p.MaNKH == mankh).FirstOrDefaultAsync();

            db.DSNguoiThamGiaBaiBaos.Remove(dSNguoiThamGiaBaiBao);
            await db.SaveChangesAsync();

            return(RedirectToAction("Edit", new { id = id, manhakhoahoc = manhakhoahoc }));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> EditDanhSachNguoiThamGiaBaiBao([Bind(Include = "MaBaiBao,MaNKH,LaTacGiaChinh")] DSNguoiThamGiaBaiBao dSNguoiThamGiaBaiBao)
        {
            if (ModelState.IsValid)
            {
                db.DSNguoiThamGiaBaiBaos.AddOrUpdate(dSNguoiThamGiaBaiBao);

                await db.SaveChangesAsync();

                return(RedirectToAction("DanhSachNguoiThamGiaBaiBao"));
            }
            return(View(dSNguoiThamGiaBaiBao));
        }
Ejemplo n.º 3
0
        /* EDit nguoi tham gia bai bao*/
        public async Task <ActionResult> EditDanhSachNguoiThamGiaBaiBao(int?id, int?manhakhoahoc)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DSNguoiThamGiaBaiBao dSNguoiThamGiaBaiBao = await db.DSNguoiThamGiaBaiBaos.Where(p => p.MaBaiBao == id && p.MaNKH == manhakhoahoc).FirstOrDefaultAsync();

            if (dSNguoiThamGiaBaiBao == null)
            {
                return(HttpNotFound());
            }
            return(View(dSNguoiThamGiaBaiBao));
        }
        // GET: AdminDSNguoiThamGiaBaiBao/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DSNguoiThamGiaBaiBao dSNguoiThamGiaBaiBao = await db.DSNguoiThamGiaBaiBaos.FindAsync(id);

            if (dSNguoiThamGiaBaiBao == null)
            {
                return(HttpNotFound());
            }
            return(View(dSNguoiThamGiaBaiBao));
        }
Ejemplo n.º 5
0
        // GET: AdminDSNguoiThamGiaBaiBao/Delete/5
        public async Task <ActionResult> Delete(int?id, int manhakhoahoc, int mankh)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DSNguoiThamGiaBaiBao dSNguoiThamGiaBaiBao = await db.DSNguoiThamGiaBaiBaos.Where(p => p.MaBaiBao == id && p.MaNKH == manhakhoahoc).FirstOrDefaultAsync();

            if (dSNguoiThamGiaBaiBao == null)
            {
                return(HttpNotFound());
            }
            ViewBag.manhakhoahoc = manhakhoahoc;
            ViewBag.mabaibao     = id;
            ViewBag.mankh        = mankh;
            return(View(dSNguoiThamGiaBaiBao));
        }
Ejemplo n.º 6
0
        /* DElete guoi tha gia bai bao*/
        public async Task <ActionResult> DeleteDanhSachNguoiThamGiaBaiBao(int?id, int?manhakhoahoc)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DSNguoiThamGiaBaiBao dSNguoiThamGiaBaiBao = await db.DSNguoiThamGiaBaiBaos.Where(p => p.MaBaiBao == id && p.MaNKH == manhakhoahoc).FirstOrDefaultAsync();

            if (dSNguoiThamGiaBaiBao == null)
            {
                return(HttpNotFound());
            }
            db.DSNguoiThamGiaBaiBaos.Remove(dSNguoiThamGiaBaiBao);
            await db.SaveChangesAsync();

            return(RedirectToAction("DanhSachNguoiThamGiaBaiBao"));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> EditDanhSachNguoiThamGiaBaiBao([Bind(Include = "MaBaiBao,MaNKH,LaTacGiaChinh")] DSNguoiThamGiaBaiBao dSNguoiThamGiaBaiBao)
        {
            if (ModelState.IsValid)
            {
                DSNguoiThamGiaBaiBao tacGia = await db.DSNguoiThamGiaBaiBaos.Where(p => p.MaBaiBao == dSNguoiThamGiaBaiBao.MaBaiBao && p.MaNKH == dSNguoiThamGiaBaiBao.MaNKH).FirstOrDefaultAsync();

                if (tacGia != null)
                {
                    tacGia.LaTacGiaChinh = dSNguoiThamGiaBaiBao.LaTacGiaChinh;
                }
                else
                {
                    db.DSNguoiThamGiaBaiBaos.Remove(dSNguoiThamGiaBaiBao);
                }

                await db.SaveChangesAsync();

                return(RedirectToAction("DanhSachNguoiThamGiaBaiBao"));
            }
            return(View(dSNguoiThamGiaBaiBao));
        }
Ejemplo n.º 8
0
        public async Task <ActionResult> CreateDanhSachNguoiThamGiaBaiBao([Bind(Include = "MaBaiBao,MaNKH,LaTacGiaChinh")] DSNguoiThamGiaBaiBao dSNguoiThamGiaBaiBao)
        {
            if (ModelState.IsValid)
            {
                db.DSNguoiThamGiaBaiBaos.Add(dSNguoiThamGiaBaiBao);
                await db.SaveChangesAsync();

                return(RedirectToAction("DanhSachNguoiThamGiaBaiBao"));
            }
            var dsnguoidathamgia = db.DSNguoiThamGiaBaiBaos.Where(p => p.MaBaiBao == dSNguoiThamGiaBaiBao.MaBaiBao).Select(p => p.MaNKH).ToList();
            var lstAllNKH        = db.NhaKhoaHocs.Where(p => !dsnguoidathamgia.Contains(p.MaNKH)).Select(p => new
            {
                p.MaNKH,
                TenNKH = p.HoNKH + " " + p.TenNKH
            }).ToList();

            ViewBag.MaNKH     = new SelectList(lstAllNKH, "MaNKH", "TenNKH");
            ViewBag.tenbaibao = db.BaiBaos.Find(dSNguoiThamGiaBaiBao.MaBaiBao).TenBaiBao;
            ViewBag.mabaibao  = dSNguoiThamGiaBaiBao.MaBaiBao;
            return(View());
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> Edit(List <int> LinhVuc, List <string> DeTaiBaiBao, List <string> DSNguoiThamGiaBaiBao, [Bind(Include = "MaBaiBao,MaISSN,TenBaiBao,LaTrongNuoc,CQXuatBan,MaLoaiTapChi,MaCapTapChi,NamDangBao,TapPhatHanh,SoPhatHanh,TrangBaiBao,LienKetWeb")] BaiBao baiBao, HttpPostedFileBase linkUpload)
        {
            if (ModelState.IsValid)
            {
                var baibao = db.BaiBaos.Where(p => p.MaBaiBao == baiBao.MaBaiBao).Include(p => p.LinhVucs).Include(p => p.DSBaiBaoDeTais).Include(p => p.DSNguoiThamGiaBaiBaos).FirstOrDefault();
                baiBao.LinhVucs              = baibao.LinhVucs;
                baiBao.DSBaiBaoDeTais        = baibao.DSBaiBaoDeTais;
                baiBao.DSNguoiThamGiaBaiBaos = baibao.DSNguoiThamGiaBaiBaos;
                /* xử lý ảnh upload*/
                if (linkUpload != null && linkUpload.ContentLength > 0)
                {
                    string filename = Path.GetFileNameWithoutExtension(linkUpload.FileName) + "_" + baiBao.MaBaiBao.ToString() + Path.GetExtension(linkUpload.FileName);
                    string path     = Path.Combine(Server.MapPath("~/App_Data/uploads/baibao_file"), filename);
                    if (!String.IsNullOrEmpty(baibao.LinkFileUpLoad))
                    {
                        string oldpath = Path.Combine(Server.MapPath("~/App_Data/uploads/baibao_file"), baibao.LinkFileUpLoad);
                        if (System.IO.File.Exists(oldpath))
                        {
                            System.IO.File.Delete(oldpath);
                        }
                    }
                    linkUpload.SaveAs(path);
                    baiBao.LinkFileUpLoad = filename;
                }
                else
                {
                    baiBao.LinkFileUpLoad = baibao.LinkFileUpLoad;
                }
                db.BaiBaos.AddOrUpdate(baiBao);
                /* phần xửa lý lĩnh vực*/

                if (LinhVuc != null)
                {
                    var deletedlinhvuc = baibao.LinhVucs.Where(p => !LinhVuc.Contains(p.MaLinhVuc)).ToList();
                    var addedlinhvuc   = LinhVuc.Except(baibao.LinhVucs.Select(p => p.MaLinhVuc).ToList <int>());
                    var addlinhvuc     = db.LinhVucs.Where(p => addedlinhvuc.Contains(p.MaLinhVuc)).ToList();
                    foreach (var d in deletedlinhvuc)
                    {
                        baibao.LinhVucs.Remove(d);
                    }
                    foreach (var a in addlinhvuc)
                    {
                        baibao.LinhVucs.Add(a);
                    }
                }
                else
                {
                    foreach (var x in baibao.LinhVucs)
                    {
                        baibao.LinhVucs.Remove(x);
                    }
                }


                /* xừ lý người tham gia bài báo*/
                if (DSNguoiThamGiaBaiBao != null)
                {
                    db.DSNguoiThamGiaBaiBaos.Where(p => p.MaBaiBao == baibao.MaBaiBao && p.LaTacGiaChinh == false).ForEach(z => db.DSNguoiThamGiaBaiBaos.Remove(z));
                    foreach (var mankh in DSNguoiThamGiaBaiBao)
                    {
                        DSNguoiThamGiaBaiBao nguoiTGBB = new DSNguoiThamGiaBaiBao
                        {
                            LaTacGiaChinh = false,
                            MaBaiBao      = baibao.MaBaiBao,
                            MaNKH         = Int32.Parse(mankh)
                        };
                        baibao.DSNguoiThamGiaBaiBaos.Add(nguoiTGBB);
                    }
                }

                /* xử lý đề tài bài báo*/
                if (DeTaiBaiBao != null)
                {
                    db.DSBaiBaoDeTais.Where(p => p.MaBaiBao == baibao.MaBaiBao).ForEach(z => db.DSBaiBaoDeTais.Remove(z));
                    foreach (var madetai in DeTaiBaiBao)
                    {
                        DSBaiBaoDeTai detai = new DSBaiBaoDeTai
                        {
                            MaBaiBao = baiBao.MaBaiBao,
                            MaDeTai  = Int32.Parse(madetai)
                        };
                        db.DSBaiBaoDeTais.Add(detai);
                    }
                }

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            var lstAllNKH = db.NhaKhoaHocs.Where(p => p.MaNKH != 1).Select(p => new
            {
                p.MaNKH,
                TenNKH = p.HoNKH + " " + p.TenNKH
            }).ToList();
            var tacgiaphu   = db.NhaKhoaHocs.Where(p => p.DSNguoiThamGiaBaiBaos.Any(d => d.MaBaiBao == baiBao.MaBaiBao && d.LaTacGiaChinh == false)).Select(p => p.MaNKH).ToList();
            var detaibaibao = db.DSBaiBaoDeTais.Where(p => p.MaBaiBao == baiBao.MaBaiBao).Select(p => p.MaDeTai).ToList();

            ViewBag.MaCapTapChi          = new SelectList(db.CapTapChis, "MaCapTapChi", "TenCapTapChi", baiBao.MaCapTapChi);
            ViewBag.MaLoaiTapChi         = new SelectList(db.PhanLoaiTapChis, "MaLoaiTapChi", "TenLoaiTapChi", baiBao.MaLoaiTapChi);
            ViewBag.DSNguoiThamGiaBaiBao = new MultiSelectList(lstAllNKH, "MaNKH", "TenNKH", tacgiaphu);
            ViewBag.LinhVuc  = new MultiSelectList(db.LinhVucs, "MaLinhVuc", "TenLinhVuc", baiBao.LinhVucs);
            ViewBag.DeTai    = new MultiSelectList(db.DeTais, "MaDeTai", "TenDeTai", detaibaibao);
            ViewBag.NguonGoc = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Trong nước", Value = "true"
                },
                new SelectListItem {
                    Text = "Ngoài nước", Value = "false"
                }
            };

            return(View(baiBao));
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> Create(List <int> LinhVuc, List <string> DeTaiBaiBao, List <string> DSNguoiThamGiaBaiBao, [Bind(Include = "MaBaiBao,MaISSN,TenBaiBao,LaTrongNuoc,CQXuatBan,MaLoaiTapChi,MaCapTapChi,NamDangBao,TapPhatHanh,SoPhatHanh,TrangBaiBao,LienKetWeb")] BaiBao baiBao, HttpPostedFileBase linkUpload)
        {
            if (ModelState.IsValid)
            {
                if (linkUpload != null && linkUpload.ContentLength > 0)
                {
                    string filename = Path.GetFileNameWithoutExtension(linkUpload.FileName) + "_" + baiBao.MaBaiBao.ToString() + Path.GetExtension(linkUpload.FileName);
                    string path     = Path.Combine(Server.MapPath("~/App_Data/uploads/baibao_file"), filename);
                    linkUpload.SaveAs(path);
                    baiBao.LinkFileUpLoad = filename;
                }
                if (LinhVuc != null)
                {
                    baiBao.LinhVucs = db.LinhVucs.Where(p => LinhVuc.Contains(p.MaLinhVuc)).ToList();
                }

                db.BaiBaos.Add(baiBao);
                db.SaveChanges();

                UserLoginViewModel user = (UserLoginViewModel)Session["user"];
                db.DSNguoiThamGiaBaiBaos.Add(new DSNguoiThamGiaBaiBao
                {
                    LaTacGiaChinh = true,
                    MaBaiBao      = baiBao.MaBaiBao,
                    MaNKH         = user.MaNKH
                });

                if (DSNguoiThamGiaBaiBao != null)
                {
                    foreach (var mankh in DSNguoiThamGiaBaiBao)
                    {
                        DSNguoiThamGiaBaiBao nguoiTGBB = new DSNguoiThamGiaBaiBao
                        {
                            LaTacGiaChinh = false,
                            MaBaiBao      = baiBao.MaBaiBao,
                            MaNKH         = Int32.Parse(mankh)
                        };
                        db.DSNguoiThamGiaBaiBaos.Add(nguoiTGBB);
                        db.SaveChanges();
                    }
                }
                if (DeTaiBaiBao != null)
                {
                    foreach (var madetai in DeTaiBaiBao)
                    {
                        DSBaiBaoDeTai detai = new DSBaiBaoDeTai
                        {
                            MaBaiBao = baiBao.MaBaiBao,
                            MaDeTai  = Int32.Parse(madetai)
                        };
                        db.DSBaiBaoDeTais.Add(detai);
                        db.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }


            var lstAllNKH = db.NhaKhoaHocs.Where(p => p.MaNKH != 1).Select(p => new
            {
                p.MaNKH,
                TenNKH = p.HoNKH + " " + p.TenNKH
            }).ToList();
            var tacgiaphu   = db.NhaKhoaHocs.Where(p => p.DSNguoiThamGiaBaiBaos.Any(d => d.MaBaiBao == baiBao.MaBaiBao && d.LaTacGiaChinh == false)).Select(p => p.MaNKH).ToList();
            var detaibaibao = db.DSBaiBaoDeTais.Where(p => p.MaBaiBao == baiBao.MaBaiBao).Select(p => p.MaDeTai).ToList();

            ViewBag.MaCapTapChi          = new SelectList(db.CapTapChis, "MaCapTapChi", "TenCapTapChi", baiBao.MaCapTapChi);
            ViewBag.MaLoaiTapChi         = new SelectList(db.PhanLoaiTapChis, "MaLoaiTapChi", "TenLoaiTapChi", baiBao.MaLoaiTapChi);
            ViewBag.DSNguoiThamGiaBaiBao = new MultiSelectList(lstAllNKH, "MaNKH", "TenNKH", tacgiaphu);
            ViewBag.LinhVuc  = new MultiSelectList(db.LinhVucs, "MaLinhVuc", "TenLinhVuc", baiBao.LinhVucs);
            ViewBag.DeTai    = new MultiSelectList(db.DeTais, "MaDeTai", "TenDeTai", detaibaibao);
            ViewBag.NguonGoc = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Trong nước", Value = "true"
                },
                new SelectListItem {
                    Text = "Ngoài nước", Value = "false"
                }
            };

            return(View(baiBao));
        }