Exemple #1
0
        /// <summary>
        /// 根据做法类型id查询和显示该做法类型下的所有做法
        /// </summary>
        /// <param name="wayTypeId">做法类型id</param>
        /// <param name="type">type=0表示全部加载数据,并显示到表格中,type!=0表示选中树节点时显示其对应的数据</param>
        private void LoadBaseData(DischesWayName dwn, int type)
        {
            if (dwn == null)
            {
                return;
            }
            int wayTypeId = dwn.DischesWayNameId;

            if (type != 0)
            {
                DishesWayTableItems.Clear();
            }
            //加载数据
            ICollection <DischesWay> dws = dwn.DischesWay;

            if (dws != null)
            {
                foreach (var d in dws)
                {
                    if (d.Deleted == 1)
                    {
                        continue;
                    }
                    _DishesWayBean = new DishesWayBean();
                    _DishesWayBean.CreateDishesWayBean(d);
                    _DishesWayBean.DischesWayName = dwn.Name;
                    //设置显示行号和编码
                    _DishesWayBean.LineNumber = DishesWayTableItems.Count + 1;
                    StringBuilder sb = new StringBuilder();
                    if (wayTypeId < 10)
                    {
                        if (wayTypeId == 0)
                        {
                            sb.Append(wayTypeId);
                        }
                        else
                        {
                            sb.Append("0").Append(wayTypeId);
                        }
                    }
                    else
                    {
                        sb.Append(wayTypeId);
                    }
                    sb.Append(d.Code);
                    _DishesWayBean.Code = sb.ToString();
                    if (!SelectedFlag)
                    {
                        DishesWaySelectedItem = DishesWayBean;
                        SelectedFlag          = true;
                    }
                    DishesWayTableItems.Add(_DishesWayBean);
                }
            }
        }
Exemple #2
0
        private void LoadDishesWayData(DischesWayName dwn, TreeNodeModel node)
        {
            ICollection <DischesWay> dws = dwn.DischesWay;

            if (dws != null)
            {
                foreach (var d in dws)
                {
                    if (d.Deleted == 0)
                    {
                        _DishesWayBean = new DishesWayBean();
                        _DishesWayBean.CreateDishesWayBean(d);
                        _DishesWayBean.LineNumber = DishesWayTableItems.Count + 1;
                        DishesWayTableItems.Add(DishesWayBean);
                    }
                }
            }
        }
        /// <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();
        }