/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.RoomType model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.roomTypeID != null) { strSql1.Append("roomTypeID,"); strSql2.Append("'" + model.roomTypeID + "',"); } if (model.roomTypePrice > 0) { strSql1.Append("roomTypePrice,"); strSql2.Append("" + model.roomTypePrice + ","); } strSql.Append("insert into RoomType("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.RoomType DataRowToModel(DataRow row) { Maticsoft.Model.RoomType model = new Maticsoft.Model.RoomType(); if (row != null) { if (row["roomTypeID"] != null) { model.roomTypeID = row["roomTypeID"].ToString(); } if (row["roomTypePrice"] != null && row["roomTypePrice"].ToString() != "") { model.roomTypePrice = decimal.Parse(row["roomTypePrice"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.RoomType GetModel(string roomTypeID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" roomTypeID,roomTypePrice "); strSql.Append(" from RoomType "); strSql.Append(" where roomTypeID='" + roomTypeID + "' "); Maticsoft.Model.RoomType model = new Maticsoft.Model.RoomType(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.RoomType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update RoomType set "); if (model.roomTypePrice > 0) { strSql.Append("roomTypePrice=" + model.roomTypePrice + ","); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where roomTypeID='" + model.roomTypeID + "' "); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }