/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_trends model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_trends("); strSql.Append("t_app_id,t_newcount,t_activecount,t_time"); strSql.Append(") values ("); strSql.Append("@t_app_id,@t_newcount,@t_activecount,@t_time"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@t_app_id", SqlDbType.Int, 4), new SqlParameter("@t_newcount", SqlDbType.Int, 4), new SqlParameter("@t_activecount", SqlDbType.Int, 4), new SqlParameter("@t_time", SqlDbType.DateTime) }; parameters[0].Value = model.t_app_id; parameters[1].Value = model.t_newcount; parameters[2].Value = model.t_activecount; parameters[3].Value = model.t_time; object obj = DbHelperSQLTotal.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_trends GetModel(int t_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select t_id, t_app_id, t_newcount, t_activecount, t_time "); strSql.Append(" from jmp_trends "); strSql.Append(" where t_id=@t_id"); SqlParameter[] parameters = { new SqlParameter("@t_id", SqlDbType.Int, 4) }; parameters[0].Value = t_id; JMP.MDL.jmp_trends model = new JMP.MDL.jmp_trends(); DataSet ds = DbHelperSQLTotal.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["t_id"].ToString() != "") { model.t_id = int.Parse(ds.Tables[0].Rows[0]["t_id"].ToString()); } if (ds.Tables[0].Rows[0]["t_app_id"].ToString() != "") { model.t_app_id = int.Parse(ds.Tables[0].Rows[0]["t_app_id"].ToString()); } if (ds.Tables[0].Rows[0]["t_newcount"].ToString() != "") { model.t_newcount = int.Parse(ds.Tables[0].Rows[0]["t_newcount"].ToString()); } if (ds.Tables[0].Rows[0]["t_activecount"].ToString() != "") { model.t_activecount = int.Parse(ds.Tables[0].Rows[0]["t_activecount"].ToString()); } if (ds.Tables[0].Rows[0]["t_time"].ToString() != "") { model.t_time = DateTime.Parse(ds.Tables[0].Rows[0]["t_time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 获得数据列表 /// </summary> public List <JMP.MDL.jmp_trends> DataTableToList(DataTable dt) { List <JMP.MDL.jmp_trends> modelList = new List <JMP.MDL.jmp_trends>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JMP.MDL.jmp_trends model; for (int n = 0; n < rowsCount; n++) { model = new JMP.MDL.jmp_trends(); if (dt.Rows[n]["t_id"].ToString() != "") { model.t_id = int.Parse(dt.Rows[n]["t_id"].ToString()); } if (dt.Rows[n]["t_app_id"].ToString() != "") { model.t_app_id = int.Parse(dt.Rows[n]["t_app_id"].ToString()); } if (dt.Rows[n]["t_newcount"].ToString() != "") { model.t_newcount = int.Parse(dt.Rows[n]["t_newcount"].ToString()); } if (dt.Rows[n]["t_activecount"].ToString() != "") { model.t_activecount = int.Parse(dt.Rows[n]["t_activecount"].ToString()); } if (dt.Rows[n]["t_time"].ToString() != "") { model.t_time = DateTime.Parse(dt.Rows[n]["t_time"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_trends model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_trends set "); strSql.Append(" t_app_id = @t_app_id , "); strSql.Append(" t_newcount = @t_newcount , "); strSql.Append(" t_activecount = @t_activecount , "); strSql.Append(" t_time = @t_time "); strSql.Append(" where t_id=@t_id "); SqlParameter[] parameters = { new SqlParameter("@t_id", SqlDbType.Int, 4), new SqlParameter("@t_app_id", SqlDbType.Int, 4), new SqlParameter("@t_newcount", SqlDbType.Int, 4), new SqlParameter("@t_activecount", SqlDbType.Int, 4), new SqlParameter("@t_time", SqlDbType.DateTime) }; parameters[0].Value = model.t_id; parameters[1].Value = model.t_app_id; parameters[2].Value = model.t_newcount; parameters[3].Value = model.t_activecount; parameters[4].Value = model.t_time; int rows = DbHelperSQLTotal.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_trends model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_trends model) { return(dal.Add(model)); }