Esempio n. 1
0
    protected void Button_changePassword_Click(object sender, EventArgs e)
    {
        if (this.TextBox_newPassword.Text != this.TextBox_confirmNewPassword.Text)
        {
            this.Label_message.Text = "新密码 和 再输入一遍新密码 不一致。请重新输入。";
            return;
        }

        LibraryChannel channel = sessioninfo.GetChannel(true);

        try
        {
            string strError = "";
            long   lRet     = // sessioninfo.Channel.
                              channel.ChangeReaderPassword(
                null,
                this.TextBox_readerBarcode.Text,
                this.TextBox_oldPassword.Text,
                this.TextBox_newPassword.Text,
                out strError);
            if (lRet != 1)  // 2008/9/12 changed
            {
                this.Label_message.Text = strError;
                return;
            }
        }
        finally
        {
            sessioninfo.ReturnChannel(channel);
        }

        sessioninfo.Password = this.TextBox_newPassword.Text;
        // 注:这里登出,迫使读者重新登录,也是可以的做法

        this.Label_message.Text = "密码修改成功。";
    }
Esempio n. 2
0
        private void button_reader_changePassword_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.textBox_reader_barcode.Text == "")
            {
                MessageBox.Show(this, "尚未输入读者证条码号。");
                this.textBox_reader_barcode.Focus();
                return;
            }

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

            bool bOldPasswordEnabled = this.textBox_reader_oldPassword.Enabled;

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

            this.Update();
            this.MainForm.Update();

            this.EnableControls(false);

            try
            {
                long lRet = Channel.ChangeReaderPassword(
                    stop,
                    this.textBox_reader_barcode.Text,
                    bOldPasswordEnabled == false ? null : this.textBox_reader_oldPassword.Text,
                    this.textBox_reader_newPassword.Text,
                    out strError);
                if (lRet == 0)
                {
                    goto ERROR1;
                }
                if (lRet == -1)
                {
                    goto ERROR1;
                }
            }
            finally
            {
                this.EnableControls(true);

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

            MessageBox.Show(this, "读者密码已经被成功修改。");

            this.textBox_reader_barcode.SelectAll();
            this.textBox_reader_barcode.Focus();
            return;

ERROR1:
            MessageBox.Show(this, strError);

            // 焦点重新定位到密码输入域
            this.textBox_reader_oldPassword.Focus();
            this.textBox_reader_oldPassword.SelectAll();
        }