示例#1
0
        public bool addDetail(Sach sach, decimal soluong)
        {
            var chitiet = new ChiTietPhieuXuat
            {
                MaSoSach = sach.MaSoSach,
                Sach     = sach,
                SoLuong  = soluong,
                DonGia   = sach.GiaBan
            };

            foreach (var ct in ChiTiet)
            {
                if (ct.Equals(chitiet))
                {
                    ct.SoLuong += chitiet.SoLuong;
                    return(true);
                }
            }
            ChiTiet.Add(chitiet);
            return(true);
        }
 public JsonResult isDetailExisted(string masosach)
 {
     var key = Int32.Parse(masosach);
     var chitiet = new ChiTietPhieuXuat();
     chitiet.MaSoSach = key;
     if (_phieu.isDetailExisted(chitiet))
     {
         return Json(true,JsonRequestBehavior.AllowGet);
     }
     else
     {
         return Json(false, JsonRequestBehavior.AllowGet);
     }
 }
 public ViewResult BlankEditorRow()
 {
     var chitiet = new ChiTietPhieuXuat();
     var founded = false;
     foreach (Sach s in SachManager.getAllAlive().Where(s => s.Soluong > 0).ToList())
     {
         chitiet.MaSoSach = s.MaSoSach;
         if (_phieu.ChiTiet.Contains(chitiet))
         {
             continue;
         }
         founded = true;
         break;
     }
     if (!founded)
     {
         return null;
     }
     ViewBag.cultureInfo = CultureInfo;
     ViewBag.DMSach = new SelectList(SachManager.getAllAlive()
                                         .Where(s => s.Soluong > 0).ToList(),
                             nameof(SachManager.Properties.MaSoSach),
                             nameof(SachManager.Properties.TenSach), "");
     chitiet.SoLuong = 1;
     chitiet.DonGia = chitiet.Sach.GiaBan;
     _phieu.addDetail(chitiet);
     return View("ChiTietEditorRow", chitiet);
 }
 public static bool edit(ChiTietPhieuXuat chitiet)
 {
     try
     {
         using(EntitiesDataContext db = new EntitiesDataContext())
         {
             CHITIETPHIEUXUAT ct;
             ct = (from c in db.CHITIETPHIEUXUATs
                   where c.masophieuxuat.Equals(chitiet.MaSoPhieuXuat)
                   && c.masosach.Equals(chitiet.MaSoSach)
                   select c).SingleOrDefault();
             if (ct == null) return false;
             ct.soluong = chitiet.SoLuong;
             ct.trangthai = chitiet.TrangThai;
             db.SubmitChanges();
             return true;
         }
     }catch(Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }
示例#5
0
 /// <summary>
 /// Kiểm tra chi tiết đã có trong danh sách chưa
 /// </summary>
 /// <param name="chitiet"></param>
 /// <returns></returns>
 public bool isDetailExisted(ChiTietPhieuXuat chitiet)
 {
     return(_chitiet.Contains(chitiet));
 }
 public static bool add(ChiTietPhieuXuat chitiet, int masophieuxuat)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             CHITIETPHIEUXUAT ct;
             ct = (from c in db.CHITIETPHIEUXUATs
                   where c.masophieuxuat.Equals(masophieuxuat)
                   && c.masosach.Equals(chitiet.MaSoSach)
                   select c).SingleOrDefault();
             if (ct != null) return false;
             ct = new CHITIETPHIEUXUAT
             {
                 masophieuxuat = masophieuxuat,
                 masosach = chitiet.MaSoSach,
                 soluong = chitiet.SoLuong,
                 dongia = chitiet.DonGia,
                 trangthai = chitiet.TrangThai == null ? 0 : 1
             };
             db.CHITIETPHIEUXUATs.InsertOnSubmit(ct);
             db.SubmitChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }
 public static bool add(ChiTietPhieuXuat chitiet)
 {
     return add(chitiet, chitiet.MaSoPhieuXuat);
 }
 /// <summary>
 /// Kiểm tra chi tiết đã có trong danh sách chưa
 /// </summary>
 /// <param name="chitiet"></param>
 /// <returns></returns>
 public bool isDetailExisted(ChiTietPhieuXuat chitiet)
 {
     return _chitiet.Contains(chitiet);
 }
 public bool addDetail(Sach sach, decimal soluong)
 {
     var chitiet = new ChiTietPhieuXuat
     {
         MaSoSach = sach.MaSoSach,
         Sach = sach,
         SoLuong = soluong,
         DonGia = sach.GiaBan
     };
     foreach(var ct in ChiTiet)
     {
         if (ct.Equals(chitiet))
         {
             ct.SoLuong += chitiet.SoLuong;
             return true;
         }
     }
     ChiTiet.Add(chitiet);
     return true;
 }
示例#10
0
 /// <summary>
 /// Thêm chi tiết vào danh sách chi tiết của phiếu
 /// </summary>
 /// <param name="chitiet"></param>
 /// <returns></returns>
 public bool addDetail(ChiTietPhieuXuat chitiet)
 {
     if (isDetailExisted(chitiet))
     {
         return false;
     }
     _chitiet.Add(chitiet);
     return true;
 }