private void buttonApply_Click(object sender, EventArgs e) { if (0 == this.textBoxUserID.Text.Length || (0 == this.textBoxLimitedKey.Text.Length && 0 == this.textBoxFullKey.Text.Length) || 0 == this.textBoxUserName.Text.Length ) { MessageBox.Show("You must enter a UserID, a Limited or Full Key, and select a character."); return; } if (-1 != this.listBoxCharacters.SelectedIndex) { // update Character ch = new Character((CharacterObject)this.listBoxCharacters.SelectedItem); IDBRecord rec = (IDBRecord)ch; rec.SetValueString((ulong)Character.QueryValues.UserID, this.textBoxUserID.Text); rec.SetValueString((ulong)Character.QueryValues.LimitedKey, this.textBoxLimitedKey.Text); rec.SetValueString((ulong)Character.QueryValues.FullKey, this.textBoxFullKey.Text); rec.SetValueString((ulong)Character.QueryValues.RegCode, this.textBoxRegCode.Text); this.m_db.UpdateRecord(ch); } else if (null != this.m_SelectedObject) { // insert new Character ch = new Character(this.m_SelectedObject); IDBRecord rec = (IDBRecord)ch; rec.SetValueString((ulong)Character.QueryValues.UserID, this.textBoxUserID.Text); rec.SetValueString((ulong)Character.QueryValues.LimitedKey, this.textBoxLimitedKey.Text); rec.SetValueString((ulong)Character.QueryValues.FullKey, this.textBoxFullKey.Text); rec.SetValueString((ulong)Character.QueryValues.RegCode, this.textBoxRegCode.Text); this.m_db.InsertRecord(ch); this.DialogResult = DialogResult.OK; this.Close(); } }
private void buttonSelectCharacter_Click(object sender, EventArgs e) { if (0 == this.textBoxUserID.Text.Length || (0 == this.textBoxLimitedKey.Text.Length && 0 == this.textBoxFullKey.Text.Length) ) { MessageBox.Show("You must enter a UserID, and a Key before selecting a character."); return; } EveApiId id = new EveApiId(this.textBoxUserID.Text, (0 != textBoxFullKey.Text.Length) ? textBoxFullKey.Text : textBoxLimitedKey.Text); CharacterCollection col = EveApi.GetCharacterList(m_db, id); IDBCollectionContents con = (IDBCollectionContents)col; if (1 > con.Count()) { return; } ListSelectDlg ls = new ListSelectDlg(); for (int i = 0; i < con.Count(); ++i) { IDBRecord rec = con.GetRecordInterface(i); rec.SetValueString((ulong)Character.QueryValues.UserID, this.textBoxUserID.Text); rec.SetValueString((ulong)Character.QueryValues.LimitedKey, this.textBoxLimitedKey.Text); rec.SetValueString((ulong)Character.QueryValues.FullKey, this.textBoxFullKey.Text); rec.SetValueString((ulong)Character.QueryValues.RegCode, this.textBoxRegCode.Text); CharacterObject obj = (CharacterObject)rec.GetDataObject(); string test = obj.ToString(); ls.List.Items.Add(obj); } Button btn = (Button)sender; ls.Location = this.PointToScreen(new Point(btn.Location.X, btn.Location.Y + btn.Height)); DialogResult ret = ls.ShowDialog(); if (DialogResult.OK == ret) { CharacterObject newObj = (CharacterObject)ls.List.SelectedItem; foreach (CharacterObject obj in this.listBoxCharacters.Items) { if (0 == obj.ToString().CompareTo(newObj.ToString())) { this.listBoxCharacters.SelectedItem = obj; this.textBoxLimitedKey.Text = this.textBoxLimitedKey.Text; this.textBoxFullKey.Text = this.textBoxFullKey.Text; return; } } this.listBoxCharacters.SelectedIndex = -1; m_SelectedObject = newObj; FillFromNewCharacter(); } }
public DatabaseError InsertRecord(IDBRecord record) { m_ErrorCode = DatabaseError.NoError; SQLiteCommand sqlite_cmd = (SQLiteCommand)m_conn.CreateCommand(); try { sqlite_cmd.CommandText = record.GetDBInsert(); sqlite_cmd.ExecuteNonQuery(); sqlite_cmd.CommandText = "SELECT last_insert_rowid();"; record.SetValueString(record.GetIDQueryValue(), sqlite_cmd.ExecuteScalar()); } catch (System.Data.SQLite.SQLiteException e) { string msg = e.Message; m_ErrorCode = DatabaseError.ExceptionSQL; } return(m_ErrorCode); }