using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Net; using System.Text; using System.Windows.Forms; using Omega.Properties; using System.Globalization; using System.Threading; using System.Xml; using System.Xml.Linq; using System.Linq; namespace Omega.Forms { public partial class frmLogin : Omega.BasicForms.frmCommon { public frmLogin() { InitializeComponent(); } private void OK_Click(object sender, EventArgs e) { string fileToLoad = Application.StartupPath + @"\Settings.xml"; XElement root = XElement.Load(fileToLoad); var selected = (from cli in root.Descendants("user") where cli.Element("username").Value == UserName.EditValue.ToString() select cli).FirstOrDefault(); if (selected.Element("Password").Value == common.MD5Hash(Password.Text)) { this.Hide(); SettingInfo.UserName = this.UserName.EditValue.ToString().Trim(); var frm = new frmMain(); frm.ShowDialog(); this.Close(); } else { MessageBox.Show("Bạn nhập sai mật khẩu hoặc tên truy cập", "Cảnh báo", MessageBoxButtons.OK); } } private void Cancel_Click(object sender, EventArgs e) { Application.Exit(); } } }