Example #1
0
        void openBalanceUpdateForm(BalanceType btype, int entry_index = 0)
        {
            UpdateBalanceForm balance_form = new UpdateBalanceForm();

            //пополнение
            balance_form.entry_sum_direction.SelectedIndex = (int)btype;
            balance_form.btnApply.Click += (fSender, eSender) =>
            {
                decimal   bdata_amount  = balance_form.entry_amount.Value;
                FundEntry entry         = logic.getEntry(entry_index);
                decimal   entry_balance = logic.calcEntryBalance(entry);
                bool      can_continue  = true;

                //если вычет средств, то проверяем баланс
                if (btype == BalanceType.Outcome && bdata_amount > entry_balance)
                {
                    //запрашивается вычет баланса больше, чем есть
                    can_continue = false;
                    alert("Вы пытаетесь вычесть баланса больше, чем доступно в задаче");
                }

                if (can_continue)
                {
                    BalanceData bdata = new BalanceData();
                    bdata.amount  = bdata_amount;
                    bdata.comment = balance_form.textBox_comment.Text;
                    bdata.type    = btype;
                    logic.addBalanceData(bdata, btype, entry_index);
                    balance_form.Close();
                    rebuildTable();
                }
            };
            balance_form.ShowDialog();
        }
Example #2
0
        void BtnEntryHistoryClick(object sender, EventArgs e)
        {
            int entry_index = getSelectedCellIndex();

            if (entry_index >= 0)
            {
                FundEntry          entry        = logic.getEntry(entry_index);
                BalanceHistoryForm history_form = new BalanceHistoryForm(entry);
                history_form.ShowDialog();
            }
        }
Example #3
0
        void BtnCreateClick(object sender, EventArgs e)
        {
            //создаем диалоговое окно заполнения данных новой записи
            EntryForm entryForm = new FundTracking.View.EntryForm();

            //событие сохранения записи
            entryForm.btnSaveEntry.Click += (fSender, eSender) =>
            {
                if (entryForm.textBox_title.Text == "")
                {
                    alert("Необходимо заполнить заголовок записи");
                }
                else
                {
                    FundEntry entry = new FundEntry();
                    entry.title         = entryForm.textBox_title.Text;                     //название задачи
                    entry.income        = new List <BalanceData>();                         //по нулям по умолчанию
                    entry.outcome       = new List <BalanceData>();                         //по нулям по умолчанию
                    entry.need_amount   = entryForm.entry_amount.Value;                     //сколько необходимо средств
                    entry.comment       = entryForm.textBox_comment.Text;
                    entry.use_deadline  = entryForm.checkBox_deadline.Checked;
                    entry.deadline_date = entryForm.dateTimePicker.Value;

                    int entry_typeIndex = entryForm.entry_type.SelectedIndex;
                    if (entry_typeIndex == -1)
                    {
                        //тип задания не был выбран
                        entry_typeIndex = 0;                         //используем значение по умолчанию
                    }
                    //смотрим, есть ли такой EntryType
                    if (Enum.IsDefined(typeof(EntryType), entry_typeIndex))
                    {
                        entry.type = (EntryType)entry_typeIndex;
                    }
                    else
                    {
                        entry.type = (EntryType)0;
                    }
                    //string entry_type_str = entry.type.GetDescription();
                    //Debug.Print(entry_type_str);
                    //сохранение записи
                    logic.addEntry(entry);
                    //закрытие формы
                    entryForm.Close();
                    rebuildTable();
                }
            };
            entryForm.ShowDialog();
        }
Example #4
0
        void DGV_allEntrysCellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            //клик по ячейке таблицы
            int entry_index = getSelectedCellIndex();

            if (entry_index >= 0)
            {
                FundEntry entry         = logic.getEntry(entry_index);
                string    entry_comment = entry.comment;
                if (entry_comment == "")
                {
                    entry_comment = "Нет комментария";
                }
                alert("Комментарий: " + entry_comment + "\n\nОсновная сумма: " + entry.need_amount.ToString() + " д.ед");
            }
        }
Example #5
0
        public decimal calcEntryBalance(FundEntry entry)
        {
            decimal balance_income  = 0;
            decimal balance_outcome = 0;

            //TOQ: есть решения более быстрые?
            for (int i = 0; i < entry.income.Count; i++)
            {
                balance_income += entry.income[i].amount;
            }
            for (int i = 0; i < entry.outcome.Count; i++)
            {
                balance_outcome += entry.outcome[i].amount;
            }
            return(balance_income - balance_outcome);
        }
Example #6
0
        public List <BalanceData> buildFinanceList(Dictionary <EntryType, bool> exclude_types = null)
        {
            //кажется, нужен refactoring
            List <BalanceData> result_list = new List <BalanceData>();
            //string line = "";
            decimal entry_balance = 0;

            string[]  enum_descriptions = EntryType.Payment.Descriptions();
            decimal[] enum_balances     = new decimal[enum_descriptions.Length];
            //проход по записям
            for (int i = 0; i < dataContainer.entrys_list.Count; i++)
            {
                FundEntry entry = dataContainer.entrys_list[i];
                entry_balance = this.calcEntryBalance(entry);
                int entry_typeINT = (int)entry.type;
                enum_balances[entry_typeINT] += entry_balance;
            }
            //проход по типам записей
            for (int j = 0; j < enum_descriptions.Length; j++)
            {
                bool can_continue = true;
                if (exclude_types != null)
                {
                    //exclude_types
                    EntryType entry_type = (EntryType)j;
                    if (exclude_types[entry_type] == true)
                    {
                        //найден тип, который надо исключить
                        //Debug.Print("Исключаем тип: " + entry_type.GetDescription());
                        can_continue = false;
                    }
                }
                if (can_continue)
                {
                    BalanceData bdata = new BalanceData();
                    bdata.amount  = enum_balances[j];
                    bdata.comment = enum_descriptions[j] + ": " + enum_balances[j].ToString() + " д.ед";
                    result_list.Add(bdata);
                }
            }

            return(result_list);
        }
Example #7
0
        private void SaveClicked(object sender, System.EventArgs e)
        {
            Unfocus();

            if (Uri.IsWellFormedUriString(BridgeEntry.Text, UriKind.Absolute) &&
                Uri.IsWellFormedUriString(RouteEntry.Text, UriKind.Absolute) &&
                Uri.IsWellFormedUriString(FundEntry.Text, UriKind.Absolute))
            {
                Config.BridgeServerUrl   = BridgeEntry.Text;
                Config.RouteServerUrl    = RouteEntry.Text;
                Config.IdentityServerUrl = FundEntry.Text;

                Application.Current.Properties[Config.BridgeService]   = Config.BridgeServerUrl;
                Application.Current.Properties[Config.IdentityService] = Config.IdentityServerUrl;
                Application.Current.Properties[Config.RouteService]    = Config.RouteServerUrl;
                Application.Current.SavePropertiesAsync();

                ShowErrorMessage(AppResources.SettingsChanged);
            }
            else
            {
                EventHandler handleHandler = (sv, ev) => {
                    if (!Uri.IsWellFormedUriString(BridgeEntry.Text, UriKind.Absolute))
                    {
                        BridgeEntry.Focus();
                    }
                    else if (!Uri.IsWellFormedUriString(RouteEntry.Text, UriKind.Absolute))
                    {
                        RouteEntry.Focus();
                    }
                    else if (!Uri.IsWellFormedUriString(FundEntry.Text, UriKind.Absolute))
                    {
                        FundEntry.Focus();
                    }
                };

                ShowErrorMessage(AppResources.InvalidUrl, false, handleHandler);
            }
        }
Example #8
0
 public BalanceHistoryForm(FundEntry new_entry)
 {
     InitializeComponent();
     this.entry = new_entry;
 }
Example #9
0
 /// <summary>
 /// удаление записи
 /// </summary>
 /// <param name="entry">запись</param>
 public void deleteEntry(FundEntry entry)
 {
     dataContainer.entrys_list.Remove(entry);
     fs.save(dataContainer);
 }
Example #10
0
 public void addEntry(FundEntry entry)
 {
     dataContainer.entrys_list.Add(entry);
     fs.save(dataContainer);
 }