Beispiel #1
0
        static public Comand getComand(String id)
        {
            DataTable dTable = new DataTable();
            String    sqlQuery;
            Comand    list = null;

            if (!isOpen)
            {
                return(list);
            }

            try
            {
                sqlQuery = "SELECT * FROM main where id = '" + id + "'";
                SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlQuery, m_dbConn);
                adapter.Fill(dTable);
                if (dTable.Rows.Count > 0)
                {
                    list = new Comand(dTable.Rows[0].ItemArray[0].ToString(),
                                      dTable.Rows[0].ItemArray[1].ToString(),
                                      dTable.Rows[0].ItemArray[2].ToString(),
                                      dTable.Rows[0].ItemArray[3].ToString(),
                                      dTable.Rows[0].ItemArray[4].ToString());
                }
            }
            catch (SQLiteException ex)
            { Console.WriteLine("Error: " + ex.Message); }
            return(list);
        }
Beispiel #2
0
        static public void putComand(Comand comand)
        {
            if (!isOpen)
            {
                return;
            }

            try
            {
                SQLiteCommand cmd = new SQLiteCommand("insert into main (Name, childID, ParentID, type) values('" + comand.Text + "', '','" + comand.ParentID + "', '" + comand.Type + "')");
                cmd.Connection = m_dbConn;
                cmd.ExecuteNonQuery();
                cmd.CommandText = ("update main set childID = childID || " + comand.Id + " || ';' where id = '" + comand.ParentID + "'");
                cmd.ExecuteNonQuery();
            }
            catch (SQLiteException ex)
            { Console.WriteLine("Error: " + ex.Message); }
        }
Beispiel #3
0
        static void makeChoice(object sc, Telegram.Bot.Args.CallbackQueryEventArgs ev)
        {
            if (data == null)
            {
                return;
            }
            var message = ev.CallbackQuery.Data;

            Console.WriteLine(message);
            var chatID = ev.CallbackQuery.Message.Chat.Id;

            data = DBClass.getComands(Users[chatID]);
            try
            {
                String[] messArr = message.Split("_");
                if (messArr[0] != Users[chatID])
                {
                    return;
                }
                if (messArr[1] == "back")
                {
                    Comand t = DBClass.getComand(messArr[0]);
                    Users[chatID] = t.ParentID;
                    showMessage(chatID);
                }
                else if (messArr[1] == "helpyes")
                {
                    workWithHelp(chatID, true);
                }
                else if (messArr[1] == "helpno")
                {
                    Comand t = DBClass.getComand(messArr[0]);
                    Users[chatID] = t.ParentID;
                    showMessage(chatID);
                }
                else
                {
                    Users[chatID] = data[Convert.ToInt32(messArr[1])].Id;
                    showMessage(chatID);
                }
            }
            catch (Exception) { }
        }