public void InitUserInterface() { try { //注册主窗口 MainFormMDI.MainMDIForm = this; MainFormMDI.MainTabManager = xtab_manager; MainFormMDI.OldBarSubItem = barOld; MainFormMDI.AccontTabControl = AccontForm.xtabAccont; MainFormMDI.AccontForm = AccontForm; MainFormMDI.RegOldBar = true; this.SuspendLayout(); YIESplashScreen.SendSplashScreenManager("加载用户界面..."); SetLookAndFeel(); //设置状态栏文本 SetStatusText(); YIESplashScreen.SendSplashScreenManager("下载当前登录用户权限窗口..."); //获取用户权限 LoadNavBar( ); YIESplashScreen.SendSplashScreenManager("加载系统导航窗口..."); this.ResumeLayout(); } catch (Exception ex) { Msg.ShowException(ex); } finally { SplashScreenManager.CloseForm(); } }
public static bool CheckServerDate() { YIESplashScreen.SendSplashScreenManager("获取系统时间...."); DateTime ldt_ServerDatetime; try { ldt_ServerDatetime = DateTime.Now; TimeSpan ts = ldt_ServerDatetime - DateTime.Now; //如果客户机时间和服务器时间相差2分钟以上,不允许进入系统 if (ts.Days > 0 || ts.Hours > 1 || ts.Minutes >= 2) { Msg.ShowError(string.Format("当前服务器时间和本地时间相差{0}天{1}小时{2}分", ts.Days.ToString(), ts.Hours.ToString(), ts.Minutes.ToString())); return(false); } } //连接数据库失败!! catch (Exception e) { Msg.ShowException(e); return(false); } return(true); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);//捕获系统所产生的异常。 Application.ApplicationExit += new EventHandler(Application_ApplicationExit); SplashScreenManager.ShowForm(typeof(YIESplashScreen)); YIESplashScreen.SendSplashScreenManager("读取用户配置..."); Program.CheckInstance(); //单个实例程序运行 SystemConfig.ReadSettings(); //读取用户配置 //账套服务器数据连接测试 YIESplashScreen.SendSplashScreenManager("测试数据库连接..."); if (!BridgeDataBase.InitializeBridge()) { Application.Exit(); OpenConnTools.OpenTools(); return; } YIESplashScreen.SendSplashScreenManager("注册控件和汉化信息..."); //注册皮肤 #region 注册皮肤 DevExpress.UserSkins.BonusSkins.Register(); DevExpress.Skins.SkinManager.EnableFormSkins(); UserLookAndFeel.Default.SetSkinStyle(SystemConfig.CurrentConfig.SkinName); #endregion #region 控件汉化 System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-Hans"); System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-Hans"); #endregion //YIESplashScreen.SendSplashScreenManager("检查系统更新..."); //if(CheckVision.YIEMISVision()) //{ // //执行更新方法 // Application.Exit(); //} YIESplashScreen.SendSplashScreenManager("系统登录信息"); //系统登录 //if( YIESetOfBooks.Login() ) if (LoginFrm.Login()) { //检查系统时间,相差2分钟以上不允许登录 //if (!CheckServerDate()) Application.Exit(); Program.YIEMainForm = new YIEMain(); //窗口初始化 Program.YIEMainForm.InitUserInterface(); Program.YIEMainForm.Show(); Application.Run(Program.YIEMainForm); } else//登录失败,退出程序 { Application.Exit(); } }