-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditForm.cs
45 lines (43 loc) · 1.36 KB
/
EditForm.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
namespace WinForms.Client
{
public partial class EditForm : DevExpress.XtraEditors.XtraForm
{
public EditForm()
{
InitializeComponent();
}
public static (bool changesSaved, OrderItem item) EditItem(OrderItem orderItem)
{
using var form = new EditForm();
var clonedItem = new OrderItem
{
Id = orderItem.Id,
ProductName = orderItem.ProductName,
UnitPrice = orderItem.UnitPrice,
Quantity = orderItem.Quantity,
Discount = orderItem.Discount,
OrderDate = orderItem.OrderDate
};
form.orderItemBindingSource.DataSource = clonedItem;
if (form.ShowDialog() == DialogResult.OK)
{
return (true, clonedItem);
}
return (false, orderItem);
}
public static (bool changesSaved, OrderItem? item) CreateItem()
{
using var form = new EditForm();
var newItem = new OrderItem()
{
OrderDate = DateTime.Now
};
form.orderItemBindingSource.DataSource = newItem;
if (form.ShowDialog() == DialogResult.OK)
{
return (true, newItem);
}
return (false, null);
}
}
}