教师管理操作流程1、使用Teacher账号登陆——教师管理系统代码区域:if(loginType==教师){stringsql=string.Format(selectcount(*)fromteacherwhereLoginId='{0}'ANDLoginPwd='{1}',loginId,loginPwd);try{SqlCommandcommand=newSqlCommand(sql,DBHelper.connection);DBHelper.connection.Open();count=(int)command.ExecuteScalar();if(count==1){isValidUser=true;}else{index++;if(index=3){message=用户名或密码不存在!;}elseif(index=3){Application.Exit();}isValidUser=false;}}catch(Exceptionex){message=ex.Message;Console.WriteLine(ex.Message);}查询修改信息查询教师基本信息(代码区域:)TeacherBaseFormteacherBaseForm=newTeacherBaseForm();teacherBaseForm.Show();TeacherBaseForm(教师基本信息窗体)查询及修改学生信息(代码区域:)UpdateStudentFormupdateStudentForm=newUpdateStudentForm();updateStudentForm.Show();SearchTeacherForm.cs(查询及修改信息窗体)AddScoreForm(学生成绩录入窗体)录入按钮代码:stringsql=string.Format(selectStudentId,StudentNo,StudentNamefromStudentwhereStudentId='{0}',txtId.Text);try{SqlCommandcommand=newSqlCommand(sql,DBHelper.connection);DBHelper.connection.Open();SqlDataReaderreader=command.ExecuteReader();while(reader.Read()){id=(int)reader[StudentId];no=(string)reader[StudentNo];name=(string)reader[StudentName];}reader.Close();}catch(Exceptionex){MessageBox.Show(ex.Message);}finally{DBHelper.connection.Close();}if(TianJia()){if(txtId.Text==Convert.ToString(id)&&txtStudentNo.Text==no&&txtStudentName.Text==name){stringstudentName=txtStudentName.Text;stringsdudentNo=txtStudentNo.Text;stringsubject=cboSubject.Text;stringscore=txtScore.Text;intclassId=GetClassId();stringstudentId=txtId.Text;stringsql1=string.Format(insertintoScore(StudentNo,Subject,SScore,SName,ClassId,StudentId)values('{0}','{1}','{2}','{3}','{4}',{5}),sdudentNo,subject,score,studentName,classId,studentId);try{SqlCommandcommand=newSqlCommand(sql1,DBHelper.connection);DBHelper.connection.Open();intresult=command.ExecuteNonQuery();if(result!=1){MessageBox.Show(添加失败,输入提示,MessageBoxButtons.OK,MessageBoxIcon.Information);}else{MessageBox.Show(添加成功,输入提示,MessageBoxButtons.OK,MessageBoxIcon.Information);}}catch(Exceptionex){//MessageBox.Show(操作数据库出错!,输入提示,MessageBoxButtons.OK,MessageBoxIcon.Information);//Console.WriteLine(ex.Message);MessageBox.Show(ex.Message);}finally{DBHelper.connection.Close();}}else{MessageBox.Show(您输入的学生在数据库中没有,请重新输入,输入提示,MessageBoxButtons.OK,MessageBoxIcon.Information);}}}privatevoidAddScoreForm_Load(objectsender,EventArgse){stringsql=selectgradeNamefromGrade;try{SqlCommandcommand=newSqlCommand(sql,DBHelper.connection);DBHelper.connection.Open();SqlDataReaderreader=command.ExecuteReader();while(reader.Read()){stringgradeName=(string)reader[0];cboGrade.Items.Add(gradeName);}reader.Close();}catch(Exceptionex){MessageBox.Show(ex.Message);}finally{DBHelper.connection.Close();}stringsql1=selectSubjectNamefromSubject;try{SqlCommandcommand=newSqlCommand(sql1,DBHelper.connection);DBHelper.connection.Open();SqlDataReaderreader=command.ExecuteReader();while(reader.Read()){stringsubName=(string)reader[0];cboSubject.Items.Add(subName);}reader.Close();}catch(Exceptionex){MessageBox.Show(ex.Message);}finally{DBHelper.connection.Close();}}privatevoidcboGrade_SelectedIndexChanged(objectsender,EventArgse){if(cboGrade.Text.Trim()!=){intgradeId=-1;stringsql=string.Format(selectGradeIdfromGradewhereGradeName='{0}',cboGrade.Text);SqlCommandcommand=newSqlCommand(sql,DBHelper.connection);try{DBHelper.connection.Open();SqlDataReaderreader=command.ExecuteReader();if(reader.Read()){gradeId=(int)reader[0];}reader.Close();}catch(Exceptionex){MessageBox.Show(操作数据库出错);Console.WriteLine(ex.Message);}finally{DBHelper.connection.Close();}sql=SELECTClassNameFROMClassWHEREGradeId=+gradeId;command.CommandText=sql;try{DBHelper.connection.Open();SqlDataReaderreader=command.ExecuteReader();stringclassName=;cboClass.Items.Clear();while(reader.Read()){className=(string)reader[ClassName];cboClass.Items.Add(className);}reader.Close();}catch(Exceptionex){MessageBox.Show(操作数据库出错);Console.WriteLine(ex.Message);}finally{DBHelper.connection.Close();}}}privatevoidtxtId_TextChanged(objectsender,EventArgse){}UpdateScoreForm(更新成绩窗体)保存按钮代码:DialogResultresult=MessageBox.Show(确实要将修改保存到数据库吗?,输入提示,MessageBoxButtons.OK,MessageBoxIcon.Information);if(result==DialogResult.OK){SqlCommandBuilderbuilder=newSqlCommandBuilder(dataAdapter);dataAdapter.Update(dataSet,Score);MessageBox.Show(保存成功,输入提示,MessageBoxButtons.OK,MessageBoxIcon.Information);}else{MessageBox.Show(保存失败,输入提示,MessageBoxButtons.OK,MessageBoxIcon.Information);}