private void ExpenseForm_Load(object sender, EventArgs e)
        {
            Size = this.MdiParent.Size;

            List <ExpenseDomain> expenses = null;

            ProgressTrackerForm progressTrackerForm = new ProgressTrackerForm();

            progressTrackerForm.ProcessInformation = "Mengambil data pengeluaran...";

            progressTrackerForm.Task = new ProgressTrackerForm.BackgroundTask(
                () =>
            {
                expenses = LogicFactory.ExpenseLogic.GetAllExpenses();

                _expenses = new List <ExpenseDomain>();
                foreach (ExpenseDomain expense in expenses)
                {
                    Month month = _months.Find(p => p.Index == expense.Month);
                    if (month != null)
                    {
                        expense.DisplayedMonth = month.Name;
                    }
                    expense.DisplayedAmount = expense.Amount.ToString("#,##0");

                    _expenses.Add(expense);
                }
            }
                );

            progressTrackerForm.ShowDialog();

            RefreshGrid();
        }
        private void filterButton_Click(object sender, EventArgs e)
        {
            Month fromMonth = filterFromMonthComboBox.SelectedItem as Month;
            Month toMonth   = filterToMonthComboBox.SelectedItem as Month;

            int  fromYear;
            bool includeFromYear = int.TryParse(filterFromYearTextBox.Text, out fromYear);

            int  toYear;
            bool includeToYear = int.TryParse(filterToYearTextBox.Text, out toYear);

            if (fromYear > toYear)
            {
                MessageBox.Show("Tahun sampai tidak boleh lebih lama dari tahun dari!");
                return;
            }
            else if (fromYear == toYear)
            {
                if (fromMonth.Index > toMonth.Index)
                {
                    MessageBox.Show("Bulan sampai tidak boleh lebih lama dari bulan dari!");
                    return;
                }
            }

            _filterActive       = true;
            _setSelectedExpense = true;

            ProgressTrackerForm progressTrackerForm = new ProgressTrackerForm();

            progressTrackerForm.ProcessInformation = "Memfilter data pengeluaran...";
            progressTrackerForm.Task = new ProgressTrackerForm.BackgroundTask(
                () =>
            {
                _displayedExpenses = _expenses.FindAll(p =>
                {
                    bool match = true;

                    match &= fromMonth.Index <= p.Month;

                    if (includeFromYear)
                    {
                        match &= fromYear <= p.Year;
                    }

                    match &= toMonth.Index >= p.Month;

                    if (includeToYear)
                    {
                        match &= toYear >= p.Year;
                    }

                    return(match);
                });
            });

            progressTrackerForm.ShowDialog();

            RefreshGrid();
        }
Beispiel #3
0
        private void generateReportButton_Click(object sender, EventArgs e)
        {
            Month fromMonth = filterFromMonthComboBox.SelectedItem as Month;
            Month toMonth   = filterToMonthComboBox.SelectedItem as Month;

            int  year;
            bool includeFromYear = int.TryParse(yearTextBox.Text, out year);

            if (fromMonth.Index > toMonth.Index)
            {
                MessageBox.Show("Bulan sampai tidak boleh lebih lama dari bulan dari!");
                return;
            }

            string message           = null;
            ProgressTrackerForm form = new ProgressTrackerForm();

            form.ProcessInformation = "Mencetak laporan...";
            form.Task = new ProgressTrackerForm.BackgroundTask(
                () =>
            {
                LogicFactory.AccountingLogic.GenerateAccountingReport(fromMonth, toMonth, year, out message);
            });
            form.ShowDialog();

            if (!String.IsNullOrEmpty(message))
            {
                MessageBox.Show("Gagal mencetak laporan!");
                Clipboard.SetText(message);
            }
        }
        private void IncomeClusterForm_Load(object sender, EventArgs e)
        {
            Size = this.MdiParent.Size;

            ProgressTrackerForm progressTrackerForm = new ProgressTrackerForm();

            progressTrackerForm.ProcessInformation = "Mengambil data pendapatan cluster...";

            progressTrackerForm.Task = new ProgressTrackerForm.BackgroundTask(
                () =>
            {
                _incomeClusters = new List <IncomeClusterDomain>();
                List <IncomeClusterDomain> incomeClusters = LogicFactory.IncomeLogic.GetAllIncomeClusters();

                foreach (IncomeClusterDomain incomeCluster in incomeClusters)
                {
                    ClusterDomain cluster = _clusters.Find(p => p.Id == incomeCluster.ClusterId);
                    if (cluster != null)
                    {
                        incomeCluster.ClusterName = cluster.ClusterName;
                    }
                    incomeCluster.DisplayedAmount = incomeCluster.Amount.ToString("#,##0");

                    Month month = _months.Find(p => p.Index == incomeCluster.Month);
                    incomeCluster.DisplayedMonth = month.Name;

                    _incomeClusters.Add(incomeCluster);
                }
            }
                );

            progressTrackerForm.ShowDialog();
            RefreshGrid();
        }
