main
 1using System;
 2using System.Collections.Generic;
 3using gorilla.commons.utility;
 4using MoMoney.DTO;
 5using momoney.presentation.presenters;
 6using momoney.presentation.views;
 7using MoMoney.Presentation.Winforms.Helpers;
 8using MoMoney.Presentation.Winforms.Krypton;
 9using MoMoney.Presentation.Winforms.Resources;
10
11namespace MoMoney.Presentation.Winforms.Views
12{
13    public partial class AddBillPaymentView : ApplicationDockedWindow, IAddBillPaymentView
14    {
15        ControlAction<EventArgs> submit_clicked = x => { };
16        readonly IBindableList<CompanyDTO> companies_list;
17
18        public AddBillPaymentView()
19        {
20            InitializeComponent();
21            titled("Add Bill Payment").icon(ApplicationIcons.AddBillPayment);
22            ux_submit_button.Click += (sender, e) => submit_clicked(e);
23            companies_list = ux_company_names.create_for<CompanyDTO>();
24        }
25
26        public void attach_to(IAddBillPaymentPresenter presenter)
27        {
28            submit_clicked = x => presenter.submit_bill_payment(create_dto());
29        }
30
31        public void run(IEnumerable<CompanyDTO> companys)
32        {
33            companies_list.bind_to(companys);
34        }
35
36        public void run(IEnumerable<BillInformationDTO> bills)
37        {
38            ux_bill_payments_grid.DataSource = bills.databind();
39        }
40
41        AddNewBillDTO create_dto()
42        {
43            return new AddNewBillDTO
44                       {
45                           company_id = companies_list.get_selected_item().id,
46                           due_date = ux_due_date.Value,
47                           total = ux_amount.Text.to_double()
48                       };
49        }
50    }
51}