产品生命周期追溯系统源代码-修改后
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Crownwood.DotNetMagic.Forms;
using Utility;
using BLL;
namespace Template
{
public partial class FrmLogin : DotNetMagicForm
{
private bool _passwordRequired = true;
public event EventHandler OkClicked;
//private ReCordUserNameBLL reCordUserNameBLL = null;
public FrmLogin()
{
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
//reCordUserNameBLL = new ReCordUserNameBLL();
}
#region Property
/// <summary>
/// Gets or sets the text currently in the user textbox.
/// </summary>
//private delegate void ComboBoxcbUserID();
//public void server()
//{
// ComboBoxcbUserID cb = delegate()//使用委托
// {
// };
// cbUserID.Invoke(cb);
//}
public string User
{
get
{
return this.txtUserID.Text.Trim();
}
set
{
this.txtUserID.Text = value;
}
}
/// <summary>
/// Gets the text currently in the password textbox
/// </summary>
public string Password
{
get
{
return this.txtPassWord.Text.Trim();
}
}
/// <summary>
/// Gets or sets if the password is required.
/// </summary>
public bool PasswordRequired
{
get
{
return this._passwordRequired;
}
set
{
if (value == this._passwordRequired)
{
return;
}
this._passwordRequired = value;
}
}
#endregion
#region Controls Event
private void FrmLogin_Load(object sender, EventArgs e)
{
panelSetIP.Visible = false;
this.Size = new Size(552, 384);//552, 486
linkLbl.Text = "设置↓";
GlobalSetting.ReadConfig();
txtSetIP.Text = GlobalSetting.IP;
txtPort.Text = GlobalSetting.Port;
//t.Focus();
txtUserID.Focus();
}
private void btnOk_Click(object sender, EventArgs e)
{
try
{
this.OkPressed();
}
catch (Exception ex)
{
MsgBox.Warn(ex.Message);
return;
}
}
private void btnCancle_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtPassWord_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (this.IsEntryComplete())
{
this.OkPressed();
}
else
{
if (this._passwordRequired && String.IsNullOrEmpty(this.txtPassWord.Text.Trim()))
{
this.ShowPasswordRequired();
}
}
e.Handled = true;
e.SuppressKeyPress = true;
}
}
#endregion
#region Other Method
/// <summary>
/// Raises the OkClicked event.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">A System.EventArgs that contains the event data.</param>
private void OnOkClicked(object sender, EventArgs e)
{
if (this.OkClicked != null)
{
this.OkClicked(sender, e);
}
}
private void OkPressed()
{
if (this.txtUserID.Text.Trim().Length == 0)
{
this.ShowUserRequired();
return;
}
if (this.PasswordRequired && String.IsNullOrEmpty(this.txtPassWord.Text.Trim()))
{
this.ShowPasswordRequired();
return;
}
this.txtUserID.Enabled = false;
this.txtPassWord.Enabled = false;
this.btnOk.Enabled = false;
if (this.panelSetIP.Visible == true)
{
GlobalSetting.IP = txtSetIP.Text.Trim();
GlobalSetting.Port = txtPort.Text.Trim();
GlobalSetting.SaveConfig();
}
Application.DoEvents();
this.StartAnimation();
Application.DoEvents();
this.OnOkClicked(this, new EventArgs());
}
private void StartAnimation()
{
if (this.Created)
{
if (!this.Disposing)
{
this.gradientAnimationLogon.Start();
}
}
}
/// <summary>
/// Shows the bad user name or password message.
/// </summary>
/// <remarks>
/// Also resets the dialog.
/// </remarks>
public void ShowBadUserPassword()
{
if (!this.Disposing)
{
this.Reset();
this.txtPassWord.Text = string.Empty;
this.txtPassWord.Focus();
}
}
/// <summary>
/// Resets the dialog and it's controls to their default states.
/// </summary>
public void Reset()
{
if (!this.Disposing)
{
this.gradientAnimationLogon.Stop();
Application.DoEvents();
this.txtUserID.Enabled = true;
this.txtPassWord.Enabled = true;
this.btnOk.Enabled = true;
}
}
private void ShowUserRequired()
{
if (!this.Disposing)
{
MsgBox.Warn("用户名必须填写。");
this.txtUserID.Focus();
}
}
private void ShowPasswordRequired()
{
if (!this.Disposing)
{
MsgBox.Warn("密码必须填写。");
this.txtPassWord.Focus();
}
}
/// <summary>
/// Determines if based on the current configuration has everything that is required been filed in.
/// </summary>
/// <returns>true or false</returns>
private bool IsEntryComplete()
{
bool returnValue = false;
if (!String.IsNullOrEmpty(this.txtUserID.Text.Trim()))
{
if (this._passwordRequired)
{
if (!String.IsNullOrEmpty(this.txtPassWord.Text.Trim()))
{
returnValue = true;
}
}
else
{
returnValue = true;
}
}
return returnValue;
}
#endregion
private void cboUserID_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (this.IsEntryComplete())
{
this.OkPressed();
}
else
{
if (String.IsNullOrEmpty(this.txtUserID.Text.Trim()))
{
this.ShowUserRequired();
}
else
{
this.txtPassWord.Focus();
}
}
e.Handled = true;
e.SuppressKeyPress = true;
}
}
private void linkLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (panelSetIP.Visible == false && linkLbl.Text == "设置↓")
{
this.Size = new Size(552, 486);
panelSetIP.Visible = true;
linkLbl.Text = "设置↑";
}
else
{
panelSetIP.Visible = false;
linkLbl.Text = "设置↓";
this.Size = new Size(552, 384);
}
}
private void cbUserID_TextChanged(object sender, EventArgs e)
{
txtPassWord.Text = string.Empty;
//checkPass.Checked = false;
}
private void txtUserID_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (this.IsEntryComplete())
{
this.OkPressed();
}
else
{
if (String.IsNullOrEmpty(this.txtUserID.Text.Trim()))
{
this.ShowUserRequired();
}
else
{
this.txtPassWord.Focus();
}
}
e.Handled = true;
e.SuppressKeyPress = true;
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using Crownwood.DotNetMagic.Forms;
using BLL;
using Utility;
using ListBar;
namespace Template
{
public partial class FrmMain : DotNetMagicForm
{
private UserBLL userBll = null;
PurchaseOrderBLL purchaseOrderBLL = new PurchaseOrderBLL();
public FrmMain()
{
InitializeComponent();
userBll = new UserBLL();
}
#region Form Event
private void FrmMain_Load(object sender, EventArgs e)
{
try
{
lblUserName.Text = "当前登录人:" + GlobalSetting.UserName;
lblDate.Text = " 登录时间:" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
ListBarItem[] itemsSys = new ListBarItem[8];
itemsSys[0] = new ListBarItem("角色管理", 0);
itemsSys[1] = new ListBarItem("用户管理", 1);
itemsSys[2] = new ListBarItem("备份数据", 6);
itemsSys[3] = new ListBarItem("修改密码", 2);
itemsSys[4] = new ListBarItem("切换用户", 3);
itemsSys[5] = new ListBarItem("系统锁定", 4);
itemsSys[6] = new ListBarItem("数据初始化", 7);
itemsSys[7] = new ListBarItem("退出系统", 5);
listBar.Groups.Add(new ListBarGroup("系统管理", itemsSys));
}
catch (Exception ex)
{
MsgBox.Warn(ex.Message);
return;
}
}
private void listBar_ItemClicked(object sender, ItemClickedEventArgs e)
{
if (e.MouseButton == MouseButtons.Left)
{
switch (e.Item.IconIndex)
{
case 0:
menuRoles_Click(null, null);
break;
case 1:
menuUser_Click(null, null);
break;
case 2:
menuChangePWD_Click(null, null);
break;
case 3:
menuChangeUser_Click(null, null);
break;
case 4:
menuLogout_Click(null, null);
break;
case 5:
menuExit_Click(null, null);
break;
case 6:
MenuLbl_Click(null, null);
break;
case 7:
MenuDeleteAll_Click(null, null);
break;
default:
break;
}
}
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
if (MsgBox.Ask("确定要退出系统吗?") != DialogResult.Yes)
{
e.Cancel = true;
}
}
catch (Exception ex)
{
MsgBox.Warn(ex.Message);
}
}
#endregion
private void menuAbout_Click(object sender, EventArgs e)
{
FrmAbout frmAbout = new FrmAbout();
frmAbout.ShowDialog();
}
private void menuExit_Click(object sender, EventArgs e)
{
this.Close();
}
public void menuLogout_Click(object sender, EventArgs e)
{
this.Visible = false;
FrmLock frmLock = new FrmLock();
frmLock.ShowDialog();
this.ShowInTaskbar = true;
this.WindowState = FormWindowState.Maximized;
this.Visible = true;
}
private void menuChangePWD_Click(object sender, EventArgs e)
{
FrmChangePwd frmChangePwd = new FrmChangePwd();
frmChangePwd.ShowDialog();
}
private void menuUser_Click(object sender, EventArgs e)
{
try
{
if (!userBll.ValidRoleByModule(GlobalSetting.UserCode, 1001))
{
MsgBox.Warn("您没有“用户管理”的权限。");
return;
}
FrmUser frmUser = FrmUser.Instance;
frmUser.MdiParent = this;
frmUser.Show();
frmUser.Activate();
}
catch (Exception ex)
{
MsgBox.Warn(ex.Message);
return;
}
}
private void menuRoles_Click(object sender, EventArgs e)
{
try
{
if (!userBll.ValidRoleByModule(GlobalSetting.UserCode, 1002))
{
MsgBox.Warn("您没有“角色管理”的权限。");
return;
}
FrmRoles frmRoles = FrmRoles.Instance;
frmRoles.MdiParent = this;
frmRoles.Show();
frmRoles.Activate();
}
catch (Exception ex)
{
MsgBox.Warn(ex.Message);
return;
}
}
private void menuChangeUser_Click(object sender, EventArgs e)
{
try
{
FrmChangeUser frmLogon = new FrmChangeUser();
if (frmLogon.ShowDialog() == DialogResult.OK)
{
lblUserName.Text = "当前登录人:" + GlobalSetting.UserName;
lblDate.Text = " 登录时间:" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
this.WindowState = FormWindowState.Maximized;
this.ShowInTaskbar = true;
}
}
catch (Exception ex)
{
MsgBox.Warn(ex.Message);
return;
}
}
private void menuCheckUpdate_Click(object sender, EventArgs e)
{
try
{
Process pro = new Process();