Exemple #1
0
        public static Oolite_System_Info AddSystem(int ID, string s)
        {
            Oolite_System_Info info = null;

            foreach (Oolite_System_Info x in Systems)
            {
                Console.WriteLine(x.ToString());
                if (String.Compare(x.ToString(), s, true) == 0)
                {
                    info = x;
                    break;
                }
            }
            if (info == null)
            {
                try
                {
                    info = new Oolite_System_Info(s, ID, grid.Tables["Systems"].NewRow());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                //Save();
            }
            return(info);
        }
Exemple #2
0
 private void CreateOrFindSystem(object sender, EventArgs e)
 {
     if (String.Compare(SelectedItem.ToString(), "<New>") == 0)
     {
         QueryNewName name = new QueryNewName("Enter new SyStem Name");
         name.ShowDialog();
         if (name.DialogResult == DialogResult.OK)
         {
             Oolite_System_Info info = Local.AddSystem(name.textBox1.Text);
             Items.Add(info);
         }
     }
 }
Exemple #3
0
        public static bool AddSystem(string s, DataRow row)
        {
            Oolite_System_Info info = null;

            foreach (Oolite_System_Info x in Systems)
            {
                if (String.Compare(x.ToString(), s, true) == 0)
                {
                    if ((x.data != row))
                    {
                        {
                            // // row.RejectChanges(); casues application fault.
                            row[1] = DBNull.Value;
                            row[0] = DBNull.Value;
                            //--- these don't work either...
                            //row.Table.AcceptChanges();
                            //row.Delete();
                            ////row.RowState = DataRowState.Deleted;
                            //row.Table.AcceptChanges();

                            //--- thrown an exception is not caught nicely by top level (middle)
                            ////throw new Exception("Abort NewRow()");
                            ////row.AcceptChanges();
                        }
                        return(false);
                    }
                    else
                    {
                        info = x;
                    }
                    //else fall through - and rename will happen ...
                    // allowed to change this name...
                }
            }

            if (info == null)
            {
                try
                {
                    Systems.Add(info = new Oolite_System_Info(s, row, false));
                    return(true);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                //Save();
            }
            return(true);
        }
Exemple #4
0
        public void Load()
        {
#if asdfasdf
            if (Local.odbc.State != ConnectionState.Closed)
            {
                OdbcCommand c = new OdbcCommand("select system_id,name,Population,Gross,Type from Oolite_Systems", Local.odbc);
                try
                {
                    OdbcDataReader r = c.ExecuteReader();

                    while (r.Read())
                    {
                        Oolite_System_Info osi = Local.AddSystem(r.GetInt32(0), r.GetString(1));
                        osi.data[2] = r.GetString(2);
                        osi.data[3] = r.GetString(3);
                        osi.data[4] = r.GetString(4);

                        //?select max(time),Commodity_Name from Oolite_Price_History  group by Commodity_Name
                        //select * from Oolite_Price_History where time in (select max(time) from Oolite_Price_History  group by Commodity_Name )

                        OdbcCommand c2 = new OdbcCommand("select Commodity_Name,price from Oolite_Price_History where time in (select max(time) from Oolite_Price_History where system_id="
                                                         + osi.data[0]
                                                         + " group by Commodity_Name )"
                                                         , Local.odbc);
                        try
                        {
                            OdbcDataReader r2 = c2.ExecuteReader();
                            while (r2.Read())
                            {
                                osi.data[r2.GetString(0)] = r2.GetDouble(1);
                            }
                        }
                        catch (Exception e2)
                        {
                            Console.WriteLine(e2);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
#endif
        }
Exemple #5
0
 static bool something(Oolite_System_Info s)
 {
     return(false);
 }