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