184 lines
5.4 KiB
C#
184 lines
5.4 KiB
C#
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraPrinting.Native.LayoutAdjustment;
|
|
using LFP_Manager.DataStructure;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace LFP_Manager.Forms
|
|
{
|
|
public partial class FmxChangePw : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
#region VARIABLES
|
|
|
|
CommConfig Config;
|
|
|
|
#endregion
|
|
|
|
#region CONSTRUCTORS
|
|
public FmxChangePw()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public FmxChangePw(CommConfig aConfig)
|
|
{
|
|
InitializeComponent();
|
|
|
|
Config = aConfig;
|
|
|
|
switch (Config.ControlLevel)
|
|
{
|
|
case 0: // User Level
|
|
RbUser.Checked = true;
|
|
break;
|
|
case 1: // Technician Level
|
|
RbTechnician.Checked = true;
|
|
break;
|
|
case 2: // Engineer Level
|
|
RbEngineer.Checked = true;
|
|
break;
|
|
case 3: // Master Level
|
|
RbMaster.Checked = true;
|
|
break;
|
|
default: // User Level
|
|
RbUser.Checked = true;
|
|
break;
|
|
}
|
|
DisplayStatus();
|
|
TmrDisplay.Start();
|
|
}
|
|
#endregion
|
|
|
|
#region BUTTON EVENT
|
|
private void BtnClose_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
private void BtnApply_Click(object sender, EventArgs e)
|
|
{
|
|
string cPW = TePW.Text;
|
|
|
|
if (RbMaster.Checked)
|
|
{
|
|
if (Config.MasterPw == cPW)
|
|
{
|
|
Config.ControlLevel = 3;
|
|
MessageBox.Show("Complete change to Mastar Level", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Wrong password for Master Level", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
else if (RbEngineer.Checked)
|
|
{
|
|
if (Config.EngineerPw == cPW)
|
|
{
|
|
Config.ControlLevel = 2;
|
|
MessageBox.Show("Complete change to Engineer Level", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Wrong password for Engineer Level", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
else if (RbTechnician.Checked)
|
|
{
|
|
if (Config.TechnicianPw == cPW)
|
|
{
|
|
Config.ControlLevel = 1;
|
|
MessageBox.Show("Complete change to Technician Level", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Wrong password for Technician Level", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
else if (RbUser.Checked)
|
|
{
|
|
Config.ControlLevel = 0;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region DISPLAY FUNCTION
|
|
private void DisplayStatus()
|
|
{
|
|
switch (Config.ControlLevel)
|
|
{
|
|
case 0: // User Level
|
|
LbCurrentLevel.Text = " Current Level: User Level";
|
|
break;
|
|
case 1: // Technician Level
|
|
LbCurrentLevel.Text = " Current Level: Technician Level";
|
|
break;
|
|
case 2: // Engineer Level
|
|
LbCurrentLevel.Text = " Current Level: Engineer Level";
|
|
break;
|
|
case 3: // Master Level
|
|
LbCurrentLevel.Text = " Current Level: Master Level";
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region FORM EVENT
|
|
private void FmxLevelConfig_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
TmrDisplay.Stop();
|
|
}
|
|
#endregion
|
|
|
|
#region COMPONENT EVENT
|
|
private void RbMaster_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (RbMaster.Checked)
|
|
{
|
|
TePW.Enabled = true;
|
|
}
|
|
TePW.Text = "";
|
|
}
|
|
|
|
private void RbEngineer_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (RbEngineer.Checked)
|
|
{
|
|
TePW.Enabled = true;
|
|
}
|
|
TePW.Text = "";
|
|
}
|
|
|
|
private void RbTechnician_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (RbTechnician.Checked)
|
|
{
|
|
TePW.Enabled = true;
|
|
}
|
|
TePW.Text = "";
|
|
}
|
|
|
|
private void RbUser_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (RbUser.Checked)
|
|
{
|
|
TePW.Enabled = false;
|
|
}
|
|
TePW.Text = "";
|
|
}
|
|
#endregion
|
|
|
|
#region TIMER EVENT
|
|
private void TmrDisplay_Tick(object sender, EventArgs e)
|
|
{
|
|
DisplayStatus();
|
|
}
|
|
#endregion
|
|
}
|
|
} |