示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(university.Model.CCOM.Homework model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Homework set ");
            strSql.Append("Week_id=@Week_id,");
            strSql.Append("DatumType_id=@DatumType_id");
            strSql.Append(" where Homework_id=@Homework_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Week_id",      SqlDbType.Int, 4),
                new SqlParameter("@DatumType_id", SqlDbType.Int, 4),
                new SqlParameter("@Homework_id",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Week_id;
            parameters[1].Value = model.DatumType_id;
            parameters[2].Value = model.Homework_id;

            int rows = DBSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(university.Model.CCOM.Homework model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Homework(");
            strSql.Append("Week_id,DatumType_id)");
            strSql.Append(" values (");
            strSql.Append("@Week_id,@DatumType_id)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Week_id",      SqlDbType.Int, 4),
                new SqlParameter("@DatumType_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Week_id;
            parameters[1].Value = model.DatumType_id;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public university.Model.CCOM.Homework DataRowToModel(DataRow row)
 {
     university.Model.CCOM.Homework model = new university.Model.CCOM.Homework();
     if (row != null)
     {
         if (row["Homework_id"] != null && row["Homework_id"].ToString() != "")
         {
             model.Homework_id = int.Parse(row["Homework_id"].ToString());
         }
         if (row["Week_id"] != null && row["Week_id"].ToString() != "")
         {
             model.Week_id = int.Parse(row["Week_id"].ToString());
         }
         if (row["DatumType_id"] != null && row["DatumType_id"].ToString() != "")
         {
             model.DatumType_id = int.Parse(row["DatumType_id"].ToString());
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Homework GetModel(int Homework_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Homework_id,Week_id,DatumType_id from Homework ");
            strSql.Append(" where Homework_id=@Homework_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Homework_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Homework_id;

            university.Model.CCOM.Homework model = new university.Model.CCOM.Homework();
            DataSet ds = DBSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }