/// <summary> /// 更新一条数据 /// </summary> public bool Update(propertyModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update property set "); strSql.Append("propertyName=@propertyName,"); strSql.Append("propertyCata=@propertyCata,"); strSql.Append("tag1=@tag1,"); strSql.Append("tag2=@tag2,"); strSql.Append("tag3=@tag3,"); strSql.Append("tag4=@tag4,"); strSql.Append("tag5=@tag5"); strSql.Append(" where propertyID=@propertyID "); SqlParameter[] parameters = { new SqlParameter("@propertyName", SqlDbType.NVarChar, 50), new SqlParameter("@propertyCata", SqlDbType.NVarChar, 50), new SqlParameter("@tag1", SqlDbType.NVarChar, 50), new SqlParameter("@tag2", SqlDbType.NVarChar, 50), new SqlParameter("@tag3", SqlDbType.NVarChar, 50), new SqlParameter("@tag4", SqlDbType.NVarChar, 50), new SqlParameter("@tag5", SqlDbType.NVarChar, 50), new SqlParameter("@propertyID", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.propertyName; parameters[1].Value = model.propertyCata; parameters[2].Value = model.tag1; parameters[3].Value = model.tag2; parameters[4].Value = model.tag3; parameters[5].Value = model.tag4; parameters[6].Value = model.tag5; parameters[7].Value = model.propertyID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public propertyModel DataRowToModel(DataRow row) { propertyModel model = new propertyModel(); if (row != null) { if (row["propertyID"] != null) { model.propertyID = row["propertyID"].ToString(); } if (row["propertyName"] != null) { model.propertyName = row["propertyName"].ToString(); } if (row["propertyCata"] != null) { model.propertyCata = row["propertyCata"].ToString(); } if (row["tag1"] != null) { model.tag1 = row["tag1"].ToString(); } if (row["tag2"] != null) { model.tag2 = row["tag2"].ToString(); } if (row["tag3"] != null) { model.tag3 = row["tag3"].ToString(); } if (row["tag4"] != null) { model.tag4 = row["tag4"].ToString(); } if (row["tag5"] != null) { model.tag5 = row["tag5"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(propertyModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into property("); strSql.Append("propertyID,propertyName,propertyCata,tag1,tag2,tag3,tag4,tag5)"); strSql.Append(" values ("); strSql.Append("@propertyID,@propertyName,@propertyCata,@tag1,@tag2,@tag3,@tag4,@tag5)"); SqlParameter[] parameters = { new SqlParameter("@propertyID", SqlDbType.NVarChar, 50), new SqlParameter("@propertyName", SqlDbType.NVarChar, 50), new SqlParameter("@propertyCata", SqlDbType.NVarChar, 50), new SqlParameter("@tag1", SqlDbType.NVarChar, 50), new SqlParameter("@tag2", SqlDbType.NVarChar, 50), new SqlParameter("@tag3", SqlDbType.NVarChar, 50), new SqlParameter("@tag4", SqlDbType.NVarChar, 50), new SqlParameter("@tag5", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.propertyID; parameters[1].Value = model.propertyName; parameters[2].Value = model.propertyCata; parameters[3].Value = model.tag1; parameters[4].Value = model.tag2; parameters[5].Value = model.tag3; parameters[6].Value = model.tag4; parameters[7].Value = model.tag5; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public propertyModel GetModel(string propertyID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 propertyID,propertyName,propertyCata,tag1,tag2,tag3,tag4,tag5 from property "); strSql.Append(" where propertyID=@propertyID "); SqlParameter[] parameters = { new SqlParameter("@propertyID", SqlDbType.NVarChar, 50) }; parameters[0].Value = propertyID; propertyModel model = new propertyModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(propertyModel model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(propertyModel model) { return(dal.Add(model)); }