Initial commit: demo 24.11
This commit is contained in:
@@ -0,0 +1,246 @@
|
||||
using System.Drawing.Drawing2D;
|
||||
using RentalApp.Data;
|
||||
using RentalApp.Helpers;
|
||||
|
||||
namespace RentalApp.Forms;
|
||||
|
||||
public class LoginForm : Form
|
||||
{
|
||||
private const int FAIL_LOCK_SECONDS = 10;
|
||||
|
||||
// --- контролы ---
|
||||
private readonly Label lblTitle = new();
|
||||
private readonly Label lblLogin = new();
|
||||
private readonly TextBox txtLogin = new();
|
||||
private readonly Label lblPassword = new();
|
||||
private readonly TextBox txtPassword = new();
|
||||
private readonly CheckBox chkShowPassword = new();
|
||||
private readonly Label lblCaptcha = new();
|
||||
private readonly PictureBox picCaptcha = new();
|
||||
private readonly TextBox txtCaptcha = new();
|
||||
private readonly Button btnRefreshCaptcha = new();
|
||||
private readonly Button btnLogin = new();
|
||||
private readonly Label lblError = new();
|
||||
|
||||
// --- состояние ---
|
||||
private int _failedAttempts = 0;
|
||||
private bool _captchaRequired = false;
|
||||
private DateTime? _captchaLockUntil = null;
|
||||
private string _currentCaptcha = "";
|
||||
private readonly System.Windows.Forms.Timer _attemptTimer = new();
|
||||
|
||||
public LoginForm()
|
||||
{
|
||||
BuildUi();
|
||||
|
||||
if (LockHelper.IsLocked())
|
||||
{
|
||||
btnLogin.Enabled = false;
|
||||
txtLogin.Enabled = false;
|
||||
txtPassword.Enabled = false;
|
||||
lblError.Text = "Вход заблокирован. Попробуйте позже.";
|
||||
}
|
||||
|
||||
txtPassword.UseSystemPasswordChar = true;
|
||||
chkShowPassword.CheckedChanged += (s, e) =>
|
||||
txtPassword.UseSystemPasswordChar = !chkShowPassword.Checked;
|
||||
|
||||
SetCaptchaVisible(false);
|
||||
|
||||
_attemptTimer.Interval = 500;
|
||||
_attemptTimer.Tick += AttemptTimer_Tick;
|
||||
|
||||
btnLogin.Click += BtnLogin_Click;
|
||||
btnRefreshCaptcha.Click += (s, e) => GenerateCaptcha();
|
||||
txtCaptcha.KeyDown += (s, e) => { if (e.KeyCode == Keys.Enter) BtnLogin_Click(s, e); };
|
||||
txtPassword.KeyDown += (s, e) => { if (e.KeyCode == Keys.Enter) BtnLogin_Click(s, e); };
|
||||
|
||||
GenerateCaptcha();
|
||||
UpdateLockUI();
|
||||
}
|
||||
|
||||
private void BuildUi()
|
||||
{
|
||||
lblTitle.AutoSize = true;
|
||||
lblTitle.Font = new Font("Segoe UI", 14F, FontStyle.Bold);
|
||||
lblTitle.Location = new Point(30, 20);
|
||||
lblTitle.Text = "Вход в систему «Приэльбрусье»";
|
||||
|
||||
lblLogin.AutoSize = true;
|
||||
lblLogin.Location = new Point(30, 70);
|
||||
lblLogin.Text = "Логин:";
|
||||
|
||||
txtLogin.Location = new Point(30, 90);
|
||||
txtLogin.Size = new Size(280, 23);
|
||||
|
||||
lblPassword.AutoSize = true;
|
||||
lblPassword.Location = new Point(30, 125);
|
||||
lblPassword.Text = "Пароль:";
|
||||
|
||||
txtPassword.Location = new Point(30, 145);
|
||||
txtPassword.Size = new Size(280, 23);
|
||||
|
||||
chkShowPassword.AutoSize = true;
|
||||
chkShowPassword.Location = new Point(30, 175);
|
||||
chkShowPassword.Text = "Показать пароль";
|
||||
|
||||
lblCaptcha.AutoSize = true;
|
||||
lblCaptcha.Location = new Point(30, 210);
|
||||
lblCaptcha.Text = "Введите символы с картинки:";
|
||||
|
||||
picCaptcha.BorderStyle = BorderStyle.FixedSingle;
|
||||
picCaptcha.Location = new Point(30, 230);
|
||||
picCaptcha.Size = new Size(120, 40);
|
||||
|
||||
txtCaptcha.Location = new Point(160, 240);
|
||||
txtCaptcha.Size = new Size(80, 23);
|
||||
|
||||
btnRefreshCaptcha.Location = new Point(250, 238);
|
||||
btnRefreshCaptcha.Size = new Size(60, 25);
|
||||
btnRefreshCaptcha.Text = "↻";
|
||||
|
||||
btnLogin.Location = new Point(30, 285);
|
||||
btnLogin.Size = new Size(280, 35);
|
||||
btnLogin.Text = "Войти";
|
||||
|
||||
lblError.AutoSize = false;
|
||||
lblError.ForeColor = Color.DarkRed;
|
||||
lblError.Location = new Point(30, 325);
|
||||
lblError.Size = new Size(280, 40);
|
||||
lblError.TextAlign = ContentAlignment.MiddleCenter;
|
||||
|
||||
ClientSize = new Size(350, 380);
|
||||
Controls.AddRange(new Control[] {
|
||||
lblTitle, lblLogin, txtLogin, lblPassword, txtPassword,
|
||||
chkShowPassword, lblCaptcha, picCaptcha, txtCaptcha,
|
||||
btnRefreshCaptcha, btnLogin, lblError
|
||||
});
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Вход";
|
||||
}
|
||||
|
||||
private void BtnLogin_Click(object? sender, EventArgs e)
|
||||
{
|
||||
lblError.Text = "";
|
||||
|
||||
if (LockHelper.IsLocked())
|
||||
{
|
||||
lblError.Text = "Вход заблокирован. Попробуйте позже.";
|
||||
return;
|
||||
}
|
||||
if (_captchaLockUntil.HasValue && DateTime.Now < _captchaLockUntil)
|
||||
{
|
||||
lblError.Text = $"Подождите {(_captchaLockUntil.Value - DateTime.Now).Seconds} сек.";
|
||||
return;
|
||||
}
|
||||
|
||||
string login = txtLogin.Text.Trim();
|
||||
string password = txtPassword.Text;
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
lblError.Text = "Введите логин и пароль.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_captchaRequired && txtCaptcha.Text.Trim() != _currentCaptcha)
|
||||
{
|
||||
lblError.Text = "Неверная captcha. Доступ заблокирован на 10 сек.";
|
||||
AppData.LogLogin(login, false);
|
||||
_captchaLockUntil = DateTime.Now.AddSeconds(FAIL_LOCK_SECONDS);
|
||||
_attemptTimer.Start();
|
||||
UpdateLockUI();
|
||||
return;
|
||||
}
|
||||
|
||||
var user = AppData.Authenticate(login, password);
|
||||
if (user == null)
|
||||
{
|
||||
_failedAttempts++;
|
||||
AppData.LogLogin(login, false);
|
||||
|
||||
if (_failedAttempts >= 2)
|
||||
{
|
||||
_captchaRequired = true;
|
||||
SetCaptchaVisible(true);
|
||||
GenerateCaptcha();
|
||||
lblError.Text = "Неудачная авторизация. Введите captcha.";
|
||||
}
|
||||
else lblError.Text = "Неверный логин или пароль.";
|
||||
return;
|
||||
}
|
||||
|
||||
AppData.LogLogin(login, true);
|
||||
var main = new MainForm(user);
|
||||
Hide();
|
||||
main.ShowDialog();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SetCaptchaVisible(bool visible)
|
||||
{
|
||||
picCaptcha.Visible = visible;
|
||||
txtCaptcha.Visible = visible;
|
||||
btnRefreshCaptcha.Visible = visible;
|
||||
lblCaptcha.Visible = visible;
|
||||
}
|
||||
|
||||
private void GenerateCaptcha()
|
||||
{
|
||||
const string chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
||||
var rnd = new Random();
|
||||
char[] arr = new char[3];
|
||||
for (int i = 0; i < arr.Length; i++) arr[i] = chars[rnd.Next(chars.Length)];
|
||||
_currentCaptcha = new string(arr);
|
||||
|
||||
var bmp = new Bitmap(picCaptcha.Width, picCaptcha.Height);
|
||||
using (var g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.Clear(Color.White);
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
var font = new Font("Arial", 24, FontStyle.Bold);
|
||||
var brush = new SolidBrush(Color.Black);
|
||||
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
var state = g.Save();
|
||||
g.TranslateTransform(8 + i * 35, 20);
|
||||
g.RotateTransform(rnd.Next(-25, 25));
|
||||
g.DrawString(arr[i].ToString(), font, brush, 0, 0);
|
||||
g.Restore(state);
|
||||
}
|
||||
var pen = new Pen(Color.Gray, 1);
|
||||
for (int i = 0; i < 6; i++)
|
||||
g.DrawLine(pen, rnd.Next(bmp.Width), rnd.Next(bmp.Height),
|
||||
rnd.Next(bmp.Width), rnd.Next(bmp.Height));
|
||||
g.DrawLine(new Pen(Color.DarkRed, 1.5f), 2, bmp.Height - 5, bmp.Width - 2, 5);
|
||||
g.DrawLine(new Pen(Color.DarkBlue, 1f), 2, 5, bmp.Width - 2, bmp.Height - 5);
|
||||
for (int i = 0; i < 30; i++)
|
||||
bmp.SetPixel(rnd.Next(bmp.Width), rnd.Next(bmp.Height), Color.LightGray);
|
||||
}
|
||||
picCaptcha.Image?.Dispose();
|
||||
picCaptcha.Image = bmp;
|
||||
txtCaptcha.Clear();
|
||||
}
|
||||
|
||||
private void AttemptTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
if (_captchaLockUntil.HasValue && DateTime.Now >= _captchaLockUntil)
|
||||
{
|
||||
_captchaLockUntil = null;
|
||||
_attemptTimer.Stop();
|
||||
UpdateLockUI();
|
||||
lblError.Text = "Блокировка снята. Повторите ввод.";
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLockUI()
|
||||
{
|
||||
bool locked = _captchaLockUntil.HasValue && DateTime.Now < _captchaLockUntil;
|
||||
btnLogin.Enabled = !locked && !LockHelper.IsLocked();
|
||||
txtLogin.Enabled = !locked && !LockHelper.IsLocked();
|
||||
txtPassword.Enabled = !locked && !LockHelper.IsLocked();
|
||||
txtCaptcha.Enabled = !locked;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,172 @@
|
||||
using RentalApp.Data;
|
||||
using RentalApp.Helpers;
|
||||
using RentalApp.Models;
|
||||
using System.IO;
|
||||
|
||||
namespace RentalApp.Forms;
|
||||
|
||||
public class MainForm : Form
|
||||
{
|
||||
private readonly Employee _user;
|
||||
private readonly System.Windows.Forms.Timer _sessionTimer = new();
|
||||
private DateTime _sessionEnd;
|
||||
private bool _warned = false;
|
||||
|
||||
// --- контролы ---
|
||||
private readonly PictureBox picEmployee = new();
|
||||
private readonly Label lblFullName = new();
|
||||
private readonly Label lblRole = new();
|
||||
private readonly Label lblSessionLabel = new();
|
||||
private readonly Label lblSessionTime = new();
|
||||
private readonly Button btnCreateOrder = new();
|
||||
private readonly Button btnAcceptReturn = new();
|
||||
private readonly Button btnReports = new();
|
||||
private readonly Button btnLoginHistory = new();
|
||||
private readonly Button btnConsumables = new();
|
||||
private readonly Button btnLogout = new();
|
||||
|
||||
public MainForm(Employee user)
|
||||
{
|
||||
_user = user;
|
||||
BuildUi();
|
||||
|
||||
lblFullName.Text = user.FullName;
|
||||
lblRole.Text = user.Role;
|
||||
|
||||
if (!string.IsNullOrEmpty(user.PhotoPath) && File.Exists(user.PhotoPath))
|
||||
picEmployee.Image = Image.FromFile(user.PhotoPath);
|
||||
else
|
||||
picEmployee.Image = SystemIcons.Information.ToBitmap();
|
||||
|
||||
btnCreateOrder.Visible = true;
|
||||
btnAcceptReturn.Visible = user.Role == "Старший смены";
|
||||
btnReports.Visible = user.Role == "Администратор";
|
||||
btnLoginHistory.Visible = user.Role == "Администратор";
|
||||
btnConsumables.Visible = user.Role == "Администратор";
|
||||
|
||||
_sessionTimer.Interval = 1000;
|
||||
_sessionTimer.Tick += SessionTimer_Tick;
|
||||
_sessionEnd = DateTime.Now.AddMinutes(10);
|
||||
_sessionTimer.Start();
|
||||
UpdateTimerLabel();
|
||||
|
||||
btnLogout.Click += (s, e) => Logout();
|
||||
|
||||
// заглушки на кнопки — чтобы не падало, если нажать
|
||||
btnCreateOrder.Click += (s, e) => MessageBox.Show("Окно оформления заказа (в разработке)");
|
||||
btnAcceptReturn.Click += (s, e) => MessageBox.Show("Окно приёма оборудования (в разработке)");
|
||||
btnReports.Click += (s, e) => MessageBox.Show("Окно отчётов (в разработке)");
|
||||
btnLoginHistory.Click += (s, e) => ShowLoginHistory();
|
||||
btnConsumables.Click += (s, e) => MessageBox.Show("Окно расходных материалов (в разработке)");
|
||||
}
|
||||
|
||||
private void BuildUi()
|
||||
{
|
||||
picEmployee.BorderStyle = BorderStyle.FixedSingle;
|
||||
picEmployee.Location = new Point(20, 20);
|
||||
picEmployee.Size = new Size(120, 140);
|
||||
picEmployee.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
|
||||
lblFullName.AutoSize = true;
|
||||
lblFullName.Font = new Font("Segoe UI", 12F, FontStyle.Bold);
|
||||
lblFullName.Location = new Point(160, 25);
|
||||
|
||||
lblRole.AutoSize = true;
|
||||
lblRole.Font = new Font("Segoe UI", 10F);
|
||||
lblRole.ForeColor = Color.DarkSlateGray;
|
||||
lblRole.Location = new Point(160, 60);
|
||||
|
||||
lblSessionLabel.AutoSize = true;
|
||||
lblSessionLabel.Location = new Point(160, 100);
|
||||
lblSessionLabel.Text = "Сеанс:";
|
||||
|
||||
lblSessionTime.AutoSize = true;
|
||||
lblSessionTime.Font = new Font("Consolas", 14F, FontStyle.Bold);
|
||||
lblSessionTime.ForeColor = Color.DarkGreen;
|
||||
lblSessionTime.Location = new Point(215, 97);
|
||||
|
||||
btnCreateOrder.Location = new Point(20, 190);
|
||||
btnCreateOrder.Size = new Size(260, 35);
|
||||
btnCreateOrder.Text = "Оформить заказ";
|
||||
|
||||
btnAcceptReturn.Location = new Point(20, 235);
|
||||
btnAcceptReturn.Size = new Size(260, 35);
|
||||
btnAcceptReturn.Text = "Принять оборудование";
|
||||
|
||||
btnReports.Location = new Point(20, 280);
|
||||
btnReports.Size = new Size(260, 35);
|
||||
btnReports.Text = "Отчёты";
|
||||
|
||||
btnLoginHistory.Location = new Point(20, 325);
|
||||
btnLoginHistory.Size = new Size(260, 35);
|
||||
btnLoginHistory.Text = "История входа";
|
||||
|
||||
btnConsumables.Location = new Point(20, 370);
|
||||
btnConsumables.Size = new Size(260, 35);
|
||||
btnConsumables.Text = "Расходные материалы";
|
||||
|
||||
btnLogout.Location = new Point(20, 420);
|
||||
btnLogout.Size = new Size(260, 35);
|
||||
btnLogout.Text = "Выйти";
|
||||
|
||||
ClientSize = new Size(480, 480);
|
||||
Controls.AddRange(new Control[] {
|
||||
picEmployee, lblFullName, lblRole, lblSessionLabel, lblSessionTime,
|
||||
btnCreateOrder, btnAcceptReturn, btnReports,
|
||||
btnLoginHistory, btnConsumables, btnLogout
|
||||
});
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Главное окно";
|
||||
}
|
||||
|
||||
private void SessionTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
var left = _sessionEnd - DateTime.Now;
|
||||
if (left.TotalSeconds <= 0)
|
||||
{
|
||||
_sessionTimer.Stop();
|
||||
MessageBox.Show("Сеанс завершён. Вход заблокирован на 3 минуты.",
|
||||
"Сеанс", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
LockHelper.SetLock(DateTime.Now.AddMinutes(3));
|
||||
Logout();
|
||||
return;
|
||||
}
|
||||
UpdateTimerLabel();
|
||||
|
||||
if (left.TotalSeconds <= 5 * 60 && !_warned)
|
||||
{
|
||||
_warned = true;
|
||||
MessageBox.Show("До окончания сеанса менее 5 минут. Проверьте кассу!",
|
||||
"Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTimerLabel()
|
||||
{
|
||||
var left = _sessionEnd - DateTime.Now;
|
||||
if (left.TotalSeconds < 0) left = TimeSpan.Zero;
|
||||
lblSessionTime.Text = $"{left.Minutes:00}:{left.Seconds:00}";
|
||||
}
|
||||
|
||||
private void ShowLoginHistory()
|
||||
{
|
||||
var text = string.Join(Environment.NewLine,
|
||||
AppData.LoginHistory
|
||||
.OrderByDescending(h => h.Time)
|
||||
.Select(h => $"{h.Time:yyyy-MM-dd HH:mm:ss} | {h.Login} | {(h.Success ? "Успешно" : "Неуспешно")}"));
|
||||
|
||||
MessageBox.Show(text, "История входа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void Logout()
|
||||
{
|
||||
_sessionTimer.Stop();
|
||||
var login = new LoginForm();
|
||||
Hide();
|
||||
login.ShowDialog();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user