Exemple #1
0
        public MainWindow()
        {
            InitializeComponent();
            manager = new ItemManager();
            listViewItems.ListViewItemSorter = new LVIComparator();

            filter = null;
            filename = null;
            ChangesSaved(true);
        }
Exemple #2
0
 private void ClearAll()
 {
     balance = 0;
     manager = new ItemManager();
     filter = null;
     filename = null;
     ChangesSaved(false);
     txtDescription.Text = "";
     FilterLVI();
     chart1.Visible = false;
     toolStrip1.Items[5].Enabled = false; // edit
     toolStrip1.Items[6].Enabled = false; // remove
 }
        private ItemFilter CreateFilter()
        {
            ItemFilter f = new ItemFilter();
            if (rbtnBoth.Checked) f.Type = TypeEnum.Both;
            if (rbtnIncome.Checked) f.Type = TypeEnum.Income;
            if (rbtnOutgo.Checked) f.Type = TypeEnum.Outgo;
            if (!((Category)categComboBox.SelectedItem).Equals(tmp))
            {
                f.Category = (Category)categComboBox.SelectedItem;
            }
            else
            {
                f.Category = null;
            }
            f.TimeFrom = pickerFrom.Value.Date;
            f.TimeTo = pickerTo.Value.Date;

            if (numUpDownMinValue.Value > 0 || numUpDownMaxValue.Value > 0)
            {
                f.MaxValue = numUpDownMaxValue.Value;
                f.MinValue = numUpDownMinValue.Value;
            }
            else
            {
                f.MinValue = -1;
                f.MaxValue = -1;
            }
            f.Description = null;
            return f;
        }
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (btnOk.DialogResult == DialogResult.OK)
     {
         Filter = CreateFilter();
     }
     else
     {
         Filter = null;
     }
 }
Exemple #5
0
 private void ViewAllProcess()
 {
     filter = null;
     tstripTextBoxFilter.Text = "";
     ClearAndFillLVI();
     GraphFilteredItems();
     viewAllToolStripMenuItem.Enabled = false;
     tsbtnViewAll.Enabled = false;
     sStripFiltLab.Text = "Filter: inactive";
     sStripFiltLab.BackColor = SystemColors.Menu;
 }
Exemple #6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (tstripTextBoxFilter.Text.Length > 0)
            {
                ItemFilter f = new ItemFilter();
                f.Type = TypeEnum.Both;
                f.Category = null;
                f.TimeFrom = DateTime.Now;
                f.TimeTo = f.TimeFrom;
                f.MinValue = -1;
                f.MaxValue = -1;
                f.Description = tstripTextBoxFilter.Text;
                filter = f;
                FilterLVI();
            }
            else
            {
                ViewAllProcess();
            }

            timer1.Stop();
        }
Exemple #7
0
        private void OpenFileProcess()
        {
            DialogResult res = DialogResult.No;

            if (!changesSaved) res = MessageBox.Show("All changes will bee lost, continue?", "Open file", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (res == DialogResult.Yes || changesSaved)
            {
                openFileDialog.InitialDirectory = Directory.GetCurrentDirectory();
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    ItemManager manBackup = manager;
                    ItemFilter filtBackup = filter;
                    bool savedBackup = changesSaved;
                    String fileBackup = filename;
                    ClearAll();
                    if (manager.LoadItems(openFileDialog.FileName))
                    {
                        filename = openFileDialog.FileName;
                        ChangesSaved(true);
                    }
                    else
                    {
                        MessageBox.Show("Wrong input file", "Wrong file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        manager = manBackup;
                        filter = filtBackup;
                        if (filter != null) sStripFiltLab.Text = "Filter: active";
                        filename = fileBackup;
                        ChangesSaved(savedBackup);
                    }

                    ClearAndFillLVI();
                    FilterLVI();
                }
            }
        }
Exemple #8
0
        private void FilterProcess()
        {
            FilterWindow filterWindow = new FilterWindow();
            filterWindow.Filter = filter;
            filterWindow.InitWindowByFilter();

            if (filterWindow.ShowDialog() == DialogResult.OK)
            {
                filter = filterWindow.Filter;
                FilterLVI();
            }
        }