LoginForm - Save username, password to ConfigurationFile.

This commit is contained in:
DucDangAnh 2020-07-13 15:35:01 +07:00
parent 73e353b99e
commit 5773b6d48e
3 changed files with 30 additions and 5 deletions

View File

@ -2,6 +2,8 @@
<configuration>
<appSettings>
<add key="DOOR_ACCESS_DEVICE_CONTROL_IP" value="192.168.1.200" />
<add key="DEFAULT_USERNAME" value="congvao1" />
<add key="DEFAULT_PASSWORD" value="123456a@" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />

View File

@ -126,9 +126,11 @@
// lblLoginStatus
//
this.lblLoginStatus.AutoSize = true;
this.lblLoginStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblLoginStatus.ForeColor = System.Drawing.SystemColors.ControlLight;
this.lblLoginStatus.Location = new System.Drawing.Point(294, 117);
this.lblLoginStatus.Name = "lblLoginStatus";
this.lblLoginStatus.Size = new System.Drawing.Size(66, 13);
this.lblLoginStatus.Size = new System.Drawing.Size(90, 18);
this.lblLoginStatus.TabIndex = 4;
this.lblLoginStatus.Text = "Login Status";
//
@ -154,6 +156,7 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AIParking - Hệ thống quản lý bãi đỗ xe - Đăng nhập";
this.TopMost = true;
this.Load += new System.EventHandler(this.LoginForm_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImageLogo)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -1,4 +1,6 @@
using System;
using OpenCvSharp;
using System;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
@ -69,7 +71,7 @@ namespace AIParkingApplication
var execeptioMessage = loginResult.Exception.Message;
if (execeptioMessage.Contains("Error converting value"))
{
lblLoginStatus.UpdateLabel("Tên tài khoản hoặc mật khẩu không đúng!", Color.Red);
lblLoginStatus.UpdateLabel("Sai tên tài khoản hoặc mật khẩu!", Color.Red);
return;
}
@ -83,13 +85,13 @@ namespace AIParkingApplication
if (loginResult.IsLoginSuccess)
{
Util.AddOrUpdateAppSettings("DEFAULT_USERNAME", txtUsername.Text);
Util.AddOrUpdateAppSettings("DEFAULT_PASSWORD", txtPassword.Text);
new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData).Show();
Hide();
}
}
private void btnLogin_Click(object sender, EventArgs e)
{
Login();
@ -102,5 +104,23 @@ namespace AIParkingApplication
Application.Exit();
}
}
private void ReadAppConfiguration()
{
try
{
txtUsername.Text = ConfigurationManager.AppSettings["DEFAULT_USERNAME"];
txtPassword.Text = ConfigurationManager.AppSettings["DEFAULT_PASSWORD"];
}
catch (Exception ex)
{
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
}
}
private void LoginForm_Load(object sender, EventArgs e)
{
ReadAppConfiguration();
}
}
}