📄 selectimporttable.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>
/// SelectImportTable 摘要
///
/// 警告: 如果您更改该类的名称,则将需要更改
/// 与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。 否则,
/// 设计器将不能与此窗体关联的
/// 本地化资源正确交互。
/// </summary>
public __gc class SelectImportTable : public System::Windows::Forms::Form
{
//--------------------成员声明------------------------
public:
String* SendImportID;
private:
LinkDataBase* MyDataBase; //数据库连接类
DataSet* ds;
String* strTableName;
private: System::Windows::Forms::DataGrid * dgrdImportTable;
String* strSQL;
//-------------------成员声明结束-----------------------
public:
SelectImportTable(String* strSQL)
{
InitializeComponent();
this->MyDataBase = new LinkDataBase();
this->strTableName = new String("进货单");
if(strSQL != NULL)
this->strSQL = strSQL;
else
this->strSQL = new String("Select * from 进货单");
this->ds = this->MyDataBase->SelectDataBase(this->strSQL,this->strTableName);
this->DataGridStateControl();
this->dgrdImportTable->DataSource = ds->Tables->Item[0];
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Button * button1;
private: System::Windows::Forms::Button * btnOK;
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container* components;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
void InitializeComponent(void)
{
this->button1 = new System::Windows::Forms::Button();
this->btnOK = new System::Windows::Forms::Button();
this->dgrdImportTable = new System::Windows::Forms::DataGrid();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdImportTable))->BeginInit();
this->SuspendLayout();
//
// button1
//
this->button1->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->button1->Location = System::Drawing::Point(392, 347);
this->button1->Name = S"button1";
this->button1->Size = System::Drawing::Size(88, 32);
this->button1->TabIndex = 9;
this->button1->Text = S"取消";
//
// btnOK
//
this->btnOK->DialogResult = System::Windows::Forms::DialogResult::OK;
this->btnOK->Location = System::Drawing::Point(160, 347);
this->btnOK->Name = S"btnOK";
this->btnOK->Size = System::Drawing::Size(88, 32);
this->btnOK->TabIndex = 8;
this->btnOK->Text = S"确定";
this->btnOK->Click += new System::EventHandler(this, btnOK_Click);
//
// dgrdImportTable
//
this->dgrdImportTable->DataMember = S"";
this->dgrdImportTable->Dock = System::Windows::Forms::DockStyle::Top;
this->dgrdImportTable->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dgrdImportTable->Location = System::Drawing::Point(0, 0);
this->dgrdImportTable->Name = S"dgrdImportTable";
this->dgrdImportTable->Size = System::Drawing::Size(712, 296);
this->dgrdImportTable->TabIndex = 7;
//
// SelectImportTable
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(712, 389);
this->Controls->Add(this->button1);
this->Controls->Add(this->btnOK);
this->Controls->Add(this->dgrdImportTable);
this->Name = S"SelectImportTable";
this->Text = S"查看进货单";
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdImportTable))->EndInit();
this->ResumeLayout(false);
}
void DataGridStateControl()
{
DataGridTableStyle* ts = new DataGridTableStyle();
ts->AlternatingBackColor = Color::LightGray;
ts->MappingName = this->ds->Tables->Item[0]->TableName;
ts->AllowSorting = true;
int numCols = this->ds->Tables->Item[0]->Columns->Count;
for(int i = 0;i < numCols;i++)
{
DataGridNoActiveCellColumn* aNoActiveCellColumn = new DataGridNoActiveCellColumn();
aNoActiveCellColumn->MappingName = this->ds->Tables->Item[0]->Columns->Item[i]->ColumnName;
aNoActiveCellColumn->NullText = String::Empty;
aNoActiveCellColumn->Format = S"F";
ts->GridColumnStyles->Add(aNoActiveCellColumn);
}
this->dgrdImportTable->TableStyles->Add(ts);
}
private: System::Void btnOK_Click(System::Object * sender, System::EventArgs * e)
{
int intCurrentRowNumber = this->dgrdImportTable->CurrentCell.RowNumber;
SendImportID = this->dgrdImportTable->get_Item(intCurrentRowNumber,0)->ToString();
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -