Beispiel #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <DTcms.Model.CurriculumCategory> DataTableToList(DataTable dt)
        {
            List <DTcms.Model.CurriculumCategory> modelList = new List <DTcms.Model.CurriculumCategory>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                DTcms.Model.CurriculumCategory model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new DTcms.Model.CurriculumCategory();

                    if (dt.Rows[n]["CurriculumCategoryId"].ToString() != "")
                    {
                        model.CurriculumCategoryId = int.Parse(dt.Rows[n]["CurriculumCategoryId"].ToString());
                    }

                    if (dt.Rows[n]["CategoryId"].ToString() != "")
                    {
                        model.CategoryId = int.Parse(dt.Rows[n]["CategoryId"].ToString());
                    }

                    if (dt.Rows[n]["CurriculumId"].ToString() != "")
                    {
                        model.CurriculumId = int.Parse(dt.Rows[n]["CurriculumId"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.CurriculumCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "CurriculumCategory set ");

            strSql.Append(" CategoryId = @CategoryId , ");
            strSql.Append(" CurriculumId = @CurriculumId  ");
            strSql.Append(" where CurriculumCategoryId=@CurriculumCategoryId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@CurriculumCategoryId", SqlDbType.Int, 4),
                new SqlParameter("@CategoryId",           SqlDbType.Int, 4),
                new SqlParameter("@CurriculumId",         SqlDbType.Int, 4)
            };

            parameters[0].Value = model.CurriculumCategoryId;
            parameters[1].Value = model.CategoryId;
            parameters[2].Value = model.CurriculumId;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DTcms.Model.CurriculumCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "CurriculumCategory(");
            strSql.Append("CategoryId,CurriculumId");
            strSql.Append(") values (");
            strSql.Append("@CategoryId,@CurriculumId");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CategoryId",   SqlDbType.Int, 4),
                new SqlParameter("@CurriculumId", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.CategoryId;
            parameters[1].Value = model.CurriculumId;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DTcms.Model.CurriculumCategory GetModel(int CurriculumCategoryId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select CurriculumCategoryId, CategoryId, CurriculumId  ");
            strSql.Append("  from " + databaseprefix + "CurriculumCategory ");
            strSql.Append(" where CurriculumCategoryId=@CurriculumCategoryId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CurriculumCategoryId", SqlDbType.Int, 4)
            };
            parameters[0].Value = CurriculumCategoryId;


            DTcms.Model.CurriculumCategory model = new DTcms.Model.CurriculumCategory();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["CurriculumCategoryId"].ToString() != "")
                {
                    model.CurriculumCategoryId = int.Parse(ds.Tables[0].Rows[0]["CurriculumCategoryId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CategoryId"].ToString() != "")
                {
                    model.CategoryId = int.Parse(ds.Tables[0].Rows[0]["CategoryId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CurriculumId"].ToString() != "")
                {
                    model.CurriculumId = int.Parse(ds.Tables[0].Rows[0]["CurriculumId"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(DTcms.Model.CurriculumCategory model)
 {
     return(dal.Update(model));
 }
Beispiel #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(DTcms.Model.CurriculumCategory model)
 {
     return(dal.Add(model));
 }