Beispiel #5
0
        public MainForm()
        {
            InitializeComponent();
            Assembly assembly         = Assembly.GetExecutingAssembly();
            FileInfo fileInfo         = new FileInfo(assembly.Location);
            string   databaseFilePath = Path.Combine(fileInfo.DirectoryName, "IPL.sqlite");

            string appDataPertagasPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Pertagas");

            if (!Directory.Exists(appDataPertagasPath))
            {
                Directory.CreateDirectory(appDataPertagasPath);
            }

            if (!File.Exists(Path.Combine(appDataPertagasPath, "IPL.sqlite")))
            {
                File.Copy(databaseFilePath, Path.Combine(appDataPertagasPath, "IPL.sqlite"));
            }

            databaseFilePath = Path.Combine(appDataPertagasPath, "IPL.sqlite");

            ProgressTrackerForm trackerForm = new ProgressTrackerForm();

            trackerForm.ProcessInformation = "Mengkonfigurasi database...";
            trackerForm.Task = new ProgressTrackerForm.BackgroundTask(
                () =>
            {
                LogicFactory.Initialize(databaseFilePath);
            });
            trackerForm.ShowDialog();
            this.FormClosed += MainForm_FormClosed;
        }
Beispiel #6
0
        private void IncomeForm_Load(object sender, EventArgs e)
        {
            Size = this.MdiParent.Size;


            List <IncomeDomain> incomes = null;

            ProgressTrackerForm progressTrackerForm = new ProgressTrackerForm();

            progressTrackerForm.ProcessInformation = "Mengambil data pendapatan...";
            progressTrackerForm.Task = new ProgressTrackerForm.BackgroundTask(
                () =>
            {
                incomes = LogicFactory.IncomeLogic.GetAllIncomes();

                _incomes = new List <IncomeDomain>();
                foreach (IncomeDomain income in incomes)
                {
                    Month month = _months.Find(p => p.Index == income.Month);
                    if (month != null)
                    {
                        income.DisplayedMonth = month.Name;
                    }

                    IncomeSourceDomain incomeSource = _incomeSources.Find(p => p.Id == income.IncomeSourceId);
                    if (incomeSource != null)
                    {
                        income.IncomeSourceDescription = incomeSource.Description;
                    }

                    income.DisplayedAmount = income.Amount.ToString("#,##0");

                    _incomes.Add(income);
                }
            });

            progressTrackerForm.ShowDialog();

            RefreshGrid();
        }
        private void filterButton_Click(object sender, EventArgs e)
        {
            Month fromMonth = filterFromMonthComboBox.SelectedItem as Month;
            Month toMonth   = filterToMonthComboBox.SelectedItem as Month;

            int  fromYear;
            bool includeFromYear = int.TryParse(filterFromYearTextBox.Text, out fromYear);

            int  toYear;
            bool includeToYear = int.TryParse(filterToYearTextBox.Text, out toYear);

            if (fromYear > toYear)
            {
                MessageBox.Show("Tahun sampai tidak boleh lebih lama dari tahun dari!");
                return;
            }
            else if (fromYear == toYear)
            {
                if (fromMonth.Index > toMonth.Index)
                {
                    MessageBox.Show("Bulan sampai tidak boleh lebih lama dari bulan dari!");
                    return;
                }
            }

            _filterActive = true;

            ClusterDomain      cluster      = filterClusterComboBox.SelectedItem as ClusterDomain;
            AddressBlockDomain addressBlock = filterAddressBlockComboBox.SelectedItem as AddressBlockDomain;

            ProgressTrackerForm progressTrackerForm = new ProgressTrackerForm();

            progressTrackerForm.ProcessInformation = "Memfilter data pendapatan cluster...";

            progressTrackerForm.Task = new ProgressTrackerForm.BackgroundTask(
                () =>
            {
                _displayedIncomeClusters = _incomeClusters.FindAll(p =>
                {
                    bool match = true;

                    if (cluster != null)
                    {
                        match &= p.ClusterId == cluster.Id;
                    }

                    match &= fromMonth.Index <= p.Month;

                    if (includeFromYear)
                    {
                        match &= fromYear <= p.Year;
                    }

                    match &= toMonth.Index >= p.Month;

                    if (includeToYear)
                    {
                        match &= toYear >= p.Year;
                    }

                    if (addressBlock != null)
                    {
                        match &= (!String.IsNullOrEmpty(p.AddressBlock) && p.AddressBlock.ToLower().Trim() == addressBlock.Block.ToLower().Trim());
                    }

                    if (!String.IsNullOrEmpty(filterAddressNumberTextBox.Text))
                    {
                        match &= (!String.IsNullOrEmpty(p.AddressNumber) && p.AddressNumber.ToLower().Trim() == filterAddressNumberTextBox.Text.ToLower().Trim());
                    }

                    return(match);
                });
            });

            progressTrackerForm.ShowDialog();

            _setSelectedIncomeCluster = true;
            RefreshGrid();
        }