Пример #1
0
        private bool Add(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Insert into routes_expeditions (name, start, end, Status) values (@name, @start, @end, @stat)"))
            {
                cmd.AddParameterWithValue("@name", Name);
                cmd.AddParameterWithValue("@start", StartDate);
                cmd.AddParameterWithValue("@end", EndDate);
                cmd.AddParameterWithValue("@stat", (Deleted ? 1 : 0) + (EDSM ? 2 : 0));

                cn.SQLNonQueryText(cmd);

                using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from routes_expeditions"))
                {
                    Id = (long)cn.SQLScalar(cmd2);
                }

                using (DbCommand cmd2 = cn.CreateCommand("INSERT INTO route_systems (routeid, systemname) VALUES (@routeid, @name)"))
                {
                    cmd2.AddParameter("@routeid", DbType.String);
                    cmd2.AddParameter("@name", DbType.String);

                    foreach (var sysname in Systems)
                    {
                        cmd2.Parameters["@routeid"].Value = Id;
                        cmd2.Parameters["@name"].Value    = sysname;
                        cn.SQLNonQueryText(cmd2);
                    }
                }

                return(true);
            }
        }
Пример #2
0
        private bool Update(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("UPDATE routes_expeditions SET name=@name, start=@start, end=@end, Status=@stat WHERE id=@id"))
            {
                cmd.AddParameterWithValue("@id", Id);
                cmd.AddParameterWithValue("@name", Name);
                cmd.AddParameterWithValue("@start", StartDate);
                cmd.AddParameterWithValue("@end", EndDate);
                cmd.AddParameterWithValue("@stat", (Deleted ? 1 : 0) + (EDSM ? 2 : 0));
                cn.SQLNonQueryText(cmd);

                using (DbCommand cmd2 = cn.CreateCommand("DELETE FROM route_systems WHERE routeid=@routeid"))
                {
                    cmd2.AddParameterWithValue("@routeid", Id);
                    cn.SQLNonQueryText(cmd2);
                }

                using (DbCommand cmd2 = cn.CreateCommand("INSERT INTO route_systems (routeid, systemname) VALUES (@routeid, @name)"))
                {
                    cmd2.AddParameter("@routeid", DbType.String);
                    cmd2.AddParameter("@name", DbType.String);

                    foreach (var sysname in Systems)
                    {
                        cmd2.Parameters["@routeid"].Value = Id;
                        cmd2.Parameters["@name"].Value    = sysname;
                        cn.SQLNonQueryText(cmd2);
                    }
                }

                return(true);
            }
        }
Пример #3
0
 static private bool Delete(SQLiteConnectionUser cn, long id)
 {
     using (DbCommand cmd = cn.CreateCommand("DELETE FROM CaptainsLog WHERE id = @id"))
     {
         cmd.AddParameterWithValue("@id", id);
         cn.SQLNonQueryText(cmd);
         return(true);
     }
 }
Пример #4
0
 private bool Delete(SQLiteConnectionUser cn)
 {
     using (DbCommand cmd = cn.CreateCommand("DELETE FROM Bookmarks WHERE id = @id"))
     {
         cmd.AddParameterWithValue("@id", id);
         cn.SQLNonQueryText(cmd);
         return(true);
     }
 }
Пример #5
0
 public static void ClearEDSMID()
 {
     using (SQLiteConnectionUser cn = new SQLiteConnectionUser(utc: true))
     {
         using (DbCommand cmd = cn.CreateCommand("UPDATE SystemNote SET EdsmId=0"))
         {
             cn.SQLNonQueryText(cmd);
         }
     }
 }
Пример #6
0
        private bool Delete(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("DELETE FROM SystemNote WHERE id = @id"))
            {
                cmd.AddParameterWithValue("@id", id);
                cn.SQLNonQueryText(cmd);

                globalSystemNotes.RemoveAll(x => x.id == id);     // remove from list any containing id.
                return(true);
            }
        }
Пример #7
0
        private bool Add(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Insert into wanted_systems (systemname) values (@systemname)"))
            {
                cmd.AddParameterWithValue("@systemname", system);
                cn.SQLNonQueryText(cmd);

                using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from wanted_systems"))
                {
                    id = (long)cn.SQLScalar(cmd2);
                }
                return(true);
            }
        }
Пример #8
0
        public bool Update(SQLiteConnectionUser cn, DbTransaction tn = null)
        {
            using (DbCommand cmd = cn.CreateCommand("Update TravelLogUnit set Name=@Name, Type=@type, size=@size, Path=@Path, CommanderID=@CommanderID  where ID=@id", tn))
            {
                cmd.AddParameterWithValue("@ID", id);
                cmd.AddParameterWithValue("@Name", Name);
                cmd.AddParameterWithValue("@Type", type);
                cmd.AddParameterWithValue("@size", Size);
                cmd.AddParameterWithValue("@Path", Path);
                cmd.AddParameterWithValue("@CommanderID", CommanderId);

                cn.SQLNonQueryText(cmd);

                return(true);
            }
        }
Пример #9
0
        private bool Update(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Update CaptainsLog set Commander=@c, Time=@t, SystemName=@s, BodyName=@b, Note=@n, Tags=@g, Parameters=@p where ID=@id"))
            {
                cmd.AddParameterWithValue("@id", ID);
                cmd.AddParameterWithValue("@c", Commander);
                cmd.AddParameterWithValue("@t", TimeUTC);
                cmd.AddParameterWithValue("@s", SystemName);
                cmd.AddParameterWithValue("@b", BodyName);
                cmd.AddParameterWithValue("@n", Note);
                cmd.AddParameterWithValue("@g", Tags);
                cmd.AddParameterWithValue("@p", Parameters);
                cn.SQLNonQueryText(cmd);

                return(true);
            }
        }
Пример #10
0
        private bool Update(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Update SystemNote set Name=@Name, Time=@Time, Note=@Note, Journalid=@journalid, EdsmId=@EdsmId  where ID=@id"))
            {
                cmd.AddParameterWithValue("@ID", id);
                cmd.AddParameterWithValue("@Name", SystemName);
                cmd.AddParameterWithValue("@Note", Note);
                cmd.AddParameterWithValue("@Time", Time);
                cmd.AddParameterWithValue("@journalid", Journalid);
                cmd.AddParameterWithValue("@EdsmId", EdsmId);

                cn.SQLNonQueryText(cmd);

                Dirty = false;
            }

            return(true);
        }
Пример #11
0
        private bool Update(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Update Bookmarks set StarName=@sname, x = @xp, y = @yp, z = @zp, Time=@time, Heading = @head, Note=@note, PlanetMarks=@pmarks  where ID=@id"))
            {
                cmd.AddParameterWithValue("@ID", id);
                cmd.AddParameterWithValue("@sname", StarName);
                cmd.AddParameterWithValue("@xp", x);
                cmd.AddParameterWithValue("@yp", y);
                cmd.AddParameterWithValue("@zp", z);
                cmd.AddParameterWithValue("@time", Time);
                cmd.AddParameterWithValue("@head", Heading);
                cmd.AddParameterWithValue("@note", Note);
                cmd.AddParameterWithValue("@pmarks", PlanetaryMarks?.ToJsonString());

                cn.SQLNonQueryText(cmd);

                return(true);
            }
        }
Пример #12
0
        private bool Add(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Insert into TravelLogUnit (Name, type, size, Path, CommanderID) values (@name, @type, @size, @Path, @CommanderID)"))
            {
                cmd.AddParameterWithValue("@name", Name);
                cmd.AddParameterWithValue("@type", type);
                cmd.AddParameterWithValue("@size", Size);
                cmd.AddParameterWithValue("@Path", Path);
                cmd.AddParameterWithValue("@CommanderID", CommanderId);

                cn.SQLNonQueryText(cmd);

                using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from TravelLogUnit"))
                {
                    id = (long)cn.SQLScalar(cmd2);
                }

                return(true);
            }
        }
Пример #13
0
        private bool Add(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Insert into CaptainsLog (Commander, Time, SystemName, BodyName, Note, Tags, Parameters) values (@c,@t,@s,@b,@n,@g,@p)"))
            {
                cmd.AddParameterWithValue("@c", Commander);
                cmd.AddParameterWithValue("@t", TimeUTC);
                cmd.AddParameterWithValue("@s", SystemName);
                cmd.AddParameterWithValue("@b", BodyName);
                cmd.AddParameterWithValue("@n", Note);
                cmd.AddParameterWithValue("@g", Tags);
                cmd.AddParameterWithValue("@p", Parameters);
                cn.SQLNonQueryText(cmd);

                using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from CaptainsLog"))
                {
                    ID = (long)cn.SQLScalar(cmd2);
                }

                return(true);
            }
        }
Пример #14
0
        private bool Add(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Insert into Bookmarks (StarName, x, y, z, Time, Heading, Note, PlanetMarks) values (@sname, @xp, @yp, @zp, @time, @head, @note, @pmarks)"))
            {
                cmd.AddParameterWithValue("@sname", StarName);
                cmd.AddParameterWithValue("@xp", x);
                cmd.AddParameterWithValue("@yp", y);
                cmd.AddParameterWithValue("@zp", z);
                cmd.AddParameterWithValue("@time", Time);
                cmd.AddParameterWithValue("@head", Heading);
                cmd.AddParameterWithValue("@note", Note);
                cmd.AddParameterWithValue("@pmarks", PlanetaryMarks?.ToJsonString());

                cn.SQLNonQueryText(cmd);

                using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from Bookmarks"))
                {
                    id = (long)cn.SQLScalar(cmd2);
                }

                return(true);
            }
        }
Пример #15
0
        private bool AddToDbAndGlobal(SQLiteConnectionUser cn)
        {
            using (DbCommand cmd = cn.CreateCommand("Insert into SystemNote (Name, Time, Note, journalid, edsmid) values (@name, @time, @note, @journalid, @edsmid)"))
            {
                cmd.AddParameterWithValue("@name", SystemName);
                cmd.AddParameterWithValue("@time", Time);
                cmd.AddParameterWithValue("@note", Note);
                cmd.AddParameterWithValue("@journalid", Journalid);
                cmd.AddParameterWithValue("@edsmid", EdsmId);

                cn.SQLNonQueryText(cmd);

                using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from SystemNote"))
                {
                    id = (long)cn.SQLScalar(cmd2);
                }

                globalSystemNotes.Add(this);

                Dirty = false;

                return(true);
            }
        }