-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainViewModel.cs
53 lines (47 loc) · 1.65 KB
/
MainViewModel.cs
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
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Xpf.Printing;
using DevExpress.XtraReports.UI;
using Reports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace Viewer {
[POCOViewModel]
public class MainViewModel {
readonly XtraReport orderReport = new OrderReport();
public virtual XtraReport Report { get; protected set; }
public virtual bool RequestDocumentCreation { get; set; }
public virtual int OrderId { get; set; }
protected MainViewModel() {
RequestDocumentCreation = true;
Report = orderReport;
}
public void ShowOrders() {
Report.Dispose();
RequestDocumentCreation = false;
Report = orderReport;
RequestDocumentCreation = true;
}
public bool CanShowOrders() {
return Report != orderReport;
}
public void OnPreviewMouseClick(DocumentPreviewMouseEventArgs args) {
var orderId = args.ElementTag as int?;
if(!orderId.HasValue)
return;
OrderId = orderId.Value;
var invoiceReport = new InvoiceReport();
invoiceReport.Parameters["OrderId"].Value = OrderId;
Report = invoiceReport;
}
public void OnPreviewMouseMove(DocumentPreviewMouseEventArgs args) {
var orderId = args.ElementTag as int?;
if(!orderId.HasValue)
return;
OrderId = orderId.Value;
Mouse.SetCursor(Cursors.Hand);
}
}
}