Beispiel #1
0
        private void button_OK_Click(object sender, System.EventArgs e)
        {
            if (textBox_url.Text == "")
            {
                MessageBox.Show(this, "尚未指定服务器URL...");
                return;
            }

            if (textBox_newPassword.Text != textBox_newPasswordConfirm.Text)
            {
                MessageBox.Show(this, "新密码和确认密码不一致,请重新输入...");
                return;
            }

            if (textBox_userName.Text == "")
            {
                MessageBox.Show(this, "尚未输入用户名。");
                return;
            }

            channel = Channels.GetChannel(textBox_url.Text);
            Debug.Assert(channel != null, "Channels.GetChannel 异常");

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在修改密码...");

            stop.BeginLoop();

            int nRet;
            string strError;

            EnableControls(false);
            button_Cancel.Text = "中断";


            nRet = channel.ChangePassword(
                textBox_userName.Text,
                textBox_oldPassword.Text,
                textBox_newPassword.Text,
                checkBox_manager.Checked,
                out strError);

            EnableControls(true);

            stop.EndLoop();

            stop.OnStop -= new StopEventHandler(this.DoStop);
            stop.Initial("");

            button_Cancel.Enabled = true;	// 因为Cancel按钮还有退出对话框的功能
            button_Cancel.Text = "取消";

            if (nRet == -1)
                goto ERROR1;

            channel = null;

            MessageBox.Show(this, "密码修改成功。");

            this.DialogResult = DialogResult.OK;
            this.Close();
            return;

        ERROR1:
            button_Cancel.Enabled = true;
            button_Cancel.Text = "取消";

            channel = null;
            MessageBox.Show(this, "修改密码失败,原因:" + strError);
        }