Ejemplo n.º 1
0
        private void form_load_func()
        {
            //while (true)
            //{
            //}
            work_progress = "正在获取软件版本号...";
            productName   = "";
            int cur_version = get_current_version(ref productName);

            //if (productName == "收银" || productName == "前台")
            //    register.Visible = true;
            //else
            //    register.Visible = false;

            work_progress = "正在检测网络连接...";
            db            = new BathDBDataContext(connectionString);
            if (!db.DatabaseExists())
            {
                BathClass.printErrorMsg("连接IP不对或者网络不通,请重试!");
                this.Close();
                return;
                //PCListForm pCListForm = new PCListForm();
                //if (pCListForm.ShowDialog() != DialogResult.OK)
                //{
                //    //_logIn_progress_form.Close();
                //    this.Close();
                //    return;
                //}

                //connectionIP = pCListForm.ip;
                //BathClass.set_config_by_key("connectionIP", connectionIP);
                //db = new BathDBDataContext(connectionString);
                //if (!db.DatabaseExists())
                //{
                //    BathClass.printErrorMsg("连接IP不对或者网络不通,请重试!");
                //    //_logIn_progress_form.Close();
                //    this.Close();
                //    return;
                //}
            }

            work_progress = "正在检测软件版注册序列号...";
            //if (productName == "收银" || productName == "前台")
            //{
            if (!RegisterForm.registered())
            {
                hasRegistered = false;
            }

            if (hasRegistered)
            {
                register.Visible = false;
            }
            else if (!hasRegistered && !checkTrialTimes())
            {
                okBtn.Enabled = false;
            }
            //}

            work_progress = "正在读取软件用户名...";
            read_users();
            id.Items.AddRange(idList.ToArray());
            if (id.Items.Count != 0)
            {
                id.Text = id.Items[0].ToString();
            }

            current_box = id;
            current_box.Focus();

            work_progress = "正在从服务器获取最新软件版本号...";
            BathClass.download_file(connectionIP, "version.ini", productName + "/version.ini");
            int new_version = read_version();

            if (new_version > cur_version)
            {
                //_logIn_progress_form.Close();
                start_updtate();
                this.Close();
                return;
            }
            updateSystemTime();
            //_logIn_progress_form.Close();
        }