Example #1
0
        /// <summary>
        /// 重命名产品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRename_Click(object sender, EventArgs e)
        {
            string souce = (string)lbxProductCategory.SelectedValue;

            if (souce == (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"))
            {
                HTUi.PopError("当前产品名称不可修改");
                return;
            }

            String newname = "";

            if (!MSG.Inputbox("new", "rename", out newname))
            {
                return;
            }

            if (newname == string.Empty)
            {
                HTUi.PopWarn("命名错误,名字不能为空");
                return;
            }
            var pdtlist = GetProductList();

            foreach (var pdt in pdtlist)
            {
                if (pdt == newname)
                {
                    HTUi.PopWarn("命名冲突,当前产品已存在");
                    return;
                }
            }

            //重新命名Recipe manager中recipe ID
            JFDLAFProductRecipe jFDLAFProductRecipe = JFHubCenter.Instance.RecipeManager.GetRecipe("Product", (string)souce) as JFDLAFProductRecipe;

            if (jFDLAFProductRecipe == null)
            {
                HTUi.PopWarn("Recipe Manager中不存在recipe:" + souce);
                return;
            }
            jFDLAFProductRecipe.Categoty = "Product";
            jFDLAFProductRecipe.ID       = newname;

            JFDLAFBoxRecipe jFDLAFBoxRecipe = JFHubCenter.Instance.RecipeManager.GetRecipe("Box", (string)souce) as JFDLAFBoxRecipe;

            if (jFDLAFBoxRecipe == null)
            {
                HTUi.PopWarn("Recipe Manager中不存在recipe:" + souce);
                return;
            }
            jFDLAFBoxRecipe.Categoty = "Box";
            jFDLAFBoxRecipe.ID       = newname;

            JFHubCenter.Instance.RecipeManager.AddRecipe(jFDLAFProductRecipe.Categoty, jFDLAFProductRecipe.ID, jFDLAFProductRecipe as IJFRecipe);
            JFHubCenter.Instance.RecipeManager.AddRecipe(jFDLAFBoxRecipe.Categoty, jFDLAFBoxRecipe.ID, jFDLAFBoxRecipe as IJFRecipe);
            JFHubCenter.Instance.RecipeManager.RemoveRecipe("Product", souce);
            JFHubCenter.Instance.RecipeManager.RemoveRecipe("Box", souce);
            JFHubCenter.Instance.RecipeManager.Save();

            ChangeProdcutName(newname, souce);
            HTUi.TipHint("重命名成功!");
            lbxProductCategory.DataSource = GetProductList();
            return;
        }
Example #2
0
        /// <summary>
        /// 创建产品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateProduct_Click(object sender, EventArgs e)
        {
            String newfile = "";

            if (!MSG.Inputbox("Copy&New", "请输入新的产品名", out newfile))
            {
                return;
            }

            if (newfile == string.Empty)
            {
                HTUi.PopWarn("命名错误,名字不能为空");
                return;
            }
            //新增Product Recipe到recipe Dictionary中
            JFDLAFProductRecipe jFDLAFProductRecipe = new JFDLAFProductRecipe();

            if (JFHubCenter.Instance.RecipeManager.GetRecipe("Product", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID")) != null)
            {
                jFDLAFProductRecipe = ((JFDLAFProductRecipe)JFHubCenter.Instance.RecipeManager.GetRecipe("Product", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"))).Clone();
            }

            jFDLAFProductRecipe.ID       = newfile;
            jFDLAFProductRecipe.Categoty = "Product";
            jFDLAFProductRecipe.SaveParamsToCfg();
            JFHubCenter.Instance.RecipeManager.AddRecipe(jFDLAFProductRecipe.Categoty, jFDLAFProductRecipe.ID, jFDLAFProductRecipe as IJFRecipe);


            ////新增Box Recipe到recipe Dictionary中
            JFDLAFBoxRecipe jFDLAFBoxRecipe = new JFDLAFBoxRecipe();

            if (JFHubCenter.Instance.RecipeManager.GetRecipe("Box", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID")) != null)
            {
                jFDLAFBoxRecipe = ((JFDLAFBoxRecipe)JFHubCenter.Instance.RecipeManager.GetRecipe("Box", (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID"))).Clone();
            }
            jFDLAFBoxRecipe.MagezineBox = jFDLAFProductRecipe.MagezineBox;
            jFDLAFBoxRecipe.MgzIdx      = jFDLAFProductRecipe.MgzIdx;
            jFDLAFBoxRecipe.ID          = newfile;
            jFDLAFBoxRecipe.Categoty    = "Box";
            jFDLAFBoxRecipe.SaveParamsToCfg();
            JFHubCenter.Instance.RecipeManager.AddRecipe(jFDLAFBoxRecipe.Categoty, jFDLAFBoxRecipe.ID, jFDLAFBoxRecipe as IJFRecipe);

            //此处后面需要保存
            JFHubCenter.Instance.RecipeManager.Save();

            var pdtlist = GetProductList();

            foreach (var pdt in pdtlist)
            {
                if (pdt == newfile)
                {
                    HTUi.PopWarn("无法新建,当前产品已存在");
                    return;
                }
            }
            string souce = (string)JFHubCenter.Instance.SystemCfg.GetItemValue("CurrentID");

            if (!CreateProduct(souce, newfile))
            {
                HTUi.PopWarn("产品创建失败!");
                return;
            }
            HTLog.Info("产品创建成功!");
            HTUi.TipHint("产品创建成功!");
            lbxProductCategory.DataSource = GetProductList();
            return;
        }