//加载选中项
 private void LoadLittleRawMaterial(TreeNodeModel node)
 {
     new Task(() =>
     {
         List<Raw> raws = _MaterialDataService.FindAllRawByBigRawIdAndDeletedStatus(int.Parse(node.Id));
         DispatcherHelper.CheckBeginInvokeOnUI(() =>
         {
             LittleMaterialItems.Clear();
             if (raws != null)
             {
                 foreach (var raw in raws)
                 {
                     _LittleRawMaterialBean = new LittleRawMaterialBean();
                     _LittleRawMaterialBean.Code = (LittleMaterialItems.Count + 1).ToString();
                     _LittleRawMaterialBean.ParentRaw = node.Text;
                     _LittleRawMaterialBean.CreateLittleRawMaterialBean(raw);
                     LittleMaterialItems.Add(LittleRawMaterialBean);
                 }
             }
         });
     }).Start();
 }
        //加载小类树和对应的数据
        private void InitLittleRawMaterial()
        {
            _LittleRootTreeNode = null;
            _LittleRootTreeNode = new TreeNodeModel("全部大类");
            _LittleRootTreeNode.Expanded = true;

            List<Raw> raws = _MaterialDataService.FindAllBigRawByDeletedStatus();
            if (raws != null)
            {
                LittleMaterialItems.Clear();
                foreach (var raw in raws)
                {
                    if (raw.ParentRawId == 0 || raw.ParentRawId == null)
                    {
                        TreeNodeModel node = new TreeNodeModel(raw.Name, _LittleRootTreeNode);
                        _LittleRootTreeNode.Children.Add(node);
                        node.Id = raw.RawId.ToString();
                        //根据大类编号查找全部的小类
                        List<Raw> childrens = _MaterialDataService.FindAllRawByBigRawIdAndDeletedStatus(raw.RawId);
                        if (childrens != null)
                        {
                            foreach (var child in childrens)
                            {
                                _LittleRawMaterialBean = new LittleRawMaterialBean();
                                _LittleRawMaterialBean.CreateLittleRawMaterialBean(child);
                                _LittleRawMaterialBean.Code = (LittleMaterialItems.Count + 1).ToString();
                                _LittleRawMaterialBean.ParentRaw = node.Text;
                                _LittleMaterialItems.Add(LittleRawMaterialBean);
                            }
                        }

                    }

                }
            }

            _LittleFirstGeneration = new ObservableCollection<TreeNodeModel>(new TreeNodeModel[] { _LittleRootTreeNode });
        }
 //type=0表示新增原料资料,type=1表示新增大类,type=2表示新增小类,type=3表示新增单位
 private void AddData(int type)
 {
     switch (type)
     {
         case 1:   //新增大类
             
             _BaseMaterialBean = new BaseMaterialBean();
             _BaseMaterialBean.Name = "";
             _RawMaterialBean.CreateBy = SubjectUtils.GetAuthenticationId();
             _RawMaterialBean.CreateDatetime = DateTime.Now;
             _BaseMaterialBean.Code = (BaseRawMaterialItems.Count + 1).ToString();
             BaseRawMaterialItems.Add(BaseMaterialBean);
             break;
         case 2:  //小类
             if (SelectedLittleRawNode != null)
             {
                 _LittleRawMaterialBean = new LittleRawMaterialBean();
                 _LittleRawMaterialBean.Name = "";
                 _LittleRawMaterialBean.Code = (LittleMaterialItems.Count + 1).ToString();
                 _LittleRawMaterialBean.ParentRawId = int.Parse(SelectedLittleRawNode.Id);
                 _LittleRawMaterialBean.ParentRaw = SelectedLittleRawNode.Text;
                 _LittleRawMaterialBean.CreateBy = SubjectUtils.GetAuthenticationId();
                 _LittleRawMaterialBean.CreateDatetime = DateTime.Now;
                 LittleMaterialItems.Add(LittleRawMaterialBean);
             }
             break;
         case 3:  //单位
             _BaseMaterialBean = new BaseMaterialBean();
             _BaseMaterialBean.Name = "";
             _BaseMaterialBean.Code = (BaseRawMaterialItems.Count + 1).ToString();
             _RawMaterialBean.CreateBy = SubjectUtils.GetAuthenticationId();
             _RawMaterialBean.CreateDatetime = DateTime.Now;
             BaseRawMaterialItems.Add(BaseMaterialBean);
             break;
         default:  //原料资料
             //把界面上的一下东东隐藏和显示
             if (SelectedRawNode == null || SelectedRawNode.Parent.Equals(RootTreeNode))
             {
                 MessageBox.Show("请选择原料小类");
                 return;
             }
             else
             {
                 //是小类,弹出新增原料页面
                 AddRawMaterialBaseData();
                 RawMaterialXaml = new RawMaterialView();
                 RawMaterialXaml.RecordControll.Visibility = Visibility.Hidden;
                 RawMaterialXaml.Continue.Visibility = Visibility.Visible;
                 RawMaterialXaml.ShowDialog();
             }
             break;
     }
 }