-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form_EditNachislSumma.cs
101 lines (91 loc) · 3.55 KB
/
Form_EditNachislSumma.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Windows.Forms;
namespace MongoDB_Base
{
public partial class Form_EditNachislSumma : Form
{
MongoDB_Class _Obj = MongoDB_Class.GetObject();
Class_NachislSumma StuObj_;
public Form_EditNachislSumma(Class_NachislSumma StuObj)
{
InitializeComponent();
StuObj_ = StuObj;
}
private void LoadData()
{
StuObj_.Id = int.Parse(TBID.Text.ToString().Trim());
StuObj_.AccountCD = comboBoxAbonent.SelectedItem.ToString();
StuObj_.ServiceCD = comboBoxService.SelectedItem.ToString();
StuObj_.NachislSum = double.Parse(TBSum.Text.ToString().Trim());
StuObj_.NachislMonth = TBMonth.Text.ToString().Trim();
StuObj_.NachislYear = int.Parse(TBYear.Text.ToString().Trim());
}
private void DataLoad()
{
TBID.Text = StuObj_.Id.ToString();
comboBoxAbonent.Text = StuObj_.AccountCD;
comboBoxService.Text = StuObj_.ServiceCD;
TBSum.Text = StuObj_.NachislSum.ToString();
TBMonth.Text = StuObj_.NachislMonth.ToString();
TBYear.Text = StuObj_.NachislYear.ToString();
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (TBID.Text != "" && TBSum.Text != "" && TBMonth.Text != "" && TBYear.Text != "" && comboBoxAbonent.Text != "" && comboBoxService.Text != "")
{
LoadData();
if (TBID.Modified == false)
_Obj.Update_NachislSumma_Information(StuObj_);
else
_Obj.Insert_NachislSumma_Information(StuObj_);
}
else
MessageBox.Show("Поля заполнены неверно");
DialogResult = DialogResult.OK;
Close();
}
private void buttonDelete_Click(object sender, EventArgs e)
{
LoadData();
_Obj.Delete_NachislSumma_Infromation(StuObj_);
DialogResult = DialogResult.OK;
Close();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void TBID_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar <= 47 || e.KeyChar >= 58) && e.KeyChar != 8)
{
e.Handled = true;
MessageBox.Show("Введите целое число");
}
}
private void TBMonth_KeyPress(object sender, KeyPressEventArgs e)
{
if (TBMonth.Text.Length == 1)
TBMonth.Text = TBMonth.Text.ToUpper();
TBMonth.Select(TBMonth.Text.Length, 0);
if (e.KeyChar != 8 && (e.KeyChar < 'А' || e.KeyChar > 'я'))
{
e.Handled = true;
MessageBox.Show("Название месяца пишется на кириллице");
}
}
private void TBSum_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar <= 47 || e.KeyChar >= 58) && e.KeyChar != 8 && e.KeyChar != 44)
{
e.Handled = true;
MessageBox.Show("Число пишется через запятую");
}
}
private void Form_EditNachislSumma_Load(object sender, EventArgs e)
{
DataLoad();
}
}
}