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

📄 payoffhistory.h

📁 Visual C++.net数据库开发经典案例
💻 H
字号:
#pragma once
#include "LinkDataBase.h"
#include "DataGridComboboxColumn.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> 
	/// PayoffHistory 摘要
	///
	/// 警告: 如果您更改该类的名称,则将需要更改 
	///          与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的 
	///          “资源文件名”属性。  否则,
	///          设计器将不能与此窗体关联的
	///          本地化资源正确交互。
	/// </summary>
	public __gc class PayoffHistory : public System::Windows::Forms::Form
	{
	//--------------------成员声明------------------------
	private:
		LinkDataBase* MyDataBase;	//数据库连接类
		DataSet* ds;		
		String* strTableName;
	protected: System::Windows::Forms::ImageList *  imageList1;
			   String* strSQL;
	//-------------------成员声明结束-----------------------
	public: 
		PayoffHistory(void)
		{
			InitializeComponent();
			this->MyDataBase = new LinkDataBase();
			this->strSQL = S"SELECT 职员基本信息表.姓名, 工资发放历史表.* FROM 职员基本信息表 INNER JOIN 工资发放历史表 ON 职员基本信息表.职员编号 = 工资发放历史表.职员编号";
			this->strTableName = S"工资发放历史表";
			this->ds = this->MyDataBase->SelectDataBase(this->strSQL,this->strTableName);
			this->dgrdSalaryHistory->DataSource = this->ds->Tables->Item[S"工资发放历史表"]->DefaultView;
			this->DataGridStateControl();
		}
        
	protected: 
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}
	private: System::Windows::Forms::GroupBox *  groupBox2;
	private: System::Windows::Forms::Button *  btnHandout;
	private: System::Windows::Forms::Button *  btnSearch;
	private: System::Windows::Forms::Label *  label23;
	private: System::Windows::Forms::TextBox *  tBoxDate;
	private: System::Windows::Forms::Label *  label22;
	private: System::Windows::Forms::TextBox *  tBoxName;
	private: System::Windows::Forms::DataGrid *  dgrdSalaryHistory;
	private: System::ComponentModel::IContainer *  components;

	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>


		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = new System::ComponentModel::Container();
			System::Resources::ResourceManager *  resources = new System::Resources::ResourceManager(__typeof(My::PayoffHistory));
			this->groupBox2 = new System::Windows::Forms::GroupBox();
			this->btnHandout = new System::Windows::Forms::Button();
			this->imageList1 = new System::Windows::Forms::ImageList(this->components);
			this->btnSearch = new System::Windows::Forms::Button();
			this->label23 = new System::Windows::Forms::Label();
			this->tBoxDate = new System::Windows::Forms::TextBox();
			this->label22 = new System::Windows::Forms::Label();
			this->tBoxName = new System::Windows::Forms::TextBox();
			this->dgrdSalaryHistory = new System::Windows::Forms::DataGrid();
			this->groupBox2->SuspendLayout();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdSalaryHistory))->BeginInit();
			this->SuspendLayout();
			// 
			// groupBox2
			// 
			this->groupBox2->Controls->Add(this->btnHandout);
			this->groupBox2->Controls->Add(this->btnSearch);
			this->groupBox2->Controls->Add(this->label23);
			this->groupBox2->Controls->Add(this->tBoxDate);
			this->groupBox2->Controls->Add(this->label22);
			this->groupBox2->Controls->Add(this->tBoxName);
			this->groupBox2->Dock = System::Windows::Forms::DockStyle::Top;
			this->groupBox2->Location = System::Drawing::Point(0, 0);
			this->groupBox2->Name = S"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(560, 79);
			this->groupBox2->TabIndex = 7;
			this->groupBox2->TabStop = false;
			// 
			// btnHandout
			// 
			this->btnHandout->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
			this->btnHandout->ImageIndex = 11;
			this->btnHandout->ImageList = this->imageList1;
			this->btnHandout->Location = System::Drawing::Point(448, 24);
			this->btnHandout->Name = S"btnHandout";
			this->btnHandout->Size = System::Drawing::Size(64, 24);
			this->btnHandout->TabIndex = 16;
			this->btnHandout->Text = S"退出";
			this->btnHandout->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			this->btnHandout->Click += new System::EventHandler(this, btnHandout_Click);
			// 
			// imageList1
			// 
			this->imageList1->ImageSize = System::Drawing::Size(16, 16);
			this->imageList1->ImageStream = (__try_cast<System::Windows::Forms::ImageListStreamer *  >(resources->GetObject(S"imageList1.ImageStream")));
			this->imageList1->TransparentColor = System::Drawing::Color::Transparent;
			// 
			// btnSearch
			// 
			this->btnSearch->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
			this->btnSearch->ImageIndex = 6;
			this->btnSearch->ImageList = this->imageList1;
			this->btnSearch->Location = System::Drawing::Point(360, 24);
			this->btnSearch->Name = S"btnSearch";
			this->btnSearch->Size = System::Drawing::Size(64, 24);
			this->btnSearch->TabIndex = 15;
			this->btnSearch->Text = S"查询";
			this->btnSearch->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			this->btnSearch->Click += new System::EventHandler(this, btnSearch_Click);
			// 
			// label23
			// 
			this->label23->Location = System::Drawing::Point(167, 32);
			this->label23->Name = S"label23";
			this->label23->Size = System::Drawing::Size(56, 16);
			this->label23->TabIndex = 13;
			this->label23->Text = S"日期";
			// 
			// tBoxDate
			// 
			this->tBoxDate->Location = System::Drawing::Point(231, 28);
			this->tBoxDate->Name = S"tBoxDate";
			this->tBoxDate->Size = System::Drawing::Size(80, 21);
			this->tBoxDate->TabIndex = 12;
			this->tBoxDate->Text = S"";
			// 
			// label22
			// 
			this->label22->Location = System::Drawing::Point(10, 32);
			this->label22->Name = S"label22";
			this->label22->Size = System::Drawing::Size(56, 16);
			this->label22->TabIndex = 11;
			this->label22->Text = S"职员姓名";
			// 
			// tBoxName
			// 
			this->tBoxName->Location = System::Drawing::Point(74, 28);
			this->tBoxName->Name = S"tBoxName";
			this->tBoxName->Size = System::Drawing::Size(80, 21);
			this->tBoxName->TabIndex = 10;
			this->tBoxName->Text = S"";
			// 
			// dgrdSalaryHistory
			// 
			this->dgrdSalaryHistory->DataMember = S"";
			this->dgrdSalaryHistory->Dock = System::Windows::Forms::DockStyle::Fill;
			this->dgrdSalaryHistory->HeaderForeColor = System::Drawing::SystemColors::ControlText;
			this->dgrdSalaryHistory->Location = System::Drawing::Point(0, 79);
			this->dgrdSalaryHistory->Name = S"dgrdSalaryHistory";
			this->dgrdSalaryHistory->Size = System::Drawing::Size(560, 302);
			this->dgrdSalaryHistory->TabIndex = 8;
			// 
			// PayoffHistory
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(560, 381);
			this->Controls->Add(this->dgrdSalaryHistory);
			this->Controls->Add(this->groupBox2);
			this->Name = S"PayoffHistory";
			this->Text = S"工资发放历史";
			this->groupBox2->ResumeLayout(false);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdSalaryHistory))->EndInit();
			this->ResumeLayout(false);

		}		
		//------------------设置表格样式----------------------
		void DataGridStateControl()
		{
			DataGridTableStyle* ts = new DataGridTableStyle();
			DataGridNoActiveCellColumn* aTextColumn;
			ts->AlternatingBackColor = Color::LightGray;
			ts->MappingName = this->ds->Tables->Item[S"工资发放历史表"]->TableName;

			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->dgrdSalaryHistory->TableStyles->Add(ts);
			this->dgrdSalaryHistory->Select(0);
		}
	private: System::Void btnSearch_Click(System::Object *  sender, System::EventArgs *  e)
			 {
				 String* Filter = String::Format(S"(姓名 like '%{0}%') and (Convert(日期,'System::String') like '%{1}%')",this->tBoxName->Text->Trim(),this->tBoxDate->Text->Trim());
				 this->ds->Tables->Item[S"工资发放历史表"]->DefaultView->RowFilter = Filter;
			 }

private: System::Void btnHandout_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 this->Close();
		 }

};
}

⌨️ 快捷键说明

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