Example #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtServer.Text.Trim() == "")
            {
                MessageBox.Show("請輸入資料庫Server名稱﹒然後再試一次﹒", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (rbtDataSQL.Checked)
            {
                if (txtUid.Text.Trim() == "")
                {
                    MessageBox.Show("請輸入資料庫使用者名稱﹒然後再試一次﹒", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            Js.BLL.Sys.SysComDal bll = new Js.BLL.Sys.SysComDal();
            string strCn = bll.GetConnection(this.txtServer.Text, DataBase, this.txtUid.Text, this.txtPwd.Text, this.rbtDataWind.Checked);
            if (strCn.Length > 0)
            {
                Js.Com.ConfigHelper.SetKeyValue(System.Windows.Forms.Application.ExecutablePath, "BusinessUnit", Js.Com.DEncrypt.DESEncrypt.Encrypt(strCn));

                Js.Com.User.ConnectStringBU = strCn;
                Js.Com.User.ServerBU = txtServer.Text.Trim();
                Js.Com.User.UidBU = txtUid.Text.Trim();
                Js.Com.User.PwdBU = this.txtPwd.Text.Trim();
                Js.Com.User.AuthenticationBU = this.rbtDataWind.Checked;

                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("因在初始化提供者時遭遇錯誤,系統登錄失敗.。", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }