public static bool update(Shake model) { string cmd = "update [shake] set shaketime=@shaketime where username=@username"; SqlParameter[] p = new SqlParameter[] { new SqlParameter("username", SqlDbType.NVarChar, 50), new SqlParameter("shaketime", SqlDbType.DateTime) }; p[0].Value = model.username; p[1].Value = model.shakeTime; return(helper.Execute(cmd, p) > 0); }
public static bool updatePositionInfo(PositionInfo model) { string cmd = "update [PositionInfo] set Latitude=@latitude,Longitude=@longitude where username=@username"; SqlParameter[] p = new SqlParameter[] { new SqlParameter("latitude", SqlDbType.Float), new SqlParameter("longitude", SqlDbType.Float), new SqlParameter("username", SqlDbType.NVarChar, 50), }; p[0].Value = model.latitude; p[1].Value = model.longitude; p[2].Value = model.strangerName; if (helper.Execute(cmd, p) > 0) { return(true); } return(false); }
public static bool AddData(UserInfo model) { string cmd = "INSERT INTO [UserInfo] VALUES (@username,@password,@state,@sex,@nickName,@birthday)"; SqlParameter[] Params = new SqlParameter[] { new SqlParameter("username", SqlDbType.NVarChar, 50), new SqlParameter("password", SqlDbType.NVarChar), new SqlParameter("state", SqlDbType.Int), new SqlParameter("sex", SqlDbType.Bit), new SqlParameter("nickName", SqlDbType.NVarChar, 50), new SqlParameter("birthday", SqlDbType.Date) }; Params[0].Value = model.username; Params[1].Value = model.password; Params[2].Value = model.state; Params[3].Value = model.sex; Params[4].Value = model.nickName; Params[5].Value = model.birthday; int r = helper.Execute(cmd, Params); return(r > 0); }
/// <summary> /// 获取用户未读消息并设为已读 /// </summary> public static List <Message> GetUnreadMsg(string username) { string cmd = "select * from [Message] where ToId=@username and flag=0 order by sendTime"; List <Message> ans = new List <Message>(); SqlParameter[] p = new SqlParameter[] { new SqlParameter("username", System.Data.SqlDbType.NVarChar, 50), }; p[0].Value = username; DataTable dt = helper.Query(cmd, p); if (dt.Rows.Count > 0) { string updateStr = ""; foreach (DataRow dr in dt.Rows) { var m = DataRowToModel(dr); ans.Add(m); updateStr += generateSetReadCMD(m); } helper.Execute(updateStr); } return(ans); }
public static bool SaveOrUpdate(Settings model) { string cmd; if (Exist(model.username)) { cmd = "update [settings] set username=@username,settings=@settings"; } else { cmd = "insert into [settings] (username,settings) VALUES (@username,@settings)"; } SqlParameter[] p = new SqlParameter[] { new SqlParameter("username", SqlDbType.NVarChar, 50), new SqlParameter("settings", SqlDbType.NVarChar, -1) }; p[0].Value = model.username; p[1].Value = model.settings; return(helper.Execute(cmd, p) > 0); }