private void button_worker_changePassword_Click(object sender, EventArgs e) { string strError = ""; if (this.textBox_worker_userName.Text == "") { MessageBox.Show(this, "尚未输入用户名。"); this.textBox_worker_userName.Focus(); return; } if (this.textBox_worker_newPassword.Text != this.textBox_worker_confirmNewPassword.Text) { MessageBox.Show(this, "新密码 和 确认新密码不一致。请重新输入。"); this.textBox_worker_newPassword.Focus(); return; } stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在修改工作人员密码 ..."); stop.BeginLoop(); this.Update(); this.MainForm.Update(); this.EnableControls(false); try { long lRet = 0; // 非强制修改密码,即本人修改 if (this.checkBox_worker_force.Checked == false) { if (this.textBox_worker_userName.Text != "!changeKernelPassword") { // return: // -1 error // 0 登录未成功 // 1 登录成功 lRet = Channel.Login(this.textBox_worker_userName.Text, this.textBox_worker_oldPassword.Text, "type=worker,client=dp2circulation|" + Program.ClientVersion, out strError); if (lRet == -1) { goto ERROR1; } if (lRet == 0) { strError = "旧密码不正确"; goto ERROR1; } } try { lRet = Channel.ChangeUserPassword( stop, this.textBox_worker_userName.Text, this.textBox_worker_oldPassword.Text, this.textBox_worker_newPassword.Text, out strError); if (lRet == -1) { goto ERROR1; } } finally { string strError_1 = ""; Channel.Logout(out strError_1); } } // 强制修改密码 if (this.checkBox_worker_force.Checked == true) { UserInfo info = new UserInfo(); info.UserName = this.textBox_worker_userName.Text; info.Password = this.textBox_worker_newPassword.Text; // 当action为"resetpassword"时,则info.ResetPassword状态不起作用,无论怎样都要修改密码。resetpassword并不修改其他信息,也就是说info中除了Password/UserName以外其他成员的值无效。 lRet = Channel.SetUser( stop, "resetpassword", info, out strError); if (lRet == -1) { goto ERROR1; } } } finally { this.EnableControls(true); stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); } MessageBox.Show(this, "工作人员 '" + this.textBox_worker_userName.Text + "' 密码已经被成功修改。"); this.textBox_worker_userName.SelectAll(); this.textBox_worker_userName.Focus(); return; ERROR1: MessageBox.Show(this, strError); // 焦点重新定位到密码输入域 this.textBox_worker_oldPassword.Focus(); this.textBox_worker_oldPassword.SelectAll(); }
private void button_dp2library_changePassword_Click(object sender, EventArgs e) { string strError = ""; if (this.textBox_dp2library_userName.Text == "") { MessageBox.Show(this, "尚未输入用户名。"); this.textBox_dp2library_userName.Focus(); return; } if (this.textBox_dp2library_newPassword.Text != this.textBox_dp2library_confirmNewPassword.Text) { MessageBox.Show(this, "新密码 和 确认新密码不一致。请重新输入。"); this.textBox_dp2library_newPassword.Focus(); return; } stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在修改 dp2library 用户密码 ..."); stop.BeginLoop(); this.EnableControls(false); this.Update(); this.MainForm.Update(); try { long lRet = 0; // 获得server url if (String.IsNullOrEmpty(this.LibraryServerName) == true) { strError = "尚未指定服务器名"; goto ERROR1; } dp2Server server = this.MainForm.Servers.GetServerByName(this.LibraryServerName); if (server == null) { strError = "服务器名为 '" + this.LibraryServerName + "' 的服务器不存在..."; goto ERROR1; } string strServerUrl = server.Url; this.Channel = this.Channels.GetChannel(strServerUrl); // 非强制修改密码,即本人修改 if (this.checkBox_dp2library_force.Checked == false) { // return: // -1 error // 0 登录未成功 // 1 登录成功 lRet = Channel.Login(this.textBox_dp2library_userName.Text, this.textBox_dp2library_oldPassword.Text, "location=dp2Catalog,type=worker,client=dp2catalog|" + Program.ClientVersion, /* * "", * false, * */ out strError); if (lRet == -1) { goto ERROR1; } if (lRet == 0) { strError = "旧密码不正确"; goto ERROR1; } try { lRet = Channel.ChangeUserPassword( stop, this.textBox_dp2library_userName.Text, this.textBox_dp2library_oldPassword.Text, this.textBox_dp2library_newPassword.Text, out strError); if (lRet == -1) { goto ERROR1; } } finally { string strError_1 = ""; Channel.Logout(out strError_1); } } // 强制修改密码 if (this.checkBox_dp2library_force.Checked == true) { UserInfo info = new UserInfo(); info.UserName = this.textBox_dp2library_userName.Text; info.Password = this.textBox_dp2library_newPassword.Text; // 当action为"resetpassword"时,则info.ResetPassword状态不起作用,无论怎样都要修改密码。resetpassword并不修改其他信息,也就是说info中除了Password/UserName以外其他成员的值无效。 lRet = Channel.SetUser( stop, "resetpassword", info, out strError); if (lRet == -1) { goto ERROR1; } } } finally { this.EnableControls(true); stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); } MessageBox.Show(this, "dp2library 用户 '" + this.textBox_dp2library_userName.Text + "' 密码修改成功。"); this.textBox_dp2library_userName.SelectAll(); this.textBox_dp2library_userName.Focus(); return; ERROR1: MessageBox.Show(this, strError); // 焦点重新定位到密码输入域 this.textBox_dp2library_oldPassword.Focus(); this.textBox_dp2library_oldPassword.SelectAll(); }
private void button_dp2library_changePassword_Click(object sender, EventArgs e) { string strError = ""; if (this.textBox_dp2library_userName.Text == "") { MessageBox.Show(this, "尚未输入用户名。"); this.textBox_dp2library_userName.Focus(); return; } if (this.textBox_dp2library_newPassword.Text != this.textBox_dp2library_confirmNewPassword.Text) { MessageBox.Show(this, "新密码 和 确认新密码不一致。请重新输入。"); this.textBox_dp2library_newPassword.Focus(); return; } stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在修改 dp2library 用户密码 ..."); stop.BeginLoop(); this.EnableControls(false); this.Update(); this.MainForm.Update(); try { long lRet = 0; // 获得server url if (String.IsNullOrEmpty(this.LibraryServerName) == true) { strError = "尚未指定服务器名"; goto ERROR1; } dp2Server server = this.MainForm.Servers.GetServerByName(this.LibraryServerName); if (server == null) { strError = "服务器名为 '" + this.LibraryServerName + "' 的服务器不存在..."; goto ERROR1; } string strServerUrl = server.Url; this.Channel = this.Channels.GetChannel(strServerUrl); // 非强制修改密码,即本人修改 if (this.checkBox_dp2library_force.Checked == false) { // return: // -1 error // 0 登录未成功 // 1 登录成功 lRet = Channel.Login(this.textBox_dp2library_userName.Text, this.textBox_dp2library_oldPassword.Text, "location=dp2Catalog,type=worker", /* "", false, * */ out strError); if (lRet == -1) { goto ERROR1; } if (lRet == 0) { strError = "旧密码不正确"; goto ERROR1; } try { lRet = Channel.ChangeUserPassword( stop, this.textBox_dp2library_userName.Text, this.textBox_dp2library_oldPassword.Text, this.textBox_dp2library_newPassword.Text, out strError); if (lRet == -1) goto ERROR1; } finally { string strError_1 = ""; Channel.Logout(out strError_1); } } // 强制修改密码 if (this.checkBox_dp2library_force.Checked == true) { UserInfo info = new UserInfo(); info.UserName = this.textBox_dp2library_userName.Text; info.Password = this.textBox_dp2library_newPassword.Text; // 当action为"resetpassword"时,则info.ResetPassword状态不起作用,无论怎样都要修改密码。resetpassword并不修改其他信息,也就是说info中除了Password/UserName以外其他成员的值无效。 lRet = Channel.SetUser( stop, "resetpassword", info, out strError); if (lRet == -1) goto ERROR1; } } finally { this.EnableControls(true); stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); } MessageBox.Show(this, "dp2library 用户 '" + this.textBox_dp2library_userName.Text + "' 密码已经被成功修改。"); this.textBox_dp2library_userName.SelectAll(); this.textBox_dp2library_userName.Focus(); return; ERROR1: MessageBox.Show(this, strError); // 焦点重新定位到密码输入域 this.textBox_dp2library_oldPassword.Focus(); this.textBox_dp2library_oldPassword.SelectAll(); }