📄 lookupstafferinfo.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>
/// LookupStafferInfo 摘要
///
/// 警告: 如果您更改该类的名称,则将需要更改
/// 与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。 否则,
/// 设计器将不能与此窗体关联的
/// 本地化资源正确交互。
/// </summary>
public __gc class LookupStafferInfo : public System::Windows::Forms::Form
{
//--------------------成员声明------------------------
private:
LinkDataBase* MyDataBase; //数据库连接类
DataSet* ds;
String* strTableName;
protected: System::Windows::Forms::ImageList * imageList1;
String* strSQL;
//-------------------成员声明结束-----------------------
public:
LookupStafferInfo(void)
{
InitializeComponent();
this->MyDataBase = new LinkDataBase();
this->strSQL = S"SELECT * FROM 职员基本信息表";
this->strTableName = S"职员基本信息表";
this->ds = this->MyDataBase->SelectDataBase(this->strSQL,this->strTableName);
this->dgrdStafferInfo->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::GroupBox * groupBox1;
private: System::Windows::Forms::Label * label6;
private: System::Windows::Forms::Label * label5;
private: System::Windows::Forms::Label * label4;
private: System::Windows::Forms::Label * label3;
private: System::Windows::Forms::Label * label2;
private: System::Windows::Forms::ComboBox * cmbStaffNativePlace;
private: System::Windows::Forms::ComboBox * cmbStaffNation;
private: System::Windows::Forms::ComboBox * cmbStaffSex;
private: System::Windows::Forms::TextBox * tBoxStaffNameCode;
private: System::Windows::Forms::TextBox * tBoxStaffName;
private: System::Windows::Forms::DataGrid * dgrdStafferInfo;
private: System::Windows::Forms::Button * btnSearch;
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::LookupStafferInfo));
this->groupBox1 = new System::Windows::Forms::GroupBox();
this->btnSearch = new System::Windows::Forms::Button();
this->imageList1 = new System::Windows::Forms::ImageList(this->components);
this->label6 = new System::Windows::Forms::Label();
this->label5 = new System::Windows::Forms::Label();
this->label4 = new System::Windows::Forms::Label();
this->label3 = new System::Windows::Forms::Label();
this->label2 = new System::Windows::Forms::Label();
this->cmbStaffNativePlace = new System::Windows::Forms::ComboBox();
this->cmbStaffNation = new System::Windows::Forms::ComboBox();
this->cmbStaffSex = new System::Windows::Forms::ComboBox();
this->tBoxStaffNameCode = new System::Windows::Forms::TextBox();
this->tBoxStaffName = new System::Windows::Forms::TextBox();
this->dgrdStafferInfo = new System::Windows::Forms::DataGrid();
this->groupBox1->SuspendLayout();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdStafferInfo))->BeginInit();
this->SuspendLayout();
//
// groupBox1
//
this->groupBox1->Controls->Add(this->btnSearch);
this->groupBox1->Controls->Add(this->label6);
this->groupBox1->Controls->Add(this->label5);
this->groupBox1->Controls->Add(this->label4);
this->groupBox1->Controls->Add(this->label3);
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Controls->Add(this->cmbStaffNativePlace);
this->groupBox1->Controls->Add(this->cmbStaffNation);
this->groupBox1->Controls->Add(this->cmbStaffSex);
this->groupBox1->Controls->Add(this->tBoxStaffNameCode);
this->groupBox1->Controls->Add(this->tBoxStaffName);
this->groupBox1->Dock = System::Windows::Forms::DockStyle::Top;
this->groupBox1->Location = System::Drawing::Point(0, 0);
this->groupBox1->Name = S"groupBox1";
this->groupBox1->Size = System::Drawing::Size(656, 96);
this->groupBox1->TabIndex = 0;
this->groupBox1->TabStop = false;
//
// btnSearch
//
this->btnSearch->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->btnSearch->ImageIndex = 6;
this->btnSearch->ImageList = this->imageList1;
this->btnSearch->Location = System::Drawing::Point(528, 36);
this->btnSearch->Name = S"btnSearch";
this->btnSearch->Size = System::Drawing::Size(56, 24);
this->btnSearch->TabIndex = 37;
this->btnSearch->Text = S"查询";
this->btnSearch->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->btnSearch->Click += new System::EventHandler(this, btnSearch_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;
//
// label6
//
this->label6->Location = System::Drawing::Point(360, 24);
this->label6->Name = S"label6";
this->label6->Size = System::Drawing::Size(56, 16);
this->label6->TabIndex = 36;
this->label6->Text = S"籍贯";
//
// label5
//
this->label5->Location = System::Drawing::Point(256, 24);
this->label5->Name = S"label5";
this->label5->Size = System::Drawing::Size(56, 16);
this->label5->TabIndex = 35;
this->label5->Text = S"民族";
//
// label4
//
this->label4->Location = System::Drawing::Point(200, 24);
this->label4->Name = S"label4";
this->label4->Size = System::Drawing::Size(32, 16);
this->label4->TabIndex = 34;
this->label4->Text = S"性别";
//
// label3
//
this->label3->Location = System::Drawing::Point(112, 24);
this->label3->Name = S"label3";
this->label3->Size = System::Drawing::Size(56, 16);
this->label3->TabIndex = 33;
this->label3->Text = S"姓名简码";
//
// label2
//
this->label2->Location = System::Drawing::Point(24, 24);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing::Size(56, 16);
this->label2->TabIndex = 32;
this->label2->Text = S"姓名";
//
// cmbStaffNativePlace
//
System::Object* __mcTemp__1[] = new System::Object*[6];
__mcTemp__1[0] = S"北京";
__mcTemp__1[1] = S"广东";
__mcTemp__1[2] = S"安徽";
__mcTemp__1[3] = S"江西";
__mcTemp__1[4] = S"山东";
__mcTemp__1[5] = S"其它";
this->cmbStaffNativePlace->Items->AddRange(__mcTemp__1);
this->cmbStaffNativePlace->Location = System::Drawing::Point(360, 40);
this->cmbStaffNativePlace->Name = S"cmbStaffNativePlace";
this->cmbStaffNativePlace->Size = System::Drawing::Size(144, 20);
this->cmbStaffNativePlace->TabIndex = 31;
//
// cmbStaffNation
//
System::Object* __mcTemp__2[] = new System::Object*[7];
__mcTemp__2[0] = S"汉族";
__mcTemp__2[1] = S"维吾尔族";
__mcTemp__2[2] = S"蒙古族";
__mcTemp__2[3] = S"满族";
__mcTemp__2[4] = S"藏族";
__mcTemp__2[5] = S"彝族";
__mcTemp__2[6] = S"其它";
this->cmbStaffNation->Items->AddRange(__mcTemp__2);
this->cmbStaffNation->Location = System::Drawing::Point(256, 40);
this->cmbStaffNation->Name = S"cmbStaffNation";
this->cmbStaffNation->Size = System::Drawing::Size(96, 20);
this->cmbStaffNation->TabIndex = 30;
//
// cmbStaffSex
//
System::Object* __mcTemp__3[] = new System::Object*[2];
__mcTemp__3[0] = S"男";
__mcTemp__3[1] = S"女";
this->cmbStaffSex->Items->AddRange(__mcTemp__3);
this->cmbStaffSex->Location = System::Drawing::Point(200, 40);
this->cmbStaffSex->Name = S"cmbStaffSex";
this->cmbStaffSex->Size = System::Drawing::Size(48, 20);
this->cmbStaffSex->TabIndex = 29;
//
// tBoxStaffNameCode
//
this->tBoxStaffNameCode->Location = System::Drawing::Point(112, 40);
this->tBoxStaffNameCode->Name = S"tBoxStaffNameCode";
this->tBoxStaffNameCode->Size = System::Drawing::Size(80, 21);
this->tBoxStaffNameCode->TabIndex = 28;
this->tBoxStaffNameCode->Text = S"";
//
// tBoxStaffName
//
this->tBoxStaffName->Location = System::Drawing::Point(24, 40);
this->tBoxStaffName->Name = S"tBoxStaffName";
this->tBoxStaffName->Size = System::Drawing::Size(80, 21);
this->tBoxStaffName->TabIndex = 27;
this->tBoxStaffName->Text = S"";
//
// dgrdStafferInfo
//
this->dgrdStafferInfo->DataMember = S"";
this->dgrdStafferInfo->Dock = System::Windows::Forms::DockStyle::Fill;
this->dgrdStafferInfo->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dgrdStafferInfo->Location = System::Drawing::Point(0, 96);
this->dgrdStafferInfo->Name = S"dgrdStafferInfo";
this->dgrdStafferInfo->Size = System::Drawing::Size(656, 230);
this->dgrdStafferInfo->TabIndex = 3;
//
// LookupStafferInfo
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(656, 326);
this->Controls->Add(this->dgrdStafferInfo);
this->Controls->Add(this->groupBox1);
this->Name = S"LookupStafferInfo";
this->Text = S"职员信息查询";
this->groupBox1->ResumeLayout(false);
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdStafferInfo))->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->dgrdStafferInfo->TableStyles->Add(ts);
this->dgrdStafferInfo->Select(0);
}
private: System::Void btnSearch_Click(System::Object * sender, System::EventArgs * e)
{
String* Filter = S"";
String* strName = this->tBoxStaffName->Text->Trim();
String* strNameCode = this->tBoxStaffNameCode->Text->Trim();
String* strSex = this->cmbStaffSex->Text->Trim();
String* strNation = this->cmbStaffNation->Text->Trim();
String* strNativePlace = this->cmbStaffNativePlace->Text->Trim();
if(String::Compare(strName,String::Empty) != 0)
{
Filter = String::Format(S"{0}姓名 like '{1}%' and ",Filter,strName);
}
if(String::Compare(strNameCode,String::Empty) != 0)
{
Filter = String::Format(S"{0}姓名简码 like '{1}%' and ",Filter,strNameCode);
}
if(String::Compare(strSex,String::Empty) != 0)
{
Filter = String::Format(S"{0}性别 like '{1}%' and ",Filter,strSex);
}
if(String::Compare(strNation,String::Empty) != 0)
{
Filter = String::Format(S"{0}民族 like '{1}%' and ",Filter,strNation);
}
if(String::Compare(strNativePlace,String::Empty) != 0)
{
Filter = String::Format(S"{0}籍贯 like '{1}%' and ",Filter,strNativePlace);
}
if(String::Compare(Filter,S"") != 0)
Filter = Filter->Substring(0,Filter->Length - 5);
this->ds->Tables->Item[S"职员基本信息表"]->DefaultView->RowFilter = Filter;
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -