📄 loginbegin2.cs
字号:
// m_Shortcut1.Save();
}
catch
{
}
#endregion
#region 登录
if(conn.GetTableCount("RegOrgBase","RegOrgPwd = '"+ txtPwd.Text +"' and RegUserKey = '"+ AllStr.Key +"' ") == 1)
{
System.Net.IPAddress addr = new System.Net.IPAddress(System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0].Address);
JinrmGzglServ.GetGzglData jgs = null;
string _WebServiceUrl = AllStr.WebServiceUrl;
jgs = new GzglClient.JinrmGzglServ.GetGzglData(AllStr.WebServiceUrl);
jgs.SetDogLoginBegion(AllStr.Key,addr.ToString(),"");
AllStr.UserId = "1";
AllStr.UserName = "管理员";
AllStr.AreaId = conn.GetValueFromName("RegOrgAreaId","RegOrgBase","RegUserKey = '"+ AllStr.Key +"' ");
AllStr.OrgBaseId = conn.GetValueFromName("RegOrgName","RegOrgChild","RegUserKey = '"+ AllStr.Key +"' and IsFirst = 'True' ");
MianFrom mf = new MianFrom();
mf.Show();
this.Hide();
}
else
{
MessageBox.Show("你输入的帐号或密码错误!");
}
#endregion
}
private void btnCanel_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void LoginBegin2_Load(object sender, System.EventArgs e)
{
//AllStr.IsDebug = true;
#region 区划判断
string settingFilePath = Application.StartupPath + "//Config//App.xml";//配置文件路径
if(File.Exists(settingFilePath))//检测配置文件是否存在
{
DataSet ds = new DataSet();
ds.ReadXml(settingFilePath);//加载配置文件
if(ds.Tables[0].Rows[0]["SettingValue"].ToString() == "" || ds.Tables[0].Rows[1]["SettingValue"].ToString() == "")
{
frmAreaChoose fac = new frmAreaChoose();
fac.ShowDialog();
// frmSystemConfig fsc = new frmSystemConfig();
// fsc.ShowDialog();
}
}
else
{
MessageBox.Show("加载配置文件出错1!");
return;
}
#endregion
#region 加载配置文件
if(!PublicFuc.LoadSetting())
{
MessageBox.Show("加载配置文件出错2!");
}
#endregion
#region 状态检测
// bool flag = false;//线程状态标志
// this.Cursor = Cursors.WaitCursor;
// btnLogin.Enabled = false;
// if(!flag)
// {
// Thread tr = new Thread(new ThreadStart(GetUpdate));
// tr.IsBackground = true;
// tr.Start();
// }
// this.Cursor = Cursors.Default;
GetUpdate();
#endregion
txtPwd.Focus();
this.Text += " -- 审批部门: " + PublicFuc.GetAreaName(AllStr.AreaId) + " 工资处 (" + AllStr.AreaId + ")";
}
#region 初始化加载
private void GetUpdate()
{
//判断是否需要升级
GetUpdateInfo();
JinrmGzglServ.GetGzglData jgs = null;
string _WebServiceState = "";
string _WebServiceUrl = AllStr.WebServiceUrl;
#region 检测服务器状态
ShowState = "检查服务器状态...";
ShowLabel();
try
{
jgs = new GzglClient.JinrmGzglServ.GetGzglData(AllStr.WebServiceUrl);
_WebServiceState = jgs.GetWebServiceState();
ServerState = "服务器状态:" + _WebServiceState;
ShowLabel();
if(_WebServiceState == "正常")
{
LLBToUrl.Enabled = true;
}
}
catch
{
_WebServiceState = "无法连接服务器!";
ShowState = "无法连接服务器!";
ServerState = "服务器状态:" + _WebServiceState;
ShowLabel();
return;
}
#endregion
#region 加密狗检测
DataSet ds = jgs.GetBindInfoFromDogNum(AllStr.Key);
if(ds.Tables["RegOrgBase"].Rows.Count == 0 || ds.Tables["RegOrgChild"].Rows.Count == 0 )//服务器未绑定
{
#region 服务器未绑定
ShowState = "绑定单位!";
ShowLabel();
frmChooseOrg fco = new frmChooseOrg();
if(fco.ShowDialog() == DialogResult.OK)
{
ds = jgs.GetBindInfoFromDogNum(AllStr.Key);
ShowState = "绑定成功,请登录!";
ShowLabel();
btnLogin.Enabled = true;
}
#endregion
}
#region 服务器已经绑定--下载服务器信息
conn.ExecDelete("RegOrgBase","");
conn.ExecDelete("RegOrgChild","");
try
{
conn.ExecInsert("RegOrgBase","RegUserKey,RegOrgPwd,RegOrgAreaId,ContactsName,ContactsPhone",
"'"+ ds.Tables[0].Rows[0]["RegUserKey"].ToString() +"','"+ ds.Tables[0].Rows[0]["RegOrgPwd"].ToString() +"','"+ ds.Tables[0].Rows[0]["RegOrgAreaId"].ToString() +"','"+ ds.Tables[0].Rows[0]["ContactsName"].ToString() +"','"+ ds.Tables[0].Rows[0]["ContactsPhone"].ToString() +"' ");
for(int i=0;i<ds.Tables[1].Rows.Count;i++)
{
conn.ExecInsert("RegOrgChild","RegUserKey,RegOrgBaseId,RegOrgName,RegParentId,IsFirst",
"'"+ ds.Tables[1].Rows[i]["RegUserKey"].ToString() +"','"+ ds.Tables[1].Rows[i]["RegOrgBaseId"].ToString() +"','"+ ds.Tables[1].Rows[i]["OrgName"].ToString() +"','"+ ds.Tables[1].Rows[i]["RegParentId"].ToString() +"','"+ ds.Tables[1].Rows[i]["IsFirst"].ToString() +"' ");
}
}
catch
{
}
ShowState = "获取成功,请登录!";
ShowLabel();
btnLogin.Enabled = true;
#endregion
#endregion
}
#endregion
#region 判断是否需要升级
private void GetUpdateInfo()
{
#region 检测是否需要更新
string UpdatePath = Application.StartupPath + "\\Update";
string UpdateFilePath = UpdatePath + "\\Update.xml";
#region 下载更新文件
try
{
System.Net.WebClient myWebClient = new System.Net.WebClient();
// myWebClient.DownloadFile("http://gz.wukunsoft.com/UpdateFiles/Update.xml",UpdateFilePath);
// myWebClient.DownloadFile("http://gz.wukunsoft.com/UpdateFiles/GzglClientUpdate.exe",Application.StartupPath + "\\GzglClientUpdate.exe");
myWebClient.DownloadFile("http://218.92.102.27/GzWeb/UpdateFiles/Update.xml",UpdateFilePath);
myWebClient.DownloadFile("http://218.92.102.27/GzWeb/UpdateFiles/GzglClientUpdate.exe",Application.StartupPath + "\\GzglClientUpdate.exe");
}
catch
{
MessageBox.Show("未能连接到有效的更新服务器!");
}
#endregion
#region 比较版本号
if(File.Exists(UpdateFilePath))
{
DataSet ds = new DataSet();
ds.ReadXml(UpdateFilePath);
if(AllStr.Version != ds.Tables[0].Rows[0]["SettingValue"].ToString())
{
#region 打开更新程序
DialogResult result = MessageBox.Show(this, "检测到新版程序,是否现在更新?", "更新程序!", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if(result == DialogResult.Yes)
{
//声明一个程序信息类
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
//设置外部程序名
Info.FileName = "GzglClientUpdate.exe";
//设置外部程序的启动参数(命令行参数)为test.txt
Info.Arguments = "test.txt";
//设置外部程序工作目录为 C:\
Info.WorkingDirectory = Application.StartupPath + "\\";
//声明一个程序类
System.Diagnostics.Process Proc ;
try
{
//启动外部程序
Proc = System.Diagnostics.Process.Start(Info);
Application.Exit();
}
catch
{
MessageBox.Show("启动更新程序失败!");
}
}
else
{
Application.Exit();
}
#endregion
}
}
else
{
//MessageBox.Show("丢失重要配置文件,请重新安装软件,如需更新请至<http://218.92.102.27/gzAppUpdate>下载补丁程序,谢谢!");
}
#endregion
#endregion
}
#endregion
#region 判断服务返回值
private bool SetbtnLoginEnabled(string _WebServiceState)
{
switch(_WebServiceState)
{
case "正常":
return true;
default:
return false;
}
}
#endregion
#region 委托开始
delegate void ShowL();//ReceF
private void ShowLabel()
{
ShowL SL = new ShowL(ShowLabelMain);
this.BeginInvoke(SL);
}
private void ShowLabelMain()
{
labShowState.Text = ShowState;
labServerState.Text = ServerState;
}
#endregion
private void btnSetting_Click(object sender, System.EventArgs e)
{
frmAreaChoose fac = new frmAreaChoose();
if(fac.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(" 修改成功,请重新打开程序!");
Application.Exit();
}
}
private void LLBToUrl_LinkClicked_1(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
IE ie = new IE();
ie.Show();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -