⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scoreinput.h

📁 Visual C++.net数据库开发经典案例
💻 H
📖 第 1 页 / 共 2 页
字号:
			this->btnSave->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
			this->btnSave->ImageIndex = 0;
			this->btnSave->ImageList = this->imageList1;
			this->btnSave->Location = System::Drawing::Point(544, 48);
			this->btnSave->Name = S"btnSave";
			this->btnSave->Size = System::Drawing::Size(96, 32);
			this->btnSave->TabIndex = 67;
			this->btnSave->Text = S"提交";
			this->btnSave->Click += new System::EventHandler(this, btnSave_Click);
			// 
			// btnSearch
			// 
			this->btnSearch->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
			this->btnSearch->ImageIndex = 12;
			this->btnSearch->ImageList = this->imageList1;
			this->btnSearch->Location = System::Drawing::Point(312, 48);
			this->btnSearch->Name = S"btnSearch";
			this->btnSearch->Size = System::Drawing::Size(96, 32);
			this->btnSearch->TabIndex = 66;
			this->btnSearch->Text = S"查询";
			this->btnSearch->Click += new System::EventHandler(this, btnSearch_Click);
			// 
			// tBoxPinYin
			// 
			this->tBoxPinYin->Location = System::Drawing::Point(96, 56);
			this->tBoxPinYin->Name = S"tBoxPinYin";
			this->tBoxPinYin->Size = System::Drawing::Size(144, 21);
			this->tBoxPinYin->TabIndex = 65;
			this->tBoxPinYin->Text = S"";
			// 
			// label13
			// 
			this->label13->Location = System::Drawing::Point(24, 64);
			this->label13->Name = S"label13";
			this->label13->Size = System::Drawing::Size(48, 11);
			this->label13->TabIndex = 64;
			this->label13->Text = S"拼音码";
			// 
			// tBoxCourseName
			// 
			this->tBoxCourseName->Location = System::Drawing::Point(96, 88);
			this->tBoxCourseName->Name = S"tBoxCourseName";
			this->tBoxCourseName->Size = System::Drawing::Size(144, 21);
			this->tBoxCourseName->TabIndex = 10;
			this->tBoxCourseName->Text = S"";
			// 
			// label9
			// 
			this->label9->Location = System::Drawing::Point(24, 96);
			this->label9->Name = S"label9";
			this->label9->Size = System::Drawing::Size(56, 11);
			this->label9->TabIndex = 9;
			this->label9->Text = S"课程名称";
			// 
			// tBoxCourseID
			// 
			this->tBoxCourseID->Location = System::Drawing::Point(96, 24);
			this->tBoxCourseID->Name = S"tBoxCourseID";
			this->tBoxCourseID->Size = System::Drawing::Size(144, 21);
			this->tBoxCourseID->TabIndex = 2;
			this->tBoxCourseID->Text = S"";
			// 
			// label5
			// 
			this->label5->Location = System::Drawing::Point(24, 32);
			this->label5->Name = S"label5";
			this->label5->Size = System::Drawing::Size(56, 11);
			this->label5->TabIndex = 1;
			this->label5->Text = S"课程编号";
			// 
			// label1
			// 
			this->label1->Location = System::Drawing::Point(80, 48);
			this->label1->Name = S"label1";
			this->label1->Size = System::Drawing::Size(40, 16);
			this->label1->TabIndex = 69;
			this->label1->Text = S"成绩";
			// 
			// ScoreInput
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(744, 437);
			this->Controls->Add(this->groupBox2);
			this->Controls->Add(this->dataGrid1);
			this->Controls->Add(this->groupBox3);
			this->Controls->Add(this->groupBox1);
			this->Name = S"ScoreInput";
			this->Text = S"成绩输入";
			this->groupBox1->ResumeLayout(false);
			this->groupBox2->ResumeLayout(false);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdCourse))->EndInit();
			this->groupBox4->ResumeLayout(false);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dataGrid1))->EndInit();
			this->groupBox3->ResumeLayout(false);
			this->ResumeLayout(false);

		}		
	private:
				
		//-----------------------设置表格各列的属性-----------------------
		void DataGridStateCourse()
		{

			DataGridTableStyle* ts = new DataGridTableStyle();			
			ts->MappingName = this->ds->Tables->Item[S"成绩单"]->TableName;
			
			DataGridNoActiveCellColumn* aTextColumn;
			ts->AllowSorting = false;
			ts->AlternatingBackColor = Color::LightGray;

			int numCols = this->ds->Tables->Item[S"成绩单"]->Columns->Count;
			for(int i = 0;i < numCols;i++)
			{
				aTextColumn = new DataGridNoActiveCellColumn();
				aTextColumn->get_TextBox()->Enabled = false;
				aTextColumn->MappingName = this->ds->Tables->Item[S"成绩单"]->Columns->Item[i]->ColumnName;
				aTextColumn->HeaderText = this->ds->Tables->Item[S"成绩单"]->Columns->Item[i]->ColumnName;
				aTextColumn->NullText = S"";
				aTextColumn->Format = S"D";
				ts->GridColumnStyles->Add(aTextColumn);
			}

			this->dgrdCourse->TableStyles->Add(ts);
  		 }
private: System::Void btnQuit_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 String* tempSQL = S"exec sf_终止选课";
			 this->MyDataBase->SQLOperate(tempSQL);
		 }

private: System::Void btnEdit_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(String::Compare(this->tBoxMark->Text,String::Empty) == 0)
				 return;
			 //修改成绩
			 int row = this->dgrdCourse->CurrentRowIndex;
			 String* tempSQL = String::Format(S"Update 成绩表 Set 成绩 = '{0}' Where 编号 = '{1}'",this->tBoxMark->Text,this->ds->Tables->Item[S"成绩单"]->Rows->Item[row]->Item[S"编号"]->ToString());
			 this->MyDataBase->SQLOperate(tempSQL);
			 //更新
			 this->ds->Tables->Item[S"成绩单"]->Clear();
			 this->CourseAdapter->Fill(this->ds->Tables->Item[S"成绩单"]);
		 }

private: System::Void btnSearch_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 String* strCourseID = this->tBoxCourseID->Text->Trim();
			 String* strCourseName = this->tBoxCourseName->Text->Trim();
			 String* strPinYin = this->tBoxPinYin->Text->Trim();
			 String* Filter = S"";
			 if(String::Compare(strCourseID,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (成绩表.课程编号 LIKE '%{1}%')",Filter,strCourseID);
			 }
			 if(String::Compare(strCourseName,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (课程信息.课程名称 LIKE '%{1}%')",Filter,strCourseName);
			 }
			 if(String::Compare(strPinYin,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (课程信息.拼音码 LIKE '%{1}%')",Filter,strPinYin);
			 }

			 if(String::Compare(Filter,String::Empty) != 0)
			 {
				 this->ds->Clear();
				 this->strSQL = String::Format(S"SELECT 成绩表.编号, 成绩表.课程编号, 课程信息.课程名称, 学生信息.学号, 学生信息.姓名,成绩表.成绩 FROM 成绩表 INNER JOIN  课程信息 ON 成绩表.课程编号 = 课程信息.课程编号 INNER JOIN 学生信息 ON 成绩表.学号 = 学生信息.学号 Where (成绩表.是否已确定成绩 = 'N'){0}",Filter);
				 this->strTableName = S"成绩单";
				 this->MyDataBase->SelectDataBase(this->CourseAdapter,this->ds,this->strSQL,this->strTableName);

				 this->dgrdCourse->DataSource = this->ds->Tables->Item[S"成绩单"];
				 if(this->ds->Tables->Item[S"成绩单"]->Rows->Count > 0)
				 {
					 this->tBoxMark->ReadOnly = false;					
					 this->btnEdit->Enabled = true;
					 this->DataGridStateCourse();
				 }
				 else
				 {
					 this->tBoxMark->ReadOnly = true;
					 this->btnEdit->Enabled = false;
				 }
				 
			 }			
		 }

private: System::Void btnSave_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 String* tempSQL = String::Format(S"exec sf_成绩提交 '{0}'",this->ds->Tables->Item[S"成绩单"]->Rows->Item[0]->Item[S"课程编号"]->ToString());
			 this->MyDataBase->SQLOperate(tempSQL);
			 MessageBox::Show(S"提交成功");

			 String* strCourseID = this->tBoxCourseID->Text->Trim();
			 String* strCourseName = this->tBoxCourseName->Text->Trim();
			 String* strPinYin = this->tBoxPinYin->Text->Trim();
			 String* Filter = S"";
			 if(String::Compare(strCourseID,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (成绩表.课程编号 LIKE '%{1}%')",Filter,strCourseID);
			 }
			 if(String::Compare(strCourseName,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (课程信息.课程名称 LIKE '%{1}%')",Filter,strCourseName);
			 }
			 if(String::Compare(strPinYin,String::Empty) != 0)
			 {
				 Filter = String::Format(S"{0} AND (课程信息.拼音码 LIKE '%{1}%')",Filter,strPinYin);
			 }


			 this->ds->Clear();
				 this->strSQL = String::Format(S"SELECT 成绩表.编号, 成绩表.课程编号, 课程信息.课程名称, 学生信息.学号, 学生信息.姓名,成绩表.成绩 FROM 成绩表 INNER JOIN  课程信息 ON 成绩表.课程编号 = 课程信息.课程编号 INNER JOIN 学生信息 ON 成绩表.学号 = 学生信息.学号 Where (成绩表.是否已确定成绩 = 'N'){0}",Filter);
				 this->strTableName = S"成绩单";
				 this->MyDataBase->SelectDataBase(this->CourseAdapter,this->ds,this->strSQL,this->strTableName);

				 this->dgrdCourse->DataSource = this->ds->Tables->Item[S"成绩单"];
				 if(this->ds->Tables->Item[S"成绩单"]->Rows->Count > 0)
				 {
					 this->tBoxMark->ReadOnly = false;					
					 this->btnEdit->Enabled = true;					 
				 }
				 else
				 {
					 this->tBoxMark->ReadOnly = true;
					 this->btnEdit->Enabled = false;
				 }
		 }

};
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -