예제 #1
0
 public DiaDiem()
 {
     ten       = new TenDiaDiem();
     dichvu    = new DichVu();
     duong     = new Duong();
     phuong    = new Phuong();
     quanhuyen = new QuanHuyen();
     tinhthanh = new TinhThanh();
 }
예제 #2
0
        public ActionResult DeleteP(int MaPhuong)//Xóa phuong
        {
            Phuong p = db.Phuong.Find(MaPhuong);

            if (p == null)
            {
                return(HttpNotFound());
            }
            db.Phuong.Remove(p);
            db.SaveChanges();
            return(RedirectToAction("Phuong"));
        }
예제 #3
0
 public ActionResult CreateP(string TenPhuong, int MaQuan)
 {
     if (ModelState.IsValid)
     {
         Phuong p = db.Phuong.SingleOrDefault(x => x.TenPhuong == TenPhuong);
         if (p != null)
         {
             ModelState.AddModelError("", "Phường đã có");
         }
         else
         {
             Phuong t = new Phuong();
             t.TenPhuong = TenPhuong;
             t.MaQuan    = MaQuan;
             db.Phuong.Add(t);
             db.SaveChanges();
             return(RedirectToAction("Phuong"));
         }
     }
     return(RedirectToAction("Phuong"));
 }
예제 #4
0
        public JsonResult Search(SearchModel entity)
        {
            List <BaiViet> listBaiViet = new List <BaiViet>();
            var            res         = db.BaiViets.ToList();
            //Search Quan
            Quan   q = db.Quans.Find(entity.idQuan);
            Phuong p = db.Phuongs.Find(entity.idPhuong);
            KieuBD k = db.KieuBDS.Find(entity.idBDS);
            LoaiBD l = db.LoaiBDS.Find(entity.idLoaiBDS);

            string temp = "";

            if (q == null)
            {
                temp = "";
            }
            else
            {
                temp = q.TenQuan;
            }
            if (p == null)
            {
                temp = temp;
            }
            else
            {
                temp += " " + p.TenPhuong;
            }
            if (l == null)
            {
                temp = temp;
            }
            else
            {
                temp += " " + l.TenLoai;
            }
            if (k == null)
            {
                temp = temp;
            }
            else
            {
                temp += " " + k.TenKieu;
            }

            var listNT = db.NhaTroes.SqlQuery("select * from NhaTro n where n.SoNha like N'%" + temp + "%'").ToList();

            foreach (var item in res)
            {
                foreach (var item1 in listNT)
                {
                    if (item.idNT == item1.idNT)
                    {
                        listBaiViet.Add(item);
                    }
                }
            }
            //string tempJ = string.Empty;
            //tempJ = JsonConvert.SerializeObject(listBaiViet, Formatting.Indented, new JsonSerializerSettings
            //{
            //    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            //});

            return(Json(listBaiViet, JsonRequestBehavior.AllowGet));
        }