Esempio n. 1
0
        private void lstbSessions_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBoxSessionItem item = (ListBoxSessionItem)lstbSessions.SelectedItem;

            if (item != null)
            {
                Session session = storage.findSession(item.id);
                if (session == null)
                {
                    return;
                }
                pGridSession.SelectedObject = session;
                currentSession = session;
                enableDisableButtons(true, true);
            }
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to permanently delete this session?", "Delete session", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                ListBoxSessionItem item = (ListBoxSessionItem)lstbSessions.SelectedItem;
                if (item != null)
                {
                    storage.deleteSession(item.id);
                    loadSessionsInList();
                    loadStatistics();
                    enableDisableButtons(false, true);
                }
            }
        }
Esempio n. 3
0
        public List <ListBoxSessionItem> findSessionsForUser(string user, EventType cof)
        {
            SQLiteConnection con = new SQLiteConnection(connString);

            con.Open();
            SQLiteCommand cmd = new SQLiteCommand("select id, decimalScoring, score, decimalScore,innerX, startTime " +
                                                  "  from Sessions where user = @user and courseOfFire = @cof " +
                                                  "  order by id desc", con);

            cmd.Parameters.AddWithValue("@cof", cof.Name);
            cmd.Parameters.AddWithValue("@user", user);
            SQLiteDataReader          rdr = cmd.ExecuteReader();
            List <ListBoxSessionItem> ret = new List <ListBoxSessionItem>();

            while (rdr.Read())
            {
                long     id             = rdr.GetInt64(0);
                int      decimalScoring = rdr.GetInt32(1);
                int      score          = rdr.GetInt32(2);
                decimal  decimalScore   = rdr.GetDecimal(3);
                int      innerX         = rdr.GetInt32(4);
                DateTime date           = convertStringToDate(rdr.GetString(5));

                if (decimalScoring == 0)
                {
                    ListBoxSessionItem item = new ListBoxSessionItem(date.ToString("yyyy-MM-dd"), score + "-" + innerX + "x", id);
                    ret.Add(item);
                }
                else
                {
                    ListBoxSessionItem item = new ListBoxSessionItem(date.ToString("yyyy-MM-dd"), decimalScore + "-" + innerX + "x", id);
                    ret.Add(item);
                }
            }

            rdr.Close();
            con.Close();
            return(ret);
        }