summaryrefslogtreecommitdiff
path: root/src/app/Cmpp298.Assignment3.Desktop.UI/EditInvoiceView.cs
blob: fac853c47a89d20a4e190afa57bd9a4f048715b2 (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
67
68
69
70
71
72
73
74
75
76
77
using System;
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 EditInvoiceView : Form, IEditInvoiceView {
		private DesktopDropDownList _termsDropDown;
		private EditInvoicePresenter _presenter;

		public EditInvoiceView( string invoiceId ) {
			InitializeComponent( );

			_termsDropDown = new DesktopDropDownList( uxTermsDropDownList );
			_presenter = new EditInvoicePresenter( invoiceId, this );

			uxUpdateButton.Click += delegate { UpdateAndCloseWindow( ); };
			uxCancelButton.Click += delegate { Close( ); };

			_presenter.Initialize( );
		}

		public IDropDownListAdapter TermsDropDown {
			get { return _termsDropDown; }
		}

		public string VendorName {
			get { return uxVendorNameTextBox.Text; }
			set { uxVendorNameTextBox.Text = value; }
		}

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

		public string InvoiceDate {
			get { return uxInvoiceDatePicker.Value.ToString( ); }
			set { uxInvoiceDatePicker.Value = Convert.ToDateTime( value ); }
		}

		public string InvoiceTotal {
			get { return uxInvoiceTotalTextBox.Text; }
			set { uxInvoiceTotalTextBox.Text = value; }
		}

		public string PaymentTotal {
			get { return uxPaymentTotalTextBox.Text; }
			set { uxPaymentTotalTextBox.Text = value; }
		}

		public string CreditTotal {
			get { return uxCreditTotalTextBox.Text; }
			set { uxCreditTotalTextBox.Text = value; }
		}

		public string DueDate {
			get { return uxDueDatePicker.Value.ToString( ); }
			set { uxDueDatePicker.Value = Convert.ToDateTime( value ); }
		}

		public string PaymentDate {
			get { return uxPaymentDatePicker.Value.ToString( ); }
			set { uxPaymentDatePicker.Value = Convert.ToDateTime( value ); }
		}

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

		private void UpdateAndCloseWindow( ) {
			_presenter.UpdateInvoice( );
			Close( );
		}
	}
}