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