/// <summary> /// 更新一条数据 /// </summary> public bool Update(Info_deviceModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Info_device set "); strSql.Append("deviceNum=SQL2012deviceNum,"); strSql.Append("deviceCount=SQL2012deviceCount,"); strSql.Append("IsDelete=SQL2012IsDelete"); strSql.Append(" where deviceID=SQL2012deviceID"); SqlParameter[] parameters = { new SqlParameter("SQL2012deviceNum", SqlDbType.VarChar, 50), new SqlParameter("SQL2012deviceCount", SqlDbType.Int, 4), new SqlParameter("SQL2012IsDelete", SqlDbType.Bit, 1), new SqlParameter("SQL2012deviceID", SqlDbType.Int, 4) }; parameters[0].Value = model.deviceNum; parameters[1].Value = model.deviceCount; parameters[2].Value = model.IsDelete; parameters[3].Value = model.deviceID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Info_deviceModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Info_device("); strSql.Append("deviceNum,deviceCount,IsDelete)"); strSql.Append(" values ("); strSql.Append("SQL2012deviceNum,SQL2012deviceCount,SQL2012IsDelete)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("SQL2012deviceNum", SqlDbType.VarChar, 50), new SqlParameter("SQL2012deviceCount", SqlDbType.Int, 4), new SqlParameter("SQL2012IsDelete", SqlDbType.Bit, 1) }; parameters[0].Value = model.deviceNum; parameters[1].Value = model.deviceCount; parameters[2].Value = model.IsDelete; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Info_deviceModel DataRowToModel(DataRow row) { Info_deviceModel model = new Info_deviceModel(); if (row != null) { if (row["deviceID"] != null && row["deviceID"].ToString() != "") { model.deviceID = int.Parse(row["deviceID"].ToString()); } if (row["deviceNum"] != null) { model.deviceNum = row["deviceNum"].ToString(); } if (row["deviceCount"] != null && row["deviceCount"].ToString() != "") { model.deviceCount = int.Parse(row["deviceCount"].ToString()); } if (row["IsDelete"] != null && row["IsDelete"].ToString() != "") { if ((row["IsDelete"].ToString() == "1") || (row["IsDelete"].ToString().ToLower() == "true")) { model.IsDelete = true; } else { model.IsDelete = false; } } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Info_deviceModel GetModel(int deviceID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 deviceID,deviceNum,deviceCount,IsDelete from Info_device "); strSql.Append(" where deviceID=SQL2012deviceID"); SqlParameter[] parameters = { new SqlParameter("SQL2012deviceID", SqlDbType.Int, 4) }; parameters[0].Value = deviceID; Info_deviceModel model = new Info_deviceModel(); 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(Info_deviceModel model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Info_deviceModel model) { return(dal.Add(model)); }