예제 #1
0
        public void Back(object parameter)
        {
            UpdateUserWindow win = (UpdateUserWindow)parameter;

            if (win != null)
            {
                win.Close();
            }
        }
예제 #2
0
 public void JumpToUpdate(object parameter)
 {
     if (ID == 0)
     {
         MessageBox.Show("请选择要修改对象");
     }
     else
     {
         UpdateUserWindow a = new UpdateUserWindow();
         UpdateUserViewModel._id = ID;
         a.ShowDialog();
         LoadUserInfo();
         ID = 0;
     }
 }
예제 #3
0
        public void updateStudent(object parameter)
        {
            WriteLog("进行了修改操作");
            List <User>       list = new List <User>();
            SQLiteDataService ds   = new SQLiteDataService();

            list.Add(new User()
            {
                ID = ID, Name = Name, Age = Age, Sex = Sex, Remarks = Remarks
            });

            if (Name.Length > 18)
            {
                MessageBox.Show("姓名过长!");
                return;
            }

            if (Age > 100 || Age < 0)
            {
                MessageBox.Show("年龄输入有误!");
                return;
            }

            if (Sex.Length == 0)
            {
                MessageBox.Show("请选择性别");
                return;
            }

            if (Remarks.Length > 3)
            {
                MessageBox.Show("备注过长!");
                return;
            }

            if (list[0].Name == null)
            {
                MessageBox.Show("姓名不能为空");
                return;
            }
            Regex reg = new Regex(@"[^0-9]"); // 排除型字符组(取反思想)

            if (!reg.IsMatch(list[0].Name))
            {
                MessageBox.Show("请输入正确姓名");
                return;
            }
            if (list[0].Age <= 0 || list[0].Age >= 150 || list[0].Age.GetType() == list[0].Name.GetType())
            {
                MessageBox.Show("请输入正确年龄");
                return;
            }

            ds.UpdateUser(list);
            MessageBox.Show("修改成功");
            UpdateUserWindow win = (UpdateUserWindow)parameter;

            if (win != null)
            {
                win.Close();
            }
        }