public ChapterEntity Update(int id, ChapterEntity obj)
        {
            ChapterEntity chapter = new ChapterEntity();

            try
            {
                MySqlCommand cmd = db.connection.CreateCommand();

                cmd.CommandText = "UPDATE " + Constants.USER_TABLE_NAME + " SET '" + Constants.USER_COLUMN_NAME_FIRST_NAME + "' = " + obj.Name + ", '" + Constants.USER_COLUMN_NAME_LAST_NAME + "' " + obj.CourseId +
                                  "WHERE " + Constants.USER_COLUMN_NAME_ID + " = " + obj.Id;

                IDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    chapter.Id       = reader.GetInt32(0);
                    chapter.CourseId = reader.GetInt32(2);
                    chapter.Name     = reader.GetString(1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                db.connection.Close();
            }

            return(chapter);
        }
Exemplo n.º 2
0
 public int SaveChapter(ChapterEntity entity, string loginName)
 {
     if (string.IsNullOrEmpty(entity.ChapterId))
     {
         using (IDbConnection conn = DBContext.GetConnection(DataBaseName.AccountTrianDB, ReadOrWriteDB.Write))
         {
             string query = string.Format(@"INSERT INTO Train_Chapter
                                             (ChapterId
                                             ,ClassId
                                             ,ChapterTitle
                                             ,ChapterContent
                                             ,VideoUrl
                                             ,VideoTitle
                                             ,ChapterNum
                                             ,Remark
                                             ,Status
                                             ,CreateTime
                                             ,CreateUser
                                             ,UpdateTime
                                             ,UpdateUser)
                                         VALUES
                                             ('{0}'
                                             ,'{1}'
                                             ,'{2}'
                                             ,'{3}'
                                             ,'{4}'
                                             ,'{5}'
                                             ,'{6}'
                                             ,'{7}'
                                             ,'{8}'
                                             ,getdate()
                                             ,'{9}'
                                             ,getdate()
                                             ,'{10}')",
                                          Guid.NewGuid().ToString(), entity.ClassId, entity.ChapterTitle, entity.ChapterContent, entity.VideoUrl, entity.VideoTitle,
                                          entity.ChapterNum, entity.Remark, 1, loginName, loginName);
             return(conn.Execute(query));
         }
     }
     else
     {
         using (IDbConnection conn = DBContext.GetConnection(DataBaseName.AccountTrianDB, ReadOrWriteDB.Write))
         {
             string query = string.Format(@" UPDATE Train_Chapter
                                             SET  ClassId='{0}'
                                                 ,ChapterTitle='{1}'
                                                 ,ChapterContent='{2}'
                                                 ,VideoUrl='{3}'
                                                 ,VideoTitle='{4}'
                                                 ,ChapterNum='{5}'
                                                 ,Remark='{6}'
                                                 ,UpdateTime = getdate()
                                                 ,UpdateUser = '******'
                                             WHERE ChapterId='{8}'",
                                          entity.ClassId, entity.ChapterTitle, entity.ChapterContent, entity.VideoUrl, entity.VideoTitle, entity.ChapterNum,
                                          entity.Remark, loginName, entity.ChapterId);
             return(conn.Execute(query));
         }
     }
 }
        public ChapterEntity FindById(int id)
        {
            ChapterEntity chapter = new ChapterEntity();

            try
            {
                MySqlCommand cmd = db.connection.CreateCommand();

                cmd.CommandText = "SELECT * FROM " + Constants.USER_TABLE_NAME + " WHERE " + Constants.USER_COLUMN_NAME_ID + " = " + id;

                IDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    chapter.Id       = reader.GetInt32(0);
                    chapter.CourseId = reader.GetInt32(2);
                    chapter.Name     = reader.GetString(1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                db.connection.Close();
            }
            return(chapter);
        }
Exemplo n.º 4
0
    /// <summary>
    /// 打开管卡地图
    /// </summary>
    private void OpenGameLevelMapView()
    {
        m_GameLevelMapView = UIViewUtil.Instance.OpenWindow(UIViewType.GameLevelMap).GetComponent <UIGameLevelMapView>();
        m_GameLevelMapView.OnClickGameLevelItem = OnClickGameLevelMapViewViewDetailsItem;
        DataTransfer  data   = new DataTransfer();
        ChapterEntity entity = ChapterDBModel.Instance.Get(1);

        data.SetData(ConstDefine.ChapterId, entity.Id);
        data.SetData(ConstDefine.ChapterName, entity.ChapterName);
        data.SetData(ConstDefine.ChapterBG, entity.BG_Pic);
        List <GameLevelEntity> entityList = GameLevelDBModel.Instance.GetNeedEntityById(entity.Id);

        if (entityList != null || entityList.Count > 0)
        {
            List <DataTransfer> dataArr = new List <DataTransfer>();
            for (int i = 0; i < entityList.Count; i++)
            {
                DataTransfer dataChild = new DataTransfer();
                dataArr.Add(dataChild);
                dataArr[i].SetData(ConstDefine.GameLevelId, entityList[i].Id);
                dataArr[i].SetData(ConstDefine.GameLevelIsBoss, entityList[i].isBoss);
                dataArr[i].SetData(ConstDefine.GameLevelName, entityList[i].Name);
                dataArr[i].SetData(ConstDefine.GameLevelPosInMap, entityList[i].GetPosInMap());
                dataArr[i].SetData(ConstDefine.GameLevelIcon, entityList[i].Ico);
            }
            data.SetData(ConstDefine.GameLevelArr, dataArr);
        }

        m_GameLevelMapView.SetUI(data);
    }
Exemplo n.º 5
0
    //Add
    internal string AddSql(ChapterEntity data)
    {
        string colNames = "";
        string colValue = "";

        colNames += " Id ";
        colValue += " " + this.GetNewId() + " ";

        colNames += ",Name_Ar";
        colValue += ",@Name_Ar";

        colNames += ",Name_En";
        colValue += ",@Name_En";

        colNames += ",PartId";
        colValue += "," + data.BookPartData.Id + "";

        colNames += ",Cont";
        colValue += ",@Cont";

        colNames += ",RowId";
        colValue += ",'" + data.RowId + "'";

        colNames += ",DateMade";
        colValue += ",'" + this.dbHelper.GetServerDate().ToDateVal().FormatDate("MM/dd/yyyy HH:mm") + "'";

        colNames += ",MadeById";
        colValue += "," + data.MadeById + "";

        //-------------------------------
        string sql = " INSERT INTO Chapters ( " + colNames + " ) VALUES ( " + colValue + " ) ";

        return(sql);
    }
Exemplo n.º 6
0
    public int Add(ChapterEntity data)
    {
        string sql = this.AddSql(data);

        System.Data.SqlClient.SqlParameter NameArParam = new System.Data.SqlClient.SqlParameter();
        NameArParam.ParameterName = "Name_Ar";
        NameArParam.DbType        = DbType.String;
        NameArParam.Direction     = ParameterDirection.Input;
        NameArParam.Value         = data.Name_Ar;

        System.Data.SqlClient.SqlParameter NameEnParam = new System.Data.SqlClient.SqlParameter();
        NameEnParam.ParameterName = "Name_En";
        NameEnParam.DbType        = DbType.String;
        NameEnParam.Direction     = ParameterDirection.Input;
        NameEnParam.Value         = data.Name_En;

        System.Data.SqlClient.SqlParameter ContParam = new System.Data.SqlClient.SqlParameter();
        ContParam.ParameterName = "Cont";
        ContParam.DbType        = DbType.String;
        ContParam.Direction     = ParameterDirection.Input;
        ContParam.Value         = data.Cont;

        int x = this.dbHelper.whriteData(sql, new List <IDataParameter>()
        {
            ContParam, NameArParam, NameEnParam
        });

        return(x);
    }
Exemplo n.º 7
0
    public List <ChapterEntity> GetList(int partId)
    {
        List <ChapterEntity> lst = null;

        DataTable table;
        string    sql = this.GetSql();

        sql += " WHERE PartId = " + partId + " ";

        table = this.dbHelper.retriveData(sql);

        if (table != null && table.Rows.Count > 0)
        {
            lst = new List <ChapterEntity>();

            foreach (DataRow row in table.Rows)
            {
                ChapterEntity data = new ChapterEntity();
                this.SetData(row, data);

                lst.Add(data);
            }
        }
        return(lst);
    }
Exemplo n.º 8
0
        public async Task <ChapterDomain> CreateAsync(ChapterDomain chapterDomain)
        {
            ChapterEntity chapterEntity        = Mapper.Map <ChapterEntity>(chapterDomain);
            EntityEntry <ChapterEntity> entity = await DbSet.AddAsync(chapterEntity);

            return(Mapper.Map <ChapterDomain>(entity.Entity));
        }
        public List <ChapterEntity> FindAllChapterByCourse(int CourseId)
        {
            List <ChapterEntity> chapterEntities = new List <ChapterEntity>();

            try
            {
                MySqlCommand cmd = db.connection.CreateCommand();

                cmd.CommandText = $"SELECT * FROM {Constants.CHAPTER_TABLE_NAME} WHERE {Constants.CHAPTER_COLUMN_NAME_COURSE_ID} = {CourseId}";

                IDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    ChapterEntity chapterEntity = new ChapterEntity();

                    chapterEntity.Id       = reader.GetInt32(0);
                    chapterEntity.Name     = reader.GetString(1);
                    chapterEntity.CourseId = reader.GetInt32(2);

                    chapterEntities.Add(chapterEntity);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                db.connection.Close();
            }

            return(chapterEntities);
        }
Exemplo n.º 10
0
    public void OpenGameLevelMapView(Transform windowUiPanelContainerTrans)
    {
        //读取本地配置表
        //默认读取第一章
        ChapterEntity chapterEntity = ChapterDBModel.GetInstance.GetEntityById(1);

        TransferData data = null;

        if (chapterEntity != null)
        {
            data = new TransferData();
            {
                data.SetValue <string>("ChapterName", chapterEntity.ChapterName);
                data.SetValue <int>("ChapterId", chapterEntity.Id);
                data.SetValue <string>("ChapterMapBg", chapterEntity.BG_Pic);
            }
        }

        //读取关卡
        List <GameLevelEntity> gameLevelEntities = GameLevelDBModel.GetInstance.GetListByChapterId(chapterEntity.Id);

        if (gameLevelEntities != null || gameLevelEntities.Count > 0)
        {
            data.SetValue <List <GameLevelEntity> >("GameLevelList", gameLevelEntities);
        }

        m_uIGameLevelMapView = WindowUIMgr.Instance.OpenWindow(WindowUIType.GameLevelMap).GetComponent <UIGameLevelMapView>();
        m_uIGameLevelMapView.transform.SetParent(windowUiPanelContainerTrans);
        m_uIGameLevelMapView.transform.localScale    = Vector3.one * 0.8f;
        m_uIGameLevelMapView.transform.localPosition = Vector3.zero;
        m_uIGameLevelMapView.transform.localRotation = Quaternion.identity;

        m_uIGameLevelMapView.SetUI(data, OnClickGameLevelCallback, windowUiPanelContainerTrans);
    }
Exemplo n.º 11
0
 public static void InsertChapter(ChapterEntity chapter)
 {
     using (var db = new DataContext())
     {
         db.Chapter.Add(chapter);
         db.SaveChanges();
     }
 }
Exemplo n.º 12
0
    private void OpenMainQuestView()
    {
        //加载panel部分
        mUIPanelQuestView       = UIViewManagerNGUI.Instance.OpenWindowUI(UIPanelType.MainQuest, true).GetComponent <UIPanelMainQuestView>();
        mUIPanelQuestDetailView = mUIPanelQuestView.transform.GetComponentInChildren <UIPanelMainQuestDetailView>();
        ReadExcelDataUtil excel         = new ReadExcelDataUtil();
        ChapterEntity     chapterEntity = ChapterDBModel.Instance.Get(1);

        excel.SetValue(Constant.EXCEL_ChapterId, chapterEntity.Id);
        excel.SetValue(Constant.EXCEL_ChapterName, chapterEntity.ChapterName);
        mUIPanelQuestView.SetUI(excel);

        //读取item详情(本地excel)部分
        //获取了GameQuest.xls里的全部内容,现在开始整理归类
        List <GameQuestEntity> questEntityList = GameQuestDBModel.Instance.GetAllData();

        #region 为item按章节分组的过程,并添加进dic中
        if (dic.Count == 0)
        {
            int tempChapterCount = 1;   //临时变量,用于分组使用
            int tempIndex        = 0;
            for (int i = 0; i < questEntityList.Count; i++)
            {
                if (questEntityList[i].ChapterID != tempChapterCount) //章节发生了改变
                {
                    List <GameQuestEntity> questEntityPage = new List <GameQuestEntity>();
                    tempIndex = i;
                    for (int j = 0; j < tempIndex; j++)
                    {
                        questEntityPage.Add(questEntityList[j]);
                    }
                    dic.Add(tempChapterCount, questEntityPage);//《页码,item详情》
                    tempChapterCount++;
                }
            }
            List <GameQuestEntity> questEntityLastPage = new List <GameQuestEntity>();    //循环结束,把最后一篇的内容加到dic中
            for (int j = tempIndex; j < questEntityList.Count; j++)
            {
                tempIndex = questEntityList.Count;
                questEntityLastPage.Add(questEntityList[j]);
            }
            dic.Add(tempChapterCount, questEntityLastPage);//《页码,item详情》
        }

        #endregion

        //先加载panel,完毕后再加载item
        mUIPanelQuestView.OnViewLoadDone = () =>
        {
            //把做好的dic传给PanelView,view上可以直接使用
            mUIPanelQuestView.SetInfosDic(dic);

            //打开主线面板时,默认显示第一篇的关卡内容
            mUIPanelQuestView.SetQuestItem(1);
        };

        mUIPanelQuestView.OnItemClick = OnQuestItemClick;  //这一步是点击一个item后,panel要做的事
    }
Exemplo n.º 13
0
    private void SetData(DataRow Row, ChapterEntity data)
    {
        data.Id              = Row["Id"].ToString().ToIntVal();
        data.Name_Ar         = Row["Name_Ar"].ToString();
        data.Name_En         = Row["Name_En"].ToString();
        data.BookPartData.Id = Row["PartId"].ToString().ToIntVal();
        data.Cont            = Row["Cont"].ToString();
        data.RowId           = Row["RowId"].ToString();
        data.DateMade        = Row["DateMade"].ToString().ToDateVal();

        data.MadeById = Row["MadeById"].ToString().ToIntVal();
    }
Exemplo n.º 14
0
        public ChapterEntity GetOpenBook()
        {
            var book          = _bookReposistory.Where(c => c.BookOpened && c.Chapters.Where(ch => ch.ChapterOpened).Any()).AsQueryable().Include(b => b.Chapters).FirstOrDefault();
            var content       = book.Chapters.Where(c => c.ChapterOpened).FirstOrDefault();
            var chapterEntity = new ChapterEntity
            {
                Content  = content.Content,
                BookName = book.BookTitle
            };

            return(chapterEntity);
        }
Exemplo n.º 15
0
        private static ChapterEntity MySqlRead2Chapter(MySqlDataReader reader)
        {
            var chapter = new ChapterEntity
            {
                ChapterId    = reader.GetString("ChapterId"),
                ArticleId    = reader.GetString("ArticleId"),
                Content      = reader.GetString("Content"),
                Summary      = reader.GetString("Summary"),
                SerialNumber = reader.GetInt32("SerialNumber"),
                Title        = reader.GetString("Title"),
                CreatTime    = reader.GetDateTime("CreatTime")
            };

            return(chapter);
        }
Exemplo n.º 16
0
 public ActionResult SaveChapter(ChapterEntity entity, string loginName)
 {
     try
     {
         var result = new ClassBC().SaveChapter(entity, CurrentUserInfo.Account);
         if (result == 0)
         {
             return(Json(string.Empty));
         }
         return(Json("保存成功"));
     }
     catch (Exception ex)
     {
         return(Json(string.Empty));
     }
 }
Exemplo n.º 17
0
        public static int InsertChapter(ChapterEntity chapter)
        {
            if (chapter == null)
            {
                return(0);
            }
            //INSERT INTO Persons (LastName, Address) VALUES ('Wilson', 'Champs-Elysees')
            var sql = $"INSERT INTO chapter (ChapterId,ArticleId,Content,Summary,SerialNumber,Title,CreatTime) " +
                      $"VALUES ('{chapter.ChapterId}','{chapter.ArticleId}','{chapter.Content}','{chapter.Summary}','{chapter.SerialNumber}','{chapter.Title}','{chapter.CreatTime}')";

            using (var cmd = new MySqlCommand(sql, HyMySqlHelper.MySqlConnection))
            {
                var num = cmd.ExecuteNonQuery();
                return(num);
            }
        }
Exemplo n.º 18
0
    //Update
    public string UpdateSql(int id, ChapterEntity data)
    {
        string sql = "UPDATE Chapters SET   ";

        sql += " Name_Ar = @Name_Ar ";
        sql += ",Name_En = @Name_En ";
        sql += ",PartId = " + data.BookPartData.Id + " ";
        sql += ",Cont = @Cont ";
        //---------------
        sql += ",DateMade = '" + this.dbHelper.GetServerDate().ToDateVal().FormatDate("MM/dd/yyyy HH:mm") + "'";

        sql += ",MadeById = " + data.MadeById + "";

        sql += " WHERE Id = " + id + " ";

        return(sql);
    }
Exemplo n.º 19
0
        public static int UpdateChapterByChapterId(ChapterEntity chapter)
        {
            int a = 0;

            using (var db = new DataContext())
            {
                ChapterEntity chapterEntity = db.Chapter
                                              .Where(b => b.ChapterId.Equals(chapter.ChapterId)).FirstOrDefault();
                if (chapterEntity != null)
                {
                    chapterEntity = chapter;
                }

                a = db.SaveChanges();
            }
            return(a);
        }
Exemplo n.º 20
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.B))
     {
         GameEntry.DataTable.LoadDataTable <ChapterDBModel>("Assets/DownLoad/DataTable/Chapter.bytes", 0, 132);
     }
     if (Input.GetKeyUp(KeyCode.C))
     {
         ChapterDBModel chapterDBModel = GameEntry.DataTable.GetDataTable <ChapterDBModel>();
         ChapterEntity  chapterEntity  = chapterDBModel.Get(1);
         Debug.Log(chapterEntity.ChapterName);
         chapterEntity = chapterDBModel.Get(2);
         Debug.Log(chapterEntity.ChapterName);
     }
     if (Input.GetKeyUp(KeyCode.D))
     {
         GameEntry.DataTable.DestroyDataTable <ChapterDBModel>();
     }
 }
