#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數據庫
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.