/// <summary> /// 切换选择的条目,主要用于查看上一条和下一条记录 /// 0是上一条记录,1是下一条记录 /// </summary> /// <param name="type"></param> private void SwitchSelectedItem(int type) { switch (type) { case 0: currentItem = DishesWayTableItems.IndexOf(DishesWaySelectedItem) - 1; break; case 1: currentItem = DishesWayTableItems.IndexOf(DishesWaySelectedItem) + 1; break; } if (currentItem < 0) { MessageBox.Show("已经是第一条记录了!"); currentItem = 0; return; } if (currentItem > DishesWayTableItems.Count - 1) { MessageBox.Show("已经是最后一条记录了!"); currentItem = DishesWayTableItems.Count - 1; return; } DishesWaySelectedItem = DishesWayTableItems.ElementAt(currentItem); DishesWayBean = DishesWaySelectedItem; DishesWayBean.CurrentScaleText = (currentItem + 1) + "/" + DishesWayTableItems.Count; }
/// <summary> /// 0代表是新增做法类型 1表示修改做法类型 /// </summary> /// <param name="type"></param> private void OpenDishesWin(ButtonEventType type) { DishesWaySettingXaml = new DishesWaySettingWindow(); switch (type) { case ButtonEventType.ADD: if (SelectedTreeNode == null) { MessageBox.Show("请选择做法类型!"); return; } InitAddData(); DishesWaySettingXaml.AddDescription.Visibility = Visibility.Visible; DishesWaySettingXaml.Continue.Visibility = Visibility.Visible; DishesWaySettingXaml.UpdateRecord.Visibility = Visibility.Hidden; break; case ButtonEventType.UPDATE: if (DishesWaySelectedItem == null) { MessageBox.Show("请选择要修改的做法!"); return; } DishesWayBean = new DishesWayBean(); DishesWayBean.IsReadOnlyCode = true; DishesWaySelectedItem.UpdateBy = SubjectUtils.GetAuthenticationId(); DishesWaySelectedItem.UpdateDatetime = DateTime.Now; DishesWayBean.CreateDishesWayBean(DishesWaySelectedItem); DishesWayBean.CurrentScaleText = (DishesWayTableItems.IndexOf(DishesWaySelectedItem) + 1) + "/" + DishesWayTableItems.Count; DishesWaySettingXaml.AddDescription.Visibility = Visibility.Hidden; DishesWaySettingXaml.Continue.Visibility = Visibility.Hidden; DishesWaySettingXaml.UpdateRecord.Visibility = Visibility.Visible; break; } DishesWaySettingXaml.ShowDialog(); }