/// <summary> /// 得到一个对象实体 /// </summary> public cuotiModel DataRowToModel(DataRow row) { cuotiModel model=new cuotiModel(); if (row != null) { if(row["nc_ctid"]!=null) { model.nc_ctid=row["nc_ctid"].ToString(); } if(row["nc_qid"]!=null) { model.nc_qid=row["nc_qid"].ToString(); } if(row["nc_uid"]!=null) { model.nc_uid=row["nc_uid"].ToString(); } } return model; }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(cuotiModel model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into cuoti("); strSql.Append("nc_qid,nc_uid)"); strSql.Append(" values ("); strSql.Append("@nc_qid,@nc_uid)"); SqlParameter[] parameters = { new SqlParameter("@nc_qid", SqlDbType.NChar,10), new SqlParameter("@nc_uid", SqlDbType.NChar,20)}; parameters[0].Value = model.nc_qid; parameters[1].Value = model.nc_uid; int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(cuotiModel model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update cuoti set "); strSql.Append("nc_qid=@nc_qid,"); strSql.Append("nc_uid=@nc_uid"); strSql.Append(" where nc_ctid=@nc_ctid "); SqlParameter[] parameters = { new SqlParameter("@nc_qid", SqlDbType.NChar,10), new SqlParameter("@nc_uid", SqlDbType.NChar,20), new SqlParameter("@nc_ctid", SqlDbType.NChar,20)}; parameters[0].Value = model.nc_qid; parameters[1].Value = model.nc_uid; parameters[2].Value = model.nc_ctid; int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } }
/// <summary> /// 得到一个对象实体 /// </summary> public cuotiModel GetModel(string nc_ctid) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 nc_ctid,nc_qid,nc_uid from cuoti "); strSql.Append(" where nc_ctid=@nc_ctid "); SqlParameter[] parameters = { new SqlParameter("@nc_ctid", SqlDbType.NChar,20) }; parameters[0].Value = nc_ctid; cuotiModel model=new cuotiModel(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }