VC2010制作学生管理系统

P359

String^ strSql = L"SELECT 学号,姓名,性别,出生时间,专业,总学分,备注\ FROM XSB WHERE "; if (this->textBox1->Text == String::Empty) strSql += L"1>0"; else strSql += L"学号 LIKE '"+ this->textBox1->Text + L"'"; strSql += L" AND "; if (this->textBox2->Text == String::Empty) strSql += L"1>0"; else strSql += L"姓名 LIKE '"+ this->textBox2->Text + L"'"; strSql += L" AND "; if (this->comboBox1->SelectedIndex == -1) strSql += L" 1>0 "; else strSql += L" 专业 LIKE '" + comboBox1->Items[comboBox1->SelectedIndex] + L"'"; this->dataSet1->Clear(); this->sqlSelectCommand1->CommandText = strSql; this->sqlDataAdapter1->Fill(this->dataSet1);

p360 Form2^ form2 = gcnew Form2(); form2->ShowDialog();

p362 String^strSql = L"SELECT 学号,姓名,专业,总学分 FROM XSB WHERE "; if (this->textBox1->Text == String::Empty) strSql += L"1<0"; else strSql += L"学号='" + this->textBox1->Text + L"'"; SqlCommand^ cmd = gcnew SqlCommand(strSql, this->sqlConnection1); SqlDataReader^ reader = cmd->ExecuteReader(); if (reader->Read()){ this->textBox2->Text = reader->GetString(0); this->textBox3->Text = reader->GetString(1); this->textBox4->Text = reader->GetString(2); this->textBox5->Text = reader->GetInt32(3).ToString(); } reader->Close(), this->sqlConnection1->Close(); strSql = L"SELECT 课程号,课程名,开课学期,学时,学分,成绩 FROM XS_KC_CJ WHERE"; if (this->textBox1->Text == String::Empty) strSql += L"1<0"; else strSql += L"学号='" + this->textBox1->Text + L"'"; this->dataSet1->Clear(); this->sqlSelectCommand1->CommandText = strSql; this->sqlDataAdapter1->Fill(this->dataSet1); Form3^form3 = gcnew Form3(); form3->ShowDialog();

p363

p364 if (this->textBox1->Text == String::Empty) return; if (this->textBox2->Text == String::Empty) return; try { String^strConn = L"Data Source=PHEI-PINBO-PC;Initial Catalog=PXSCJ;\ Persist Security Info=True;User ID=sa;Password=123456"; SqlConnection^conn = gcnew SqlConnection(strConn); conn->Open(); String^strSql ='"+textBox1->Text+L"'"; SqlCommand^ cmd = gcnew SqlCommand(strSql, conn); SqlDataReader^ reader = cmd->ExecuteReader(); if (reader->HasRows) { strSql = L"UPDATE XSB SET"; strSql += L"姓名=@姓名,性别=@性别,出生时间=@出生时 间,"; strSql += L"专业=@专业,总学分=@总学分,备注=@备注"; strSql += L"WHERE 学号=@学号"; } else { strSql = L"INSERT XSB VALUES("; strSql += L"@学号,@姓名,@性别,@出生时间,@专业,@总学 分,@备注)"; } reader->Close(); cmd->CommandText = strSql; SqlParameter^ paramXh = cmd->CreateParameter(); paramXh->ParameterName = L"@学号"; paramXh->SqlDbType = SqlDbType::VarChar; paramXh->Direction = ParameterDirection::Input; paramXh->Value = this->textBox1->Text; cmd->Parameters->Add(paramXh); SqlParameter^ paramXm = cmd->CreateParameter(); paramXm->ParameterName = L"@姓名"; paramXm->SqlDbType = SqlDbType::VarChar; paramXm->Direction = ParameterDirection::Input; paramXm->Value = this->textBox2->Text; cmd->Parameters->Add(paramXm); = L"SELECT*FROM XSB WHERE 学 号

SqlParameter^ paramXb = cmd->CreateParameter(); paramXb->ParameterName = L"@性别"; paramXb->SqlDbType = SqlDbType::Bit; paramXb->Direction = ParameterDirection::Input; paramXb->Value = this->radioButton1->Checked; cmd->Parameters->Add(paramXb); SqlParameter^ paramCssj = cmd->CreateParameter(); paramCssj->ParameterName = L"@出生时间"; paramCssj->SqlDbType = SqlDbType::DateTime; paramCssj->Direction = ParameterDirection::Input; paramCssj->Value = this->dateTimePicker1->Value; cmd->Parameters->Add(paramCssj); SqlParameter^ paramZy = cmd->CreateParameter(); paramZy->ParameterName = L"@专业"; paramZy->SqlDbType = SqlDbType::VarChar; paramZy->Direction = ParameterDirection::Input; if (this->comboBox2->SelectedIndex == -1) paramZy->Value = DBNull::Value; else paramZy->Value comboBox2->Items[comboBox2->SelectedIndex]; cmd->Parameters->Add(paramZy); SqlParameter^ paramZxf = cmd->CreateParameter(); paramZxf->ParameterName = L"@总学分"; paramZxf->SqlDbType = SqlDbType::Int; paramZxf->Direction = ParameterDirection::Input; if (this->textBox3->Text == String::Empty) paramZxf->Value = DBNull::Value; else paramZxf->Value = Convert::ToInt32(textBox3->Text); cmd->Parameters->Add(paramZxf); SqlParameter^ paramBz = cmd->CreateParameter(); paramBz->ParameterName = L"@备注"; paramBz->SqlDbType = SqlDbType::VarChar; paramBz->Direction = ParameterDirection::Input; if (this->textBox4->Text == String::Empty) paramBz->Value = DBNull::Value;

=

else paramBz->Value = this->textBox4->Text; cmd->Parameters->Add(paramBz); cmd->ExecuteNonQuery(); conn->Close(); MessageBox::Show(L"已更新该记录."); } catch (SqlException^ e){ MessageBox::Show(e->ToString()); } } P366 if (this->textBox1->Text == String::Empty) return; try { String^ strConn = L"Data Source=PHEI-PINBO-PC;Initial Persist Security Info=True;User ID=sa;Password=123456"; SqlConnection^conn = gcnew SqlConnection(strConn); conn->Open(); String^strSql ='"+textBox1->Text+L"'"; SqlCommand^ cmd = gcnew SqlCommand(strSql, conn); SqlDataReader^ reader = cmd->ExecuteReader(); if (!reader->HasRows) { MessageBox::Show(L"该记录不存在!"); reader->Close(), conn->Close(); return; } strSql = L"DELETE FROM XSB WHERE 学号='" + textBox1->Text + L"'"; cmd->CommandText = strSql; cmd->ExecuteNonQuery(); reader->Close(),conn->Close(); MessageBox::Show(L"已删除该学生记录."); } catch (SqlException^ e){ MessageBox::Show(e->ToString()); Form4^ form4 = gcnew Form4(); form4->ShowDialog(); = L"SELECT*FROM XSB WHERE 学 号

p367

try { this->sqlConnection1->Open(); String^ strSql = L"SELECT 学号 FROM XSB ORDER BY 学号"; SqlCommand^ cmd = gcnew SqlCommand(strSql,

this->sqlConnection1); SqlDataReader^ reader = cmd->ExecuteReader(); this->dataSet1->Clear(); this->comboBox1->Items->Clear(); while (reader->Read()) comboBox1->Items->Add(reader[L"学号"]); reader->Close(), this->sqlConnection1->Close(); } catch (SqlException^ e) { MessageBox::Show(e->ToString()); } } P368 try { if (this->comboBox1->SelectedIndex == -1) return; String^ strSql = L"SELECT 姓名 FROM XSB WHERE 学号='"; strSql += comboBox1->Items[comboBox1->SelectedIndex] + L"'"; this->sqlConnection1->Open(); SqlCommand^ cmd = this->sqlConnection1); SqlDataReader^ reader = cmd->ExecuteReader(); reader->Read(); this->textBox1->Text = reader->GetString(0); reader->Close(), this->sqlConnection1->Close(); strSql = L"SELECT 课程号,课程名,开课学期,学时,学分,成绩 FROM XS_KC_CJ"; strSql += L"WHERE comboBox1->Items[comboBox1->SelectedIndex] + L"'"; 学 号 '" +

gcnew

SqlCommand(strSql,

this->dataSet1->Clear(); this->sqlSelectCommand1->CommandText = strSql; this->sqlDataAdapter1->Fill(this->dataSet1); } catch (SqlException^ e) { MessageBox::Show(e->ToString());

}

P369

} if (this->comboBox2->SelectedIndex == -1) return; try { String^ strSql = L"SELECT 课程号,学分, FROM KCB WHERE 课程号='"; strSql += comboBox2->Items[comboBox2->SelectedIndex] + L"'"; this->sqlConnection1->Open(); SqlCommand^ cmd = gcnew SqlCommand(strSql, this->sqlConnection1); SqlDataReader^ reader = cmd->ExecuteReader(); reader->Read(); this->textBox2->Text = reader->GetString(0); this->textBox4->Text = reader->GetByte(1).ToString(); reader->Close(), this->sqlConnection1->Close(); } catch (SqlException^ e) { MessageBox::Show(e->ToString()); } }

try { this->sqlConnection1->Open(); String^ strSql = L"SELECT 课程号 FROM KCB ORDER BY 课程号"; SqlCommand^cmd = gcnew SqlCommand(strSql, this->sqlConnection1); SqlDataReader^ reader = cmd->ExecuteReader(); this->comboBox2->Items->Clear(); while (reader->Read()) this->comboBox2->Items->Add(reader[L"课程号 "]); reader->Close(), this->sqlConnection1->Close(); } catch (SqlException^ e) { MessageBox::Show(e->ToString()); } } USE[PXSCJ] GO ALTER PROCEDURE CJ_Data(@in_xh char(6),@in_kch char(3),@in_cj int) AS DECLARE @in_count int

P385

DECLARE @in_xf tinyint DECLARE @in_cjb_cj int SET @in_xf=(SELECT 学分 FROM KCB WHERE 课程号=@in_kch) SET @in_count=(SELECT COUNT(*)FROM CJB WHERE 学号=@in_xh AND 课程号=@in_kch) SET @in_cjb_cj=(SELECT 成绩 FROM CJB WHERE 学号=@in_xh AND 课程号=@in_kch) IF (@in_count>0) BEGIN DELETE FROM CJB WHERE 学号=@in_xh AND 课程号=@in_kch IF (@in_cjb_cj>60) BEGIN UPDATE XSB SET 总学分=总学分-@in_xf WHERE 学号=@in_xh END END IF (@in_cj!=-1) BEGIN INSERT INTO CJB VALUES(@in_xh,@in_kch,@in_cjb_cj) IF (@in_cj>60) BEGIN UPDATE XSB SET 总学分=总学分+@in_xf WHERE 学号=@in_xh END END


相关文档

学生综合管理系统的制作与实现
学生信息管理系统-作品制作说明
学生信息管理系统的制作
学生信息管理系统制作步骤.ppt
学生信息管理系统的设计与制作
学生信息管理系统制作步骤 共32页
学生信息管理系统作品制作说明
ASP制作学生档案管理系统
数据结构:运用单链表 制作 学生成绩管理系统
学生管理系统--任课教师版的制作
电脑版