protected void OnPlaceRightClicked(Place place) { MenuItem openPlace; MenuItem addToReserve; MenuItem removeFromReserve; MenuItem openReserve; Menu dropDown = new Menu (); openPlace = new MenuItem ("Открыть место"); openPlace.Activated += (s,args) => { var dlg = new PlaceDlg (place.Id); dlg.Show(); dlg.Run(); dlg.Destroy(); }; openPlace.Show (); dropDown.Append (openPlace); if (planviewwidget1.CurrentReserve != null) { if (planviewwidget1.CurrentReserve.Places.Any(p=>p.Id==place.Id)) { removeFromReserve = new MenuItem ("Удалить из резерва"); removeFromReserve.Activated += (s, args) => { planviewwidget1.CurrentReserve.Places.Remove( planviewwidget1.CurrentReserve.Places.Where(p=>p.Id==place.Id).Single() ); OnReserveChanged(this,null); }; dropDown.Append (removeFromReserve); removeFromReserve.Show (); }else{ Polygon polygon = planviewwidget1.Floor.Polygons.Single (p => p.Place.Id == place.Id); if (polygon.Status == PlaceStatus.Vacant) { addToReserve = new MenuItem ("Добавить в резерв"); addToReserve.Activated += (s, args) => { planviewwidget1.CurrentReserve.Places.Add (place); OnReserveChanged (this, null); }; dropDown.Append (addToReserve); addToReserve.Show (); } } } else { Reserve reserve; using (var tempUoW = UnitOfWorkFactory.CreateWithoutRoot ()) { reserve = tempUoW.Session.QueryOver<Reserve> ().Where(r=>r.Date>DateTime.Today).JoinQueryOver<Place>(r=>r.Places).Where(p=>p.Id==place.Id).SingleOrDefault (); } if (reserve!= null) { openReserve = new MenuItem ("Открыть резерв"); openReserve.Activated += (s, args) => { uow = UnitOfWorkFactory.CreateForRoot<Reserve>(reserve.Id); planviewwidget1.CurrentReserve = uow.Root; reserveDeleteButton.Sensitive=true; OnReserveChanged (this, null); }; dropDown.Append (openReserve); openReserve.Show (); } } dropDown.Popup (); }
protected virtual void OnPlaceOpenPlace(object o, EventArgs args) { int result, type; string place; TreeIter iter; treeviewPlaces.Selection.GetSelected(out iter); place = PlaceSort.GetValue(iter, (int)PlaceCol.place_no).ToString (); type = Convert.ToInt32(PlaceSort.GetValue(iter, (int)PlaceCol.type_place_id)); int id = Convert.ToInt32(PlaceSort.GetValue(iter, (int)PlaceCol.id)); PlaceDlg winPlace = new PlaceDlg(id); winPlace.Show(); result = winPlace.Run(); winPlace.Destroy(); if((ResponseType)result == ResponseType.Ok) { UpdatePlaces(); } }
protected virtual void OnButtonViewClicked(object sender, System.EventArgs e) { TreeIter iter; int type, itemid; string place; ResponseType result; switch (notebookMain.CurrentPage) { case 0: treeviewPlaces.Selection.GetSelected (out iter); place = PlaceSort.GetValue (iter, (int)PlaceCol.place_no).ToString (); type = Convert.ToInt32 (PlaceSort.GetValue (iter, (int)PlaceCol.type_place_id)); int id = Convert.ToInt32 (PlaceSort.GetValue (iter, (int)PlaceCol.id)); PlaceDlg winPlace = new PlaceDlg (id); winPlace.Show (); result = (ResponseType)winPlace.Run (); winPlace.Destroy (); if (result == ResponseType.Ok) UpdatePlaces (); break; case 1: treeviewLessees.Selection.GetSelected (out iter); itemid = Convert.ToInt32 (LesseesSort.GetValue (iter, (int)LesseesCol.id)); LesseeDlg winLessee = new LesseeDlg (); winLessee.Fill (itemid); winLessee.Show (); result = (ResponseType)winLessee.Run (); winLessee.Destroy (); if (result == ResponseType.Ok) UpdateLessees (); break; case 2: treeviewContract.Selection.GetSelected (out iter); itemid = (int)ContractSort.GetValue (iter, (int)ContractCol.id); ContractDlg winContract = new ContractDlg (itemid); winContract.Show (); result = (ResponseType)winContract.Run (); winContract.Destroy (); if (result == ResponseType.Ok) UpdateContract (); break; default: break; } }
protected virtual void OnButtonAddClicked(object sender, System.EventArgs e) { switch (notebookMain.CurrentPage) { case 0: PlaceDlg winPlace = new PlaceDlg (); winPlace.Show (); winPlace.Run (); winPlace.Destroy (); UpdatePlaces (); break; case 1: LesseeDlg winLessee = new LesseeDlg (); winLessee.Show (); winLessee.Run (); winLessee.Destroy (); UpdateLessees (); break; case 2: ContractDlg winContract = new ContractDlg (); winContract.Show (); winContract.Run (); winContract.Destroy (); UpdateContract (); break; default: break; } }