Esempio n. 1
0
 public void userAdded(User usr)
 {
     DataGridViewRow row = new DataGridViewRow();
     row.HeaderCell.Value = usr.Name;
     row.HeaderCell.Tag = usr;
     grid.Rows.Add(row);
 }
Esempio n. 2
0
 public User addUser(string login, string name, bool showUser)
 {
     Int64 rowid = mDB.executeInsert("INSERT INTO Users (login, name, showUser) VALUES ("+
         "'"+login+"', '"+name+"', "+(showUser?"'true'":"'false'")+")");
     User usr = new User(rowid, login, name, showUser);
     if (showUser)
         mListener.userAdded(usr);
     return usr;
 }
Esempio n. 3
0
 public void initialize()
 {
     string dbname = "itp.db";
     mDB = new SQLite();
     bool exists = mDB.open(dbname, false);
     if (!exists)
     {
         mDB.open(dbname, true);
         mDB.executeNonQuery("CREATE TABLE Users(" +
             "userid INTEGER PRIMARY KEY, " +
             "login TEXT UNIQUE, " +
             "name TEXT, " +
             "showUser BOOLEAN)");
         mDB.executeNonQuery("CREATE TABLE Categories(" +
             "catid INTEGER PRIMARY KEY, " +
             "category TEXT, "+
             "shorthand TEXT, "+
             "supervisor INTEGER, "+
             "FOREIGN KEY(supervisor) REFERENCES Users(userid)"+
             ")");
         mDB.executeNonQuery("CREATE TABLE Tasks(" +
             "taskid INTEGER PRIMARY KEY, "+
             "title TEXT,"+
             "description TEXT,"+
             "actionPoints TEXT,"+
             "category INTEGER,"+
             "duration INTEGER,"+
             "inserted DATE, " +
             "modified DATE, " +
             "state INTEGER, " +
             "FOREIGN KEY(category) REFERENCES Categories(catid)"+
             ")");
         mDB.executeNonQuery("CREATE TABLE Schedule(" +
            "schedid INTEGER PRIMARY KEY, " +
            "task INTEGER," +
            "user INTEGER," +
            "startdate DATE," +
            "FOREIGN KEY(task) REFERENCES Tasks(taskid)" +
            "FOREIGN KEY(user) REFERENCES Users(userid)" +
            ")");
     }
     DataTable users = mDB.executeQuery("SELECT userid, login, name, showUser FROM Users WHERE showUser='******'");
     foreach (DataRow row in users.Rows)
     {
         User usr = new User((int)row[0], (string)row[1], (string)row[2], (bool)row[3]);
         mListener.userAdded(usr);
     }
     if (!exists)
     {
         addUser("mast2639", "Marco", true);
     }
 }