Esempio n. 1
0
        public bool SendBack(ChapterInfo model, bool Replace)
        {
            if (true == Replace)
            {
                //List<ModelChapter> list = null;
                Dictionary<int, ChapterInfo> list = null;
                string path = "";
                switch(_Type)
                {
                    case 0:
                        list = ModelManager.m_DicMoudleList;
                        break;
                    case 1:
                        list = ModelManager.m_DicSkillList;
                        break;
                    case 2:
                        list = ModelManager.m_DicBankList;
                        break;
                    case 3:
                        list = ModelManager.m_DicIntensifyList;
                        break;
                }
                //if (_Type == 0)
                //{
                //    list = ModelManager.m_DicSkillList;
                //    path = ModelManager._PathSkill;
                //}
                //else
                //{
                //    list = ModelManager.m_DicMoudleList;
                //    path = ModelManager._PathModule;
                //}

                bool isReplace = false;
                if (true == ModelManager.AddModelToList(model, list, out isReplace))
                {
                    //TODO:保存章節信息到數據庫
                    if (!isReplace)
                    {
                        if (false == this.AddChapterToDB(model))
                            return false;
                    }
                    else
                    {
                        if (false == this.UpdateChapterToDB(model))
                            return false;
                    }

                    //if (true == ModelManager.SetListToFile(list, path))
                    {
                        this.panelModelList.BringToFront();
                        this.panelModelInfo.SendToBack();
                        if(isReplace != true)
                        {
                            switch(_Type)
                            {
                                case 0:
                                    SystemConfig._maxModuleId = model.ID;
                                    break;
                                case 1:
                                    SystemConfig._maxSkillId = model.ID;
                                    break;
                                case 2:
                                    SystemConfig._maxBankId = model.ID;
                                    break;
                                case 3:
                                    SystemConfig._maxIntensifyId = model.ID;
                                    break;
                            }
                            //if (_Type == 0)
                            //{
                            //    SystemConfig._maxSkillId = model.Id;
                            //}
                            //else
                            //{
                            //    SystemConfig._maxModuleId = model.Id;
                            //}

                            SystemConfig.SaveModelId();
                        }
                        
                        AddItem(model.ID, model.Name, model.IsEnable, model.Classification, model.Count);
                        
                        return true;
                    }

                }

                return false;
            }
            else
            {
                this.panelModelList.BringToFront();
                this.panelModelInfo.SendToBack();
                return true;
            }
        }