/// <summary>
        /// type=0表示正常保存新增或者修改,其他为上一条记录或者下一条记录保存
        /// </summary>
        /// <param name="type"></param>
        private void SaveDishesWay(int type)
        {
            if (string.IsNullOrEmpty(DishesWayBean.Code))
            {
                MessageBox.Show("请输入做法编码");
                return;
            }
            if (string.IsNullOrEmpty(DishesWayBean.Code.Trim()))
            {
                MessageBox.Show("做法编码不能是空字符!");
                return;
            }
            if (string.IsNullOrEmpty(DishesWayBean.Name))
            {
                MessageBox.Show("请输入做法名称");
                return;
            }
            if (string.IsNullOrEmpty(DishesWayBean.Name.Trim()))
            {
                MessageBox.Show("做法名称不能是空字符!");
                return;
            }
            bool hasSaveSuccess = false;
            //保存做法,调用数据持久层方法,将数据保存到数据库中
            DischesWay dw = DishesWayBean.CreateDishesWay(DishesWayBean);

            if (DishesWaySettingXaml.Continue.IsVisible)
            {
                //新增
                //hasSaveSuccess = _DataService.Add(dw);
                List <DischesWay> ddd = _DataService.FindDishesWayByCode(DishesWayBean.Code);
                if (ddd != null && ddd.Count > 1)
                {
                    //说明已经存在
                    MessageBox.Show("对不起,做法编码重复,不能保存!");
                    return;
                }
                hasSaveSuccess = _DataService.Add(DishesWayBean.Code, DishesWayBean.DischesWayNameId, DishesWayBean.Name, DishesWayBean.PingYing, DishesWayBean.AddPrice, DishesWayBean.AddPriceByNum);
            }
            else
            {
                //修改
                hasSaveSuccess = _DataService.Modify(dw);
            }
            if (hasSaveSuccess)
            {
                MessageBox.Show("保存成功");
                if (type == 0)
                {
                    DishesWaySettingXaml.Close();
                }
                DishesWaySettingXaml.IsTextBoxTextChanged = false;
                LoadTreeData(SelectedTreeNode);
            }
            else
            {
                MessageBox.Show("保存失败");
            }
            DishesWaySettingXaml.IsTextBoxTextChanged = false;
        }
Beispiel #2
0
        private void SaveDishesWay()
        {
            if (DishesWayBean.Name == null)
            {
                MessageBox.Show("请输入做法名称");
                return;
            }
            bool hasSaveSuccess = false;
            //保存做法,调用数据持久层方法,将数据保存到数据库中
            DischesWay dw = DishesWayBean.CreateDishesWay(DishesWayBean);

            if (DishesWaySettingXaml.Continue.IsVisible)
            {
                //新增
                hasSaveSuccess = _DataService.Add(dw);
            }
            else
            {
                //修改
                hasSaveSuccess = _DataService.Modify(dw);
            }
            if (hasSaveSuccess)
            {
                MessageBox.Show("保存成功");
                LoadTreeData(SelectedTreeNode);
            }
            else
            {
                MessageBox.Show("保存失败");
            }
            MarketTypeSetView.IsTextBoxTextChanged = false;
        }
Beispiel #3
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);
                }
            }
        }
Beispiel #4
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();
        }