private void button_save_Click(object sender, EventArgs e) { log.Debug("Save button clicked"); SQLiteConnection conn = SQLiteConnectionFactory.GetPrimaryDBConnection(); GroupDAO dao = new GroupDAO(); Group group = new Group(); try { label_message.ForeColor = Color.Blue; group.GroupName = textBox_groupName.Text; if (isUpdate) { group.GroupId = Convert.ToInt32(label_groupId.Text); log.Debug("Attempting to update group " + group.GroupId + ": " + group.GroupName); dao.Update(group, conn); label_message.Text = "Updated group: " + group.GroupName; log.Debug("Updated group successful"); } else { log.Debug("Attempting to save new group: " + group.GroupName); dao.Create(group, conn); label_message.Text = "Created New group: " + group.GroupName; log.Debug("Create new group successful"); this.Close(); } } catch (Exception ex) { log.Error("Error saving/updating group ", ex); label_message.ForeColor = Color.Red; label_message.Text = ex.Message; } }
private Group InsertTestGroup(SQLiteConnection conn, int i) { GroupDAO groupDAO = new GroupDAO(); string name = lastNames[rand.Next(0, lastNames.Length - 1)] + " Group" + i; Group g = new Group() { GroupName = name }; groupDAO.Create(g, conn); g.GroupId = groupDAO.Read("SELECT * FROM groups WHERE group_id = (SELECT max(group_id) FROM groups)", conn)[0].GroupId; return g; }
private Group InsertTestGroup(SQLiteConnection conn) { GroupDAO groupDAO = new GroupDAO(); Group g = new Group() { GroupName = "HuntTestGroup" }; groupDAO.Create(g, conn); g.GroupId = groupDAO.Read("SELECT * FROM groups WHERE group_name = 'HuntTestGroup'", conn)[0].GroupId; return g; }