Exemplo n.º 21
0
    public bool GetData()
    {
        bool          x    = false;
        ChapterEntity data = delGetData(this.Id);

        if (!data.IsNull_Ex())
        {
            x             = true;
            this.Id       = data.Id;
            this.DateMade = data.DateMade;

            this.MadeById        = data.MadeById;
            this.Name_Ar         = data.Name_Ar;
            this.Name_En         = data.Name_En;
            this.BookPartData.Id = data.BookPartData.Id;
            this.Cont            = data.Cont;
            this.RowId           = data.RowId;
        }
        return(x);
    }
Exemplo n.º 22
0
        public static int UpdateChapterByChapterId(string chapterId, string chapterTitle, string chapterContextHtml, string chapterSummary, int v)
        {
            int a = 0;

            using (var db = new DataContext())
            {
                ChapterEntity chapterEntity = db.Chapter
                                              .Where(b => b.ChapterId.Equals(chapterId)).FirstOrDefault();
                if (chapterEntity != null)
                {
                    chapterEntity.Title        = chapterTitle;
                    chapterEntity.Content      = chapterContextHtml;
                    chapterEntity.Summary      = chapterSummary;
                    chapterEntity.SerialNumber = v;
                }

                a = db.SaveChanges();
            }
            return(a);
        }
Exemplo n.º 23
0
    public ChapterEntity GetData(string rowId)
    {
        ChapterEntity data = null;

        DataTable table;
        string    sql = this.GetSql();

        sql += " WHERE RowId = '" + rowId + "' ";

        table = this.dbHelper.retriveData(sql);


        if (table != null && table.Rows.Count > 0)
        {
            DataRow row = table.Rows[0];

            data = new ChapterEntity();
            this.SetData(row, data);
        }

        return(data);
    }
        public ChapterEntity Create(ChapterEntity obj)
        {
            try
            {
                MySqlCommand cmd = db.connection.CreateCommand();

                cmd.CommandText = "INSERT INTO " + Constants.CHAPTER_TABLE_NAME + " (" + Constants.CHAPTER_COLUMN_NAME_NAME + ", " + Constants.CHAPTER_COLUMN_NAME_COURSE_ID + ") VALUES (@name, @user_id)";

                cmd.Parameters.AddWithValue("@name", obj.Name);
                cmd.Parameters.AddWithValue("@user_id", obj.CourseId);

                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                db.connection.Close();
            }
            return(obj);
        }
Exemplo n.º 25
0
        public async Task <ChapterDomain> GetAsync(string category)
        {
            ChapterEntity chapter = await DbSet.SingleOrDefaultAsync(chapter => chapter.Category == category);

            return(Mapper.Map <ChapterDomain>(chapter));
        }
Exemplo n.º 26
0
        public int SaveChapter(ChapterEntity entity, string loginName)
        {
            ClassDA da = new ClassDA();

            return(da.SaveChapter(entity, loginName));
        }