public JsonResult LapPhieu(List <int> listDC)
 {
     if (listDC == null)
     {
         return(Json(new
         {
             status = false,
             mess = "Bạn chưa chọn dụng cụ"
         }));
     }
     else
     {
         string name = HttpContext.User.Identity.Name;
         var    ktv  = db.NhanViens.SingleOrDefault(x => x.Username.Equals(name) && x.Status == 1);
         if (ktv == null)
         {
             return(Json(new
             {
                 status = false,
                 mess = "Có lỗi xảy ra"
             }));
         }
         PhieuXuatKho px = new PhieuXuatKho();
         px.IDKTV     = ktv.ID;
         px.KiemDuyet = false;
         px.NgayXuat  = DateTime.Now;
         px.Status    = 0;
         foreach (int value in listDC)
         {
             var vd = db.KhoVatDungs.Find(value);
             if (vd == null || vd.Status == 2)
             {
                 return(Json(new
                 {
                     status = false,
                     mess = "Có lỗi xảy ra"
                 }));
             }
             else
             {
                 vd.Status = 2;
             }
             CTPhieuXuatKho ct = new CTPhieuXuatKho();
             ct.IDVatDung = value;
             px.CTPhieuXuatKhoes.Add(ct);
         }
         db.PhieuXuatKhoes.Add(px);
         db.SaveChanges();
         return(Json(new
         {
             status = true
         }));
     }
 }
Exemple #2
0
        public JsonResult XoaChitietPhieuXuat(int idctpx)
        {
            CTPhieuXuatKho ctpx = db.CTPhieuXuatKhoes.SingleOrDefault(x => x.ID == idctpx);

            db.CTPhieuXuatKhoes.Remove(ctpx);

            KhoVatDung vatdung = db.KhoVatDungs.SingleOrDefault(x => x.ID == ctpx.IDVatDung);

            vatdung.Status = 1;

            db.SaveChanges();
            return(Json(new
            {
                status = true
            }));
        }
Exemple #3
0
        public JsonResult LuuCTPhieuXuat(int idvatdung, int idktv, int idpx)
        {
            //Lưu chi tiết
            CTPhieuXuatKho ct = new CTPhieuXuatKho();

            ct.IDPhieuXuat = idpx;
            ct.IDVatDung   = idvatdung;
            ct.Status      = 0;

            //Thay đổi Status vật dụng
            KhoVatDung vd = db.KhoVatDungs.SingleOrDefault(x => x.ID == idvatdung);

            vd.Status = 2;

            db.CTPhieuXuatKhoes.Add(ct);
            db.SaveChanges();
            return(Json(new
            {
                status = true,
            }));
        }