public void Initialize() { dao = null; dao = new GuideDAO(); conn = null; conn = SQLiteConnectionFactory.GetPrimaryDBConnection(); }
public MainForm() { InitializeComponent(); RefreshComboBoxes(); SetLookAndFeel(); guideDAO = new GuideDAO(); comboBox_startDateRelational.SelectedIndex = 0; comboBox_endDateRelational.SelectedIndex = 0; this.Hide(); new LoadingScreen(this).ShowDialog(); }
private void button_save_Click(object sender, EventArgs e) { log.Debug("Save button clicked"); SQLiteConnection conn = SQLiteConnectionFactory.GetPrimaryDBConnection(); GuideDAO dao = new GuideDAO(); Guide guide = new Guide(); try { label_message.ForeColor = Color.Blue; guide.GuideName = textBox_guideName.Text; if (isUpdate) { guide.GuideId = Convert.ToInt32(label_guideId.Text); log.Debug("Attempting to update guide " + guide.GuideId + ": " + guide.GuideName); dao.Update(guide, conn); label_message.Text = "Updated Guide: " + guide.GuideName; log.Debug("Update guide successful"); } else { log.Debug("Attempting to save new guide: " + guide.GuideName); dao.Create(guide, conn); label_message.Text = "Created New guide: " + guide.GuideName; log.Debug("Create new guide successful"); this.Close(); } } catch (Exception ex) { log.Error("Error saving/updating guide", ex); label_message.ForeColor = Color.Red; label_message.Text = ex.Message; } }
private Guide InsertTestGuide(SQLiteConnection conn, int i) { GuideDAO guideDAO = new GuideDAO(); string name = GetRandomName() + i; Guide g = new Guide() { GuideName = name }; guideDAO.Create(g, conn); g.GuideId = guideDAO.Read("SELECT * FROM guides WHERE guide_id = (SELECT max(guide_id) FROM guides)", conn)[0].GuideId; return g; }
private Guide InsertTestGuide(SQLiteConnection conn) { GuideDAO guideDAO = new GuideDAO(); Guide g = new Guide() { GuideName = "HuntTestGuide" }; guideDAO.Create(g, conn); g.GuideId = guideDAO.Read("SELECT * FROM guides WHERE guide_name = 'HuntTestGuide'", conn)[0].GuideId; return g; }