/// <summary> /// 更新一条数据 /// </summary> public bool Update(WeiXinPF.Model.wx_fc_fyImpression model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_fc_fyImpression set "); strSql.Append("wid=@wid,"); strSql.Append("fid=@fid,"); strSql.Append("openid=@openid,"); strSql.Append("content=@content,"); strSql.Append("sort_id=@sort_id,"); strSql.Append("quantity=@quantity,"); strSql.Append("createDate=@createDate"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@fid", SqlDbType.Int, 4), new SqlParameter("@openid", SqlDbType.VarChar, 300), new SqlParameter("@content", SqlDbType.VarChar, 800), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@quantity", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.fid; parameters[2].Value = model.openid; parameters[3].Value = model.content; parameters[4].Value = model.sort_id; parameters[5].Value = model.quantity; parameters[6].Value = model.createDate; parameters[7].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_fc_fyImpression DataRowToModel(DataRow row) { WeiXinPF.Model.wx_fc_fyImpression model = new WeiXinPF.Model.wx_fc_fyImpression(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } if (row["fid"] != null && row["fid"].ToString() != "") { model.fid = int.Parse(row["fid"].ToString()); } if (row["openid"] != null) { model.openid = row["openid"].ToString(); } if (row["content"] != null) { model.content = row["content"].ToString(); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["quantity"] != null && row["quantity"].ToString() != "") { model.quantity = int.Parse(row["quantity"].ToString()); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WeiXinPF.Model.wx_fc_fyImpression model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_fc_fyImpression("); strSql.Append("wid,fid,openid,content,sort_id,quantity,createDate)"); strSql.Append(" values ("); strSql.Append("@wid,@fid,@openid,@content,@sort_id,@quantity,@createDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@fid", SqlDbType.Int, 4), new SqlParameter("@openid", SqlDbType.VarChar, 300), new SqlParameter("@content", SqlDbType.VarChar, 800), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@quantity", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime) }; parameters[0].Value = model.wid; parameters[1].Value = model.fid; parameters[2].Value = model.openid; parameters[3].Value = model.content; parameters[4].Value = model.sort_id; parameters[5].Value = model.quantity; parameters[6].Value = model.createDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_fc_fyImpression GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,wid,fid,openid,content,sort_id,quantity,createDate from wx_fc_fyImpression "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; WeiXinPF.Model.wx_fc_fyImpression model = new WeiXinPF.Model.wx_fc_fyImpression(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }