123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- 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.Toolkits;
- namespace WpfTest1
- {
- /// <summary>
- /// AddDoctor是添加医师的交互界面
- /// AddDoctor.xaml 的交互逻辑
- /// </summary>
- public partial class AddDoctor : Window
- {
- MainWindow father;
- //int check = 0;
- public AddDoctor(MainWindow father)
- {
- this.father = father;
- InitializeComponent();
- }
- /*
- private void radioButton_Checked(object sender, RoutedEventArgs e)
- {
- check = 1;
- }
- */
- //添加按钮
- private void addButtonClick(object sender, RoutedEventArgs e)
- {
- if (name.Text == "")
- {
- MessageBox.Show("请填写用户名!");
- name.Focus();
- return;
- }
- if (pwd.Password == "")
- {
- MessageBox.Show("请填写密码!");
- pwd.Focus();
- return;
- }
- if (pwd_1.Password == "")
- {
- MessageBox.Show("请填写确认密码!");
- pwd_1.Focus();
- return;
- }
- if (phone.Text == "")
- {
- MessageBox.Show("请填写联系电话!");
- phone.Focus();
- return;
- }
- if (pwd_1.Password != pwd.Password)
- {
- MessageBox.Show("两次输入的密码不一致,请重新输入!");
- pwd.Focus();
- return;
- }
- string doctor_name = FilterDangerousCharacter.filter(name.Text);
- string doctor_pwd = Toolkits.ComputeHash.GetMD5(FilterDangerousCharacter.filter(pwd.Password));
- string doctor_phone = FilterDangerousCharacter.filter(phone.Text);
- int doctor_dir_flag = 0;
- if ((Boolean)(radioButton.IsChecked)) doctor_dir_flag = 1;
- int doctor_del_flag = 0;
- bool success_flag = true;
- try
- {
- if (SQLite.SQLiteModel.checkRepeatDoctor(doctor_name))
- {
- MessageBox.Show("用户名选择重复,请选择新的用户名!");
- name.Focus();
- return;
- }
- SQLite.SQLiteModel.InsertDoctorData(doctor_name,
- doctor_pwd,
- doctor_phone,
- Convert.ToBoolean(doctor_dir_flag),
- Convert.ToBoolean(doctor_del_flag)
- );
- }
- catch (Exception err)
- {
- success_flag = false;
- MessageBox.Show("数据库错误.\r\n调试信息:" + err.Message, "错误");
- }
- if (success_flag)
- {
- MessageBox.Show("添加医生成功", "提示");
- father.LoadDoctorDataGrid();
- this.Close();
- }
- }
- //重置按钮
- private void resetButtonClick(object sender, RoutedEventArgs e)
- {
- name.Text = "";
- phone.Text = "";
- pwd.Password = "";
- pwd_1.Password = "";
- radioButton.IsChecked = false;
- name.Focus();
- }
- //取消按钮
- private void cancelButtonClick(object sender, RoutedEventArgs e)
- {
- MessageBoxResult dr = MessageBox.Show("是否放弃添加?", "提示", MessageBoxButton.OKCancel);
- if (dr == MessageBoxResult.OK)
- {
- this.Close();
- }
- else if (dr == MessageBoxResult.Cancel)
- {
- return;
- }
- //this.Close();
- }
- }
- }
|