Ejemplo n.º 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            System.Diagnostics.Process[] papp = System.Diagnostics.Process.GetProcessesByName(Application.ProductName);
            if (papp.Length > 1)
            {
                SetForegroundWindow(Process.GetCurrentProcess().MainWindowHandle);
            }
            else
            {
                SetForegroundWindow(Process.GetCurrentProcess().MainWindowHandle);
            }

            Program.NowLoginMan = String.Empty;

            if (true)
            {
                bool isDB = true;
                while (isDB)
                {
                    try
                    {
                        SqlConnection conn = DBUtils.GetConnection();
                        if (conn.State == ConnectionState.Open)
                        {
                            conn.Close();
                            conn.Dispose();
                            isDB = false;
                        }
                        else
                        {
                            throw new Exception("指定的数据库不存在或者数据库配置错误!");
                        }
                    }
                    catch (Exception)
                    {
                        Global.ShowSysInfo("指定的数据库不存在或者数据库配置错误!");
                        DBConfig     dbconfig    = new DBConfig();
                        DialogResult dbconfigrtn = dbconfig.ShowDialog();
                        dbconfig.Dispose();

                        if (dbconfigrtn != DialogResult.OK)
                        {
                            return;
                        }
                    }
                }

                Program.CpuInfo = Publics.GetFirstMacAddress();
                // 判断是否首次注册
                SysRegister sr = SqlBaseProvider.GetSysRegister(Publics.GetRegisterNumber(Program.CpuInfo));

                // 如果未注册则进行注册
                if (String.IsNullOrEmpty(sr.DeptID))
                {
                    Register rgForm = new Register();
                    if (rgForm.ShowDialog() != DialogResult.OK)
                    {
                        Application.Exit();
                    }
                }
            }

            Login lg = new Login();

FirstLogined:
            DialogResult rtn = lg.ShowDialog();

            Program.NowLoginMan = lg.txtManID.Text;

            if (rtn == DialogResult.OK)
            {
GotoMain:
                Application.Run(new MainForm());
                if (isCancel)
                {
                    isCancel = false;
                    goto GotoMain;
                }
            }
            else if (rtn == DialogResult.Yes)
            {
                FirstLogin first = new FirstLogin();

                if (first.ShowDialog() == DialogResult.OK)
                {
                    goto FirstLogined;
                }
                else
                {
                    Application.Exit();
                }
            }
            else
            {
                Application.Exit();
            }
        }
Ejemplo n.º 2
0
        private void Password_Click(object sender, EventArgs e)
        {
            FirstLogin first = new FirstLogin();

            first.ShowDialog();
        }