init lserp cs 5.0
This commit is contained in:
@@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using System.Data;
|
||||
|
||||
using CommonLib.utils;
|
||||
using ERPClient.main;
|
||||
using CommonLib;
|
||||
|
||||
namespace ERPClient
|
||||
{
|
||||
public sealed class ClientMain
|
||||
{
|
||||
private static ClientMain _instance = null;
|
||||
public static ClientMain Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new ClientMain();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private ClientMain()
|
||||
{
|
||||
}
|
||||
|
||||
public void StartApp()
|
||||
{
|
||||
ERPInfo.Instance.WSName = PubUtil.GetMachineName();
|
||||
//c#连接数据库
|
||||
if (!DBConfig.Instance.CreateConnection())
|
||||
{
|
||||
MessageBox.Show("数据库连接不正常,请重新配置!错误码:001");
|
||||
RunConfigForm();
|
||||
return;
|
||||
}
|
||||
//delphi连接数据库
|
||||
StringBuilder ConStr = new StringBuilder();
|
||||
ConStr.Append(DBConfig.Instance.GetDelphiConStr());
|
||||
if (PubUtil.Delphi_Init(ConStr) == 0)
|
||||
{
|
||||
MessageBox.Show("数据库连接不正常,请重新配置!错误码:002");
|
||||
RunConfigForm();
|
||||
return;
|
||||
}
|
||||
//显示登陆窗体
|
||||
FrmLogin _frmLogin = new FrmLogin();
|
||||
_frmLogin.ShowDialog();
|
||||
PubUtil.ReleaseForm(_frmLogin);
|
||||
_frmLogin = null;
|
||||
//登陆正确方可继续下一步
|
||||
if (ERPInfo.Instance.LoginResult == false)
|
||||
return;
|
||||
//登陆正确后重新设置连接
|
||||
//delphi连接数据库
|
||||
ConStr.Clear();
|
||||
ConStr.Append(DBConfig.Instance.GetDelphiConStr());
|
||||
if (PubUtil.Delphi_Init(ConStr) == 0)
|
||||
{
|
||||
MessageBox.Show("数据库连接不正常,请重新配置!错误码:002");
|
||||
RunConfigForm();
|
||||
return;
|
||||
}
|
||||
|
||||
//记录登录日志
|
||||
PubUtil.WriteOpLog("", "", "登录软件", "进入操作", "系统登录");
|
||||
//换了用户重新写入登录用户
|
||||
if (DBConfig.Instance.LoginName != ERPInfo.Instance.EmployeeName)
|
||||
{
|
||||
DBConfig.Instance.LoginName = ERPInfo.Instance.EmployeeName;
|
||||
DBConfig.Instance.WriteConfig2();
|
||||
}
|
||||
//模拟服务器时间
|
||||
ServerTimer.StartTimer();
|
||||
//升级检查
|
||||
//if (DBConfig.Instance.GetUpdateFlag())
|
||||
//{
|
||||
// FrmDownLoad _frmDownload = new FrmDownLoad();
|
||||
// DialogResult _dialogResult = _frmDownload.ShowDialog();
|
||||
// PubUtil.ReleaseForm(_frmDownload);
|
||||
// _frmDownload = null;
|
||||
// if (_dialogResult != DialogResult.OK)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
//如果只有一个模块直接启动主界面
|
||||
DataTable dtSys = SqlHelper.ExecuteDataSet(CommandType.Text, "select * from P_SubSystemTab where UseEd=1 order by SubSysId", "P_SubSystemTab").Tables[0];
|
||||
if (dtSys != null && dtSys.Rows.Count == 1)
|
||||
{
|
||||
ERPInfo.Instance.SubCount = dtSys.Rows.Count;
|
||||
while (Program.m_bitMain == null)
|
||||
Thread.Sleep(100);
|
||||
ERPInfo.Instance.SubSysId = Convert.ToInt32(dtSys.Rows[0]["SubSysId"]);
|
||||
ERPInfo.Instance.SubSysName = dtSys.Rows[0]["SubSysName"].ToString();
|
||||
FrmMain frm = new FrmMain();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERPInfo.Instance.SubCount = dtSys.Rows.Count;
|
||||
GoSelectSubSystem();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换用户
|
||||
/// </summary>
|
||||
public void GoSwithUser()
|
||||
{
|
||||
ERPInfo.Instance.ExitResult = ENUMCloseAction.caNone;
|
||||
FrmMain _frmMain = new FrmMain();
|
||||
_frmMain.ShowDialog();
|
||||
PubUtil.ReleaseForm(_frmMain);
|
||||
_frmMain = null;
|
||||
if (ERPInfo.Instance.ExitResult == ENUMCloseAction.caNone)
|
||||
{
|
||||
ERPInfo.Instance.SubSysId = 0;
|
||||
GoSelectSubSystem();
|
||||
}
|
||||
if (ERPInfo.Instance.ExitResult == ENUMCloseAction.caRelogin)
|
||||
{
|
||||
GoSwithUser();
|
||||
}
|
||||
//记录登出日志
|
||||
PubUtil.WriteOpLog("", "", "退出软件", "软件退出", "系统登录");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动数据库配置
|
||||
/// </summary>
|
||||
private void RunConfigForm()
|
||||
{
|
||||
FrmConfig _frmConfig = new FrmConfig();
|
||||
_frmConfig.ShowDialog();
|
||||
PubUtil.ReleaseForm(_frmConfig);
|
||||
_frmConfig = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择子系统
|
||||
/// </summary>
|
||||
private void GoSelectSubSystem()
|
||||
{
|
||||
FrmSelSubSystem _frmSelSubSystem = new FrmSelSubSystem();
|
||||
if (_frmSelSubSystem.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
//记录登出日志
|
||||
PubUtil.WriteOpLog("", "", "退出软件", "软件退出", "系统登录");
|
||||
PubUtil.ReleaseForm(_frmSelSubSystem);
|
||||
return;
|
||||
}
|
||||
PubUtil.ReleaseForm(_frmSelSubSystem);
|
||||
_frmSelSubSystem = null;
|
||||
// ERPInfo.Instance.SubSysId = 1;
|
||||
//没有选择到正确子系统
|
||||
if (ERPInfo.Instance.SubSysId == 0)
|
||||
{
|
||||
//记录登出日志
|
||||
PubUtil.WriteOpLog("", "", "退出软件", "软件退出", "系统登录");
|
||||
return;
|
||||
}
|
||||
//设置delphi公用库参数
|
||||
ERPInfo.Instance.SetDephiDllParams();
|
||||
|
||||
ERPInfo.Instance.ExitResult = ENUMCloseAction.caNone;
|
||||
FrmMain _frmMain = new FrmMain();
|
||||
_frmMain.ShowDialog();
|
||||
|
||||
PubUtil.ReleaseForm(_frmMain);
|
||||
_frmMain = null;
|
||||
if (ERPInfo.Instance.ExitResult == ENUMCloseAction.caNone)
|
||||
{
|
||||
ERPInfo.Instance.SubSysId = 0;
|
||||
GoSelectSubSystem();
|
||||
}
|
||||
if (ERPInfo.Instance.ExitResult == ENUMCloseAction.caRelogin)
|
||||
{
|
||||
GoSwithUser();
|
||||
}
|
||||
//记录登出日志
|
||||
PubUtil.WriteOpLog("", "", "退出软件", "软件退出", "系统登录");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user