private void btnSave_Click(object sender, EventArgs e) { UserBLL bll = new UserBLL(); bool b = bll.Exists("1"); MessageBox.Show(b.ToString()); if (Vaildation() == false) { return; } User usr; usr = new User(); usr.Id = UserList.GenerateUserID(); usr.Name = tbName.Text; usr.Sex = cbSex.SelectedIndex; usr.Year = Convert.ToInt32(cbNewYear.Text); usr.Month = Convert.ToInt32(cbNewMonth.Text); usr.Day = Convert.ToInt32(cbNewDay.Text); usr.Hour = Convert.ToInt32(nudNewHour.Value); usr.Minute = Convert.ToInt32(nudNewMinte.Value); UserList.Add(usr); MessageBox.Show("保存成功.", "消息"); }
private void btnSave_Click(object sender, EventArgs e) { User usr; //usr = UserList.FindByName(this.tbName.Text); //if (UserList.IsExist(usr)) //{ // MessageBox.Show("该用户已经存在"); //} //else //{ usr = new User(); usr.Id = UserList.GenerateUserID(); usr.Name = tbName.Text; usr.Sex = cbSex.SelectedIndex; usr.Year = Convert.ToInt32(cbNewYear.Text); usr.Month = Convert.ToInt32(cbNewMonth.Text); usr.Day = Convert.ToInt32(cbNewDay.Text); usr.Hour = Convert.ToInt32(nudNewHour.Value); usr.Minute = Convert.ToInt32(nudNewMinte.Value); UserList.Add(usr); //} this.LoadUserList(); MessageBox.Show("保存成功.", "消息"); }