void SetMaxId() { var sql = "select max(id) from tempspotorders"; int mid = -1; using (DBServer db = new DBServer()) { var r = db.ExcuteScale(sql); if (r is int) { mid = (int)r; } } if (mid > 0) { IdService <SpotOrder> .Instance.SetCurrentOrderId(mid + 1); } }