1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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
- {
- /// <summary>
- /// ModifyDoctorPWD.xaml 的交互逻辑
- /// </summary>
- 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;
- }
- }
- }
- }
|