Пример #1
0
 /// <summary>
 /// 添加一个群,个人分组也是
 /// </summary>
 /// <param name="group">群资料</param>
 /// <returns>成功?</returns>
 public bool addGroup(Group group)
 {
     string cmdString = "INSERT INTO " +
         DBcolumns.TABLE_GROUP + "("+
         DBcolumns.GROUP_NAME+","+
         DBcolumns.GROUP_NUM + ","+
         DBcolumns.GROUP_TIME+","+
         DBcolumns.GROUP_NOTICE+","+
         DBcolumns.GROUP_TYPE+") VALUES(\'" +
         //group.GroupId + ",\'" +
         group.GroupName + "\'," +
         group.Num + ",\'" +
         group.Time + "\',\'" +
         group.Notice + "\',\'" +
         group.Type + "\')";
     ExecuteNonQuery(cmdString, Constant.globalDbPath + "global.db");
     return true;
 }
Пример #2
0
 /// <summary>
 /// 查询群的资料
 /// </summary>
 /// <param name="groupId">群ID</param>
 /// <returns>群资料</returns>
 public Group queryGroup(int groupId)
 {
     string cmdString = "SELECT * FROM "+
         DBcolumns.TABLE_GROUP+" WHERE " +
         DBcolumns.GROUP_ID + " = " + groupId;
     SQLiteConnection conn = new SQLiteConnection("Data Source=" + Constant.globalDbPath + "global.db");
     conn.Open();
     SQLiteCommand  cmd = new SQLiteCommand(cmdString,conn);
     SQLiteDataReader dr = cmd.ExecuteReader();
     int count = dr.FieldCount;
     if (dr.Read())
     {
         Group gr = new Group();
         gr.GroupId = dr.GetInt32(0);
         gr.GroupName = dr.GetString(1);
         gr.Num = dr.GetInt32(2);
         gr.Time = dr.GetString(3) ;
         gr.Notice = dr.GetString(4);
         gr.Type = dr.GetString(5);
         conn.Close();
         return gr;
     }
     conn.Close();
     return null;
 }