public void Update(EMOpenGPSInfo entity) { StringBuilder sql = new StringBuilder(); sql.Append(string.Format("update movo_open_gpsinfo set Results='{0}'", entity.Results)); if (entity.LastSetTime.HasValue) sql.Append(string.Format(",LastSetTime='{0}'", entity.LastSetTime.Value)); sql.Append(string.Format(" where id={0};", entity.ID)); MySqlHelper.ExecuteNonQuery(ConnectionString, sql.ToString()); }
public static EMOpenGPSInfo ConvertInfo(DataRow row) { if (row == null) { return null; } EMOpenGPSInfo info = new EMOpenGPSInfo(); info.ID = (ulong)row["ID"]; info.GPSCode = row["GPSCode"].ToString(); info.Type = System.Convert.ToInt32(row["Type"]); info.Results = row["Results"].ToString(); if (row["LastSetTime"] == DBNull.Value || row["LastSetTime"] == null) info.LastSetTime = null; else info.LastSetTime = DateTimeConvertHelper.Parse(row["LastSetTime"].ToString()); return info; }
public void Add(EMOpenGPSInfo entity) { string sql = string.Format(@"INSERT INTO movo_open_gpsinfo (`GPSCode`, `Type`) VALUES ('{0}','{1}');", entity.GPSCode, entity.Type); MySqlHelper.ExecuteNonQuery(ConnectionString, sql); }
/// <summary> /// 根据GPSCode获取movo_open_gpsinfo中的信息 /// </summary> /// <param name="gpsCode"></param> /// <returns></returns> public EMOpenGPSInfo GetOpenGPSInfoDeatails(string gpsCode) { EMOpenGPSInfo emGPs = null; if (!string.IsNullOrEmpty(gpsCode)) { string sCmdText = string.Format(@"SELECT ID, GPSCode, Type, Results, LastSetTime FROM movo_open_gpsinfo WHERE Type=1 AND GPSCode='{0}' order by LastSetTime desc limit 0,1 ", gpsCode); using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, sCmdText)) { if (sdr != null) { if (sdr.Read()) { emGPs = new EMOpenGPSInfo(); emGPs.ID = sdr.GetUInt64(0); emGPs.GPSCode = sdr.GetStringExt(1); emGPs.Type = sdr.GetInt32(2); emGPs.Results = sdr.GetStringExt(3); emGPs.LastSetTime = sdr.GetDateTimeNull(4); } sdr.Close(); } } } return emGPs; }