示例#1
0
        public int AddAppliance(Applaince a)
        {
            string cs = "URI=file:C:\\temp\\smarthouse.db";

            using (SQLiteConnection con = new SQLiteConnection(cs))
            {
                try
                {
                    SQLiteCommand cmd = new SQLiteCommand(con);
                    con.Open();

                    cmd.CommandText = "insert into Appliance (name,commands,gestures,appgroup) values (";
                    cmd.CommandText += "'" + a.name + "','" + a.command + "','" + a.gestures + "','" + a.appgroup.appgroupnum + "')";
                    cmd.ExecuteNonQuery();
                }
                catch (SQLiteException ex)
                {
                    // Display error
                    Console.WriteLine("Error: " + ex.ToString());
                }

                con.Close();
            }
            return getLastId("Appliance","appnum");
        }
示例#2
0
        public List<string> getAllApplainceNames()
        {
            int groupnum = 0;
            string cs = "URI=file:C:\\temp\\smarthouse.db";
            Applaince app1 = new Applaince();
            List<string> namelist = new List<string>();
            using (SQLiteConnection con = new SQLiteConnection(cs))
            {
                con.Open();

                string stm = "select name from appliance";

                using (SQLiteCommand cmd = new SQLiteCommand(stm, con))
                {

                    using (SQLiteDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            namelist.Add(rdr.GetString(0));
                        }
                    }
                }
                con.Close();
            }
            return namelist;
        }
示例#3
0
        public Applaince getApp(string name)
        {
            int groupnum = 0;
            string cs = "URI=file:C:\\temp\\smarthouse.db";
            Applaince app1 = new Applaince();
            using (SQLiteConnection con = new SQLiteConnection(cs))
            {
                con.Open();

                string stm = "SELECT *  FROM Appliance where name = \""+name+"\"";

                using (SQLiteCommand cmd = new SQLiteCommand(stm, con))
                {

                    using (SQLiteDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            app1.appnum = rdr.GetInt32(0);
                            app1.name = rdr.GetString(1);
                            app1.command = rdr.GetString(2);
                            app1.gestures = rdr.GetString(3);
                            groupnum = rdr.GetInt32(4);
                        }
                    }
                }

                stm = "SELECT * FROM Feature where appnum= "+app1.appnum;
                app1.features = new List<Feature>();
                using (SQLiteCommand cmd = new SQLiteCommand(stm, con))
                {

                    using (SQLiteDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            //Feature tmp = new Feature();
                            int values = rdr.GetInt32(0);
                            int featurenum = rdr.GetInt32(1);
                            string names = rdr.GetString(2);
                            string enums = rdr.GetString(3);

                            app1.features.Add(new Feature(featurenum,names,enums,values) );
                            Console.WriteLine();
                        }
                    }
                }
                con.Close();
            }
            return app1;
        }
示例#4
0
 public Window2()
 {
     InitializeComponent();
     ap = new Applaince();
     ap.appgroup = new ApplainceGroup();
 }