Ejemplo n.º 1
0
        // return:
        //      0   Cancel
        //      1   OK
        int ResetSerialCode(
            bool bAllowSetBlank,
            string strOldSerialCode,
            string strOriginCode)
        {
            Hashtable ext_table = StringUtil.ParseParameters(strOriginCode);
            string strMAC = (string)ext_table["mac"];
            if (string.IsNullOrEmpty(strMAC) == true)
                strOriginCode = "!error";
            else
                strOriginCode = Cryptography.Encrypt(strOriginCode,
                this.CopyrightKey);
            SerialCodeForm dlg = new SerialCodeForm();
            dlg.Font = this.Font;
            dlg.DefaultCodes = new List<string>(new string[] {
                "community|社区版",
                "singleCommunity|单机版的社区版",
                "miniCommunity|小型版的社区版",
            });
            dlg.SerialCode = strOldSerialCode;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.OriginCode = strOriginCode;

        REDO:
            dlg.ShowDialog(this);
            if (dlg.DialogResult != DialogResult.OK)
                return 0;

            if (string.IsNullOrEmpty(dlg.SerialCode) == true)
            {
                if (bAllowSetBlank == true)
                {
                    DialogResult result = MessageBox.Show(this,
        "确实要将序列号设置为空?\r\n\r\n(一旦将序列号设置为空,dp2Library XE 将自动退出,下次启动需要重新设置运行模式和序列号。此时可重新选择评估模式运行,但数据库数量和可修改的记录数量都会受到一定限制)",
        "dp2Library XE",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question,
        MessageBoxDefaultButton.Button2);
                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        return 0;
                    }
                }
                else
                {
                    MessageBox.Show(this, "序列号不允许为空。请重新设置");
                    goto REDO;
                }
            }

            this.AppInfo.SetString("sn", "sn", dlg.SerialCode);
            this.AppInfo.Save();

            return 1;
        }
Ejemplo n.º 2
0
        // 出现对话框重新设置序列号
        // return:
        //      0   Cancel
        //      1   OK
        public static int ResetSerialCode(
            IWin32Window owner,
            string strTitle,
            bool bAllowSetBlank,
            ref string strSerialCode,
            string strOriginCode)
        {
            Hashtable ext_table = StringUtil.ParseParameters(strOriginCode);
            string strMAC = (string)ext_table["mac"];
            if (string.IsNullOrEmpty(strMAC) == true)
                strOriginCode = "!error";
            else 
                strOriginCode = Cryptography.Encrypt(strOriginCode,
                CopyrightKey);
            SerialCodeForm dlg = new SerialCodeForm();

            GuiUtil.AutoSetDefaultFont(dlg);

            if (string.IsNullOrEmpty(strTitle) == false)
                dlg.Text = strTitle;

            // dlg.Font = this.Font;
            dlg.SerialCode = strSerialCode;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.OriginCode = strOriginCode;

        REDO:
            dlg.ShowDialog(owner);
            if (dlg.DialogResult != DialogResult.OK)
                return 0;

            strSerialCode = dlg.SerialCode;

            if (string.IsNullOrEmpty(strSerialCode) == true)
            {
                if (bAllowSetBlank == true)
                {
                    DialogResult result = MessageBox.Show(owner,
        "确实要将序列号设置为空?\r\n\r\n(一旦将序列号设置为空,dp2Library 将按照最多 5 个前端方式运行)",
        "dp2Library",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question,
        MessageBoxDefaultButton.Button2);
                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        return 0;
                    }
                }
                else
                {
                    MessageBox.Show(owner, "序列号不允许为空。请重新设置");
                    goto REDO;
                }
            }

            return 1;
        }