Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(university.Model.CCOM.Datum_type model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Datum_type set ");
            strSql.Append("DatumType_name=@DatumType_name");
            strSql.Append(" where DatumType_id=@DatumType_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DatumType_name", SqlDbType.VarChar, 128),
                new SqlParameter("@DatumType_id",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.DatumType_name;
            parameters[1].Value = model.DatumType_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.Datum_type model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Datum_type(");
            strSql.Append("DatumType_name)");
            strSql.Append(" values (");
            strSql.Append("@DatumType_name)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@DatumType_name", SqlDbType.VarChar, 128)
            };
            parameters[0].Value = model.DatumType_name;

            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.Datum_type DataRowToModel(DataRow row)
 {
     university.Model.CCOM.Datum_type model = new university.Model.CCOM.Datum_type();
     if (row != null)
     {
         if (row["DatumType_id"] != null && row["DatumType_id"].ToString() != "")
         {
             model.DatumType_id = int.Parse(row["DatumType_id"].ToString());
         }
         if (row["DatumType_name"] != null)
         {
             model.DatumType_name = row["DatumType_name"].ToString();
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Datum_type GetModel(int DatumType_id)
        {
            StringBuilder strSql = new StringBuilder();

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

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

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