/// <summary> /// 得到一个对象实体 /// </summary> public yny_005.Model.ZFHTable DataRowToModel(DataRow row) { yny_005.Model.ZFHTable model = new yny_005.Model.ZFHTable(); if (row != null) { if (row["AllRewardStr"] != null) { model.AllRewardStr = row["AllRewardStr"].ToString(); } if (row["E_JQFHFloat"] != null && row["E_JQFHFloat"].ToString() != "") { model.E_JQFHFloat = decimal.Parse(row["E_JQFHFloat"].ToString()); } if (row["beginTime"] != null && row["beginTime"].ToString() != "") { model.beginTime = DateTime.Parse(row["beginTime"].ToString()); } if (row["FHMoney"] != null && row["FHMoney"].ToString() != "") { model.FHMoney = decimal.Parse(row["FHMoney"].ToString()); } if (row["FHState"] != null && row["FHState"].ToString() != "") { model.FHState = int.Parse(row["FHState"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(yny_005.Model.ZFHTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ZFHTable("); strSql.Append("AllRewardStr,E_JQFHFloat,beginTime,FHMoney,FHState)"); strSql.Append(" values ("); strSql.Append("@AllRewardStr,@E_JQFHFloat,@beginTime,@FHMoney,@FHState)"); SqlParameter[] parameters = { new SqlParameter("@AllRewardStr", SqlDbType.VarChar, -1), new SqlParameter("@E_JQFHFloat", SqlDbType.Decimal, 9), new SqlParameter("@beginTime", SqlDbType.DateTime), new SqlParameter("@FHMoney", SqlDbType.Decimal, 9), new SqlParameter("@FHState", SqlDbType.Int, 4) }; parameters[0].Value = model.AllRewardStr; parameters[1].Value = model.E_JQFHFloat; parameters[2].Value = model.beginTime; parameters[3].Value = model.FHMoney; parameters[4].Value = model.FHState; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public yny_005.Model.ZFHTable GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from ZFHTable "); yny_005.Model.ZFHTable model = new yny_005.Model.ZFHTable(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(yny_005.Model.ZFHTable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ZFHTable set "); strSql.Append("AllRewardStr=@AllRewardStr,"); strSql.Append("E_JQFHFloat=@E_JQFHFloat,"); strSql.Append("beginTime=@beginTime,"); strSql.Append("FHMoney=@FHMoney,"); strSql.Append("FHState=@FHState"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@AllRewardStr", SqlDbType.VarChar, -1), new SqlParameter("@E_JQFHFloat", SqlDbType.Decimal, 9), new SqlParameter("@beginTime", SqlDbType.DateTime), new SqlParameter("@FHMoney", SqlDbType.Decimal, 9), new SqlParameter("@FHState", SqlDbType.Int, 4) }; parameters[0].Value = model.AllRewardStr; parameters[1].Value = model.E_JQFHFloat; parameters[2].Value = model.beginTime; parameters[3].Value = model.FHMoney; parameters[4].Value = model.FHState; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }