Ejemplo n.º 1
0
        //初始化设置
        public void Init()
        {
            if (mainDlg == null || string.IsNullOrEmpty(ProPath) || string.IsNullOrEmpty(ProName))
            {
                //缺少初值,所有控件禁用  正常情况不应执行到这里
                tsrSheetTree.Enabled = false;
                tabSheetTool.Enabled = false;
            }
            else
            {
                XmlFile = ToFullPath(NXFun.ProcessXML);
                IsEdit  = false;

                tsrSheetTree.Enabled = true;
                tabSheetTool.Enabled = true;
                //初始化子组件
                CharEdit.ProPath = ProPath;
                CharEdit.ProName = ProName;
                CharEdit.mainDlg = mainDlg;
                CharEdit.Init();

                LabelEdit.ProPath = ProPath;
                LabelEdit.ProName = ProName;
                LabelEdit.mainDlg = mainDlg;
                LabelEdit.Init();

                FreshSheetTree();
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var service = CreateCharService();
            var detail  = service.GetCharacterById(id);
            var model   =
                new CharEdit
            {
                Char_Id      = detail.Char_Id,
                Char_Name    = detail.Char_Name,
                Level        = detail.Level,
                Achievements = detail.Achievements
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        //Edit/Update character, takes a CharEdit and uses UpdateCharacter service
        public IHttpActionResult Put(CharEdit character)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }
            var    service = CreateCharService();
            string error   = (service.UpdateCharacter(character));

            if (error != null)
            {
                return(BadRequest(error));
            }

            return(Ok());
        }
Ejemplo n.º 4
0
        public bool UpdateChar(CharEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Characters
                    .Single(e => e.Char_Id == model.Char_Id && e.OwnerID == _userId);

                entity.Char_Name    = model.Char_Name;
                entity.Level        = model.Level;
                entity.Achievements = model.Achievements;
                entity.ModifiedUtc  = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 5
0
        public bool UpdateCharacter(CharEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity      = ctx.Characters.Single(e => e.ID == model.ID && e.UserID == _userId);
                var classEntity = ctx.CharClasses.FirstOrDefault(e => e.ID == entity.ID);

                entity.Alignment        = model.Alignment;
                entity.ExperiencePoints = model.ExperiencePoints;
                entity.CharHistory      = model.CharHistory;
                entity.Level            = model.Level;
                classEntity.ID          = model.CharClassID;


                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 6
0
        public ActionResult Edit(CharEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new CharService(userId);

            if (service.UpdateCharacter(model))
            {
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Character could not be edited.");
            return(View(model));
        }
Ejemplo n.º 7
0
        public string UpdateCharacter(CharEdit character)
        {
            using (var ctx = new ApplicationDbContext())
            {
                if (ctx.Characters.Count(e => e.CharId == character.CharId) == 0)
                {
                    return($"Character {character.CharId} NOT found in table");
                }
                var entity = ctx.Characters.Single(e => e.CharId == character.CharId);
                entity.Name             = character.Name;
                entity.ShortDescription = character.ShortDescription;
                entity.Description      = character.Description;
                entity.ModifiedOn       = DateTime.Now;

                if (ctx.SaveChanges() == 1)
                {
                    return(null);
                }

                return($"Character {character.CharId} NOT updated - unknown error");
            }
        }
Ejemplo n.º 8
0
        public ActionResult Edit(int id)
        {
            var games = new SelectList(_db.Games.ToList(), "GameID", "GameName");

            ViewBag.Games = games;


            var service = CreateCharService();
            var detail  = service.GetCharacterById(id);
            var model   =
                new CharEdit
            {
                Char_Id     = detail.Char_Id,
                GameID      = detail.GameID,
                GameName    = detail.GameName,
                Char_Name   = detail.Char_Name,
                Level       = detail.Level,
                Achievement = detail.Achievement
            };

            return(View(model));
        }
Ejemplo n.º 9
0
        public ActionResult Edit(int id, CharEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.Char_Id != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var service = CreateCharService();

            if (service.UpdateChar(model))
            {
                TempData["SaveResult"] = "Your Character was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Character could not be updated.");
            return(View());
        }
Ejemplo n.º 10
0
        //刷新图纸树
        public void FreshSheetTree()
        {
            tvwSheet.Nodes.Clear();
            tvwSheet.ImageIndex         = 3;
            tvwSheet.SelectedImageIndex = 3;
            //第一个为工艺节点
            TreeNode gyTreeNode = new TreeNode();
            string   filename   = XML3DPPM.GetModelName(0, 0, XmlFile);

            gyTreeNode.Text =
                XML3DPPM.GetIndexAttr(0, 0, "gongyi_jianming", XmlFile) +
                " (" +
                filename +
                ")";
            gyTreeNode.Tag = "Gongyi";
            bool IsNull = string.IsNullOrEmpty(filename);

            gyTreeNode.ImageIndex         = IsNull?1:0;
            gyTreeNode.SelectedImageIndex = IsNull ? 1 : 0;
            tvwSheet.Nodes.Add(gyTreeNode);
            if (!string.IsNullOrEmpty(filename))
            {
                List <S_Sheet> SheetTempletList = NXFun.GetSheetTempletList(ToFullPath(filename));
                foreach (S_Sheet sheet in SheetTempletList)
                {
                    TreeNode sheetTreeNode = new TreeNode();
                    sheetTreeNode.Text               = sheet.SheetName + "_" + sheet.Remark;
                    sheetTreeNode.Tag                = "Sheet";
                    sheetTreeNode.Name               = sheet.guid; //利用guid标识图纸
                    sheetTreeNode.ImageIndex         = 2;
                    sheetTreeNode.SelectedImageIndex = 2;
                    gyTreeNode.Nodes.Add(sheetTreeNode);
                }
            }
            //之后为工序节点
            int gxNum = XML3DPPM.GetGongxuCount(XmlFile);

            for (int i = 0; i < gxNum; i++)
            {
                TreeNode gxTreeNode = new TreeNode();
                filename        = XML3DPPM.GetModelName(0, i + 1, XmlFile);
                gxTreeNode.Text =
                    XML3DPPM.GetIndexAttr(i + 1, 0, "gongxu_gongxuhao", XmlFile) +
                    "_" +
                    XML3DPPM.GetIndexAttr(i + 1, 0, "gongxu_gongxumingcheng", XmlFile) +
                    " (" +
                    filename +
                    ")";
                gxTreeNode.Tag                = "Gongxu";
                IsNull                        = string.IsNullOrEmpty(filename);
                gxTreeNode.ImageIndex         = IsNull ? 1 : 0;
                gxTreeNode.SelectedImageIndex = IsNull ? 1 : 0;
                tvwSheet.Nodes.Add(gxTreeNode);
                if (!string.IsNullOrEmpty(filename))
                {
                    List <S_Sheet> SheetTempletList = NXFun.GetSheetTempletList(ToFullPath(filename));
                    foreach (S_Sheet sheet in SheetTempletList)
                    {
                        TreeNode sheetTreeNode = new TreeNode();
                        sheetTreeNode.Text               = sheet.SheetName + "_" + sheet.Remark;
                        sheetTreeNode.Tag                = "Sheet";
                        sheetTreeNode.Name               = sheet.guid; //利用guid标识图纸
                        sheetTreeNode.ImageIndex         = 2;
                        sheetTreeNode.SelectedImageIndex = 2;
                        gxTreeNode.Nodes.Add(sheetTreeNode);
                    }
                }
            }
            tvwSheet.ExpandAll();
            CharEdit.RefreshSheet();
        }