Пример #1
0
        private void addToolStripButton_Click(object sender, EventArgs e)
        {
            _uiMode = UserInterfaceModes.Adding;
            SetUIControlsAvailability();

            addressBlockTextBox.Text = String.Empty;
        }
Пример #2
0
        private void cancelToolStripButton_Click(object sender, EventArgs e)
        {
            _uiMode = UserInterfaceModes.Viewing;
            SetUIControlsAvailability();

            expenseDataGridView_SelectionChanged(expenseDataGridView, e);
        }
Пример #3
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(clusterNameTextBox.Text))
            {
                MessageBox.Show("Nama cluster tidak boleh dikosongkan!", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (_uiMode == UserInterfaceModes.Adding)
            {
                ClusterDomain cluster = LogicFactory.ClusterLogic.AddCluster(clusterNameTextBox.Text);
                _clusters.Add(cluster);
            }
            else if (_uiMode == UserInterfaceModes.Editing)
            {
                _selectedCluster.ClusterName = clusterNameTextBox.Text;
                LogicFactory.ClusterLogic.UpdateCluster(_selectedCluster);

                ClusterDomain cluster = _clusters.Find(p => p.Id == _selectedCluster.Id);
                _clusters.Remove(cluster);
                _clusters.Add(_selectedCluster);
            }

            RefreshGrid();
            _uiMode = UserInterfaceModes.Viewing;
            SetUIControlsAvailability();
        }
Пример #4
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(incomeSourceDescriptionTextBox.Text))
            {
                MessageBox.Show("Nama cluster tidak boleh dikosongkan!", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (_uiMode == UserInterfaceModes.Adding)
            {
                IncomeSourceDomain incomeSource = LogicFactory.IncomeSourceLogic.AddIncomeSource(incomeSourceDescriptionTextBox.Text);
                _incomeSources.Add(incomeSource);
            }
            else if (_uiMode == UserInterfaceModes.Editing)
            {
                _selectedIncomeSource.Description = incomeSourceDescriptionTextBox.Text;
                LogicFactory.IncomeSourceLogic.UpdateIncomeSource(_selectedIncomeSource);

                IncomeSourceDomain incomeSource = _incomeSources.Find(p => p.Id == _selectedIncomeSource.Id);
                _incomeSources.Remove(incomeSource);
                _incomeSources.Add(_selectedIncomeSource);
            }

            RefreshGrid();
            _uiMode = UserInterfaceModes.Viewing;
            SetUIControlsAvailability();
        }
Пример #5
0
        private void addToolStripButton_Click(object sender, EventArgs e)
        {
            _uiMode = UserInterfaceModes.Adding;
            SetUIControlsAvailability();

            incomeSourceDescriptionTextBox.Text = String.Empty;
        }
Пример #6
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(yearTextBox.Text) || !_numericRegex.IsMatch(yearTextBox.Text))
            {
                MessageBox.Show("Tahun tidak boleh kosong dah harus diisi dengan angka!", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!String.IsNullOrEmpty(amountTextBox.Text) && !_numericRegex.IsMatch(amountTextBox.Text))
            {
                MessageBox.Show("Nominal harus diisi dengan angka!", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Month  month  = monthComboBox.SelectedValue as Month;
            int    year   = Convert.ToInt32(yearTextBox.Text);
            double amount = 0;

            if (!String.IsNullOrEmpty(amountTextBox.Text))
            {
                amount = Convert.ToDouble(amountTextBox.Text);
            }

            if (_uiMode == UserInterfaceModes.Adding)
            {
                ExpenseDomain expense = LogicFactory.ExpenseLogic.AddExpense(descriptionTextBox.Text, month.Index, year, amount);
                expense.DisplayedMonth  = month.Name;
                expense.DisplayedAmount = amount.ToString("#,##0");

                _expenses.Add(expense);
                _selectedExpense = expense;
            }
            else if (_uiMode == UserInterfaceModes.Editing)
            {
                _selectedExpense.Description = descriptionTextBox.Text;
                _selectedExpense.Month       = month.Index;
                _selectedExpense.Year        = year;
                _selectedExpense.Amount      = amount;

                ExpenseDomain expense = LogicFactory.ExpenseLogic.UpdateExpense(_selectedExpense);
                expense.DisplayedMonth  = month.Name;
                expense.DisplayedAmount = amount.ToString("#,##0");

                int index = _expenses.IndexOf(_selectedExpense);
                _expenses.Remove(_selectedExpense);
                _expenses.Insert(index, expense);

                _selectedExpense = expense;
            }

            _uiMode = UserInterfaceModes.Viewing;
            SetUIControlsAvailability();

            _filterActive       = false;
            _setSelectedExpense = false;
            RefreshGrid();
        }
Пример #7
0
        private void editToolStripButton_Click(object sender, EventArgs e)
        {
            if (_selectedExpense == null)
            {
                return;
            }

            _uiMode = UserInterfaceModes.Editing;
            SetUIControlsAvailability();
        }
Пример #8
0
        private void addToolStripButton_Click(object sender, EventArgs e)
        {
            _uiMode = UserInterfaceModes.Adding;
            SetUIControlsAvailability();

            firstNameTextBox.Text = String.Empty;
            lastNameTextBox.Text  = String.Empty;
            userNameTextBox.Text  = String.Empty;
            passwordTextBox.Text  = String.Empty;
        }
Пример #9
0
        private void addToolStripButton_Click(object sender, EventArgs e)
        {
            _uiMode = UserInterfaceModes.Adding;
            SetUIControlsAvailability();

            Month month = _months.Find(p => p.Index == DateTime.Today.Month);

            monthComboBox.SelectedItem = month;

            descriptionTextBox.Text = String.Empty;
            yearTextBox.Text        = DateTime.Today.Year.ToString();
            amountTextBox.Text      = String.Empty;
        }
Пример #10
0
        private void addToolStripButton_Click(object sender, EventArgs e)
        {
            _uiMode = UserInterfaceModes.Adding;
            SetUIControlsAvailability();

            if (_clusters != null && _clusters.Count > 0)
            {
                clusterComboBox.SelectedIndex = 0;
            }
            occupantTextBox.Text = String.Empty;
            addressBlockComboBox.SelectedIndex = 0;
            addressNumberTextBox.Text          = String.Empty;
            phoneNumberTextBox.Text            = String.Empty;

            Month month = _months.Find(p => p.Index == DateTime.Now.Month);

            monthComboBox.SelectedItem = month;

            yearTextBox.Text   = DateTime.Now.Year.ToString();
            amountTextBox.Text = String.Empty;
        }
Пример #11
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(userNameTextBox.Text))
            {
                MessageBox.Show("Nama Login tidak boleh dikosongkan!");
                return;
            }

            if (_uiMode == UserInterfaceModes.Adding)
            {
                string     message;
                UserDomain newUser = LogicFactory.UserLogic.AddUser(firstNameTextBox.Text, lastNameTextBox.Text, userNameTextBox.Text, passwordTextBox.Text, out message);
                if (newUser == null)
                {
                    MessageBox.Show(message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                _users.Add(newUser);
            }
            else if (_uiMode == UserInterfaceModes.Editing)
            {
                _selectedUser.FirstName = firstNameTextBox.Text;
                _selectedUser.Lastname  = lastNameTextBox.Text;
                if (_passwordChanged)
                {
                    _selectedUser.Password = passwordTextBox.Text;
                }
                _selectedUser = LogicFactory.UserLogic.UpdateUser(_selectedUser, _passwordChanged);

                UserDomain user = _users.Find(p => p.Id == _selectedUser.Id);
                _users.Remove(user);
                _users.Add(_selectedUser);
            }

            _uiMode = UserInterfaceModes.Viewing;
            SetUIControlsAvailability();

            RefreshGrid();
        }
Пример #12
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(addressBlockTextBox.Text))
            {
                MessageBox.Show("Blok tidak boleh dikosongkan!", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (_uiMode == UserInterfaceModes.Adding)
            {
                AddressBlockDomain addressBlock = LogicFactory.AddressBlockLogic.AddBlock(addressBlockTextBox.Text);
                _addressBlocks.Add(addressBlock);
            }
            else if (_uiMode == UserInterfaceModes.Editing)
            {
                _selectedBlock.Block = addressBlockTextBox.Text;
                LogicFactory.AddressBlockLogic.UpdateBlock(_selectedBlock);
            }

            RefreshGrid();
            _uiMode = UserInterfaceModes.Viewing;
            SetUIControlsAvailability();
        }
Пример #13
0
        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(yearTextBox.Text) || !_numericRegex.IsMatch(yearTextBox.Text))
            {
                MessageBox.Show("Tahun tidak boleh kosong dah harus diisi dengan angka!", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!String.IsNullOrEmpty(amountTextBox.Text) && !_numericRegex.IsMatch(amountTextBox.Text))
            {
                MessageBox.Show("Nominal harus diisi dengan angka!", null, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            ClusterDomain cluster = clusterComboBox.SelectedValue as ClusterDomain;
            Month         month   = monthComboBox.SelectedValue as Month;
            int           year    = Convert.ToInt32(yearTextBox.Text);
            double        amount  = 0;

            if (!String.IsNullOrEmpty(amountTextBox.Text))
            {
                amount = Convert.ToDouble(amountTextBox.Text);
            }

            AddressBlockDomain addressBlock = (addressBlockComboBox.SelectedItem as AddressBlockDomain);

            if (_uiMode == UserInterfaceModes.Adding)
            {
                IncomeClusterDomain incomeCluster = LogicFactory.IncomeLogic.AddIncomeCluster(cluster, occupantTextBox.Text,
                                                                                              (addressBlock != null ? addressBlock.Block : String.Empty),
                                                                                              addressNumberTextBox.Text, phoneNumberTextBox.Text, month.Index, year, amount);

                incomeCluster.ClusterName     = cluster.ClusterName;
                incomeCluster.DisplayedAmount = amount.ToString("#,##0");
                incomeCluster.DisplayedMonth  = month.Name;

                _incomeClusters.Add(incomeCluster);
                _selectedIncomeCluster = incomeCluster;
            }
            else if (_uiMode == UserInterfaceModes.Editing)
            {
                IncomeClusterDomain incomeCluster = new IncomeClusterDomain();
                incomeCluster.Id           = _selectedIncomeCluster.Id;
                incomeCluster.ClusterId    = cluster.Id;
                incomeCluster.ClusterName  = cluster.ClusterName;
                incomeCluster.OccupantName = occupantTextBox.Text;

                incomeCluster.AddressBlock = addressBlock != null ? addressBlock.Block : String.Empty;

                incomeCluster.AddressNumber   = addressNumberTextBox.Text;
                incomeCluster.PhoneNumber     = phoneNumberTextBox.Text;
                incomeCluster.Month           = month.Index;
                incomeCluster.Year            = year;
                incomeCluster.Amount          = amount;
                incomeCluster.DisplayedAmount = amount.ToString("#,##0");
                incomeCluster.DisplayedMonth  = month.Name;
                LogicFactory.IncomeLogic.UpdateIncomeCluster(incomeCluster);

                _incomeClusters.Remove(_selectedIncomeCluster);
                _incomeClusters.Add(incomeCluster);

                _selectedIncomeCluster = incomeCluster;
            }

            _setSelectedIncomeCluster = false;
            _filterActive             = false;
            _uiMode = UserInterfaceModes.Viewing;
            SetUIControlsAvailability();
            RefreshGrid();
        }