Ejemplo n.º 1
0
        private void btnModifyReminder_Click(object sender, EventArgs e)
        {
            var frm = new FrmReminderOperation(CompteActuel, false, true,
                                               CompteActuel.ReminderOperations.First(x => x.ID == lvReminderOps.SelectedItems[0].Text));

            if (frm.ShowDialog() == DialogResult.OK)
            {
                var op = new ReminderOperation(lvReminderOps.SelectedItems[0].Text)
                {
                    Type               = frm.cbxType.SelectedItem.ToString(),
                    Credit             = frm.mupCredit.Value,
                    Debit              = frm.mupDebit.Value,
                    Budget             = frm.cbxBudget.SelectedText,
                    DueDate            = frm.mcDate.SelectionStart,
                    Commentary         = frm.txtComm.Text,
                    NbOfRepetition     = (int)frm.nudNbOfRepetitions.Value,
                    RepetitionType     = (ReminderOperation.ERepititionType)frm.cbxRepetitionType.SelectedIndex,
                    AutomaticallyAdded = frm.cbAddOperations.Checked
                };

                var a =
                    CompteActuel.ReminderOperations.IndexOf(
                        CompteActuel.ReminderOperations.First(x => x.ID == lvReminderOps.SelectedItems[0].Text));
                CompteActuel.ReminderOperations.RemoveAll(x => x.ID == lvReminderOps.SelectedItems[0].Text);
                CompteActuel.ReminderOperations.Insert(a, op);

                //Delete old normal operations
                ReminderOperation.deleteNormalOperations(CompteActuel, op.ID);

                LoadReminderOps();

                if (frm.cbAddOperations.Checked)
                {
                    //Add normal operations generated from the reminder operation
                    op.addNormalOperations(CompteActuel);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnAddReminder_Click(object sender, EventArgs e)
        {
            var frm = new FrmReminderOperation(CompteActuel);

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var op = new ReminderOperation
            {
                Type               = frm.cbxType.SelectedItem.ToString(),
                Credit             = frm.mupCredit.Value,
                Debit              = frm.mupDebit.Value,
                Budget             = frm.cbxBudget.SelectedText,
                DueDate            = frm.mcDate.SelectionStart,
                Commentary         = frm.txtComm.Text,
                NbOfRepetition     = frm.nudNbOfRepetitions.Value,
                RepetitionType     = (ReminderOperation.ERepititionType)frm.cbxRepetitionType.SelectedIndex,
                AutomaticallyAdded = frm.cbAddOperations.Checked
            };

            //Add new reminder operation
            CompteActuel.ReminderOperations.Add(op);

            LoadReminderOps();

            if (frm.cbAddOperations.Checked)
            {
                //Add normal operations generated from the reminder operation
                op.addNormalOperations(CompteActuel);
            }
            else
            {
                ReminderOperation.deleteNormalOperations(CompteActuel, op.ID);
            }
        }