/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.fenshu_tongji model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update fenshu_tongji set "); strSql.Append("peixunban=@peixunban,"); strSql.Append("kecheng=@kecheng,"); strSql.Append("jiangshi=@jiangshi,"); strSql.Append("pingjunfen=@pingjunfen"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@peixunban", SqlDbType.NChar, 10), new SqlParameter("@kecheng", SqlDbType.NVarChar, 50), new SqlParameter("@jiangshi", SqlDbType.NChar, 10), new SqlParameter("@pingjunfen", SqlDbType.Float, 8) }; parameters[0].Value = model.peixunban; parameters[1].Value = model.kecheng; parameters[2].Value = model.jiangshi; parameters[3].Value = model.pingjunfen; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.fenshu_tongji model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into fenshu_tongji("); strSql.Append("peixunban,kecheng,jiangshi,pingjunfen)"); strSql.Append(" values ("); strSql.Append("@peixunban,@kecheng,@jiangshi,@pingjunfen)"); SqlParameter[] parameters = { new SqlParameter("@peixunban", SqlDbType.NChar, 10), new SqlParameter("@kecheng", SqlDbType.NVarChar, 50), new SqlParameter("@jiangshi", SqlDbType.NChar, 10), new SqlParameter("@pingjunfen", SqlDbType.Float, 8) }; parameters[0].Value = model.peixunban; parameters[1].Value = model.kecheng; parameters[2].Value = model.jiangshi; parameters[3].Value = model.pingjunfen; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.fenshu_tongji GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 peixunban,kecheng,jiangshi,pingjunfen from fenshu_tongji "); strSql.Append(" where "); SqlParameter[] parameters = { }; Maticsoft.Model.fenshu_tongji model = new Maticsoft.Model.fenshu_tongji(); 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 Maticsoft.Model.fenshu_tongji DataRowToModel(DataRow row) { Maticsoft.Model.fenshu_tongji model = new Maticsoft.Model.fenshu_tongji(); if (row != null) { if (row["peixunban"] != null) { model.peixunban = row["peixunban"].ToString(); } if (row["kecheng"] != null) { model.kecheng = row["kecheng"].ToString(); } if (row["jiangshi"] != null) { model.jiangshi = row["jiangshi"].ToString(); } if (row["pingjunfen"] != null && row["pingjunfen"].ToString() != "") { model.pingjunfen = decimal.Parse(row["pingjunfen"].ToString()); } } return(model); }