-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddSubscriptionWindow.xaml.cs
More file actions
57 lines (48 loc) · 1.69 KB
/
AddSubscriptionWindow.xaml.cs
File metadata and controls
57 lines (48 loc) · 1.69 KB
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
using System.Windows;
namespace SampleWpf;
/// <summary>
/// Interaction logic for AddSubscriptionWindow.xaml
/// </summary>
public partial class AddSubscriptionWindow : Window
{
readonly Siprix.SubscriptionModel subscr_;
readonly Siprix.ObjModel objModel_;
public AddSubscriptionWindow(Siprix.ObjModel objModel)
{
InitializeComponent();
Owner = App.Current.MainWindow;
subscr_ = Siprix.SubscriptionModel.BLF();
objModel_ = objModel;
//Set data to controls
cbAccounts.DataContext = objModel_.Accounts;
//Set controls state
bool hasAccounts = (objModel_.Accounts.Collection.Count > 0);
btnOK.IsEnabled = hasAccounts;
cbAccounts.IsEnabled = hasAccounts;
tbErrText.Visibility = hasAccounts ? Visibility.Collapsed : Visibility.Visible;
txDestExt.Focus();
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
}
private void btnOK_Click(object sender, RoutedEventArgs e)
{
//Check empty
if ((txDestExt.Text.Length == 0) ||
(tbLabel.Text.Length == 0) ||
(cbAccounts.SelectedItem == null)) return;
//Get data from controls
subscr_.ToExt = txDestExt.Text;
subscr_.AccId = ((Siprix.AccountModel)cbAccounts.SelectedItem).ID;
subscr_.Label = tbLabel.Text;
//Try to make call
int err = objModel_.Subscriptions.Add(subscr_);
if (err != Siprix.ErrorCode.kNoErr)
{
tbErrText.Text = objModel_.ErrorText(err);
return;
}
this.DialogResult = true;
}
}