| | |
| | | using DevExpress.Utils.DragDrop; |
| | | using DevExpress.XtraEditors; |
| | | using HStation.WinFrmUI; |
| | | using Yw; |
| | | using Yw.WinFrmUI; |
| | | |
| | |
| | | public FacilityMgrPage() |
| | | { |
| | | InitializeComponent(); |
| | | this.gridView1.SetNormalView(30); |
| | | this.gridView1.Columns["PlaceID"].GroupIndex = 0; |
| | | this.gridView1.GroupFormat = "{1}"; |
| | | behaviorManager1.Detach<DragDropBehavior>(gridView1); |
| | | } |
| | | |
| | | private List<FacilityViewModel> _allBindingList; |
| | |
| | | _allBindingList.Add(new FacilityViewModel(item)); |
| | | } |
| | | } |
| | | this.placeViewModelBindingSource.DataSource = _allBindingList; |
| | | this.placeViewModelBindingSource.ResetBindings(false); |
| | | this.facilityViewModelBindingSource.DataSource = _allBindingList; |
| | | this.facilityViewModelBindingSource.ResetBindings(false); |
| | | var allFacility = await new PBS.BLL.Place().GetAll(); |
| | | repositoryItemTreeListLookUpEdit1.DataSource = allFacility; |
| | | } |
| | | |
| | | //新增小区 |
| | | private void btnAddBuilding_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | //新增 |
| | | private void BtnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | /* var dlg = new AddPlaceDlg(); |
| | | dlg.SetBindingData("Build"); |
| | | dlg.ReloadDataEvent += async (Vmo) => |
| | | { |
| | | var id = await _facilityBll.Insert(Vmo); |
| | | if (id > 0) |
| | | { |
| | | _allBindingList.Add(new PlaceViewModel(Vmo)); |
| | | this.placeViewModelBindingSource.ResetBindings(false); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog();*/ |
| | | var dlg = new AddFacilityDlg(); |
| | | dlg.SetBindingData(); |
| | | dlg.ReloadDataEvent += async (vmo) => |
| | | { |
| | | var id = await _facilityBll.Insert(vmo); |
| | | if (id > 0) |
| | | { |
| | | vmo.ID = id; |
| | | _allBindingList.Add(new FacilityViewModel(vmo)); |
| | | this.facilityViewModelBindingSource.ResetBindings(false); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //新增学校 |
| | | private void btnAddschool_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | //编辑 |
| | | private void barBtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | /* var dlg = new AddPlaceDlg(); |
| | | dlg.SetBindingData("School"); |
| | | dlg.ReloadDataEvent += async (Vmo) => |
| | | { |
| | | var id = await _facilityBll.Insert(Vmo); |
| | | if (id > 0) |
| | | { |
| | | _allBindingList.Add(new PlaceViewModel(Vmo)); |
| | | this.placeViewModelBindingSource.ResetBindings(false); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog();*/ |
| | | } |
| | | |
| | | //新增医院 |
| | | private void btnAddHospital_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | /* var dlg = new AddPlaceDlg(); |
| | | dlg.SetBindingData("Hospital"); |
| | | dlg.ReloadDataEvent += async (Vmo) => |
| | | { |
| | | var id = await _facilityBll.Insert(Vmo); |
| | | if (id > 0) |
| | | { |
| | | _allBindingList.Add(new PlaceViewModel(Vmo)); |
| | | this.placeViewModelBindingSource.ResetBindings(false); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | */ |
| | | } |
| | | |
| | | //新增商铺 |
| | | private void btnAddShop_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | /* var dlg = new AddPlaceDlg(); |
| | | dlg.SetBindingData("Shop"); |
| | | dlg.ReloadDataEvent += async (Vmo) => |
| | | { |
| | | var id = await _facilityBll.Insert(Vmo); |
| | | if (id > 0) |
| | | { |
| | | _allBindingList.Add(new PlaceViewModel(Vmo)); |
| | | this.placeViewModelBindingSource.ResetBindings(false); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | */ |
| | | var vm = this.gridView1.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | { |
| | | TipFormHelper.ShowWarn("请选择数据行"); |
| | | } |
| | | var dlg = new EditFacilityDlg(); |
| | | dlg.SetBindingData(vm.Vmo); |
| | | dlg.ReloadDataEvent += async (vmo) => |
| | | { |
| | | var bol = await _facilityBll.Update(vmo); |
| | | if (bol) |
| | | { |
| | | vm.Resert(vmo); |
| | | this.facilityViewModelBindingSource.ResetBindings(false); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //删除 |
| | |
| | | return; |
| | | } |
| | | _allBindingList.Remove(vm); |
| | | this.placeViewModelBindingSource.ResetBindings(false); |
| | | this.facilityViewModelBindingSource.ResetBindings(false); |
| | | TipFormHelper.ShowSucceed("删除成功!"); |
| | | } |
| | | |
| | |
| | | |
| | | private void barCkDrag_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | SetDragEnable(this.barCkDrag.Checked); |
| | | } |
| | | |
| | | //设置拖拽可用性 |
| | | private void SetDragEnable(bool allowArag) |
| | | { |
| | | var be = this.behaviorManager1.GetBehavior<DevExpress.Utils.DragDrop.DragDropBehavior>(this.gridView1); |
| | | be.Properties.AllowDrag = allowArag; |
| | | if (barCkDrag.Checked) |
| | | { |
| | | behaviorManager1.Attach<DragDropBehavior>(this.gridView1); |
| | | } |
| | | else |
| | | { |
| | | behaviorManager1.Detach<DragDropBehavior>(gridView1); |
| | | } |
| | | } |
| | | |
| | | private async void dragDropEvents1_DragDrop(object sender, DevExpress.Utils.DragDrop.DragDropEventArgs e) |
| | |
| | | TipFormHelper.ShowWarn("上移失败!"); |
| | | return; |
| | | } |
| | | var current = this.gridView1.GetRow(rowHandle) as PlaceViewModel; |
| | | var current = this.gridView1.GetRow(rowHandle) as FacilityViewModel; |
| | | if (current == null) |
| | | { |
| | | return; |
| | | } |
| | | var prevHandle = rowHandle - 1; |
| | | var prev = this.gridView1.GetRow(prevHandle) as PlaceViewModel; |
| | | var prev = this.gridView1.GetRow(prevHandle) as FacilityViewModel; |
| | | if (prev == null) |
| | | { |
| | | return; |
| | |
| | | current.SortCode = prev.SortCode; |
| | | prev.SortCode = sortCode; |
| | | _allBindingList = _allBindingList.OrderBy(x => x.SortCode).ToList(); |
| | | this.placeViewModelBindingSource.DataSource = _allBindingList; |
| | | this.placeViewModelBindingSource.ResetBindings(false); |
| | | this.facilityViewModelBindingSource.DataSource = _allBindingList; |
| | | this.facilityViewModelBindingSource.ResetBindings(false); |
| | | this.gridView1.FocusedRowHandle = prevHandle; |
| | | } |
| | | |
| | |
| | | TipFormHelper.ShowWarn("下移失败!"); |
| | | return; |
| | | } |
| | | var current = this.gridView1.GetRow(rowHandle) as PlaceViewModel; |
| | | var current = this.gridView1.GetRow(rowHandle) as FacilityViewModel; |
| | | if (current == null) |
| | | { |
| | | return; |
| | | } |
| | | var nextHandle = rowHandle + 1; |
| | | var next = this.gridView1.GetRow(nextHandle) as PlaceViewModel; |
| | | var next = this.gridView1.GetRow(nextHandle) as FacilityViewModel; |
| | | if (next == null) |
| | | { |
| | | return; |
| | |
| | | current.SortCode = next.SortCode; |
| | | next.SortCode = sortCode; |
| | | _allBindingList = _allBindingList.OrderBy(x => x.SortCode).ToList(); |
| | | this.placeViewModelBindingSource.DataSource = _allBindingList; |
| | | this.placeViewModelBindingSource.ResetBindings(false); |
| | | this.facilityViewModelBindingSource.DataSource = _allBindingList; |
| | | this.facilityViewModelBindingSource.ResetBindings(false); |
| | | this.gridView1.FocusedRowHandle = nextHandle; |
| | | } |
| | | |
| | | private void barBtnUpdateUseStatus_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var vm = this.gridView1.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new SetUseStatusDlg(); |
| | | dlg.SetBindingData((Yw.Model.eUseStatus)vm.UseStatus); |
| | | dlg.ReloadDataEvent += async (status) => |
| | | { |
| | | var bol = await new PBS.BLL.Facility().UpdateUseStatus(vm.ID, status); |
| | | if (bol) |
| | | { |
| | | vm.UseStatus = (Yw.Vmo.eUseStatus)(int)status; |
| | | this.gridView1.RefreshRow(this.gridView1.FocusedRowHandle); |
| | | return true; |
| | | } |
| | | return false; |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | } |
| | | } |