Initial commit
This commit is contained in:
148
BMS_D1000/Form/fmPassword.cs
Normal file
148
BMS_D1000/Form/fmPassword.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using BMS_D1000H.BMSConstData;
|
||||
using BMS_D1000H.DataStructs;
|
||||
using BMS_D1000H.Utils.Functions;
|
||||
|
||||
namespace BMS_D1000H
|
||||
{
|
||||
public partial class fmPassword : Form
|
||||
{
|
||||
string password = "";
|
||||
string new_password = "";
|
||||
string confirm_password = "";
|
||||
|
||||
public int order_screen_no = 0;
|
||||
public int req_screen_no = 0;
|
||||
|
||||
public fmPassword()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void tbPassword_GotFocus(object sender, EventArgs e)
|
||||
{
|
||||
kbdValue.Show();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
((fmBMSMain)(Owner)).ScreenSaverTimeReset();
|
||||
tbPassword.Text = "";
|
||||
((fmBMSMain)(Owner)).ScreenMode = order_screen_no;
|
||||
((fmBMSMain)(Owner)).sfmMain.Show(order_screen_no);
|
||||
|
||||
((fmBMSMain)(Owner)).sfmMain.Show(order_screen_no);
|
||||
}
|
||||
|
||||
private void OKPasswordProcess(int oScreenNo)
|
||||
{
|
||||
switch (oScreenNo)
|
||||
{
|
||||
case ScreenID.HISTORY_SCREEN_ID:
|
||||
((fmBMSMain)(Owner)).BmsAlarmFile.DeleteAlarmData();
|
||||
((fmBMSMain)(Owner)).ScreenMode = req_screen_no;
|
||||
((fmBMSMain)(Owner)).sfmMain.Show(req_screen_no);
|
||||
break;
|
||||
case ScreenID.SET_MENU_SCREEN_ID:
|
||||
switch (req_screen_no)
|
||||
{
|
||||
case ScreenID.CHANGE_PASSWORD_SCREEN_ID:
|
||||
req_screen_no = ScreenID.NEW_PASSWORD_SCREEN_ID;
|
||||
this.OnActivated(null);
|
||||
break;
|
||||
case ScreenID.NEW_PASSWORD_SCREEN_ID:
|
||||
req_screen_no = ScreenID.CONFIRM_PASSWORD_SCREEN_ID;
|
||||
this.OnActivated(null);
|
||||
break;
|
||||
case ScreenID.CONFIRM_PASSWORD_SCREEN_ID:
|
||||
((fmBMSMain)(Owner)).ScreenMode = order_screen_no;
|
||||
((fmBMSMain)(Owner)).sfmMain.Show(order_screen_no);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
((fmBMSMain)(Owner)).ScreenMode = req_screen_no;
|
||||
((fmBMSMain)(Owner)).sfmMain.Show(req_screen_no);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
string aPass;
|
||||
|
||||
((fmBMSMain)(Owner)).ScreenSaverTimeReset();
|
||||
|
||||
switch (req_screen_no)
|
||||
{
|
||||
case ScreenID.NEW_PASSWORD_SCREEN_ID:
|
||||
new_password = tbPassword.Text;
|
||||
OKPasswordProcess(order_screen_no);
|
||||
break;
|
||||
case ScreenID.CONFIRM_PASSWORD_SCREEN_ID:
|
||||
confirm_password = tbPassword.Text;
|
||||
|
||||
if (confirm_password == new_password)
|
||||
{
|
||||
// Save new password
|
||||
((fmBMSMain)(Owner)).BmsAlarmFile.SaveNewPasswordData(new_password);
|
||||
OKPasswordProcess(order_screen_no);
|
||||
}
|
||||
else
|
||||
{
|
||||
lbConfigName.Text = "Failed change password";
|
||||
this.Update();
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
req_screen_no = ScreenID.NEW_PASSWORD_SCREEN_ID;
|
||||
this.OnActivated(null);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
aPass = tbPassword.Text;
|
||||
tbPassword.Text = "";
|
||||
password = ((fmBMSMain)(Owner)).BmsAlarmFile.BMS_PASSWORD;
|
||||
|
||||
if (aPass == password)
|
||||
OKPasswordProcess(order_screen_no);
|
||||
else
|
||||
lbConfigName.Text = "Wrong password, please try again";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void fmPassword_Activated(object sender, EventArgs e)
|
||||
{
|
||||
switch (req_screen_no)
|
||||
{
|
||||
case ScreenID.CHANGE_PASSWORD_SCREEN_ID:
|
||||
lbConfigName.Text = "Please input current password";
|
||||
tbPassword.Text = "";
|
||||
break;
|
||||
case ScreenID.NEW_PASSWORD_SCREEN_ID:
|
||||
lbConfigName.Text = "Please input new password";
|
||||
tbPassword.Text = "";
|
||||
break;
|
||||
case ScreenID.CONFIRM_PASSWORD_SCREEN_ID:
|
||||
lbConfigName.Text = "Please input re-confirm password";
|
||||
tbPassword.Text = "";
|
||||
break;
|
||||
default:
|
||||
lbConfigName.Text = "Please input password";
|
||||
tbPassword.Text = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void fmPassword_Load(object sender, EventArgs e)
|
||||
{
|
||||
lbSwVersion.Text = "Ver: " + ((fmBMSMain)(Owner)).AppName.Version.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user