Exemplo n.º 1
0
        public async Task <ActionResult <Khenthuong> > PostKhenthuong(Khenthuong khenthuong)
        {
            _context.Khenthuong.Add(khenthuong);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetKhenthuong", new { id = khenthuong.MaKt }, khenthuong));
        }
Exemplo n.º 2
0
        private void khenThưởngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Khenthuong kt = new Khenthuong();

            kt.Show();
            this.Hide();
        }
Exemplo n.º 3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Khenthuong khenthuong = db.Khenthuongs.Find(id);

            if (khenthuong == null)
            {
                return(HttpNotFound());
            }

            //phan quyen mod cap tren tro len co quyen
            var loggedInUser = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if ((!db.CapCongDoans.Find(db.Users.Find(db.Khenthuongs.Find(id).cdv_id).capcongdoan_id).motaphancap.Contains(db.Users.Include(x => x.CapCongDoan).SingleOrDefault(x => x.Id == loggedInUser).CapCongDoan.motaphancap) && User.IsInRole("mod")))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            ViewBag.cdv_id = new SelectList(db.Users, "Id", "name", khenthuong.cdv_id);
            //ViewBag.tochuc_id = new SelectList(db.CapCongDoans.OrderBy(s=>s.motaphancap), "Capcongdoan_id", "namephancap", khenthuong.tochuc_id);
            return(View(khenthuong));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutKhenthuong(int id, Khenthuong khenthuong)
        {
            if (id != khenthuong.MaKt)
            {
                return(BadRequest());
            }

            _context.Entry(khenthuong).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KhenthuongExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 5
0
        public ActionResult Edit([Bind(Include = "Khenthuong_id,ngaykhenthuong,hinhthuc,soquyetdinh,capkhenthuong,cdv_id,tochuc_id,scanurl,doituongKhenthuong")] Khenthuong khenthuong, HttpPostedFileBase uploadImage)
        {
            if (ModelState.IsValid)
            {
                if (uploadImage != null)
                {
                    //xoa anh cu

                    var filePath = Server.MapPath(Request["oldurl"]);
                    if (System.IO.File.Exists(filePath))
                    {
                        System.IO.File.Delete(filePath);
                    }

                    //nap anh moi
                    //string filename = Path.GetFileNameWithoutExtension(uploadImage.FileName);
                    string extension = Path.GetExtension(uploadImage.FileName);
                    string filename  = khenthuong.Khenthuong_id + DateTime.Now.ToString("yymmssfff") + extension;
                    khenthuong.scanurl = "/Image/Khenthuong/" + filename;
                    filename           = Path.Combine(Server.MapPath("~/Image/Khenthuong/"), filename);
                    uploadImage.SaveAs(filename);
                }
                else
                {
                    khenthuong.scanurl = Request["oldurl"];
                }
                db.Entry(khenthuong).State = EntityState.Modified;
                db.SaveChanges(System.Web.HttpContext.Current.User.Identity.GetUserName());
                return(RedirectToAction("Index"));
            }
            ViewBag.cdv_id = new SelectList(db.Users, "Id", "name", khenthuong.cdv_id);
            //ViewBag.tochuc_id = new SelectList(db.CapCongDoans, "Capcongdoan_id", "name", khenthuong.tochuc_id);
            return(View(khenthuong));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(string id, [Bind("KtMa,KtThanhtich,KtNgaykhenthuong,KtGhichu")] Khenthuong khenthuong)
        {
            if (id != khenthuong.KtMa)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(khenthuong);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KhenthuongExists(khenthuong.KtMa))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(khenthuong));
        }
Exemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Khenthuong khenthuong = db.Khenthuongs.Find(id);

            db.Khenthuongs.Remove(khenthuong);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "Makhenthuong,Tenkhenthuong,Noidung,Quyetdinh")] Khenthuong khenthuong)
 {
     if (ModelState.IsValid)
     {
         db.Entry(khenthuong).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(khenthuong));
 }
Exemplo n.º 9
0
        public async Task <IActionResult> Create([FromBody] Khenthuong model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            await khenThuongRepository.Create(model);

            return(Ok(model));
        }
Exemplo n.º 10
0
        public ActionResult Create([Bind(Include = "Makhenthuong,Tenkhenthuong,Noidung,Quyetdinh")] Khenthuong khenthuong)
        {
            if (ModelState.IsValid)
            {
                db.Khenthuongs.Add(khenthuong);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(khenthuong));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("KtMa,KtThanhtich,KtNgaykhenthuong,KtGhichu")] Khenthuong khenthuong)
        {
            if (ModelState.IsValid)
            {
                _context.Add(khenthuong);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(khenthuong));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Update(int id, [FromBody] Khenthuong model)
        {
            if (id != model.Id)
            {
                return(BadRequest());
            }

            model.Id = id;

            await khenThuongRepository.Update(model);

            return(Ok(model));
        }
Exemplo n.º 13
0
        // GET: Khenthuongs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Khenthuong khenthuong = db.Khenthuongs.Find(id);

            if (khenthuong == null)
            {
                return(HttpNotFound());
            }
            return(View(khenthuong));
        }
Exemplo n.º 14
0
        public ActionResult DeleteConfirmed(int id)
        {
            Khenthuong khenthuong = db.Khenthuongs.Find(id);

            //xoa anh cu
            var filePath = Server.MapPath(khenthuong.scanurl);

            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }

            db.Khenthuongs.Remove(khenthuong);
            db.SaveChanges(System.Web.HttpContext.Current.User.Identity.GetUserName());
            return(RedirectToAction("Index"));
        }
Exemplo n.º 15
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Khenthuong khenthuong = db.Khenthuongs.Find(id);

            if (khenthuong == null)
            {
                return(HttpNotFound());
            }
            //phan quyen mod cap tren tro len co quyen
            var loggedInUser = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if ((!db.CapCongDoans.Find(db.Users.Find(db.Khenthuongs.Find(id).cdv_id).capcongdoan_id).motaphancap.Contains(db.Users.Include(x => x.CapCongDoan).SingleOrDefault(x => x.Id == loggedInUser).CapCongDoan.motaphancap) && User.IsInRole("mod")))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
            return(View(khenthuong));
        }