#pragma once
namespace jellyL {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Data::SqlClient;
/// <summary>
/// Form1 摘要
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: 在此处添加构造函数代码
//
con=gcnew SqlConnection();
con->ConnectionString = L"Data Source=WIN-11OF0DUGGUS;Initial Catalog=学生信息管理;Integrated Security=True";
}
protected:
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::TextBox^ textBox5;
private: System::Windows::Forms::TextBox^ textBox6;
private: System::Windows::Forms::TextBox^ textBox7;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ button7;
private: System::Windows::Forms::Button^ button8;
private: System::Windows::Forms::Button^ button9;
private: System::Windows::Forms::Button^ button10;
private: System::Windows::Forms::Button^ button11;
private: System::Windows::Forms::DataGridView^ dataGridView1;
private: System::Windows::Forms::MenuStrip^ menuStrip1;
private: System::Windows::Forms::Button^ button12;
private: System::Data::SqlClient::SqlCommand^ sqlSelectCommand1;
private: System::Data::SqlClient::SqlConnection^ sqlConnection1;
private: System::Data::SqlClient::SqlDataAdapter^ sqlDataAdapter1;
SqlConnection^ con;//
private: System::Windows::Forms::Button^ button13;
private: System::Windows::Forms::ComboBox^ comboBox1;
private: System::Windows::Forms::TextBox^ textBox8;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::ComboBox^ comboBox2;
private: System::Windows::Forms::ToolStripMenuItem^ 学生表操作ToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ 选课表操作ToolStripMenuItem;
private: System::Windows::Forms::ComboBox^ comboBox3;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::ToolStripMenuItem^ 查询全部ToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ 精确查询ToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ 平均成绩ToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ 总成绩ToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ 操作说明CToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ 关于作者DToolStripMenuItem;
private: System::Windows::Forms::Label^ label10;
private: System::Windows::Forms::TextBox^ textBox9;
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->textBox5 = (gcnew System::Windows::Forms::TextBox());
this->textBox6 = (gcnew System::Windows::Forms::TextBox());
this->textBox7 = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->button7 = (gcnew System::Windows::Forms::Button());
this->button8 = (gcnew System::Windows::Forms::Button());
this->button9 = (gcnew System::Windows::Forms::Button());
this->button10 = (gcnew System::Windows::Forms::Button());
this->button11 = (gcnew System::Windows::Forms::Button());
this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
this->学生表操作ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->查询全部ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->精确查询ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->选课表操作ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->平均成绩ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->总成绩ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->操作说明CToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->关于作者DToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->button12 = (gcnew System::Windows::Forms::Button());
this->sqlSelectCommand1 = (gcnew System::Data::SqlClient::SqlCommand());
this->sqlConnection1 = (gcnew System::Data::SqlClient::SqlConnection());
this->sqlDataAdapter1 = (gcnew System::Data::SqlClient::SqlDataAdapter());
this->button13 = (gcnew System::Windows::Forms::Button());
this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
this->textBox8 = (gcnew System::Windows::Forms::TextBox());
this->label8 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->comboBox2 = (gcnew System::Windows::Forms::ComboBox());
this->comboBox3 = (gcnew System::Windows::Forms::ComboBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label10 = (gcnew System::Windows::Forms::Label());
this->textBox9 = (gcnew System::Windows::Forms::TextBox());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->BeginInit();
this->menuStrip1->SuspendLayout();
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(12, 25);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(29, 12);
this->label1->TabIndex = 0;
this->label1->Text = L"姓名";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(136, 25);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(29, 12);
this->label2->TabIndex = 1;
this->label2->Text = L"学号";
this->label2->Click += gcnew System::EventHandler(this, &Form1::label2_Click);
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(290, 25);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(29, 12);
this->label3->TabIndex = 2;
this->label3->Text = L"性别";
this->label3->Click += gcnew System::EventHandler(this, &Form1::label3_Click);
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(446, 25);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(29, 12);
this->label4->TabIndex = 3;
this->label4->Text = L"系名";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(541, 155);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(29, 12);
this->label5->TabIndex = 4;
this->label5->Text = L"学号";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(541, 215);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(29, 12);
this->label6->TabIndex = 5;
this->label6->Text = L"课号";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(541, 247);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(29, 12);
this->label7->TabIndex = 6;
this->label7->Text = L"成绩";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(56, 25);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(64, 21);
this->textBox1->TabIndex = 7;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(192, 22);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(64, 21);
this->textBox2->TabIndex = 8;
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(506, 22);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(64, 21);
this->textBox4->TabIndex = 10;
//
// textBox5
//
this->textBox5->Location = System::Drawing::Point(596, 152);
this->textBox5->Name = L"textBox5";
this->textBox5->Size = System::Drawing::Size(64, 21);
this->textBox5->TabIndex = 11;
//
// textBox6
//
this->textBox6->Location = System::Drawing::Point(596, 215);
this->textBox6->Name = L"textBox6";
this->textBox6->Size = System::Drawing::Size(64, 21);
this->textBox6->TabIndex = 12;
//
// textBox7
//
this->textBox7->Location = System::Drawing::Point(596, 247);
this->textBox7->Name = L"textBox7";
this->textBox7->Size = System::Drawing::Size(64, 21);
this->textBox7->TabIndex = 13;
//
// button1
//
this->button1->Location = System::Drawing::Point(16, 60);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(88, 28);
this->button1->TabIndex = 14;
this->button1->Text = L"精确查询";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(16, 106);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(88, 30);
this->button2->TabIndex = 15;
this->button2->Text = L"模糊查询";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(387, 59);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(88, 30);
this->button3->TabIndex = 16;
this->button3->Text = L"更新";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(110, 106);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(88, 30);
this->button4->TabIndex = 17;
this->button4->Text = L"插入";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
//
// button5
//
this->button5->Location = System::Drawing::Point(387, 97);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(88, 30);
this->button5->TabIndex = 18;
this->button5->Text = L"删除";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
//
// button6
//
this->button6->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button6.Image")));
this->button6->Location = System::Drawing::Point(572, 274);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(88, 30);
this->button6->TabIndex = 19;
this->button6->Text = L"查询";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
//
// button7
//
this->button7->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button7.Image")));
this->button7->Location = System::Drawing::Point(572, 310);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(88, 30);
this->button7->TabIndex = 20;
this->button7->Text = L"添加";
this->button7->UseVisualStyleBackColor = true;
this->button7->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
//
// button8
//
this->button8->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button8.Image")));
this->button8->Location = System::Drawing::Point(572, 346);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(88, 30);
this->button8->TabIndex = 21;
this->button8->Text = L"删除";
this->button8->UseVisualStyleBackColor = true;
this->button8->Click += gcnew System::EventHandler(this, &Form1::button8_Click);
//
// button9
//
this->button9->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button9.Image")));
this->button9->Location = System::Drawing::Point(572, 382);
this->button9->Name = L"button9";
this->button9->Size = System::Drawing::Size(88, 30);
this->button9->TabIndex = 22;
this->button9->Text = L"修改";
this->button9->UseVisualStyleBackColor = true;
this->button9->Click += gcnew System::EventHandler(this, &Form1::button9_Click);
//
// button10
//
this->button10->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button10.Image")));
this->button10->Location = System::Drawing::Point(387, 274);
this->button10->Name = L"button10";
this->button10->Size = System::Drawing::Size(88, 30);
this->button10->TabIndex = 23;
this->button10->Text = L"平均成绩";
this->button10->UseVisualStyleBackColor = true;
this->button10->Click += gcnew System::EventHandler(this, &Form1::button10_Click);
//
// button11
//
this->button11->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button11.Image")));
this->button11->Location = System::Drawing::Point(387, 310);
this->button11->Name = L"button11";
this->button11->Size = System::Drawing::Size(88, 30);
this->button11->TabIndex = 24;
this->button11->Text = L"总成绩";
this->button11->UseVisualStyleBackColor = true;
this->button11->Click += gcnew System::EventHandler(this, &Form1::button11_Click);
//
// dataGridView1
//
this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView1->Location = System::Drawing::Point(0, 142);
this->dataGridView1->Name = L"dataGridView1";
this->dataGridView1->RowTemplate->Height = 23;
this->dataGridView1->Size = System::Drawing::Size(369, 280);
this->dataGridView1->TabIndex = 25;
//
// menuStrip1
//
this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->学生表操作ToolStripMenuItem,
this->选课表操作ToolStripMenuItem, this->操作说明CToolStripMenuItem, this->关于作者DToolStripMenuItem});
this->menuStrip1->Location = System::Drawing::Point(0, 0);
this->menuStrip1->Name = L"menuStrip1";
this->menuStrip1->Size = System::Drawing::Size(685, 25);
this->menuStrip1->TabIndex = 26;
this->menuStrip1->Text = L"menuStrip1";
//
// 学生表操作ToolStripMenuItem
//
this->学生表操作ToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->查询全部ToolStripMenuItem,
this->精确查询ToolStripMenuItem});
this->学生表操作ToolStripMenuItem->Name = L"学生表操作ToolStripMenuItem";
this->学生表操作ToolStripMenuItem->Size = System::Drawing::Size(112, 21);
this->学生表操作ToolStripMenuItem->Text = L"学生表操作(&A)";
this->学生表操作ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::学生表操作ToolStripMenuItem_Click);
//
// 查询全部ToolStripMenuItem
//
this->查询全部ToolStripMenuItem->Name = L"查询全部ToolStripMenuItem";
this->查询全部ToolStripMenuItem->Size = System::Drawing::Size(140, 22);
this->查询全部ToolStripMenuItem->Text = L"查询全部(&A)";
this->查询全部ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::查询全部ToolStripMenuItem_Click);
//
// 精确查询ToolStripMenuItem
//
this->精确查询ToolStripMenuItem->Name = L"精确查询ToolStripMenuItem";
this->精确查询ToolStripMenuItem->Size = System::Drawing::Size(140, 22);
this->精确查询ToolStripMenuItem->Text = L"精确查询(&B)";
this->精确查询ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::精确查询ToolStripMenuItem_Click);
//
// 选课表操作ToolStripMenuItem
//
this->选课表操作ToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->平均成绩ToolStripMenuItem,
this->总成绩ToolStripMenuItem});
this->选课表操作ToolStripMenuItem->Name = L"选课表操作ToolStripMenuItem";
this->选课表操作ToolStripMenuItem->Size = System::Drawing::Size(104, 21);
this->选课表操作ToolStripMenuItem->Text = L"选课表操作( &B )";
//
// 平均成绩ToolStripMenuItem
//
this->平均成绩ToolStripMenuItem->Name = L"平均成绩ToolStripMenuItem";
this->平均成绩ToolStripMenuItem->Size = System::Drawing::Size(140, 22);
this->平均成绩ToolStripMenuItem->Text = L"平均成绩(&A)";
this->平均成绩ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::平均成绩ToolStripMenuItem_Click);
//
// 总成绩ToolStripMenuItem
//
this->总成绩ToolStripMenuItem->Name = L"总成绩ToolStripMenuItem";
this->总成绩ToolStripMenuItem->Size = System::Drawing::Size(140, 22);
this->总成绩ToolStripMenuItem->Text = L"总成绩(&B)";
this->总成绩ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::总成绩ToolStripMenuItem_Click);
//
// 操作说明CToolStripMenuItem
//
this->操作说明CToolStripMenuItem->Name = L"操作说明CToolStripMenuItem";
this->操作说明CToolStripMenuItem->Size = System::Drawing::Size(108, 21);
this->操作说明CToolStripMenuItem->Text = L"操作说明( &C )";
this->操作说明CToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::操作说明CToolStripMenuItem_Click);
//
// 关于作者DToolStripMenuItem
//
this->关于作者DToolStripMenuItem->Name = L"关于作者DToolStripMenuItem";
this->关于作者DToolStripMenuItem->Size = System::Drawing::Size(105, 21);
this->关于作者DToolStripMenuItem->Text = L"关于作者(&D )";
this->关于作者DToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::关于作者DToolStripMenuItem_Click);
//
// button12
//
this->button12->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button12.Image")));
this->button12->Location = System::Drawing::Point(387, 359);
this->button12->Name = L"button12";
this->button12->Size = System::Drawing::Size(88, 53);
this->button12->TabIndex = 27;
this->button12->Text = L"连接测试";
this->button12->UseVisualStyleBackColor = true;
this->button12->Click += gcnew System::EventHandler(this, &Form1::button12_Click);
//
// sqlSelectCommand1
//
this->sqlSelectCommand1->CommandText = L"SELECT 选课表.*, 学生表.*\r\nFROM 学生表 INNER JOIN\r\n 选课表 ON 学生表.学号 = "
L"选课表.学号 CROSS JOIN\r\n 课程表";
this->sqlSelectCommand1->Connection = this->sqlConnection1;
//
// sqlConnection1
//
this->sqlConnection1->ConnectionString = L"Data Source=WIN-11OF0DUGGUS;Initial Catalog=学生信息管理;Integrated Security=True";
this->sqlConnection1->FireInfoMessageEventOnUserErrors = false;
//
// sqlDataAdapter1
//
this->sqlDataAdapter1->SelectCommand = this->sqlSelectCommand1;
cli::array< System::Data::Common::DataColumnMapping^ >^ __mcTemp__1 = gcnew cli::array< System::Data::Common::DataColumnMapping^ >(7) {(gcnew System::Data::Common::DataColumnMapping(L"学号",
L"学号")), (gcnew System::Data::Common::DataColumnMapping(L"课号", L"课号")), (gcnew System::Data::Common::DataColumnMapping(L"分数",
L"分数")), (gcnew System::Data::Common::DataColumnMapping(L"学号1", L"学号1")), (gcnew System::Data::Common::DataColumnMapping(L"姓名",
L"姓名")), (gcnew System::Data::Common::DataColumnMapping(L"性别", L"性别")), (gcnew System::Data::Common::DataColumnMapping(L"系名",
L"系名"))};
this->sqlDataAdapter1->TableMappings->AddRange(gcnew cli::array< System::Data::Common::DataTableMapping^ >(1) {(gcnew System::Data::Common::DataTableMapping(L"Table",
L"学生表", __mcTemp__1))});
//
// button13
//
this->button13->Location = System::Drawing::Point(110, 60);
this->button13->Name = L"button13";
this->button13->Size = System::Drawing::Size(88, 29);
this->button13->TabIndex = 28;
this->button13->Text = L"查询全部";
this->button13->UseVisualStyleBackColor = true;
this->button13->Click += gcnew System::EventHandler(this, &Form1::button13_Click);
//
// comboBox1
//
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^ >(4) {L"姓名", L"学号", L"性别", L"系名"});
this->comboBox1->Location = System::Drawing::Point(278, 59);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(91, 20);
this->comboBox1->TabIndex = 29;
//
// textBox8
//
this->textBox8->Location = System::Drawing::Point(278, 106);
this->textBox8->Name = L"textBox8";
this->textBox8->Size = System::Drawing::Size(91, 21);
this->textBox8->TabIndex = 30;
//
// label8
//
this->label8->AutoSize = true;
this->label8->Location = System::Drawing::Point(219, 109);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(59, 12);
this->label8->TabIndex = 31;
this->label8->Text = L"更新/删除";
//
// label9
//
this->label9->AutoSize = true;
this->label9->Location = System::Drawing::Point(219, 62);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(53, 12);
this->label9->TabIndex = 32;
this->label9->Text = L"类型选择";
//
// comboBox2
//
this->comboBox2->FormattingEnabled = true;
this->comboBox2->Items->AddRange(gcnew cli::array< System::Object^ >(2) {L"M", L"F"});
this->comboBox2->Location = System::Drawing::Point(325, 22);
this->comboBox2->Name = L"comboBox2";
this->comboBox2->Size = System::Drawing::Size(78, 20);
this->comboBox2->TabIndex = 33;
//
// comboBox3
//
this->comboBox3->FormattingEnabled = true;
this->comboBox3->Items->AddRange(gcnew cli::array< System::Object^ >(2) {L"课号", L"学号"});
this->comboBox3->Location = System::Drawing::Point(387, 216);
this->comboBox3->Name = L"comboBox3";
this->comboBox3->Size = System::Drawing::Size(88, 20);
this->comboBox3->TabIndex = 34;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(387, 247);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(88, 21);
this->textBox3->TabIndex = 35;
//
// label10
//
this->label10->AutoSize = true;
this->label10->Location = System::Drawing::Point(529, 187);
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(41, 12);
this->label10->TabIndex = 36;
this->label10->Text = L"课程名";
//
// textBox9
//
this->textBox9->Location = System::Drawing::Point(596, 183);
this->textBox9->Name = L"textBox9";
this->textBox9->Size = System::Drawing::Size(63, 21);
this->textBox9->TabIndex = 37;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->ClientSize = System::Drawing::Size(685, 418);
this->Controls->Add(this->textBox9);
this->Controls->Add(this->label10);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->comboBox3);
this->Controls->Add(this->comboBox2);
this->Controls->Add(this->label9);
this->Controls->Add(this->label8);
this->Controls->Add(this->textBox8);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->button13);
this->Controls->Add(this->button12);
this->Controls->Add(this->dataGridView1);
this->Controls->Add(this->button11);
this->Controls->Add(this->button10);
this->Controls->Add(this->button9);
this->Controls->Add(this->button8);
this->Controls->Add(this->button7);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox7);
this->Controls->Add(this->textBox6);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label7);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->menuStrip1);
this->MainMenuStrip = this->menuStrip1;
this->Name = L"Form1";
this->Text = L"Form1";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->EndInit();
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void label3_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button12_Click(System::Object^ sender, System::EventArgs^ e) {
con=gcnew SqlConnection();
con->ConnectionString = L"Data Source=WIN-11OF0DUGGUS;Initial Catalog=学生信息管理;Integrated Security=True";
try
{
con->Open();
if(con->State==ConnectionState::Open)
MessageBox::Show("连接成功!");
}
catch(Exception^ ex)
{ MessageBox::Show("连接失败!"+ex);}
finally
{ con->Close(); }
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= " select * from 学生表 where 姓名='"+textBox1->Text+"'or 学号='"+textBox2->Text+"'";
MessageBox::Show(sql);
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= " select * from 学生表 where 姓名 like'%"+textBox1->Text+"%'";
MessageBox::Show(sql);
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= " update 学生表 set "+comboBox1->Text+" ='"+textBox8->Text+"' where 姓名='"+textBox1->Text+"' or 学号='"+textBox2->Text+"'";
MessageBox::Show(sql);
DataTable^ ourtable=gcnew DataTable();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{ourda->Fill(ourtable); MessageBox::Show("数据修改成功!"); }
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Message,"提示信息");}
}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= "delete 学生表 where " +comboBox1->Text+" ='"+textBox8->Text+"'";;
MessageBox::Show(sql);
DataTable^ ourtable=gcnew DataTable();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{ ourda->Fill(ourtable); MessageBox::Show("数据修改成功!"); }
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Message,"提示信息");}
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= " insert into 学生表(姓名,学号,性别,系名) values('"+textBox1->Text+"','"+textBox2->Text+"','"+comboBox2->Text+"','"+textBox4->Text+"')";
MessageBox::Show(sql);
DataTable^ ourtable=gcnew DataTable();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{ ourda->Fill(ourtable); MessageBox::Show("数据修改成功!"); }
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Message,"提示信息");}
// this->Close();
}
private: System::Void button13_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= " select * from 学生表";
MessageBox::Show(sql);
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
}
private: System::Void 学生表操作ToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= " select * from 选课表 where (学号='"+textBox5->Text+"'AND 课号='"+textBox6->Text+"') OR (学号='"+textBox5->Text+"'AND 课号=(SELECT 课程号 FROM 课程表 where 课程名='"+textBox9->Text+"')) ";
MessageBox::Show(sql);
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
}
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= " insert into 选课表(学号,课号,分数) values('"+textBox5->Text+"','"+textBox6->Text+"','"+textBox7->Text+"')";
MessageBox::Show(sql);
DataTable^ ourtable=gcnew DataTable();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{ ourda->Fill(ourtable); MessageBox::Show("数据修改成功!"); }
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Message,"提示信息");}
// this->Close();
}
private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= "delete 选课表 where 学号='"+textBox5->Text+"'AND 课号='"+textBox6->Text+"'";
MessageBox::Show(sql);
DataTable^ ourtable=gcnew DataTable();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{ ourda->Fill(ourtable); MessageBox::Show("数据修改成功!"); }
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Message,"提示信息");}
}
private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql= " update 选课表 set 分数 ='"+textBox7->Text+"' where 学号='"+textBox5->Text+"'AND 课号='"+textBox6->Text+"'";
MessageBox::Show(sql);
DataTable^ ourtable=gcnew DataTable();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{ourda->Fill(ourtable); MessageBox::Show("数据修改成功!"); }
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Message,"提示信息");}
}
private: System::Void button10_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql;
if(comboBox3->Text =="学号")
sql= " select AVG(分数) 个人平均分 from 选课表 where 学号= '"+textBox3->Text+"'";
//String^ sql= " select * from 选课表 where '"+comboBox3->Text+"'='"+textBox3->Text+"'";
else sql= " select AVG(分数) 课程平均分 from 选课表 where 课号= '"+textBox3->Text+"'";
MessageBox::Show(sql);
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
}
private: System::Void button11_Click(System::Object^ sender, System::EventArgs^ e) {
String^ sql;
if(comboBox3->Text =="学号")
sql= " select SUM(分数) 个人总分 from 选课表 where 学号= '"+textBox3->Text+"'";
//String^ sql= " select * from 选课表 where '"+comboBox3->Text+"'='"+textBox3->Text+"'";
else sql= " select SUM(分数) 课程总分 from 选课表 where 课号= '"+textBox3->Text+"'";
MessageBox::Show(sql);
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter( sql,con);
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
}
private: System::Void 查询全部ToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
SqlCommand ^sqlCmd=gcnew SqlCommand("查询全部",sqlConnection1);//存储过程名,数据库连接对象
sqlCmd->CommandType=CommandType::StoredProcedure;//设置调用的类型为存储过程
sqlConnection1->Open();
sqlCmd->ExecuteNonQuery();//执行存储过程
// rd=sqlCmd->ExecuteReader();
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter(sqlCmd); //将con去掉
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
sqlConnection1->Close();
}
private: System::Void 精确查询ToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
SqlCommand ^sqlCmd=gcnew SqlCommand("精确查询",sqlConnection1);//存储过程名,数据库连接对象
sqlCmd->CommandType=CommandType::StoredProcedure;//设置调用的类型为存储过程
SqlParameter ^sqlParme;
//
sqlParme=sqlCmd->Parameters->Add("@NAME",SqlDbType::VarChar);//存储过程参数1
sqlParme->Direction=ParameterDirection::Input;
sqlParme->Value=textBox1->Text; //输入的框
sqlParme=sqlCmd->Parameters->Add("@NO",SqlDbType::VarChar);//参数2
sqlParme->Direction=ParameterDirection::Input;
sqlParme->Value=textBox2->Text;
sqlConnection1->Open();
sqlCmd->ExecuteNonQuery();//执行存储过程
// rd=sqlCmd->ExecuteReader();
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter(sqlCmd); //将con去掉才能使用sqlcmd变量
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
sqlConnection1->Close();
}
private: System::Void 平均成绩ToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
//利用if判断组合框,过程用了一个输入参数,写了两个存储过程对应学号和课号
if(comboBox3->Text =="学号"){
SqlCommand ^sqlCmd=gcnew SqlCommand("平均成绩",sqlConnection1);//存储过程名,数据库连接对象
sqlCmd->CommandType=CommandType::StoredProcedure;//设置调用的类型为存储过程
SqlParameter ^sqlParme;
//
sqlParme=sqlCmd->Parameters->Add("@flag",SqlDbType::VarChar);//存储过程参数1
sqlParme->Direction=ParameterDirection::Input;
sqlParme->Value=textBox3->Text; //输入的框
sqlConnection1->Open();
sqlCmd->ExecuteNonQuery();//执行存储过程
// rd=sqlCmd->ExecuteReader();
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter(sqlCmd); //将con去掉
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
sqlConnection1->Close();
}
else { //否则按课号查询
SqlCommand ^sqlCmd=gcnew SqlCommand("平均成绩1",sqlConnection1);//存储过程名,数据库连接对象
sqlCmd->CommandType=CommandType::StoredProcedure;//设置调用的类型为存储过程
SqlParameter ^sqlParme;
//
sqlParme=sqlCmd->Parameters->Add("@flag",SqlDbType::VarChar);//存储过程参数1
sqlParme->Direction=ParameterDirection::Input;
sqlParme->Value=textBox3->Text; //输入的框
sqlConnection1->Open();
sqlCmd->ExecuteNonQuery();//执行存储过程
// rd=sqlCmd->ExecuteReader();
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter(sqlCmd); //将con去掉
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
sqlConnection1->Close();
}
}
private: System::Void 关于作者DToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("作者是南航校草:JellyLiu");
MessageBox::Show("QQ:1158161893");
}
private: System::Void 操作说明CToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("你猜!!!");
}
private: System::Void 总成绩ToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
//利用if判断组合框,过程用了一个输入参数,因为传入的学号和课号均为int型变量
if(comboBox3->Text =="学号"){
SqlCommand ^sqlCmd=gcnew SqlCommand("总成绩",sqlConnection1);//存储过程名,数据库连接对象
sqlCmd->CommandType=CommandType::StoredProcedure;//设置调用的类型为存储过程
SqlParameter ^sqlParme;
//
sqlParme=sqlCmd->Parameters->Add("@flag",SqlDbType::VarChar);//存储过程参数1
sqlParme->Direction=ParameterDirection::Input;
sqlParme->Value=textBox3->Text; //输入的框
sqlConnection1->Open();
sqlCmd->ExecuteNonQuery();//执行存储过程
// rd=sqlCmd->ExecuteReader();
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter(sqlCmd); //将con去掉
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
sqlConnection1->Close();
}
else {
SqlCommand ^sqlCmd=gcnew SqlCommand("总成绩1",sqlConnection1);//存储过程名,数据库连接对象
sqlCmd->CommandType=CommandType::StoredProcedure;//设置调用的类型为存储过程
SqlParameter ^sqlParme;
//
sqlParme=sqlCmd->Parameters->Add("@flag",SqlDbType::VarChar);//存储过程参数1
sqlParme->Direction=ParameterDirection::Input;
sqlParme->Value=textBox3->Text; //输入的框
sqlConnection1->Open();
sqlCmd->ExecuteNonQuery();//执行存储过程
// rd=sqlCmd->ExecuteReader();
DataSet^ ds=gcnew DataSet();
SqlDataAdapter^ ourda = gcnew SqlDataAdapter(sqlCmd); //将con去掉
try
{
ourda->Fill(ds,"TXL");//把数据适配器的内容添加到数据集内
this->dataGridView1->DataSource=ds->Tables["TXL"];
}
catch(System::Data::SqlClient::SqlException^ ex)
{MessageBox::Show("数据的异常信息是:"+ex->Errors,"提示信息");}
sqlConnection1->Close();
}
}
};
}
学生成绩管理系统--利用Windows窗体+SQLSERVER数据库
最新推荐文章于 2020-07-14 14:14:42 发布