140 lines
5.0 KiB
C#
140 lines
5.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using AIMSBLL;
|
|
using AIMSExtension;
|
|
using AIMSModel;
|
|
using DevComponents.DotNetBar;
|
|
using HelperDB;
|
|
|
|
namespace AIMS
|
|
{
|
|
public partial class FormLogin : Office2007Form
|
|
{
|
|
public FormLogin()
|
|
{
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|
this.EnableGlass = false;
|
|
|
|
InitializeComponent();
|
|
}
|
|
public XmlUse xmlUse = new XmlUse(Application.StartupPath + "\\AIMS.xml");
|
|
string LastNo = null;
|
|
|
|
private void frmLogin_Load(object sender, EventArgs e)
|
|
{
|
|
AIMSExtension.PublicMethod.SetLocalDateTime();
|
|
AIMSExtension.PublicMethod.HospitalName = PublicMethod.GetHospital();
|
|
//label1.Text = AIMSExtension.PublicMethod.GetSystemName();
|
|
label2.Text = PublicMethod.HospitalName + " V" + PublicMethod.NowVersion;
|
|
txtNo.Select();
|
|
txtNo.Focus();
|
|
List<string> list = xmlUse.GetNode("LastLoginNo");
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
LastNo = list[0];
|
|
if (LastNo != "")
|
|
{
|
|
txtNo.Text = LastNo;
|
|
txtPassWord.Select();
|
|
txtPassWord.Focus();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
txtNo.Select();
|
|
txtNo.Focus();
|
|
}
|
|
#if DEBUG
|
|
txtNo.Text = "admin";
|
|
txtPassWord.Text = "1";
|
|
btnOk_Click(null, null);
|
|
#endif
|
|
}
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
Person Person = BPerson.Login(txtNo.Text, txtPassWord.Text);
|
|
if (Person != null && Person.Id != null)
|
|
{
|
|
Person PersonObj = BPerson.GetModelById(Person.Id.Value);
|
|
AIMSExtension.PublicMethod.OperatorId = PersonObj.Id.Value;
|
|
AIMSExtension.PublicMethod.OperatorNo = PersonObj.No;
|
|
AIMSExtension.PublicMethod.OperatorName = PersonObj.Name;
|
|
AIMSExtension.PublicMethod.RoleId = PersonObj.RoleId.Value;
|
|
AIMSExtension.PublicMethod.DepId = PersonObj.DepId.Value;
|
|
AIMSExtension.PublicMethod.LocalIP = AIMSExtension.PublicMethod.GetLocalIP();
|
|
AIMSExtension.PublicMethod.DeptName = BDepartment.GetModel(PersonObj.DepId.Value).Name;
|
|
Role role = BRole.GetModel(PersonObj.RoleId.Value);
|
|
AIMSExtension.PublicMethod.PermissionLevel = role.PermissionLevel == null ? 0 : role.PermissionLevel.Value;
|
|
AIMSExtension.PublicMethod.RoleName = BMenu.GetMenuRootListManageStr(AIMSExtension.PublicMethod.RoleId, "功能权限");
|
|
AIMSExtension.PublicMethod.OperationSite = BOperationRoom.GetOperationSite();
|
|
if (LastNo != null && PersonObj.No != "admin" && PersonObj.No != LastNo)
|
|
xmlUse.SetNode("LastLoginNo", PersonObj.No);
|
|
List<string> list = xmlUse.GetNode("LastOperationSite");
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
PublicMethod.LastOperationSite = list[0];
|
|
}
|
|
PublicMethod.WriteLog("登录", PersonObj.Id.Value);
|
|
|
|
PublicMethod.StartCollectorDataProgram();
|
|
Hide();
|
|
//在这里为编辑器注册
|
|
new System.Threading.Thread(Reg).Start();
|
|
//DevComponents.DotNetBar.StyleManager.MetroColorGeneratorParameters = DevComponents.DotNetBar.Metro.ColorTables.MetroColorGeneratorParameters.Office2016Blue;
|
|
new FormMainManage().ShowDialog();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("用户名或密码有错误,请重新输入!", "提示", MessageBoxButtons.OK);
|
|
|
|
txtPassWord.Text = "";
|
|
txtPassWord.Focus();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 注册全局编辑器
|
|
/// </summary>
|
|
static void Reg()
|
|
{
|
|
// 预先初始化一些数据
|
|
DCSoft.Writer.WriterAppHost.PreloadSystem();
|
|
DCSoft.Writer.Controls.WriterControl.StaticSetRegisterCode(AIMSExtension.PublicMethod.Decrypt(AIMSControls.Properties.Resources.C));
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void txtNo_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyData == Keys.Enter)
|
|
{
|
|
txtPassWord.Select();
|
|
txtPassWord.Focus();
|
|
}
|
|
|
|
}
|
|
|
|
private void txtPassWord_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyData == Keys.Enter)
|
|
{
|
|
btnOk_Click(null, null);
|
|
}
|
|
}
|
|
|
|
private void btnOk_VisibleChanged(object sender, EventArgs e)
|
|
{
|
|
txtPassWord.Text = "";
|
|
}
|
|
}
|
|
}
|