Пример #1
0
        private void init()
        {
            switch (editState)
            {
            case EditState.View:
            {
                DiaDiem dd = _diaDiemRepository.getById(_id);
                diadiemname.Text    = dd.TenDD;
                diadiemname.Enabled = false;
                savebtt.Enabled     = false;
                break;
            }

            case EditState.Edit:
            {
                DiaDiem dd = _diaDiemRepository.getById(_id);
                diadiemname.Text = dd.TenDD;
                break;
            }

            case EditState.Create:
            {
                break;
            }
            }
        }
        public static bool CheckInformationDiaDiem(this DiaDiem diaDiem, string tuKhoa)
        {
            if (!string.IsNullOrEmpty(diaDiem.TenDiaDiem))
            {
                if (diaDiem.TenDiaDiem.ToLower().Contains(tuKhoa.ToLower()))
                {
                    return(true);
                }
            }

            if (!string.IsNullOrEmpty(diaDiem.DiaChi))
            {
                if (diaDiem.DiaChi.ToLower().Contains(tuKhoa.ToLower()))
                {
                    return(true);
                }
            }

            if (!string.IsNullOrEmpty(diaDiem.MaDiaDiem))
            {
                if (diaDiem.MaDiaDiem.ToLower().Contains(tuKhoa.ToLower()))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        public IHttpActionResult PutDiaDiem(string id, DiaDiem diaDiem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != diaDiem.MaDiaDiem)
            {
                return(BadRequest());
            }

            db.Entry(diaDiem).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DiaDiemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult ThemDiaDiem(DiaDiem objDiaDiem, HttpPostedFileBase fUpload)
 {
     try
     {
         if (ModelState.IsValid)
         {
             //Xử lý upload file
             if (fUpload != null &&
                 fUpload.ContentLength > 0)
             {
                 //Upload
                 fUpload.SaveAs(Server.MapPath("~/Content/Image/DiaDiem/" + fUpload.FileName));
                 //Lưu vào db
                 objDiaDiem.PictureId = fUpload.FileName;
             }
             //thêm vào database
             DataProvider.Entities.DiaDiems.Add(objDiaDiem);
             //Lưu thay đổi
             DataProvider.Entities.SaveChanges();
             logger.Info("Add a Location: " + objDiaDiem.TenDiaDiem);
         }
         return(RedirectToAction("DanhSachDiaDiem"));
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
         return(Redirect("~/ErrorPage/Return"));
     }
 }
Пример #5
0
        public IHttpActionResult PostDiaDiem(DiaDiem diaDiem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DiaDiems.Add(diaDiem);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (DiaDiemExists(diaDiem.MaDiaDiem))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = diaDiem.MaDiaDiem }, diaDiem));
        }
        public JsonResult CapNhat(string strDiaDiem)
        {
            JavaScriptSerializer serialiser = new JavaScriptSerializer();
            DiaDiem diaDiem = serialiser.Deserialize <DiaDiem>(strDiaDiem);
            bool    status  = false;
            string  message = string.Empty;
            ScriptFunctionsDataContext function = new ScriptFunctionsDataContext();
            DiaDiem dd = new DiaDiem()
            {
                MaDiaDiem   = diaDiem.MaDiaDiem,
                TenDiaDiem  = diaDiem.TenDiaDiem,
                GiaTien     = diaDiem.GiaTien,
                KhuVuc      = diaDiem.KhuVuc,
                HinhAnh     = diaDiem.HinhAnh,
                SoChoNgoi   = diaDiem.SoChoNgoi,
                SoChoConLai = diaDiem.SoChoConLai,
                TrangThai   = diaDiem.TrangThai,
            };

            if (bll.CapNhat(dd) == true)
            {
                status = true;
            }

            return(Json(new
            {
                status = status
            }));
        }
