/// <summary> /// Executes the save command /// </summary> private void SaveExecute() { try { // Creating the sector tblSector sec = new tblSector { SectorName = User.SectorName, }; sectorData.AddSector(sec); userData.AddUser(User); if (!bgWorker.IsBusy) { // This method will start the execution asynchronously in the background bgWorker.RunWorkerAsync(); } addUserWindow.Close(); } catch (Exception ex) { Debug.WriteLine("Exception" + ex.Message.ToString()); } }
public void Back(object parameter) { AddUserWindow win = (AddUserWindow)parameter; if (win != null) { win.Close(); } }
public void addStudent(object parameter) { WriteLog("进行了添加操作"); SQLiteDataService ds = new SQLiteDataService(); List <User> list = new List <User>(); list.Add(new User() { ID = 0, 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.InsertUser(list); MessageBox.Show("添加成功"); AddUserWindow win = (AddUserWindow)parameter; if (win != null) { win.Close(); } }
private void ExecuteAddCommand(object obj) { addUserWindow.DialogResult = true; addUserWindow.Close(); }