public ActionResult Create([Bind(Include = "ProjectStatusName" )] ProjectStatus ProjectStatus) { if (ModelState.IsValid) { bool bSucess = false; bSucess = ProjectStatusData.Add(ProjectStatus); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Insert"); } } return(View(ProjectStatus)); }
public ActionResult DeleteConfirmed( Int32?ProjectStatusID ) { ProjectStatus ProjectStatus = new ProjectStatus(); ProjectStatus.ProjectStatusID = System.Convert.ToInt32(ProjectStatusID); ProjectStatus = ProjectStatusData.Select_Record(ProjectStatus); bool bSucess = false; bSucess = ProjectStatusData.Delete(ProjectStatus); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Delete"); } return(null); }
// GET: /ProjectStatus/Delete/<id> public ActionResult Delete( Int32?ProjectStatusID ) { if ( ProjectStatusID == null ) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectStatus ProjectStatus = new ProjectStatus(); ProjectStatus.ProjectStatusID = System.Convert.ToInt32(ProjectStatusID); ProjectStatus = ProjectStatusData.Select_Record(ProjectStatus); if (ProjectStatus == null) { return(HttpNotFound()); } return(View(ProjectStatus)); }
public ActionResult Edit(ProjectStatus ProjectStatus) { ProjectStatus oProjectStatus = new ProjectStatus(); oProjectStatus.ProjectStatusID = System.Convert.ToInt32(ProjectStatus.ProjectStatusID); oProjectStatus = ProjectStatusData.Select_Record(ProjectStatus); if (ModelState.IsValid) { bool bSucess = false; bSucess = ProjectStatusData.Update(oProjectStatus, ProjectStatus); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Update"); } } return(View(ProjectStatus)); }
// GET: /ProjectStatus/ public ActionResult Index(string sortOrder, String SearchField, String SearchCondition, String SearchText, String Export, int?PageSize, int?page, string command) { if (command == "Show All") { SearchField = null; SearchCondition = null; SearchText = null; Session["SearchField"] = null; Session["SearchCondition"] = null; Session["SearchText"] = null; } else if (command == "Add New Record") { return(RedirectToAction("Create")); } else if (command == "Export") { Session["Export"] = Export; } else if (command == "Search" | command == "Page Size") { if (!string.IsNullOrEmpty(SearchText)) { Session["SearchField"] = SearchField; Session["SearchCondition"] = SearchCondition; Session["SearchText"] = SearchText; } } if (command == "Page Size") { Session["PageSize"] = PageSize; } ViewData["SearchFields"] = GetFields((Session["SearchField"] == null ? "Project Status I D" : Convert.ToString(Session["SearchField"]))); ViewData["SearchConditions"] = Library.GetConditions((Session["SearchCondition"] == null ? "Contains" : Convert.ToString(Session["SearchCondition"]))); ViewData["SearchText"] = Session["SearchText"]; ViewData["Exports"] = Library.GetExports((Session["Export"] == null ? "Pdf" : Convert.ToString(Session["Export"]))); ViewData["PageSizes"] = Library.GetPageSizes(); ViewData["CurrentSort"] = sortOrder; ViewData["ProjectStatusIDSortParm"] = sortOrder == "ProjectStatusID_asc" ? "ProjectStatusID_desc" : "ProjectStatusID_asc"; ViewData["ProjectStatusNameSortParm"] = sortOrder == "ProjectStatusName_asc" ? "ProjectStatusName_desc" : "ProjectStatusName_asc"; dtProjectStatus = ProjectStatusData.SelectAll(); try { if (!string.IsNullOrEmpty(Convert.ToString(Session["SearchField"])) & !string.IsNullOrEmpty(Convert.ToString(Session["SearchCondition"])) & !string.IsNullOrEmpty(Convert.ToString(Session["SearchText"]))) { dtProjectStatus = ProjectStatusData.Search(Convert.ToString(Session["SearchField"]), Convert.ToString(Session["SearchCondition"]), Convert.ToString(Session["SearchText"])); } } catch { } var Query = from rowProjectStatus in dtProjectStatus.AsEnumerable() select new ProjectStatus() { ProjectStatusID = rowProjectStatus.Field <Int32>("ProjectStatusID") , ProjectStatusName = rowProjectStatus.Field <String>("ProjectStatusName") }; switch (sortOrder) { case "ProjectStatusID_desc": Query = Query.OrderByDescending(s => s.ProjectStatusID); break; case "ProjectStatusID_asc": Query = Query.OrderBy(s => s.ProjectStatusID); break; case "ProjectStatusName_desc": Query = Query.OrderByDescending(s => s.ProjectStatusName); break; case "ProjectStatusName_asc": Query = Query.OrderBy(s => s.ProjectStatusName); break; default: // Name ascending Query = Query.OrderBy(s => s.ProjectStatusID); break; } if (command == "Export") { GridView gv = new GridView(); DataTable dt = new DataTable(); dt.Columns.Add("Project Status I D", typeof(string)); dt.Columns.Add("Project Status Name", typeof(string)); foreach (var item in Query) { dt.Rows.Add( item.ProjectStatusID , item.ProjectStatusName ); } gv.DataSource = dt; gv.DataBind(); ExportData(Export, gv, dt); } int pageNumber = (page ?? 1); int?pageSZ = (Convert.ToInt32(Session["PageSize"]) == 0 ? 5 : Convert.ToInt32(Session["PageSize"])); return(View(Query.ToPagedList(pageNumber, (pageSZ ?? 5)))); }
private async void Init() { await viewModel.LoadProject(_id); await viewModel.LoadPostProjectID(_id); await viewModel.GetListProjectDiary(_id); if (viewModel.DuAn.ImageUtilities != null) { string[] utilitiesArr = viewModel.DuAn.ImageUtilities.Split(','); Option[] utilitiesImg = new Option[utilitiesArr.Length]; List <Option> tienichduan = BDSUtilities.GetListUtilities(); for (int i = 0; i < utilitiesArr.Length; i++) { var item = utilitiesArr[i]; Option model = tienichduan.Where(x => x.Id == short.Parse(item)).SingleOrDefault(); utilitiesImg[i] = model; } flowListView.FlowItemsSource = utilitiesImg; stTienIchDuAn.IsVisible = true; } if (viewModel.DuAn.ImageList != null) { string[] ListImages = viewModel.DuAn.ImageList; for (int i = 0; i < ListImages.Length; i++) { Photo photo = new Photo(); photo.URL = Api_Link + ListImages[i]; GetPhotos.Add(photo); } lbNumImages.Text = ListImages.Count().ToString(); carouseView.ItemsSource = GetPhotos; } if (viewModel.DuAn.CategoriBDS != null) { string[] categoriArr = viewModel.DuAn.CategoriBDS.Split(','); string[] categoryNameArr = new string[categoriArr.Length]; //projectType tren app la categoriBDS tren database List <ProjectTypeModel> loaiDuAn = ProjectTypeData.GetListProjectType(); for (int i = 0; i < categoriArr.Length; i++) { var item = categoriArr[i]; ProjectTypeModel model = loaiDuAn.Where(x => x.Id == short.Parse(item)).SingleOrDefault(); categoryNameArr[i] = model.Name; } lbCategoriBDS.Text = string.Join(". ", categoryNameArr); //lay "Status" if (viewModel.DuAn.Status.HasValue) { int idStatus = viewModel.DuAn.Status.Value; List <ProjectStatusModel> listStatus = ProjectStatusData.GetList(); ProjectStatusModel modelStatus = listStatus.Single(x => x.Id == idStatus); lbStatus.Text = modelStatus.Name; if (viewModel.DuAn.Status.Value == 0) { stThoiGianMoBan.IsVisible = true; stThoiGianBanGiao.IsVisible = true; } if (viewModel.DuAn.Status.Value == 1) { stThoiGianBanGiao.IsVisible = true; } } } await ChekcIsFollowPost(); loadingPopup.IsVisible = false; stNamKhoiCong.IsVisible = true; stNamHoanThanh.IsVisible = true; // load data "Tong quan du an" lbDienTichCayXanh.Text = viewModel.DuAn.DienTichCayXanh; lbDienTichKhuDat.Text = viewModel.DuAn.DienTichKhuDat; lbDienTichSanTrungBinh.Text = viewModel.DuAn.DienTichSanTrungBinh; lbDienTichXayDung.Text = viewModel.DuAn.DienTichXayDung; lbNamKhoiCong.Text = viewModel.DuAn.NamKhoiCong.ToString(); lbNamHoanThanh.Text = viewModel.DuAn.NamHoanThanh.ToString(); lbMatDoXayDung.Text = viewModel.DuAn.MatDoXayDungPercent.ToString(); lbSoLuongSanPham.Text = viewModel.DuAn.SoLuongSanPham; lbSoTang.Text = viewModel.DuAn.SoTang.ToString(); lbSoLuongToaNha.Text = viewModel.DuAn.SoLuongToaNha.ToString(); lbSoThangMay.Text = viewModel.DuAn.SoThangMay.ToString(); lbTongDienTichSan.Text = viewModel.DuAn.TongDienTichSan; lbTongSoVongDauTu.Text = viewModel.DuAn.TongVonDauTu; lbTangHam.Text = viewModel.DuAn.TangHam.ToString(); lbThoiGianMoBan.Text = viewModel.DuAn.ThoiGianMoBan.ToString(); lbThoiGianBanGiao.Text = viewModel.DuAn.ThoiGianBanGiao.ToString(); lblChuDauTu.Text = viewModel.DuAn.ChuDauTu; lblDonViThietKeThiCong.Text = viewModel.DuAn.DonViThietKeThiCong; lblPhanKhuDuAn.Text = viewModel.DuAn.PhanKhuDuAn; var gridChildren = grContent.Children.Where(x => x.IsVisible == true).ToList(); for (int i = 0; i < gridChildren.Count(); i++) { grContent.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(9, GridUnitType.Auto) }); Grid.SetRow(gridChildren[i], i); } }
public async void Init() { bool HasResult = await viewModel.LoadPost(_id); if (!HasResult) { await DisplayAlert("", Language.bai_dang_khong_ton_tai_hoac_da_xoa, Language.dong); await Navigation.PopAsync(); return; } // cau hinh button. SetFloatingButtonGroup(); // can thue can mua thi load comment ve. hien thi o comment. if (viewModel.GetPost.PostType == 2 || viewModel.GetPost.PostType == 3) { await viewModel.LoadPostComment(); StacklayoutPostComments.IsVisible = true; onClick_HideShow_Description(null, EventArgs.Empty); // dong lai mo ta. neu post type 2 3 MessagingCenter.Subscribe <PickPostPage>(this, "OnNewPostComment", async(sender) => { loadingPopup.IsVisible = true; viewModel.PostComments.Clear(); viewModel.PostCommentPage = 1; await viewModel.LoadPostComment(); loadingPopup.IsVisible = false; }); } else { StacklayoutPostComments.IsVisible = false; } lbLoaiBatDongSan.Text = LoaiBatDongSanModel.GetList(null).SingleOrDefault(x => x.Id == viewModel.GetPost.LoaiBatDongSanId).Name; if (viewModel.GetPost.PostType == 0 || viewModel.GetPost.PostType == 1) { stListImg.IsVisible = true; } if (viewModel.GetPost.PostType == 2 || viewModel.GetPost.PostType == 3) { gridContent.Margin = new Thickness(0, 10, 0, 0); // đây frame xuong cvBDSCungKhuVuc.HeightRequest = 90; frContentPost.Margin = new Thickness(10, 0, 10, 0); } //lấy danh sách Images if (viewModel.GetPost.ImageList != null) { string[] ListImages = viewModel.GetPost.ImageList; for (int i = 0; i < ListImages.Length; i++) { Photo photo = new Photo(); photo.URL = ImageHelper.GetImageUrl("post", ListImages[i]); GetPhotos.Add(photo); } lbNumImages.Text = ListImages.Count().ToString(); carouseView.ItemsSource = GetPhotos; } if (viewModel.GetPost.TinhTrangPhapLyId.HasValue) { var TinhTrangPhapLy = viewModel.GetPost.TinhTrangPhapLyId; List <TinhTrangPhapLyModel> tinhtrangphaplyModel = TinhTrangPhapLyData.GetList(); TinhTrangPhapLyModel modelTinhTrangPhapLy = tinhtrangphaplyModel.Where(x => x.Id == TinhTrangPhapLy).SingleOrDefault(); lbTinhTrangPhapLy.Text = modelTinhTrangPhapLy.Name; } if (viewModel.GetPost.HuongId.HasValue) { var HuongNha = viewModel.GetPost.HuongId; List <HuongModel> huongnhaModel = HuongData.GetList(); HuongModel modelHuong = huongnhaModel.Where(x => x.Id == HuongNha).SingleOrDefault(); lbHuongNha.Text = modelHuong.Name; } //set trang thai duu an. if (viewModel.GetPost.Project?.Status != null) { int id_Status = viewModel.GetPost.Project.Status.Value; List <ProjectStatusModel> listStatus = ProjectStatusData.GetList(); ProjectStatusModel modelStatus = listStatus.Single(x => x.Id == id_Status); spStatus.Text = modelStatus.Name; } //kiểm tra là lấy thông tin của "nội thất tiện nghi" if (viewModel.GetPost.Utilities != null) { string[] utilitiesArr = viewModel.GetPost.Utilities.Split(','); Option[] utilitiesImg = new Option[utilitiesArr.Length]; List <Option> tienichduan = BDSUtilities.GetListUtilities(); for (int i = 0; i < utilitiesArr.Length; i++) { var item = utilitiesArr[i]; Option model = tienichduan.Where(x => x.Id == short.Parse(item)).SingleOrDefault(); utilitiesImg[i] = model; } flvUtilities.FlowItemsSource = utilitiesImg; stNoiThatTienNghi.IsVisible = true; } else { stNoiThatTienNghi.IsVisible = false; } //kiểm tra. nếu có projectId thì cho hiện "Thuộc dự an" và lấy loại bất động sản if (viewModel.GetPost.ProjectId.HasValue) { // stThuocDuAn.IsVisible = true; Guid _idProject = viewModel.GetPost.ProjectId.Value; await viewModel.LoadBDSKhac(_id, _idProject); if (viewModel.BDSKhac.Count != 0) { stBDSKhac.IsVisible = true; } // lấy loại bất động sản string[] categoriArr = viewModel.GetPost.Project.CategoriBDS.Split(','); string[] newCategoriArr = new string[categoriArr.Length]; List <ProjectTypeModel> modelCategori = ProjectTypeData.GetListProjectType(); for (int i = 0; i < categoriArr.Length; i++) { var temp = categoriArr[i]; ProjectTypeModel categoriModel = modelCategori.Where(x => x.Id == short.Parse(temp)).SingleOrDefault(); newCategoriArr[i] = categoriModel.Name; } lbCatogoriBDS.Text = string.Join(", ", newCategoriArr); } //gán dữ liệ cho label lbTongDienTichSuDung.Text = viewModel.GetPost.AreaFormatText; lbDuongVao.Text = viewModel.GetPost.DuongVao.ToString(); lbMatTien.Text = viewModel.GetPost.MatTien.ToString(); lbChieuSau.Text = viewModel.GetPost.ChieuSau.ToString(); lbTang.Text = viewModel.GetPost.Tang.ToString(); lbSoTang.Text = viewModel.GetPost.NumOfFloor.ToString(); lbSoThangMay.Text = viewModel.GetPost.SoThangMay.ToString(); lbSoDuongNgu.Text = viewModel.GetPost.NumOfBedroom.ToString(); lbSoPhongtam.Text = viewModel.GetPost.NumOfBathroom.ToString(); // hiển thị thông tin trong phần "tổng quan dự án" (những thông tin luôn hiện) stTinhTrangPhapLy.IsVisible = true; stHuongNha.IsVisible = true; stTongDienTichSuDung.IsVisible = true; //hiển thị thông tin trong phần "tổng quan dự án" (kiểm tra theo loại bất động sản) var LoaiBatDongSan = viewModel.GetPost.LoaiBatDongSanId; if (LoaiBatDongSan == 0) { stTang.IsVisible = true; stSoPhongTam.IsVisible = true; stSoDuongNgu.IsVisible = true; } if (LoaiBatDongSan == 1) { stTang.IsVisible = true; stSoPhongTam.IsVisible = true; stSoDuongNgu.IsVisible = true; } if (LoaiBatDongSan == 2) { stDuongVao.IsVisible = true; stMatTien.IsVisible = true; stSoTang.IsVisible = true; stSoPhongTam.IsVisible = true; stSoDuongNgu.IsVisible = true; } if (LoaiBatDongSan == 3) { stDuongVao.IsVisible = true; stMatTien.IsVisible = true; stSoTang.IsVisible = true; stSoPhongTam.IsVisible = true; stSoDuongNgu.IsVisible = true; } if (LoaiBatDongSan == 4) { stDuongVao.IsVisible = true; stMatTien.IsVisible = true; stSoTang.IsVisible = true; stSoPhongTam.IsVisible = true; stSoDuongNgu.IsVisible = true; } if (LoaiBatDongSan == 5) { stTang.IsVisible = true; } if (LoaiBatDongSan == 6) { stTang.IsVisible = true; stSoThangMay.IsVisible = true; } if (LoaiBatDongSan == 7) { stDuongVao.IsVisible = true; stMatTien.IsVisible = true; stSoTang.IsVisible = true; stSoPhongTam.IsVisible = true; stSoDuongNgu.IsVisible = true; } if (LoaiBatDongSan == 8) { stDuongVao.IsVisible = true; stMatTien.IsVisible = true; stChieuSau.IsVisible = true; } if (LoaiBatDongSan == 9) { stDuongVao.IsVisible = true; stMatTien.IsVisible = true; stChieuSau.IsVisible = true; } if (LoaiBatDongSan == 10) { stDuongVao.IsVisible = true; stMatTien.IsVisible = true; stChieuSau.IsVisible = true; } var gridChildren = gridContent.Children.Where(x => x.IsVisible == true).ToList(); for (int i = 0; i < gridChildren.Count(); i++) { gridContent.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(9, GridUnitType.Auto) }); Grid.SetRow(gridChildren[i], i); } //check follow await ChekcIsFollowPost(); //disable loading loadingPopup.IsVisible = false; ScrollView_Detail_M_B.IsVisible = true; }
public async void InitUpdate() { AddToolBar(); var apiResponse = await ApiHelper.Get <AddProjectModel>("api/project/" + this._id); stThongTinBoSung.IsVisible = true; if (apiResponse.IsSuccess == false) { return; } var model = apiResponse.Content as AddProjectModel; viewModel.AddProjectModel = model; DecimailEntDienTichSanTrungBinh_From.SetPrice(model.DienTichSanTrungBinh_From); DecimalEntDienTichSanTrungBinh_To.SetPrice(model.DienTichSanTrungBinh_To); DecimalDienTichCayXanhFrom.SetPrice(model.DienTichCayXanh_From); DecimalDienTichCayXanhTo.SetPrice(model.DienTichCayXanh_To); DecimalDienTichKhuDatFrom.SetPrice(model.DienTichKhuDat_From); DecimalDienTichKhuDatTo.SetPrice(model.DienTichKhuDat_To); DecimalDienTichXayDungFrom.SetPrice(model.DienTichXayDung_From); DecimalDienTichXayDungTo.SetPrice(model.DienTichXayDung_To); DecimalEntryMatDoXayDung.SetPrice(model.MatDoXayDungPercent); //set title viewModel.TitlePostProject = viewModel.AddProjectModel.Name; await Task.WhenAll( viewModel.GetProvinceAsync(), viewModel.GetDistrictAsync(), viewModel.GetWardAsync() ); //gan lai tinh/thanh, quan/huyen, phuong/xa voi ID viewModel.AddProjectModel.Province = viewModel.ProvinceList.Single(x => x.Id == model.ProvinceId); viewModel.AddProjectModel.District = viewModel.DistrictList.Single(x => x.Id == model.DistrictId); viewModel.AddProjectModel.Ward = viewModel.WardList.Single(x => x.Id == model.WardId); //set loai du an cho control // Loai du an tren app = categoriBDS trong database if (!string.IsNullOrEmpty(model.CategoriBDS)) { string[] arrCategoriBDS = model.CategoriBDS.Split(','); List <int> listLoaiDuAn = new List <int>(); foreach (var item in arrCategoriBDS) { listLoaiDuAn.Add(int.Parse(item)); } viewModel.LoaiDuAnSelecteIds = listLoaiDuAn; } //set show cac stacklayout theo loai bat dong san (so tang, tang ham....) Show(); //set trang thai cho control if (model.Status != null) { string item = viewModel.AddProjectModel.Status; var listStatus = ProjectStatusData.GetList(); ProjectStatusModel modelStatus = listStatus.Where(x => x.Id == short.Parse(item)).Single(); viewModel.AddProjectModel.TrangThai = modelStatus; } else { viewModel.AddProjectModel.TrangThai = null; } //set hinh anh cho ffimageloading if (string.IsNullOrEmpty(model.Images) == false) { string[] imageList = model.Images.Split(','); foreach (var image in imageList) { viewModel.Media.Add(new MediaFile() { PreviewPath = ImageHelper.GetImageUrl("project", image), }); } } //set ckecked tien ich du an if (model.ImageUtilities != null) { string[] arrImageUtilities = viewModel.AddProjectModel.ImageUtilities.Split(','); List <int> list = new List <int>(); foreach (var item in arrImageUtilities) { list.Add(int.Parse(item)); } viewModel.TienIchDuAnSelecteIds = list; viewModel.NumUtilitiChecked = viewModel.TienIchDuAnSelecteIds.Count(); } loadingPopup.IsVisible = false; }