Пример #7
0
        public override string ToStringFile()
        {
            string s = ", ";

            return(Maso.PadRight(7, ' ') + s + loai.PadRight(10, ' ') + s + Ten.PadRight(23, ' ') + s + NgayGio.ToString(formatXuat).PadRight(24, ' ')
                   + s + DiaDiem.PadRight(10, ' ') + s + DienGia.PadRight(10, ' ') + s + SoLuong);
        }
Пример #8
0
 public virtual void DeleteDiaDiem(DiaDiem _item)
 {
     if (_item == null)
     {
         throw new ArgumentNullException("DiaDiem");
     }
     _diadiemRepository.Delete(_item);
 }
Пример #9
0
        public void Delete(Guid CaThiID, Guid MonThiID, Guid PhongThiID)
        {
            CtMtsController ctmt    = new CtMtsController();
            Guid?           ctmtID  = ctmt.GetCtMtID(CaThiID, MonThiID);
            DiaDiem         diadiem = db.DiaDiem.Where(u => u.CaMtId == ctmtID && u.PhongThiId == PhongThiID).FirstOrDefault();

            db.DiaDiem.Remove(diadiem);
            db.SaveChanges();
        }
Пример #10
0
 public virtual void UpdateDiaDiem(DiaDiem _item)
 {
     if (_item == null)
     {
         throw new ArgumentNullException("DiaDiem");
     }
     _item.TenKhongDau = CVCommon.convertToUnSign(_item.Ten);
     _diadiemRepository.Update(_item);
 }
Пример #11
0
        public bool CapNhat(DiaDiem entity)
        {
            var diadiem = db.DiaDiems.Find(entity.ID);

            diadiem.TenDiaDiem  = entity.TenDiaDiem;
            diadiem.MotaChiTiet = entity.MotaChiTiet;
            diadiem.Images      = entity.Images;
            db.SaveChanges();
            return(true);
        }
Пример #12
0
        public IHttpActionResult GetDiaDiem(string id)
        {
            DiaDiem diaDiem = db.DiaDiems.Find(id);

            if (diaDiem == null)
            {
                return(NotFound());
            }

            return(Ok(diaDiem));
        }
Пример #13
0
        public void Post([FromBody] Object _DiaDiem)
        {
            DiaDiem DiaDiem = (DiaDiem)Serializer.Deserialize <DiaDiem>(_DiaDiem.ToString());
            bool    isValid = db.DiaDiem.Where(u => u.CaMtId == DiaDiem.CaMtId && u.PhongThiId == DiaDiem.PhongThiId).Count() == 0;

            if (isValid)
            {
                DiaDiem.DiaDiemId = Guid.NewGuid();
                db.DiaDiem.Add(DiaDiem);
                db.SaveChanges();
            }
        }
        private DiaDiem GetDiaDiem(int nguonid, ENLoaiDiaDiem loai)
        {
            var item = _diadiemRepository.Table.Where(c => c.NguonId == nguonid && c.LoaiId == (int)loai).First();

            if (item == null)
            {
                item         = new DiaDiem();
                item.NguonId = nguonid;
                item.Loai    = loai;
            }
            return(item);
        }
Пример #15
0
        public bool CapNhat(DiaDiem item)
        {
            DiaDiemDAL dal = new DiaDiemDAL(db);

            if (item != null)
            {
                return(dal.CapNhat(item));
            }
            else
            {
                return(false);
            }
        }
Пример #16
0
        private DiaDiem GetDiaDiem(int nguonid, ENLoaiDiaDiem loai)
        {
            var item = _diadiemRepository.Table.Where(c => c.NguonId == nguonid && c.LoaiId == (int)loai);

            if (item.Count() == 0)
            {
                var dd = new DiaDiem();
                dd.NguonId = nguonid;
                dd.Loai    = loai;
                return(dd);
            }
            return(item.First());
        }
Пример #17
0
        public IHttpActionResult DeleteDiaDiem(string id)
        {
            DiaDiem diaDiem = db.DiaDiems.Find(id);

            if (diaDiem == null)
            {
                return(NotFound());
            }

            db.DiaDiems.Remove(diaDiem);
            db.SaveChanges();

            return(Ok(diaDiem));
        }
Пример #18
0
        public static DiaDiemModel ToModel(this DiaDiem nvfrom, ILocalizationService _localizationService)
        {
            var nvto = new DiaDiemModel();

            if (nvfrom == null)
            {
                return(nvto);
            }
            nvto.Id       = nvfrom.Id;
            nvto.Ten      = nvfrom.Ten;
            nvto.NguonId  = nvfrom.NguonId;
            nvto.LoaiId   = nvfrom.LoaiId;
            nvto.LoaiText = nvfrom.Loai.ToCVEnumText(_localizationService);
            return(nvto);
        }
        public JsonResult Delete(string id)
        {
            bool    status  = false;
            string  message = string.Empty;
            DiaDiem dd      = bll.TimKiemTheoMa(id);

            if (bll.Xoa(dd) == true)
            {
                status = true;
            }
            return(Json(new
            {
                status = status
            }));
        }
        public ActionResult CapNhatDiaDiem(int Id)
        {
            try
            {
                HienThiDanhSachTinh();
                DiaDiem objDiaDiem = DataProvider.Entities.DiaDiems.Where(c => c.Id == Id).Single <DiaDiem>();

                return(View(objDiaDiem));
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                return(Redirect("~/ErrorPage/Return"));
            }
        }
Пример #21
0
 public int Sua(object a)
 {
     try
     {
         if (a.GetType().ToString().IndexOf("Tour") > 1)
         {
             Tour temp = (Tour)a;
             temp = db.Tours.Where(s => s.Id == temp.Id).FirstOrDefault();
             db.Entry(temp).CurrentValues.SetValues(a);
         }
         else if (a.GetType().ToString().IndexOf("TinhThanh") > 1)
         {
             TinhThanh temp = (TinhThanh)a;
             temp = db.TinhThanhs.Where(s => s.Id == temp.Id).First();
             db.Entry(temp).CurrentValues.SetValues(a);
         }
         else if (a.GetType().ToString().IndexOf("DiaDiem") > 1)
         {
             DiaDiem temp = (DiaDiem)a;
             temp = db.DiaDiems.Where(s => s.Id == temp.Id).First();
             db.Entry(temp).CurrentValues.SetValues(a);
         }
         else if (a.GetType().ToString().IndexOf("LoaiDL") > 1)
         {
             LoaiDL temp = (LoaiDL)a;
             temp = db.LoaiDLs.Where(s => s.Id == temp.Id).First();
             db.Entry(temp).CurrentValues.SetValues(a);
         }
         else if (a.GetType().ToString().IndexOf("CTTour") > 1)
         {
             CTTour temp = (CTTour)a;
             temp = db.CTTours.Where(s => s.Id == temp.Id).First();
             db.Entry(temp).CurrentValues.SetValues(a);
         }
         else if (a.GetType().ToString().IndexOf("GiaTour") > 1)
         {
             GiaTour temp = (GiaTour)a;
             temp = db.GiaTours.Where(s => s.Id == temp.Id).First();
             db.Entry(temp).CurrentValues.SetValues(a);
         }
         db.SaveChanges();
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Пример #22
0
        public void Add(Guid CaThiID, Guid MonThiID, Guid PhongThiID)
        {
            CtMtsController ctmt    = new CtMtsController();
            Guid?           ctmtID  = ctmt.GetCtMtID(CaThiID, MonThiID);
            bool            isValid = db.DiaDiem.Where(u => u.CaMtId == ctmtID && u.PhongThiId == PhongThiID).Count() == 0;

            if (isValid)
            {
                DiaDiem diadiem = new DiaDiem();
                diadiem.DiaDiemId  = Guid.NewGuid();
                diadiem.CaMtId     = ctmtID;
                diadiem.PhongThiId = PhongThiID;
                db.DiaDiem.Add(diadiem);
                db.SaveChanges();
            }
        }
Пример #23
0
        private void txtThemDD_Click(object sender, EventArgs e)
        {
            DiaDiem dd = new DiaDiem();

            dd.TenDiaDiem  = txtTenDD.Text;
            dd.TinhThanhId = dstinh[cbTinhThanh.SelectedIndex].Id;
            if (db.Them(dd) > 0)
            {
                MessageBox.Show("Thêm thành công");
            }
            else
            {
                MessageBox.Show("Thêm thất bại");
            }
            refeshDD();
        }
Пример #24
0
 private void dataGridView1_SelectionChanged(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count > 0 && dataGridView1.CurrentCell.RowIndex >= 0)
     {
         int             dong = dataGridView1.CurrentCell.RowIndex;
         DataGridViewRow row  = dataGridView1.Rows[dong];
         int             id   = int.Parse(row.Cells[0].Value.ToString());
         curDiaDiem = listDiaDiem.Select(c => c).Where(s => s.Id == id).FirstOrDefault();
         //Console.WriteLine(curTour.Ten);
         if (curDiaDiem != null)
         {
             txId.Text     = curDiaDiem.Id.ToString();
             txTen.Text    = curDiaDiem.Ten.Trim();
             txGHichu.Text = curDiaDiem.GhiChu;
         }
     }
 }
Пример #25
0
        public ActionResult Create(DiaDiem diadiem)
        {
            if (ModelState.IsValid)
            {
                var dao = new DiaDiemDao();

                long id = dao.Them(diadiem);
                if (id > 0)
                {
                    return RedirectToAction("Index", "DiaDiem");
                }
                else
                {
                    ModelState.AddModelError("", "Thêm địa điểm không thành công !");
                }
            }
            return View("Index");
        }
Пример #26
0
 public HttpResponseMessage Get(string str)
 {
     if (Test() == false)
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
     }
     try
     {
         DiaDiemDAO ddO = new DiaDiemDAO();
         DiaDiem[] result = new DiaDiem[ddO.getDsDiaDiem(str).Count];
         result = ddO.getDsDiaDiem(str).ToArray();
         var response = Request.CreateResponse<IEnumerable<DiaDiem>>(HttpStatusCode.Created, result);
         return response;
     }
     catch (Exception e)
     {
         return new HttpResponseMessage(HttpStatusCode.NotFound);
     }
 }
Пример #27
0
        public ActionResult Edit(DiaDiem diadiem)
        {
            if (ModelState.IsValid)
            {
                var dao = new DiaDiemDao();

                var result = dao.CapNhat(diadiem);

                if (result)
                {
                    return RedirectToAction("Index", "DiaDiem");
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật địa điểm không thành công !");
                }
            }
            return View("Index");
        }
Пример #28
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            if (curDiaDiem.KiemtraXoa())
            {
                curDiaDiem.Delete();
                if (listDiaDiem.Count > 0)
                {
                    curDiaDiem = listDiaDiem[0];
                }

                listDiaDiem = DalDiaDiem.GetAllDiaDiem();
                loadData();
            }
            else
            {
                MessageBox.Show("Dia dieem da duoc su dung nen khong the xoa", "Lỗi: Dia diem da duoc su dung!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
Пример #29
0
        public bool Xoa(DiaDiem item)
        {
            DiaDiemDAL dal = new DiaDiemDAL(db);

            try
            {
                if (item != null)
                {
                    return(dal.Xoa(item));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #30
0
        public ActionResult ThemMoiDiaDiem(DiaDiem diaDiem, HttpPostedFileBase post)
        {
            try
            {
                if (post != null)
                {
                    var paths = Server.MapPath("~/content/images/Destinations/");
                    var path  = "/Content/images/Destinations/";
                    post.SaveAs(paths + post.FileName);
                    diaDiem.DuongDanAnh = path + post.FileName;
                }

                _context.DiaDiems.Add(diaDiem);
                _context.SaveChanges();
                return(RedirectToAction("QuanLyDiaDiem"));
            }
            catch
            {
                return(View());
            }
        }