using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Configuration;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace M065.Config
|
{
|
public partial class AdvancedPwdFrm : Form
|
{
|
string pwd = "";
|
|
string PWD
|
{
|
get
|
{
|
if (string.IsNullOrWhiteSpace(pwd))
|
{
|
var pwdSetting = ConfigurationManager.AppSettings["Pwd"];
|
|
if (!string.IsNullOrWhiteSpace(pwdSetting))
|
{
|
pwd = pwdSetting.ToString();
|
}
|
else
|
{
|
pwd = "p@ssw0rd";
|
}
|
}
|
|
return pwd;
|
}
|
}
|
|
public AdvancedPwdFrm()
|
{
|
InitializeComponent();
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
this.DialogResult = DialogResult.Cancel;
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
{
|
CheckInputPassword();
|
}
|
|
private void CheckInputPassword()
|
{
|
string input = txtPwd.Text.Trim();
|
|
if (string.IsNullOrWhiteSpace(input))
|
{
|
MessageBox.Show("Please input password");
|
return;
|
}
|
|
if (input == PWD)
|
{
|
this.DialogResult = DialogResult.OK;
|
}
|
else
|
{
|
MessageBox.Show("Wrong Password");
|
this.DialogResult = DialogResult.Cancel;
|
}
|
}
|
|
private void txtPwd_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
CheckInputPassword();
|
}
|
}
|
}
|
}
|