using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using WpfTest1.SQLite; namespace WpfTest1 { /// /// ModifyDoctorPWD.xaml 的交互逻辑 /// public partial class ModifyDoctorPWD : Window { string id; MainWindow father; doctor target; public ModifyDoctorPWD(MainWindow father,string id) { InitializeComponent(); this.father = father; if (id == "") { MessageBox.Show("未查找到该记录", "错误"); this.Close(); } this.id = id; try { target = SQLite.SQLiteModel.getDoctorById(id); if (target == null) { MessageBox.Show("未查找到该记录", "错误"); this.Close(); } } catch (Exception err) { MessageBox.Show("数据库错误\r\n调试信息:" + err.Message + "\r\n" + err.StackTrace, "错误"); this.Close(); } } private void buttonSubmit_Click(object sender, RoutedEventArgs e) { if(passwordBoxNewPWD.Password != passwordBoxRepeatBox.Password) { MessageBox.Show("两次输入密码不一致","提示"); return; } else { bool success_flag = true; try { string pwdHash = Toolkits.ComputeHash.GetMD5(Toolkits.FilterDangerousCharacter.filter(passwordBoxNewPWD.Password)); bool director_flag = target.director_flag == 1 ? true : false; SQLiteModel.UpdateDoctorData(target.id.ToString(), target.name, pwdHash, target.phone_number, director_flag, false); } catch(Exception err) { success_flag = false; MessageBox.Show("数据库故障\r\n调试信息:"+err.StackTrace,"错误"); } if (success_flag) { MessageBox.Show("修改成功","提示"); this.Close(); } } } private void buttonCancel_Click(object sender, RoutedEventArgs e) { MessageBoxResult dr = MessageBox.Show("是否放弃添加?", "提示", MessageBoxButton.OKCancel); if (dr == MessageBoxResult.OK) { this.Close(); } else if (dr == MessageBoxResult.Cancel) { return; } } } }