-
Notifications
You must be signed in to change notification settings - Fork 1
/
FrmMainMdi.cs
142 lines (128 loc) · 5.38 KB
/
FrmMainMdi.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Globalization;
using System.Reflection;
using System.Windows.Forms;
using Persia;
namespace BaharNarenjERP
{
public partial class FrmMainMdi : Form
{
private InputLanguage _il;
private readonly TimeSpan _oneSecond = new TimeSpan(0, 0, 1);
private SolarDate _now;
public FrmMainMdi()
{
InitializeComponent();
}
private void MnuExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void MnuCustomers_Click(object sender, EventArgs e)
{
var frm = SingletonProvider<FrmCustomers>.Instance;
frm.MdiParent = this;
frm.Icon = Icon;
frm.Parent = PbxMain;
frm.Show();
}
private void MnuBranches_Click(object sender, EventArgs e)
{
var frm = SingletonProvider<FrmBranches>.Instance;
frm.MdiParent = this;
frm.Icon = Icon;
frm.Parent = PbxMain;
frm.Show();
}
private void FrmMainMdi_Load(object sender, EventArgs e)
{
TmrTime.Enabled = false;
_il = InputLanguage.CurrentInputLanguage;
Text =
((AssemblyProductAttribute)
Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0])
.Product + @" ";
Text += Assembly.GetExecutingAssembly().GetName().Version.Major + @"." +
Assembly.GetExecutingAssembly().GetName().Version.Minor + @"." +
Assembly.GetExecutingAssembly().GetName().Version.Build + @"." +
Assembly.GetExecutingAssembly().GetName().Version.Revision;
Text += @" on " + Environment.MachineName;
InputLanguage.CurrentInputLanguage =
InputLanguage.FromCulture(CultureInfo.CreateSpecificCulture("fa-IR"));
//if (DAC.RowCount("users") == 0) return;
Enabled = false;
(new FrmLogIn { Icon = Icon }).ShowDialog();
Enabled = true;
Text += @" - " + AppProperties.User.persFName + @" " + AppProperties.User.persLName;
InputLanguage.CurrentInputLanguage =
InputLanguage.FromCulture(CultureInfo.CreateSpecificCulture("fa-IR"));
if (AppProperties.User.brID == "9999" || AppProperties.MasterEntrance) return;
MnuUserManagement.Enabled = false;
MnuOptions.Enabled = false;
}
private void TmrTime_Tick(object sender, EventArgs e)
{
if (_now == null) return;
_now = Persia.Calendar.ConvertToPersian(Persia.Calendar.ConvertToGregorian(_now) + _oneSecond);
StsLblDate.Text = _now.ToString("S,H");
}
private void MnuNewCustProforma_Click(object sender, EventArgs e)
{
var frm = SingletonProvider<FrmInvoice>.Instance;
frm.MdiParent = this;
frm.Icon = Icon;
frm.Parent = PbxMain;
frm.Show();
}
private void FrmMainMdi_FormClosing(object sender, FormClosingEventArgs e)
{
InputLanguage.CurrentInputLanguage = _il;
if (AppProperties.ForceClose) return;
var dr = MessageBox.Show(@"آیا از خروج مطمئن هستید؟", @"خروج", MessageBoxButtons.YesNo,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
if (dr == DialogResult.Yes) return;
e.Cancel = true;
Activate();
InputLanguage.CurrentInputLanguage =
InputLanguage.FromCulture(CultureInfo.CreateSpecificCulture("fa-IR"));
}
private void MnuPersonnel_Click(object sender, EventArgs e)
{
var frm = SingletonProvider<FrmPersonnel>.Instance;
frm.MdiParent = this;
frm.Icon = Icon;
frm.Parent = PbxMain;
frm.Show();
}
private void MnuUserManagement_Click(object sender, EventArgs e)
{
(new FrmUserManagement() {Icon = Icon}).ShowDialog(this);
}
private void TmrTimeCheck_Tick(object sender, EventArgs e)
{
try
{
var t = new NtpTime(Properties.Settings.Default.TimeServer,
Properties.Settings.Default.TimeZoneHour * 60 + Properties.Settings.Default.TimeZoneMinute);
_now = Persia.Calendar.ConvertToPersian(t.Now);
StsLblPrompt.Text = $"زمان اینترنتی : ";
TmrTimeCheck.Interval = 3600000;
}
catch
{
//StsLblDate.Text = @"ارتباط با اینترنت مقدور نیست.";
_now = Persia.Calendar.ConvertToPersian(DateTime.Now);
StsLblPrompt.Text = $"زمان محلی : ";
TmrTimeCheck.Interval = 3600000;
}
}
private void MnuOptions_Click(object sender, EventArgs e)
{
(new FrmSettings() { Icon = Icon }).ShowDialog(this);
}
private void MnuOldCustProforma_Click(object sender, EventArgs e)
{
}
}
}