summaryrefslogtreecommitdiff
path: root/src/app/Cmpp298.Assignment3.Desktop.UI/NewInvoiceView.cs
blob: ae2135f1cdf273a9dab790005ed93755b57c290d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Windows.Forms;
using Cmpp298.Assignment3.Desktop.Adapters;
using Cmpp298.Assignment3.Dto;
using Cmpp298.Assignment3.Presentation;

namespace Cmpp298.Assignment3.Desktop.UI {
	public partial class NewInvoiceView : Form, INewInvoiceView {
		private NewInvoicePresenter _presenter;
		private DesktopDropDownList _termsDropDown;

		public NewInvoiceView( string vendorId ) {
			InitializeComponent( );
			_termsDropDown = new DesktopDropDownList( uxTermsDropDownList );
			_presenter = new NewInvoicePresenter( vendorId, this );
			_presenter.Load( );
			uxCancelButton.Click += delegate { Close( ); };
			uxSaveButton.Click += delegate { SaveAndCloseScreen( ); };
		}

		public IDropDownListAdapter Terms {
			get { return _termsDropDown; }
		}

		public string InvoiceNumber {
			get { return uxInvoiceNumberTextBox.Text; }
			set { uxInvoiceNumberTextBox.Text = value; }
		}

		public string InvoiceDate {
			get { return uxInvoiceDatePicker.Value.ToString( ); }
		}

		public string InvoiceTotal {
			get { return uxInvoiceTotalTextBox.Text; }
		}

		public string PaymentTotal {
			get { return uxPaymentTotalTextBox.Text; }
		}

		public string CreditTotal {
			get { return uxCreditTotalTextBox.Text; }
		}

		public string DueDate {
			get { return uxDueDatePicker.Value.ToString( ); }
		}

		public string PaymentDate {
			get { return uxPaymentDatePicker.Value.ToString( ); }
		}

		public void ShowError( string message ) {
			MessageBox.Show( message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error );
		}

		public void BindTo( DisplayVendorNameDto displayVendorNameDto ) {
			uxVendorNameTextBox.Text = displayVendorNameDto.VendorName;
		}

		private void SaveAndCloseScreen( ) {
			_presenter.SaveInvoice( );
			Close( );
		}
	}
}