public int DeleteAllByUserId(int userId) { string sql = "delete from Comments where userId = @userId"; SqlParameter p = new SqlParameter("@userId", userId); return(DbHelper.ExecuteNotQuery(sql, p)); }
public int Delete(int id) { string sql = "delete from admins where id=@id"; SqlParameter p = new SqlParameter("@id", id); return(DbHelper.ExecuteNotQuery(sql, p)); }
public int Add(Classify model) { string sql = "insert into classifys([ClassifyName]) VALUES(@ClassifyName)"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@ClassifyName", model.ClassifyName), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Update(Classify model) { string sql = "update classifys set ClassifyName = @ClassifyName where id = @id"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@id", model.Id), new SqlParameter("@ClassifyName", model.ClassifyName), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Delete(Dictionary<string,object> dicWhere) { StringBuilder sql = new StringBuilder("delete from Likes where 1=1"); List<SqlParameter> pList = new List<SqlParameter>(); foreach (var item in dicWhere) { sql.Append(" and " + item.Key + "=@" + item.Key.ToString()); pList.Add(new SqlParameter("@" + item.Key, item.Value)); } return DbHelper.ExecuteNotQuery(sql.ToString(), pList.ToArray()); }
public int Add(Model.Admin admin) { string sql = "insert into admins([AdminName],[Pwd]) values(@AdminName,@Pwd)"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@AdminName", admin.AdminName), new SqlParameter("@Pwd", admin.Pwd), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Add(Like model) { string sql = "insert into likes(UserId,ProjectId) VALUES(@UserId,@ProjectId)"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@UserId", model.UserId), new SqlParameter("@ProjectId", model.ProjectId), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Update(Like model) { string sql = "update classifys set ProjectId = @ProjectId where UserId = @UserId"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@UserId", model.UserId), new SqlParameter("@ProjectId", model.ProjectId), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Update(Model.Admin admin) { string sql = "update admins set AdminName=@AdminName,Pwd=@Pwd where Id=@Id"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@Id", admin.Id), new SqlParameter("@AdminName", admin.AdminName), new SqlParameter("@Pwd", admin.Pwd), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Add(Comment model) { string sql = "insert into Comments([UserId],[ProjectId],[Content]) values(@UserId,@ProjectId,@Content)"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@UserId", model.UserId), new SqlParameter("@ProjectId", model.ProjectId), new SqlParameter("@Content", model.Content) }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Add(SupportProject model) { string sql = "insert into SupportProjects([UserId],[ProjectId],[Money]) values(@UserId,@ProjectId,@Money)"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@UserId", model.UserId), new SqlParameter("@ProjectId", model.ProjectId), new SqlParameter("@Money", model.Money), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Update(Comment model) { string sql = "update Comments set UserId=@UserId,ProjectId=@ProjectId,Content=@Content where Id=@Id"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@Id", model.Id), new SqlParameter("@UserId", model.UserId), new SqlParameter("@ProjectId", model.ProjectId), new SqlParameter("@Content", model.Content) }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Update(SupportProject model) { string sql = "update SupportProjects set UserId=@UserId,ProjectId=@ProjectId,Money=@Money where Id=@Id"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@Id", model.Id), new SqlParameter("@UserId", model.UserId), new SqlParameter("@ProjectId", model.ProjectId), new SqlParameter("@Money", model.Money), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
/// <summary> /// 获取行数 /// </summary> /// <param name="where">where条件</param> /// <returns></returns> public int GetCountWhereTo(Dictionary <string, object> where) { //select UserId,count(*) as count from SupportProjects where ProjectId = 10003 group by UserId StringBuilder sb = new StringBuilder("select count(*) from SupportProjects"); List <SqlParameter> list = new List <SqlParameter>(); foreach (var item in where) { if (item.Equals(where.FirstOrDefault())) { sb.Append(" where"); } sb.Append($" {item.Key}={item.Value}"); } return(DbHelper.ExecuteNotQuery(sb.ToString(), list.ToArray())); }
public int Add(LaunchInfo model) { string sql = "insert into LaunchInfo([UserId],[TrueName],[PhoneNumber],[BankName],[Branch],[BankCard],[Address],[ProjectId]) VALUES(@UserId,@TrueName,@PhoneNumber,@BankName,@Branch,@BankCard,@Address,@ProjectId)"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@UserId", model.UserId), new SqlParameter("@TrueName", model.TrueName), new SqlParameter("@PhoneNumber", model.PhoneNumber), new SqlParameter("@BankName", model.BankName), new SqlParameter("@Branch", model.Branch), new SqlParameter("@BankCard", model.BankCard), new SqlParameter("@Address", model.Address), new SqlParameter("@ProjectId", model.ProjectId), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Update(LaunchInfo model) { string sql = "update classifys set LaunchInfo = @ClassifyName where id = @id"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@UserId", model.UserId), new SqlParameter("@TrueName", model.TrueName), new SqlParameter("@PhoneNumber", model.PhoneNumber), new SqlParameter("@BankName", model.BankName), new SqlParameter("@Branch", model.Branch), new SqlParameter("@BankCard", model.BankCard), new SqlParameter("@Address", model.Address), new SqlParameter("@ProjectId", model.ProjectId), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Add(Model.User user) { string sql = "insert into users([UserName],[Nickname],[Pwd],[Sex],[Phone],[Address],[Url],[Description],[UserPic]) values(@UserName,@Nickname,@Pwd,@Sex,@Phone,@Address,@Url,@Description,@UserPic)"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@UserName",user.UserName), new SqlParameter("@Nickname",user.Nickname), new SqlParameter("@Pwd",user.Pwd), new SqlParameter("@Sex",user.Sex), new SqlParameter("@Phone",user.Phone), new SqlParameter("@Address",user.Address), new SqlParameter("@Url",user.Url), new SqlParameter("@Description",user.Description), new SqlParameter("@UserPic",user.UserPic), }; return DbHelper.ExecuteNotQuery(sql, ps); }
public int Add(Project model) { string sql = "insert into Projects([ClassifyId],[ProjectName],[State],[CurrentMoney],[Goal],[Deadline],[LikeCount],[Content],CoverImg) values(@ClassifyId,@ProjectName,@State,@CurrentMoney,@Goal,@Deadline,@LikeCount,@Content,@CoverImg)"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@ClassifyId", model.ClassifyId), new SqlParameter("@ProjectName", model.ProjectName), new SqlParameter("@State", model.State), new SqlParameter("@CurrentMoney", model.CurrentMoney), new SqlParameter("@Goal", model.Goal), new SqlParameter("@Deadline", model.Deadline), new SqlParameter("@LikeCount", model.LikeCount), new SqlParameter("@Content", model.Content), new SqlParameter("@CoverImg", model.CoverImg), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }
public int Update(Model.User user) { string sql = "update users set UserName=@UserName,Nickname=@Nickname,Pwd=@Pwd,Sex=@Sex,Phone=@Phone,Address=@Address,Url=@Url,Description=@Description,UserPic=@UserPic where Id=@Id"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@Id",user.Id), new SqlParameter("@UserName",user.UserName), new SqlParameter("@Nickname",user.Nickname), new SqlParameter("@Pwd",user.Pwd), new SqlParameter("@Sex",user.Sex), new SqlParameter("@Phone",user.Phone), new SqlParameter("@Address",user.Address), new SqlParameter("@Url",user.Url), new SqlParameter("@Description",user.Description), new SqlParameter("@UserPic",user.UserPic), }; return DbHelper.ExecuteNotQuery(sql, ps); }
public int Update(Project model) { string sql = "update Projects set ClassifyId=@ClassifyId,ProjectName=@ProjectName,State=@State,CurrentMoney=@CurrentMoney,Goal=@Goal,Deadline=@Deadline,LikeCount=@LikeCount,Content=@Content,CoverImg=@CoverImg where Id=@Id"; SqlParameter[] ps = new SqlParameter[] { new SqlParameter("@Id", model.Id), new SqlParameter("@ClassifyId", model.ClassifyId), new SqlParameter("@ProjectName", model.ProjectName), new SqlParameter("@State", model.State), new SqlParameter("@CurrentMoney", model.CurrentMoney), new SqlParameter("@Goal", model.Goal), new SqlParameter("@Deadline", model.Deadline), new SqlParameter("@LikeCount", model.LikeCount), new SqlParameter("@Content", model.Content), new SqlParameter("@CoverImg", model.CoverImg), }; return(DbHelper.ExecuteNotQuery(sql, ps)); }