Ejemplo n.º 1
0
        public JsonResult thongtinsach(int madl, int masach)
        {
            SACHDAILIModel sach = new SACHDAILIModel();
            var            list = laysach_tuphieuxuat_daili_damua(madl);

            sach = (from l in list
                    where l.MASACH == masach
                    select l).SingleOrDefault();
            return(Json(sach, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public List <SACHDAILIModel> laysach_tuphieuxuat_daili_damua(int madl)
        {
            SACHDAILIModel model = new SACHDAILIModel();

            model.SOLUONG = 0;
            List <SACHDAILIModel> ds_sach_sachconlai = null;
            object madailimua = new SqlParameter("@MADL", madl);
            object madailitra = new SqlParameter("@MADL", madl);
            List <SACHDAILIModel> ds_sach_daili_damua = db.Database.SqlQuery <SACHDAILIModel>("splaydanhsachdamuacuamotdaili @MADL", madailimua).ToList();
            List <SACHDAILIModel> ds_sach_daili_datra = db.Database.SqlQuery <SACHDAILIModel>("splaydanhsachsachdatracuamotdaili @MADL", madailitra).ToList();

            ds_sach_sachconlai = (from mua in ds_sach_daili_damua
                                  join tra in ds_sach_daili_datra
                                  on mua.MASACH equals tra.MASACH into leftjoin
                                  from l in leftjoin.DefaultIfEmpty(model)
                                  select new SACHDAILIModel()
            {
                MASACH = mua.MASACH,
                TENSACH = mua.TENSACH,
                GIABAN = mua.GIABAN,
                SOLUONG = mua.SOLUONG - l.SOLUONG                      //
            }).ToList();
            return(ds_sach_sachconlai);
        }