internal int Editwxad(Wxad adinfo) { try { string sql = ""; sqlHelper.BeginTrancation(); if (adinfo.Id > 0) { sql = "update weixin_ad set Title='" + adinfo.Title + "',Adtype=" + adinfo.Adtype + ",Link='" + adinfo.Link + "',musicid=" + adinfo.Musicid + ",Author='" + adinfo.Author + "',Keyword='" + adinfo.Keyword + "',Applystate=" + adinfo.Applystate + ",Votecount=" + adinfo.Votecount + ",Lookcount=" + adinfo.Lookcount + " where id=" + adinfo.Id + " and comid=" + adinfo.Comid; } else { sql = "INSERT INTO weixin_ad(Comid,Title,Adtype,Link,musicid,Author,Keyword,Applystate,Votecount,Lookcount)" + " VALUES(" + adinfo.Comid + ",'" + adinfo.Title + "'," + adinfo.Adtype + ",'" + adinfo.Link + "'," + adinfo.Musicid + ",'" + adinfo.Author + "','" + adinfo.Keyword + "'," + adinfo.Applystate + "," + adinfo.Votecount + "," + adinfo.Lookcount + ")"; } var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.ExecuteNonQuery(); sqlHelper.Commit(); sqlHelper.Dispose(); return(1); } catch { sqlHelper.Rollback(); sqlHelper.Dispose(); return(0); } }
internal Wxad Getwxad(int id, int comid) { string sql = "SELECT * FROM weixin_ad where id=" + id + " and comid=" + comid; var cmd = sqlHelper.PrepareTextSqlCommand(sql); using (var reader = cmd.ExecuteReader()) { Wxad m = null; if (reader.Read()) { m = new Wxad() { Id = reader.GetValue <int>("id"), Comid = reader.GetValue <int>("Comid"), Title = reader.GetValue <string>("Title"), Adtype = reader.GetValue <int>("Adtype"), Link = reader.GetValue <string>("Link"), Author = reader.GetValue <string>("Author"), Keyword = reader.GetValue <string>("Keyword"), Applystate = reader.GetValue <int>("Applystate"), Votecount = reader.GetValue <int>("Votecount"), Lookcount = reader.GetValue <int>("Lookcount"), Musicid = reader.GetValue <int>("Musicid"), }; } return(m); } }
public int Editwxad(Wxad adinfo) { using (var helper = new SqlHelper()) { int r = new InternalWxAd(helper).Editwxad(adinfo); return(r); } }