//         public int UpdateTitleItemAssoc(TitleItemAssoc info)
//         {
//
//         }



//         private List<TitleItem> DataTableToListItem(DataTable dt)
//         {
//             List<TitleItem> list = new List<TitleItem>();
//             if (dt != null)
//             {
//                 foreach (DataRow dr in dt.Rows)
//                 {
//                     TitleItem info = new TitleItem();
//                     info.TitleItemContent = dr["TitleItemContent"] == DBNull.Value ? "" : dr["TitleItemContent"].ToString();
//                     info.TitleItemId = dr["TitleItemId"] == DBNull.Value ? -100 : Convert.ToInt32(dr["TitleItemId"]);
//                     info.TitleItemIndex = dr["TitleItemIndex"] == DBNull.Value ? -100 : Convert.ToInt32(dr["TitleItemIndex"]);
//                     if (dr["UpdateDateTime"] != DBNull.Value)
//                     {
//                         DateTime datetime;
//                         DateTime.TryParse(dr["UpdateDateTime"].ToString(), out datetime);
//                         info.UpdateDateTime = datetime;
//                     }
//                     list.Add(info);
//                 }
//             }
//             return list;
//
//        }


        private List <TitleItemAssoc> DataTableToList(DataTable dt)
        {
            List <TitleItemAssoc> list = new List <TitleItemAssoc>();

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    TitleItemAssoc info = new TitleItemAssoc();
                    info.TitleItemAssocId = dr["TitleItemAssocId"] == DBNull.Value ? -100 : Convert.ToInt32(dr["TitleItemAssocId"]);
                    info.TitleItemId      = dr["TitleItemId"] == DBNull.Value ? -100 : Convert.ToInt32(dr["TitleItemId"]);
                    info.TitleInfoId      = dr["TitleInfoId"] == DBNull.Value ? -100 : Convert.ToInt32(dr["TitleInfoId"]);
                    info.TitleItemIndex   = dr["TitleItemIndex"] == DBNull.Value ? -100 : Convert.ToInt32(dr["TitleItemIndex"]);
                    info.TitleItemContent = dr["TitleItemContent"] == DBNull.Value ? "" : Convert.ToString(dr["TitleItemContent"]);
                    if (dr["UpdateDateTime"] != DBNull.Value)
                    {
                        DateTime datetime;
                        DateTime.TryParse(dr["UpdateDateTime"].ToString(), out datetime);
                        info.UpdateDateTime = datetime;
                    }
                    list.Add(info);
                }
            }
            return(list);
        }
        public ActionResult IsExistTitleItemAssoc(TitleItemAssoc info)
        {
            bool result = TitleItemAssocbll.IsExistTitleItemAssoc(info.TitleInfoId, info.TitleItemId);
            var  res    = new ConfigurableJsonResult();

            res.Data = result == true ? 1 : 0;
            HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*");
            return(res);
        }
        /// <summary>
        /// 增加题目下的选项
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public ActionResult AddTitleItemAssoc(TitleItemAssoc info)
        {
            int result = TitleItemAssocbll.AddTitleItemAssoc(info);
            var res    = new ConfigurableJsonResult();

            res.Data = result;
            HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*");
            return(res);
        }
        public int AddTitleItemAssoc(TitleItemAssoc info)
        {
            string strSql = "insert into TitleItemAssoc (TitleInfoId,TitleItemId,TitleItemIndex,UpdateDateTime) values (@TitleInfoId,@TitleItemId,@TitleItemIndex,@UpdateDateTime)";

            return(DBFactory.GetDB(DBType.SQLITE, m_strConn).ExecuteNonQuery(strSql, new DbParameter[] {
                new SQLiteParameter()
                {
                    Value = info.TitleInfoId, ParameterName = "@TitleInfoId"
                },
                new SQLiteParameter()
                {
                    Value = info.TitleItemId, ParameterName = "@TitleItemId"
                },
                new SQLiteParameter()
                {
                    Value = info.TitleItemIndex, ParameterName = "@TitleItemIndex"
                },
                new SQLiteParameter()
                {
                    Value = info.UpdateDateTime, ParameterName = "@UpdateDateTime"
                }
            }));
        }