-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbonentInfo.xaml.cs
81 lines (74 loc) · 2.35 KB
/
AbonentInfo.xaml.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace CardFilePBX
{
public partial class AbonentInfo : Window
{
private Abonent CurrentAbonent { get; set; }
public Stack<Abonent> Prev { get; set; } = new Stack<Abonent>();
public Stack<Abonent> Next { get; set; } = new Stack<Abonent>();
public AbonentInfo()
{
this.DataContext = this;
InitializeComponent();
}
public void AddInfoCard(Abonent abonent)
{
Prev.Push(CurrentAbonent);
CurrentAbonent = abonent;
UpdateAbonent();
}
public void SetAbonent(Abonent abonent)
{
CurrentAbonent = abonent;
UpdateAbonent();
}
public void SetAbonent(List<Abonent> abonent)
{
for (int i = abonent.Count - 1; i > 0; i--)
{
Next.Push(abonent[i]);
}
CurrentAbonent = abonent.First();
UpdateAbonent();
}
private void UpdateAbonent()
{
Title = $"{CurrentAbonent.Name} {CurrentAbonent.LastName}";
ReportHeader.Text += " " + CurrentAbonent.CurrentPeriod.ToString("MM/yyyy");
FullnameCell.Text = CurrentAbonent.Patronymic.Length > 1 ? $"{CurrentAbonent.Name} {CurrentAbonent.LastName} {CurrentAbonent.Patronymic}" : $"{CurrentAbonent.Name} {CurrentAbonent.LastName}";
PhoneNumberCell.Text = CurrentAbonent.PhoneNumber;
IncomingCallTime.Text = (CurrentAbonent.Incoming).ToString();
OutgoingCallTime.Text = (CurrentAbonent.Outgoing).ToString();
AllCallTime.Text = (CurrentAbonent.Incoming + CurrentAbonent.Outgoing).ToString();
IncomingCost.Text = (CurrentAbonent.Incoming * CurrentAbonent.Tariff.Incoming).ToString();
OutgoingCost.Text = (CurrentAbonent.Outgoing * CurrentAbonent.Tariff.Outgoing).ToString();
AllCallCost.Text = (CurrentAbonent.Incoming * CurrentAbonent.Tariff.Incoming + CurrentAbonent.Outgoing * CurrentAbonent.Tariff.Outgoing).ToString();
BackButton.IsEnabled = Prev.Count > 0;
ForwardButton.IsEnabled = Next.Count > 0;
}
private void CloseAllButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void BackButton_Click(object sender, RoutedEventArgs e)
{
if (Prev.Count > 0)
{
Next.Push(CurrentAbonent);
CurrentAbonent = Prev.Pop();
UpdateAbonent();
}
}
private void ForwardButton_Click(object sender, RoutedEventArgs e)
{
if (Next.Count > 0)
{
Prev.Push(CurrentAbonent);
CurrentAbonent = Next.Pop();
UpdateAbonent();
}
}
}
}