protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CourseTableBLL ctBLL = new CourseTableBLL(); ClassBLL classBLL = new ClassBLL(); CourseBLL courBLL = new CourseBLL(); TeacherBLL teachBLL = new TeacherBLL(); DropDownList_class.DataSource = classBLL.getAll(); DropDownList_class.DataTextField = "name"; DropDownList_class.DataValueField = "ID"; DropDownList_class.DataBind(); DropDownList_course.DataSource = courBLL.getByClassId(DropDownList_class.SelectedValue); DropDownList_course.DataTextField = "name"; DropDownList_course.DataValueField = "ID"; DropDownList_course.DataBind(); string filterTeacher = "classID='" + DropDownList_class.SelectedValue + "' and courId='" + DropDownList_course.SelectedValue + "'"; DataTable tempDt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filterTeacher, null, false); DataView dv = tempDt.DefaultView; tempDt = dv.ToTable(true, "teachID"); foreach (DataRow dr in tempDt.Rows) { Teacher teacher = teachBLL.get(dr["teachID"].ToString()); DropDownList_teacher.Items.Add(new ListItem(teacher.Name, teacher.Id)); } bind(); } }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { string id = Request.QueryString["ID"].ToString(); string week = Request.QueryString["week"].ToString(); CourseBLL courBLL = new CourseBLL(); TeacherBLL teacherBLL = new TeacherBLL(); ClassBLL classBLL = new ClassBLL(); CourseTableBLL ctBLL = new CourseTableBLL(); ct = ctBLL.get(id); #region 页面数据绑定 Label_course.Text = courBLL.get(ct.CourId).Name; Label_teacher.Text = teacherBLL.get(ct.TeachID).Name; Label_class.Text = classBLL.get(ct.ClassID).Name; PageUtil.bindDropDownList(DropDownList_semester_from, ct.Semester.Substring(0, 4)); PageUtil.bindDropDownList(DropDownList_semester_to, ct.Semester.Substring(5, 4)); PageUtil.bindDropDownList(DropDownList_semester_end, ct.Semester.Substring(9, 3)); PageUtil.bindDropDownList(DropDownList_week_from, week.Split('-')[0]); PageUtil.bindDropDownList(DropDownList_week_to, week.Split('-')[1]); PageUtil.bindDropDownList(DropDownList_weekDay, ct.WeekDay); TextBox_place.Text = ct.Place; PageUtil.bindDropDownList(DropDownList_courseTime, ct.CourseTime.Split('节')[0]); #endregion }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ClassBLL classBLL = new ClassBLL(); CourseBLL courBLL = new CourseBLL(); TeacherBLL teachBLL = new TeacherBLL(); //绑定页面查询条件的数据 DropDownList_class.DataSource = classBLL.getAll(); DropDownList_class.DataTextField = "name"; DropDownList_class.DataBind(); DropDownList_class.Items.Insert(0, "全部班级"); DropDownList_course.DataSource = courBLL.getAll(); DropDownList_course.DataTextField = "name"; DropDownList_course.DataBind(); DropDownList_course.Items.Insert(0, "全部课程"); DropDownList_teacher.DataSource = teachBLL.getTeachers(); DropDownList_teacher.DataTextField = "name"; DropDownList_teacher.DataBind(); DropDownList_teacher.Items.Insert(0, "全部教师"); bind(); } }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { TeacherBLL teachBLL = new TeacherBLL(); string name = TextBox_name.Text.Trim(); string gender = RadioButton_male.Checked ? "男" : "女"; string birth = DropDownList_yearPart1.SelectedValue + DropDownList_yearPart2.SelectedValue + DropDownList_yearPart3.SelectedValue + DropDownList_yearPart4.SelectedValue; birth += DropDownList_month.SelectedValue; string title = DropDownList_title.SelectedValue; string phone = TextBox_phone.Text.Trim(); string email = TextBox_email.Text.Trim(); if (!teacher.Title.Equals(title)) { UserBLL userBLL = new UserBLL(); User user = userBLL.get(teacher.UserID); user.Type = title.Equals("辅导员") ? "2" : "1"; userBLL.update(user); } teacher.Name = name; teacher.Gender = gender; teacher.Birth = birth; teacher.Title = title; teacher.Phone = phone; teacher.Email = email; teachBLL.update(teacher); Response.Write("<script>alert('修改成功!');location.href='showTeachers.aspx';</script>"); } }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { string id = Request.QueryString["id"].ToString(); AttendanceBLL attendBLL = new AttendanceBLL(); attend = attendBLL.get(id); CourseTableBLL ctBLL = new CourseTableBLL(); CourseTable ct = ctBLL.get(attend.CourTableID); ClassBLL classBLL = new ClassBLL(); TeacherBLL teacherBLL = new TeacherBLL(); CourseBLL courseBLL = new CourseBLL(); StudentBLL stuBLL = new StudentBLL(); #region 绑定页面数据 Label_class.Text = classBLL.get(ct.ClassID).Name; Label_course.Text = courseBLL.get(ct.CourId).Name; Label_teacher.Text = teacherBLL.get(ct.TeachID).Name; Label_student.Text = stuBLL.get(attend.StudID).Name; Label_oldStatus.Text = attend.Status; Label_week.Text = ct.Week; Label_weekDay.Text = ct.WeekDay; Label_courseTime.Text = ct.CourseTime; Label_place.Text = ct.Place; #endregion }
public string GetTeacherList() { TeacherBLL bll = new TeacherBLL(); DataSet ds = bll.GetAllList(); return(ds.Tables[0].ToJson()); }
private void TeacherRemove_Click(object sender, EventArgs e)//删除按钮 { var rows = TeacherList.SelectedRows; if (rows.Count > 0) { DialogResult result = MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.OKCancel); if (result == DialogResult.Cancel) { return; } string tno = rows[0].Cells[0].Value.ToString(); TeacherBLL teacherBLL = new TeacherBLL(); if (teacherBLL.Remove(tno)) { MessageBox.Show("删除成功"); LoadTeacherList(); } else { MessageBox.Show("删除失败"); } } else { MessageBox.Show("请选择要删除的行"); } }
public string ShowEditInfo(int id) { TeacherBLL bll = new TeacherBLL(); TeacherModel mod = bll.GetModel(id); return(mod.ToJson()); }
//确定修改 private void ucBtnSave_BtnClick(object sender, EventArgs e) { if (!Check.isTeacherID(txtTID.Text)) { MessageBox.Show("工号不正确"); return; } try { teacher.TID = txtTID.Text; teacher.TName = txtName.Text; teacher.Address = txtAddress.Text; teacher.TSalary = Convert.ToDecimal(txtTSalary.Text); teacher.TGender = cmbGender.Text; teacher.Departments = cmbDepart.SelectedValue.ToString(); teacher.Birthday = Convert.ToDateTime(dtpBir.Value.ToString("yyy/MM/dd")); teacher.AdmissionTime = Convert.ToDateTime(dtpAdmission.Value.ToString("yyy/MM/dd")); teacher.Image = (Bitmap)pictureBox1.Image; TeacherBLL bll = new TeacherBLL(); string msg = bll.EditTeacher(teacher) ? "修改成功" : "修改失败"; MessageBox.Show(msg); LoadTeacherInfo(); } catch (Exception) { MessageBox.Show("修改失败"); } }
/// <summary> /// 考试信息发布页面显示 /// </summary> /// <returns></returns> public ActionResult ExamRelease() { // 获取教师信息 User user = (User)Session["User"]; Guid userId = user.ID; DataTable userTable = new TeacherBLL().GetTeacher(userId); ViewBag.TeacherName = userTable.Rows[0]["Name"]; ViewBag.CourseName = userTable.Rows[0]["CourseName"]; // 教师任课的所有班级 DataTable classTable = new ClassBLL().GetTeacherAllClass(userId); // 教师专业的题库数据 Guid courseId = Guid.Parse(userTable.Rows[0]["CourseID"].ToString()); DataTable singleTable = new SingleBLL().GetSingleOptinsByCourse(courseId); DataTable judegTable = new JudgeBLL().GetJudgeOptinsByCourse(courseId); // 打包DataSet传到前端 DataSet ds = new DataSet(); ds.Tables.Add(singleTable); ds.Tables.Add(judegTable); ds.Tables.Add(classTable); return(View(ds)); }
private void bind() { string id = Request.QueryString["id"].ToString(); ClassBLL classBLL = new ClassBLL(); clazz = classBLL.get(id); //初始化DropDownList_teacher的绑定值 TeacherBLL teachBLL = new TeacherBLL(); DropDownList_teacher.DataSource = teachBLL.getClassTeachers(); DropDownList_teacher.DataTextField = "name"; DropDownList_teacher.DataValueField = "ID"; DropDownList_teacher.DataBind(); //初始化DropDownList_monitor的绑定值 StudentBLL studBLL = new StudentBLL(); DropDownList_monitor.DataSource = studBLL.getByClassId(id); DropDownList_monitor.DataTextField = "name"; DropDownList_monitor.DataValueField = "ID"; DropDownList_monitor.DataBind(); DropDownList_monitor.Items.Insert(0, "无"); TextBox_className.Text = clazz.Name; PageUtil.bindDropDownList(DropDownList_depart, clazz.Depart); PageUtil.bindDropDownList(DropDownList_grade, clazz.Grade); PageUtil.bindDropDownList(DropDownList_teacher, clazz.TeacherID); PageUtil.bindDropDownList(DropDownList_monitor, clazz.MonitorID); }
public JsonResult GetById([FromForm] int courseId) { DataResult dr = new DataResult(); try { CourseBLL courseBLL = new CourseBLL(); CourseEntity courseEntity = courseBLL.GetById(courseId); courseEntity.videoUrl = ""; TeacherBLL teacherBLL = new TeacherBLL(); courseEntity.teacherEntity = teacherBLL.GetById(courseEntity.teacherId); CourseOrderBLL courseOrderBLL = new CourseOrderBLL(); courseEntity.countSold = courseOrderBLL.GetCountByCourseId(courseEntity.courseId); dr.code = "200"; dr.data = courseEntity; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { string courTableID = Request.QueryString["courTableID"]; CourseTableBLL ctBLL = new CourseTableBLL(); TeacherBLL teacherBLL = new TeacherBLL(); CourseBLL courBLL = new CourseBLL(); ClassBLL classBLL = new ClassBLL(); CourseTable ct = ctBLL.get(courTableID); Class clazz = classBLL.get(ct.ClassID); #region 页面数据绑定 className.Text = clazz.Name; courseName.Text = courBLL.get(ct.CourId).Name; teacherName.Text = teacherBLL.get(ct.TeachID).Name; week.Text = "第" + ct.Week + "周"; weekDay.Text = ct.WeekDay; classtTime.Text = ct.CourseTime; classAddress.Text = ct.Place; CommonBLL commBLL = new CommonBLL(); DataTable dt = commBLL.getAbsentStudent(courTableID, false); AspNetPager1.RecordCount = dt.Rows.Count; int from = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1; int to = from + AspNetPager1.PageSize - 1 > AspNetPager1.RecordCount ? AspNetPager1.RecordCount : from + AspNetPager1.PageSize - 1; GridView1.DataSource = PageUtil.getPaged(dt, from, to); GridView1.DataBind(); #endregion }
private void tnoLoadTeachCourseList(string tname)//指定教师开课信息表数据源 { TeacherBLL miBll = new TeacherBLL(); TeacherCourseBLL mibll = new TeacherCourseBLL(); dataGridView4.DataSource = mibll.tnoGetList(miBll.tnameGetTno(tname)); }
void GetBan() { TeacherBLL Teacher = new TeacherBLL(); cmbbanname.DisplayMember = "教师姓名"; cmbbanname.ValueMember = "教师编号"; cmbbanname.DataSource = Teacher.GetAllTeacher(); }
private void btnDeleban_Click(object sender, EventArgs e) { TeacherBLL teacher = new TeacherBLL(); TeachersModel model = new TeachersModel(); model.Teacher_ID = Convert.ToInt32(databanzhuren.SelectedRows[0].Cells["教师编号"].Value); teacher.DeleTeacher(model); GetAllTeacher(); }
private void yx_SelectedIndexChanged(object sender, EventArgs e)//选择学院时,更新教师下拉框的数据源 { DepartmentBLL mibll = new DepartmentBLL(); //yx.DataSource = mibll.GetAllDeptname(); TeacherBLL miBll = new TeacherBLL(); string deptname = yx.Text; js.DataSource = miBll.deptnoGetNameList(mibll.GetDeptno(deptname)); }
private void LoadTeacherList()//教师表数据源、院系号数据源 { TeacherBLL teacherBLL = new TeacherBLL(); TeacherList.DataSource = teacherBLL.GetList(); DepartmentBLL departmentBLL = new DepartmentBLL(); DeptnoT.DataSource = departmentBLL.GetAllDeptno(); }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { TeacherBLL teachBLL = new TeacherBLL(); DropDownList_teacher.DataSource = teachBLL.getClassTeachers(); DropDownList_teacher.DataTextField = "name"; DropDownList_teacher.DataValueField = "ID"; DropDownList_teacher.DataBind(); }
private void Binds() { ddlTeacherId.DataSource = TeacherBLL.AllData("", "TeacherId", ""); ddlTeacherId.DataTextField = "TeacherName"; ddlTeacherId.DataValueField = "TeacherId"; ddlTeacherId.DataBind(); rpView.DataSource = CourseBLL.AllData("", "CourseId", "asc"); rpView.DataBind(); }
private void Dept_Tname_LoadList()//按目录查询的两个下拉框数据源 { DepartmentBLL mibll = new DepartmentBLL(); yx.DataSource = mibll.GetAllDeptname(); TeacherBLL miBll = new TeacherBLL(); string deptname = yx.Text; js.DataSource = miBll.deptnoGetNameList(mibll.GetDeptno(deptname)); }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { TeacherBLL teachBLL = new TeacherBLL(); UserBLL userBLL = new UserBLL(); string teachId = TextBox_teachId.Text.Trim(); string name = TextBox_name.Text.Trim(); string gender = RadioButton_male.Checked ? "男" : "女"; string birth = DropDownList_yearPart1.SelectedValue + DropDownList_yearPart2.SelectedValue + DropDownList_yearPart3.SelectedValue + DropDownList_yearPart4.SelectedValue; birth += DropDownList_month.SelectedValue; string title = DropDownList_title.SelectedValue; string phone = TextBox_phone.Text.Trim(); string email = TextBox_email.Text.Trim(); if (teachBLL.getByTeacherId(teachId) == null) { if (userBLL.getByUsername(teachId) == null) { #region 在用户表中创建新用户 User user = new User(); user.UserName = teachId; user.Password = EncryptUtil.MD5Encrypt("12345678"); user.Type = title.Equals("辅导员") ? "2" : "1"; userBLL.save(user); #endregion Teacher teacher = new Teacher(); teacher.TeacherId = teachId; teacher.Name = name; teacher.Gender = gender; teacher.Birth = birth; teacher.Title = title; teacher.Phone = phone; teacher.Email = email; teacher.UserID = userBLL.getByUsername(teachId).Id; teachBLL.save(teacher); Response.Write("<script>alert('添加成功!');location.href='addTeacher.aspx';</script>"); } else { Response.Write("<script>alert('添加失败,用户名已存在!');location.href='addTeacher.aspx';</script>"); } } else { checkTeachId.ErrorMessage = "教师号已存在!"; checkTeachId.IsValid = false; } } }
//添加、修改 protected void btnAdd_Click(object sender, EventArgs e) { if (btnAdd.Text == "添加") { Teacher model = new Teacher(); model.Pwd = txtPwd.Value.Trim(); model.TeacherCode = txtTeacherCode.Value.Trim(); model.TeacherName = txtTeacherName.Value.Trim(); if (TeacherBLL.IsTrue(model.TeacherCode)) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该教工号已经存在,不能重复!');</script>"); return; } else { if (TeacherBLL.AddTeacher(model) > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');window.location.replace('TeacherManage.aspx');</script>"); return; } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>"); return; } } } else { Teacher model = TeacherBLL.GetIdByTeacher(Convert.ToInt32(Request.QueryString["uid"])); model.Pwd = txtPwd.Value.Trim(); model.TeacherCode = txtTeacherCode.Value.Trim(); model.TeacherName = txtTeacherName.Value.Trim(); if (TeacherBLL.IsTrue(model.TeacherCode, model.TeacherId)) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该教工号已经存在,不能重复!');</script>"); return; } else { if (TeacherBLL.UpdateTeacher(model) > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');window.location.replace('TeacherManage.aspx');</script>"); return; } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!');</script>"); return; } } } }
/// <summary> /// 绑定数据源 /// </summary> private void bind() { User user = Session["User"] as User; TeacherBLL teacherBLL = new TeacherBLL(); Teacher teacher = teacherBLL.getByUserId(user.Id); CommonBLL commBLL = new CommonBLL(); GridView1.DataSource = commBLL.getClassesByTeacherId(teacher.Id); GridView1.DataBind(); }
protected void btnDelete_Click(object sender, EventArgs e) { Int32 records = TeacherBLL.getInstance().delete(teacher_id); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "confirmMessage", "$('#confirmMessage').modal('toggle');", true); if (records > 0) { lblMessage.Text = "Profesor eliminado correctamente."; } loadData(); }
/// <summary> /// 登录按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text)) { return; } string msg; string id = textBox1.Text.Trim(); string pwd = textBox2.Text.Trim(); if (ucSwitch1.Checked) { TeacherBLL bll = new TeacherBLL(); Boolean b = bll.GetTeacherInfo(id, pwd, out msg); if (b) { //FrmTips.ShowTipsSuccess(this, msg); //fea.Obj = bll.GetTeacher(id); //FrmTeacherMain frmTeacher = new FrmTeacherMain(); //this.evtFt += new EventHandler(frmTeacher.SetTxt); //if (this.evtFt!=null) //{ // this.evtFt(this, fea); // frmTeacher.ShowDialog(); //} FrmTips.ShowTipsSuccess(this, msg); this.Tag = bll.GetTeacher(id); this.DialogResult = DialogResult.OK; } else { FrmTips.ShowTipsError(this, msg); } } else { StudentBLL bll = new StudentBLL(); Student stu = new Student(); bool b = bll.getStudentInfoBySid(id, pwd, out msg, out stu); if (b) { this.Tag = stu; this.DialogResult = DialogResult.Yes; } else { FrmTips.ShowTipsError(this, msg); } } }
private void TeacherAdd_Click(object sender, EventArgs e)//添加、修改按钮 { Teacher teacher = new Teacher() { tno = Tno.Text, tname = Tname.Text, sex = Sex.Text, title = Title.Text, deptno = DeptnoT.Text, tid = Tid.Text }; TeacherBLL teacherBLL = new TeacherBLL(); #region 添加 if (TeacherAdd.Text.Equals("添加")) { if (teacherBLL.Add(teacher)) { MessageBox.Show("添加成功"); LoadTeacherList(); } else { MessageBox.Show("添加失败"); } } #endregion #region 修改 else { if (teacherBLL.Edit(teacher)) { MessageBox.Show("修改成功"); LoadTeacherList(); Tno.ReadOnly = false; TeacherAdd.Text = "添加"; } else { MessageBox.Show("修改失败"); } } #endregion Tno.Text = ""; Tname.Text = ""; Sex.Text = ""; Title.Text = ""; DeptnoT.Text = ""; Tid.Text = ""; }
public string DeleteTeacher(int id) { TeacherBLL bll = new TeacherBLL(); bool result = bll.Delete(id); if (result) { return("删除教师信息成功!".ToJson()); } else { return("删除教师信息失败!".ToJson()); } }
public string AddTeacher(TeacherModel mod) { TeacherBLL bll = new TeacherBLL(); bool result = bll.Add(mod); if (result) { return("添加教师信息成功!".ToJson()); } else { return("添加教师信息失败!".ToJson()); } }
public string EditTeacher(TeacherModel mod) { TeacherBLL bll = new TeacherBLL(); bool result = bll.Update(mod); if (result) { return("修改教师信息成功!".ToJson()); } else { return("修改教师信息失败!".ToJson()); } }
private void btnDel_Click(object sender, EventArgs e) { TeacherBLL objTeacherBLL = new TeacherBLL(); TeacherModel objTeacherModel = new TeacherModel(); objTeacherModel.TeaNum = txtTeaNum.Text; if (objTeacherBLL.DeleteTeacher(objTeacherModel)==true) { MessageBox.Show("数据删除成功"); } else { MessageBox.Show("数据删除失败"); } ShowTable(); }
private void btnModify_Click(object sender, EventArgs e) { if (txtTeaNum.Text == "" || txtTeaName.Text == "") { MessageBox.Show("工号和姓名都不能为空!\n 请重新输入!"); } else { TeacherBLL objTeacherBLL = new TeacherBLL(); TeacherModel objTeacherModel = new TeacherModel(); objTeacherModel.TeaAdress = txtTeaAddress.Text; objTeacherModel.TeaName = txtTeaName.Text; objTeacherModel.TeaNum = txtTeaNum.Text; objTeacherModel.TeaPhone = txtTeaPhone.Text; objTeacherModel.TeaTitle = txtTeaTitle.Text; objTeacherModel.TeaSex = cbxTeaSex.Text; objTeacherModel.TeaTitle = txtTeaTitle.Text; if (objTeacherBLL.ChangeTeacher(objTeacherModel)==true) { MessageBox.Show("增加成功!"); } else MessageBox.Show("增加失败!"); } ShowTable(); }
private void ShowTable() { TeacherBLL objTeacherBLL = new TeacherBLL(); dgvTeacherInfo.DataSource = objTeacherBLL.ShowTeacher(); }
private void btnAdd_Click(object sender, EventArgs e) { #region sql语句进行添加,已注释 //TeacherBLL objTeacherBLL = new TeacherBLL(); //TeacherModel Teacher = new TeacherModel(); //Teacher.TeaNum = txtNum.Text ; //Teacher.TeaName = txtName.Text; //Teacher.TeaSex = cmbSex.Text; //Teacher.TeaAdress = txtAdress.Text; //Teacher.TeaPhone = txtPhone.Text; //Teacher.TeaTitle = txtTitle.Text; //if(objTeacherBLL.AddTeacher(Teacher)==true) // MessageBox.Show("数据添加成功"); //else // MessageBox.Show("数据添加失败"); //dgvTeacherInfo.DataSource = objTeacherBLL.ShowTeacher(); #endregion #region //存储过程 已注释 ////SqlConnection objConn = new SqlConnection("Data Source=.\\SQLExpress;Initial Catalog=StuManageSystem_2008;Integrated Security=True"); ////objConn.Open(); ////SqlCommand objSqlCommand = new SqlCommand(); //objSqlCommand.Connection = objConn; //objSqlCommand.CommandType = CommandType.StoredProcedure; //objSqlCommand.CommandText = "Teachers"; //objSqlCommand.Parameters.Add("@TeaName", SqlDbType.NChar, 10); //objSqlCommand.Parameters["@TeaName"].Value = txtName.Text; //objSqlCommand.Parameters.Add("@Sex", SqlDbType.NChar, 10); //objSqlCommand.Parameters["@TeaSex"].Value = txtSex.Text; //objSqlCommand.Parameters.Add("@TeaAdress", SqlDbType.NChar, 10); //objSqlCommand.Parameters["@TeaAdress"].Value = txtAdress.Text; //objSqlCommand.Parameters.Add("@TeaPhone", SqlDbType.NChar, 10); //objSqlCommand.Parameters["@TeaPhone"].Value = txtPhone.Text; //objSqlCommand.Parameters.Add("@TeaTitle", SqlDbType.NChar, 10); //objSqlCommand.Parameters["@TeaTitle"].Value = txtTitle.Text; //if (objSqlCommand.EndExecuteNonQuery() > 0) // MessageBox.Show("添加成功"); //else MessageBox.Show("添加失败"); //objConn.Close(); //调用类的后半段 //string SqlString = "select*from dbo.Teacher"; // dgvTeacherInfo.DataSource = objDataBase.GetDataSet(SqlString).Tables[0]; //SqlCommand objSqlCommand = new SqlCommand(); //objSqlCommand.CommandType = CommandType.StoredProcedure; //objSqlCommand.CommandText = "studentInsert"; //objSqlCommand.Parameters.AddWithValue("@TeaNum", txtNum.Text); //objSqlCommand.Parameters.AddWithValue("@TeaName", txtName.Text); //objSqlCommand.Parameters.AddWithValue("@TeaSex", cmbSex.Text); //objSqlCommand.Parameters.AddWithValue("@TeaAdress ", txtAdress.Text); //objSqlCommand.Parameters.AddWithValue("@TeaPhone", txtPhone.Text); //objSqlCommand.Parameters.AddWithValue("@TeaTitle", txtTitle.Text); //SQLClass1 objdatabase = new SQLClass1(); //if (objdatabase.GetExecute1(objSqlCommand)) // MessageBox.Show("添加成功"); //else // MessageBox.Show("添加失败"); //showDGV(); #endregion if (txtTeaNum.Text=="" || txtTeaName.Text == "") { MessageBox.Show("工号和姓名都不能为空!\n 请重新输入!"); } else { TeacherBLL objTeacherBLL = new TeacherBLL(); TeacherModel objTeacherModel = new TeacherModel(); objTeacherModel.TeaAdress = txtTeaAddress.Text; objTeacherModel.TeaName = txtTeaName.Text; objTeacherModel.TeaNum = txtTeaNum.Text; objTeacherModel.TeaPhone = txtTeaPhone.Text; objTeacherModel.TeaTitle = txtTeaTitle.Text; objTeacherModel.TeaSex = cbxTeaSex.Text; objTeacherModel.TeaTitle = txtTeaTitle.Text; if (objTeacherBLL.AddTeacher(objTeacherModel) == true) { MessageBox.Show("增加成功!"); } else MessageBox.Show("增加失败!"); } }