Exemple #1
0
        public void init( Alert alert, string defaultColor )
        {
            if (!Registration.isValid())
            {
                label7.Visible = false;
                soundField.Visible = false;
                browseButton.Visible = false;
                messageBox.ShowStamp = false;
            }

            backgroundChanged = false;

            currentAlert = alert;
            soundField.Text = alert.getSound();
            try
            {
                string background = alert.getBackground();
                if (background.ToUpper().Equals("DEFAULT"))
                {
                    background = defaultColor;
                }
                else
                {
                    backgroundChanged = true;
                }
                messageBox.RichTextBox.BackColor = Color.FromArgb(System.Convert.ToInt32(background));
            }
            catch
            {
                messageBox.RichTextBox.BackColor = Color.FromName("Window");
            }

            titleField.Text = alert.getTitle();
            messageBox.RichTextBox.Rtf = alert.getMessage();

            advancedField1.Text = alert.getSchedule();
            oneTimeField3.SelectedIndex = 0;
            timeDelayField2.SelectedIndex = 0;
            dayOfMonthField1.SelectedIndex = 0;
            dayOfMonthField3.SelectedIndex = 0;
            dayOfMonthField4.SelectedIndex = 0;
            dayOfWeekField1.SelectedIndex = 0;
            dayOfWeekField3.SelectedIndex = 0;
            positionalDayOfWeekField1.SelectedIndex = 0;
            positionalDayOfWeekField2.SelectedIndex = 0;
            positionalDayOfWeekField4.SelectedIndex = 0;
            positionalDayOfWeekField6.SelectedIndex = 0;
            this.setRadioButton();

            if (alert.getSnoozed())
            {
                MsgBox.Show("If you save, this alert will no longer be on snooze.",
                    "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        public AlertDialog(Alert alert, String color, String soundFile)
        {
            InitializeComponent();
            this.Text = "Alert!! - " + alert.getTitle();
            this.alert = alert;
            messageBox.RichTextBox.Rtf = alert.getMessage();

            try
            {
                messageBox.RichTextBox.BackColor = Color.FromArgb(System.Convert.ToInt32(color));
            }
            catch
            {
                messageBox.RichTextBox.BackColor = Color.FromName("Window");
            }

            alertLabel.Text = ""+alert.getWakeUpTime();

            this.soundFile = soundFile;
        }
Exemple #3
0
        public Alert createNewAlert( Alert alert )
        {
            SQLiteCommand cmd;

            //Create a new Entry
            cmd = conn.CreateCommand();
            cmd.CommandText = "INSERT INTO Alerts (Title, Message, Year, DayOfMonth, Month, DayOfWeek, Hour, " +
                "Minute, Snoozed, Valid, WakeUpTime, Background, Sound, Command) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters[0].Value = alert.getTitle();
            cmd.Parameters[1].Value = alert.getMessage();
            cmd.Parameters[2].Value = alert.getYear();
            cmd.Parameters[3].Value = alert.getDayOfMonth();
            cmd.Parameters[4].Value = alert.getMonth();
            cmd.Parameters[5].Value = alert.getDayOfWeek();
            cmd.Parameters[6].Value = alert.getHour();
            cmd.Parameters[7].Value = alert.getMinute();
            cmd.Parameters[8].Value = alert.getSnoozed();
            cmd.Parameters[9].Value = alert.getValid();
            cmd.Parameters[10].Value = alert.getWakeUpTime();
            cmd.Parameters[11].Value = alert.getBackground();
            cmd.Parameters[12].Value = alert.getSound();
            cmd.Parameters[13].Value = alert.getCommand();
            cmd.ExecuteNonQuery();
            cmd.Dispose();

            //Get the newly created AlertId.  Rely on sqlite, hope for no multiple access of the table.
            cmd = conn.CreateCommand();
            cmd.CommandText = "SELECT last_insert_rowid()";
            int newAlertId = Convert.ToInt32(cmd.ExecuteScalar());
            cmd.Dispose();
            alert.setAlertId(newAlertId);

            return alert;
        }
Exemple #4
0
        public void updateAlert( Alert alert )
        {
            if (alert.getAlertId() < 0)
            {
                throw new Exception("Invalid Alert Id");
            }

            SQLiteCommand cmd = conn.CreateCommand();
            cmd.CommandText = "UPDATE Alerts SET Title = ?, Message = ?, Year = ?, DayOfMonth = ?, Month = ?, " +
                "DayOfWeek = ?, Hour = ?, Minute = ?, Snoozed = ?, Valid = ?, WakeUpTime = ?, Background = ?, " +
                "Sound = ?, Command = ? WHERE AlertId = ?";
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter()); cmd.Parameters.Add(cmd.CreateParameter());
            cmd.Parameters[0].Value = alert.getTitle();
            cmd.Parameters[1].Value = alert.getMessage();
            cmd.Parameters[2].Value = alert.getYear();
            cmd.Parameters[3].Value = alert.getDayOfMonth();
            cmd.Parameters[4].Value = alert.getMonth();
            cmd.Parameters[5].Value = alert.getDayOfWeek();
            cmd.Parameters[6].Value = alert.getHour();
            cmd.Parameters[7].Value = alert.getMinute();
            cmd.Parameters[8].Value = alert.getSnoozed();
            cmd.Parameters[9].Value = alert.getValid();
            cmd.Parameters[10].Value = alert.getWakeUpTime();
            cmd.Parameters[11].Value = alert.getBackground();
            cmd.Parameters[12].Value = alert.getSound();
            cmd.Parameters[13].Value = alert.getCommand();
            cmd.Parameters[14].Value = alert.getAlertId();
            cmd.ExecuteNonQuery();
            cmd.Dispose();
        }