/// <summary> /// 更新一条数据 /// </summary> public bool Update(Parking.Core.Model.PBA_TRAFFIC_DEVICE model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PBA_TRAFFIC_DEVICE set "); strSql.Append("TRAFFIC_VALUE=@TRAFFIC_VALUE,"); strSql.Append("CHANNEL_TYPE=@CHANNEL_TYPE,"); strSql.Append("DEVICE_ID=@DEVICE_ID"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@TRAFFIC_VALUE", SqlDbType.VarChar, 50), new SqlParameter("@CHANNEL_TYPE", SqlDbType.VarChar, 50), new SqlParameter("@DEVICE_ID", SqlDbType.VarChar, 50), new SqlParameter("@ID", SqlDbType.VarChar, 32) }; parameters[0].Value = model.TRAFFIC_VALUE; parameters[1].Value = model.CHANNEL_TYPE; parameters[2].Value = model.DEVICE_ID; parameters[3].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Parking.Core.Model.PBA_TRAFFIC_DEVICE model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PBA_TRAFFIC_DEVICE("); strSql.Append("ID,TRAFFIC_VALUE,CHANNEL_TYPE,DEVICE_ID)"); strSql.Append(" values ("); strSql.Append("@ID,@TRAFFIC_VALUE,@CHANNEL_TYPE,@DEVICE_ID)"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.VarChar, 32), new SqlParameter("@TRAFFIC_VALUE", SqlDbType.VarChar, 50), new SqlParameter("@CHANNEL_TYPE", SqlDbType.VarChar, 50), new SqlParameter("@DEVICE_ID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.ID; parameters[1].Value = model.TRAFFIC_VALUE; parameters[2].Value = model.CHANNEL_TYPE; parameters[3].Value = model.DEVICE_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Parking.Core.Model.PBA_TRAFFIC_DEVICE DataRowToModel(DataRow row) { Parking.Core.Model.PBA_TRAFFIC_DEVICE model = new Parking.Core.Model.PBA_TRAFFIC_DEVICE(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["TRAFFIC_VALUE"] != null) { model.TRAFFIC_VALUE = row["TRAFFIC_VALUE"].ToString(); } if (row["CHANNEL_TYPE"] != null) { model.CHANNEL_TYPE = row["CHANNEL_TYPE"].ToString(); } if (row["DEVICE_ID"] != null) { model.DEVICE_ID = row["DEVICE_ID"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Parking.Core.Model.PBA_TRAFFIC_DEVICE GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,TRAFFIC_VALUE,CHANNEL_TYPE,DEVICE_ID from PBA_TRAFFIC_DEVICE "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.VarChar, 32) }; parameters[0].Value = ID; Parking.Core.Model.PBA_TRAFFIC_DEVICE model = new Parking.Core.Model.PBA_TRAFFIC_DEVICE(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }