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

📄 selectarrival.h

📁 我新买的书 光盘里有一个很好的教务管理系统的VC.net的按例
💻 H
字号:
#pragma once
#include "LinkDataBase.h"
#include "DataGridNoActiveCellColumn.h"

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


namespace My
{
	/// <summary> 
	/// SelectArrival 摘要
	///
	/// 警告: 如果您更改该类的名称,则将需要更改 
	///          与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的 
	///          “资源文件名”属性。  否则,
	///          设计器将不能与此窗体关联的
	///          本地化资源正确交互。
	/// </summary>
	public __gc class SelectArrival : public System::Windows::Forms::Form
	{
		//--------------------成员声明------------------------
	private:
		LinkDataBase* MyDataBase;	//数据库连接类
		SqlDataAdapter* ArrivalAdapter;
		DataSet* ds;
		String* strTableName;
		String* strSQL;
	private: System::Windows::Forms::DataGrid *  dgrdArrivals;
	public:
		String* strArrivalID;

		//-------------------成员声明结束-----------------------
	public: 
		SelectArrival(void)
		{
			InitializeComponent();
			//初始化
			this->MyDataBase = new LinkDataBase();
			this->ds = new DataSet();
			this->ArrivalAdapter = new SqlDataAdapter();		

			//查询入住单
			this->strSQL = S"Select * from 入住单";
			this->strTableName = S"入住单";
			this->MyDataBase->SelectDataBase(this->ArrivalAdapter,this->ds,this->strSQL,this->strTableName);

			
			//设置DataGrid
			this->dgrdArrivals->DataSource = this->ds->Tables->Item[S"入住单"];
			this->DataGridStateControl();			
		}
        
	protected: 
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}









	private: System::Windows::Forms::ImageList *  imageList1;
	private: System::ComponentModel::IContainer *  components;
	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>


		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = new System::ComponentModel::Container();
			this->imageList1 = new System::Windows::Forms::ImageList(this->components);
			this->dgrdArrivals = new System::Windows::Forms::DataGrid();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdArrivals))->BeginInit();
			this->SuspendLayout();
			// 
			// imageList1
			// 
			this->imageList1->ImageSize = System::Drawing::Size(16, 16);
			this->imageList1->TransparentColor = System::Drawing::Color::Transparent;
			// 
			// dgrdArrivals
			// 
			this->dgrdArrivals->DataMember = S"";
			this->dgrdArrivals->Dock = System::Windows::Forms::DockStyle::Fill;
			this->dgrdArrivals->HeaderForeColor = System::Drawing::SystemColors::ControlText;
			this->dgrdArrivals->Location = System::Drawing::Point(0, 0);
			this->dgrdArrivals->Name = S"dgrdArrivals";
			this->dgrdArrivals->Size = System::Drawing::Size(760, 557);
			this->dgrdArrivals->TabIndex = 2;
			this->dgrdArrivals->DoubleClick += new System::EventHandler(this, dgrdArrivals_DoubleClick_1);
			// 
			// SelectArrival
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(760, 557);
			this->Controls->Add(this->dgrdArrivals);
			this->Name = S"SelectArrival";
			this->Text = S"选择入住单";
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdArrivals))->EndInit();
			this->ResumeLayout(false);

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

			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->dgrdArrivals->TableStyles->Add(ts);
  		 }

		 //---------双击数据表选择入住单号------------
private: System::Void dgrdArrivals_DoubleClick_1(System::Object *  sender, System::EventArgs *  e)
		 {
			 int row = this->dgrdArrivals->CurrentCell.RowNumber;
			 this->strArrivalID = this->ds->Tables->Item[S"入住单"]->Rows->Item[row]->Item[S"入住单号"]->ToString();
			 
			 //返回
			 this->DialogResult = DialogResult::OK;
		 }

};
}

⌨️ 快捷键说明

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