Files
csharpcode/omegapro/Omega/Forms/frmChangePass.cs
2025-08-02 05:20:17 +07:00

58 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Linq;
using System.Xml.Linq;
namespace Omega.Forms
{
public partial class frmChangePass : Omega.BasicForms.frmCommon
{
public frmChangePass()
{
InitializeComponent();
}
private void Cancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void OK_Click(object sender, EventArgs e)
{
if ((this.Password.Text != this.RePassword.Text) || (this.Password.Text.Length==0) || (this.RePassword.Text.Length==0))
{
MessageBox.Show("The input values are not the same or empty","Đổi mật khẩu",MessageBoxButtons.OK);
}else
{
string fileToLoad = "Settings.xml";
XElement root = XElement.Load(fileToLoad);
var selected = (from cli in root.Descendants("user")
where cli.Element("username").Value == this.UserName.EditValue.ToString()
select cli).FirstOrDefault();
selected.Element("Password").Value = common.MD5Hash(Password.Text);
root.Save("Settings.xml");
(new frmShowSaveInfo()).Show();
this.Close();
}
}
private void frmChangePass_Load(object sender, EventArgs e)
{
this.UserName.EditValue = SettingInfo.UserName;
this.UserName.Enabled = (SettingInfo.UserName == "Admin");
}
}
}