📄 frmmain.cs
字号:
public WWAM.BLL.UserInfo UInfo
{
get
{
return uinfo;
}
}
public WWAM.BLL.SysSetting SysSet
{
get
{
return sysset;
}
}
Thread thdDBA;
bool thdKeyDBA = true;
int thdCountDBA = 0;
#endregion
#region MainForm Event
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
ActiveChinese();
thdDBA = new Thread(new ThreadStart(this.thdDBAProcess));
this.barIUserName.Caption = this.uinfo.Data.Name;
this.barIUserDuty.Caption = this.uinfo.Data.Duty;
this.barIVersion.Caption = WWAM.BLL.Global.PROGRAM_NAME+" "+WWAM.BLL.Global.PROGRAM_VERSION;
this.barICopyright.Caption = WWAM.BLL.Global.PROGRAM_COPYRIGHT;
refreshSettingMethod();
this.Text = WWAM.BLL.Global.PROGRAM_NAME;
login = new WWAM.Forms.Dlg.DlgFrmLogin();
about = new WWAM.Forms.Dlg.DlgFrmAbout(this);
msg = new WWAM.Forms.Dlg.DlgFrmMsg(this);
setting = new WWAM.Forms.Dlg.DlgFrmSysSet(this);
changepassword = new WWAM.Forms.Dlg.DlgFrmChangePassword(this);
MenuShow();
form.WaitContinue = false;
thdDBA.Start();
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing (e);
if(this.MdiChildren.Length>0)
{
if(msg.ShowQuestion("还有工作窗口没有关闭,\r\n您确定要退出系统吗?","系统退出")!=DialogResult.OK)
{
e.Cancel = true;
return;
}
}
WWAM.DBA.Common.DBLogout(uinfo.Loginid,sqlcon);
}
protected override void OnClosed(EventArgs e)
{
thdKeyDBA = false;
base.OnClosed (e);
}
#endregion
#region Thread Process Method
#region thdDBA
void thdDBAProcess()
{
while(thdKeyDBA)
{
if(thdCountDBA==9*60)
{
WWAM.DBA.Common.DBAccess(uinfo.Loginid,sqlcon);
thdCountDBA = 0;
}
else
{
thdCountDBA ++;
}
Thread.Sleep(1000);
}
}
#endregion
#endregion
#region Method
#region MenuShow
void MenuShow()
{
bool admin = this.uinfo.Data.AdminFlag;
bool single = this.sysset.SingleMode;
this.nbGOperetion.Visible = this.uinfo.Purview.MPG1 || admin;
this.nbIAdvRegist.Visible = this.uinfo.Purview.MPG1I1 && !admin;
this.nbIAdvAuth.Visible = (this.uinfo.Purview.MPG1I2 && !admin) && !single;
this.nbIAdvPay.Visible = (this.uinfo.Purview.MPG1I3 && !admin) && !single;
this.nbIAdvReport.Visible = this.uinfo.Purview.MPG1I4 || admin;
this.nbIAdvModel.Visible = this.uinfo.Purview.MPG1I5 && !admin;
this.nbGManager.Visible = this.uinfo.Purview.MPG2 || admin;
this.nbIMgrUser.Visible = this.uinfo.Purview.MPG2I1 || admin;
this.nbIMgrInfo.Visible = this.uinfo.Purview.MPG2I2 || admin;
this.nbIMgrLogin.Visible = this.uinfo.Purview.MPG2I3 || admin;
this.nbIMgrDataBack.Visible = false; //this.uinfo.Purview.MPG2I4 || admin;
this.nbISysSetting.Visible = admin;
if(this.nbGOperetion.Visible)
{
this.nbGOperetion.Expanded = true;
this.nbGManager.Expanded = false;
this.nbGNormal.Expanded = false;
}
else
{
if(this.nbGManager.Visible)
{
this.nbGOperetion.Expanded = false;
this.nbGManager.Expanded = true;
this.nbGNormal.Expanded = false;
}
else
{
this.nbGOperetion.Expanded = false;
this.nbGManager.Expanded = false;
this.nbGNormal.Expanded = true;
}
}
}
#endregion
#region RefreshSetting
public void RefreshSetting()
{
if(this.IsHandleCreated)
this.BeginInvoke(new refreshSettingDelegate(this.refreshSettingMethod));
else
refreshSettingMethod();
}
delegate void refreshSettingDelegate();
void refreshSettingMethod()
{
this.barIMode.Caption = sysset.SingleMode?"单机版":"网络版";
}
#endregion
#endregion
#region navBarMenu Event
#region 增强Group开关
private void navBarMenu_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button==MouseButtons.Left)
{
NavBarHitInfo hitInfo = navBarMenu.CalcHitInfo(new Point(e.X,e.Y));
if(hitInfo.InGroupCaption && !hitInfo.InGroupButton)
{
hitInfo.Group.Expanded = !hitInfo.Group.Expanded;
}
}
}
#endregion
#region 保证只有一个Group展开
private void navBarMenu_GroupExpanded(object sender, DevExpress.XtraNavBar.NavBarGroupEventArgs e)
{
foreach(NavBarGroup nbg in navBarMenu.Groups)
{
if(nbg.Visible && nbg.Expanded && nbg.Name!=e.Group.Name)
{
nbg.Expanded = false;
}
}
}
#endregion
#region NavBarItem ClickEvent
private void navBarMenu_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
{
string[] dlgmode = new string[]{"系统锁定","更换用户","修改密码","系统退出","关于","系统设置"};
if(Array.IndexOf(dlgmode, e.Link.Caption)!= -1)
SystemBtnClick(e.Link.Caption);
else
AddNewForm(e.Link.Item,e.Link.Caption);
}
#endregion
#region SystemBtnClick
private void SystemBtnClick(string name)
{
switch(name)
{
case "系统锁定":
#region 系统锁定
bool syslock = true;
this.Visible = false;
while(syslock)
{
syslock = (login.ShowDialog(this.uinfo.Data.Code,this.uinfo.Data.Password)!=DialogResult.OK);
}
this.Visible = true;
#endregion
break;
case "更换用户":
#region 更换用户
if(login.ShowDialog(this.uinfo.Data.Code)==DialogResult.OK)
{
int rv = WWAM.DBA.Common.DBReLogin(this.uinfo.Loginid,login.UserCode,login.UserPassword,WWAM.SysInfo.HardWare.IPString,sqlcon);
if(rv > 0)
{
this.uinfo.GetData(login.UserCode,sqlcon);
this.uinfo.Loginid = rv;
this.barIUserName.Caption = this.uinfo.Data.Name;
this.barIUserDuty.Caption = this.uinfo.Data.Duty;
foreach(Form form in this.MdiChildren)
{
form.Close();
}
MenuShow();
}
else
{
switch(rv)
{
case -1:
msg.ShowWarning("用户帐号不存在!");
break;
case -2:
msg.ShowWarning("用户帐号已停用!");
break;
case -3:
msg.ShowWarning("用户帐号禁止登录!");
break;
case -4:
msg.ShowWarning("用户密码不正确!");
break;
case -5:
msg.ShowWarning("用户在别处登陆!");
break;
case -99:
msg.ShowWarning(string.Format("数据库错误!\r\n{0}",sqlcon.LastError));
break;
default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -