public void CheckStu() { if (hasStu != null) { hasStu.Clear(); } foreach (var item in allStu) { if (studentBll.IsHaveTheStu(item) > 0) { hasStu.Add(item); } } if (hasStu.Count() > 0) { Panel1.Visible = false; Panel2.Visible = true; } else //没有异常情况 { //直接导入文档中的学生信息 int res = 0; foreach (var item in allStu) { if (studentBll.AddStudent(item) > 0) { res = 1; } else { res = 0; break; } } if (res == 1) { hasStu.Clear(); allStu.Clear(); alert("导入考生信息成功", "WaitAuditManage.aspx"); } } }
protected void ButtonAdd_Click(object sender, EventArgs e) { Student student = new Student(); student.StudentNO = Int32.Parse(TextBoxStudentNO.Text); student.StudentName = TextBoxName.Text; student.StudentAge = Int32.Parse(TextBoxAge.Text); student.StudentSex = (RadioButtonSexMale.Checked ? "男" : "女"); student.StudentFaculty = DropDownListFaculty.SelectedValue; student.StudentProvience = DropDownListProvience.SelectedValue; StudentBLL bll = new StudentBLL(); bll.AddStudent(student); }
public ResultModel Post([FromBody] Student student) { try { _studentBLL.AddStudent(student); return(new ResultModel(Code.CREATED, "thành công")); } catch (Exception ex) { if (ex.Message.Contains("Mã sinh viên đã tồn tại")) { return(new ResultModel(Code.SVERROR, ex.Message.ToString())); } else { return(new ResultModel(Code.SVERROR, "lỗi hệ thống")); } } }
private void btnOk_Click(object sender, EventArgs e) { if (IsLegal()) { //取值 Student model = new Student(); model.Class_id = student.Class_id; model.Speciality_id = student.Speciality_id; model.Name = txtName.Text.Trim(); model.ID_Card = txtIDCard.Text.Trim(); model.Sex = cbSex.SelectedIndex; model.Nationality = txtNationality.Text.Trim(); model.Address = txtAddress.Text.Trim(); model.Phone = txtPhone.Text.Trim(); model.Political_role = txtPolitical_role.Text.Trim(); model.Posecode = txtPosecode.Text.Trim(); model.Remark = txtRemark.Text; model.Submitter_id = frmMain.current_user.Id; model.Photograph = string.IsNullOrEmpty(path) ?new byte[0] : GetbytesByImage(path); //添加的数据库 StudentBLL bll = new StudentBLL(); CCWin.MessageBoxEx.Show(bll.AddStudent(model) ? "录入成功!" : "录入失败,请检查数据后重试!"); } }
private void btnSave_Click(object sender, EventArgs e) { string no = this.txtNo.Text.Trim(); string name = this.txtName.Text.Trim(); string address = this.txtAddress.Text.Trim(); string email = this.txtEmail.Text.Trim(); string phone = this.txtPhone.Text.Trim(); string pwd = this.txtPwd.Text.Trim(); string cPwd = this.txtCPwd.Text.Trim(); DateTime bornDate = this.picBornDate.Value; string gender = this.rbtnMan.Checked ? "男" :"女"; Grade grade = this.cboGrade.SelectedItem as Grade; if (name.Length == 0 || pwd.Length == 0) { MessageBox.Show("您填写的信息不完整!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!IsUpdate && no.Length == 0) { MessageBox.Show("请填写学号!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (pwd != cPwd) { MessageBox.Show("两次密码输入不一致!", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Stu = new Student( no, pwd, name, gender, grade, phone, address, bornDate, email ); if (!this.IsUpdate) { List <Student> stus = StudentBLL.GetAllStudentByStuIdAndGender(); foreach (Student s in stus) { if (s.StudentNo == Stu.StudentNo) { MessageBox.Show("已有学号为" + Stu.StudentNo + "的学生", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } try { if (StudentBLL.AddStudent(Stu)) { MessageBox.Show("添加学生成功", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearControls(); } else { MessageBox.Show("添加学生失败", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("添加学生出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { try { if (StudentBLL.UpdateStudent(Stu)) { MessageBox.Show("修改学生信息成功", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("修改学生信息失败", "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("修改学生信息出现异常\n" + ex.Message, "系统提示 ", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public int AddStudent(Student s) { return(bll.AddStudent(s)); }