📄 detailquery.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>
/// DetailQuery 摘要
///
/// 警告: 如果您更改该类的名称,则将需要更改
/// 与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。 否则,
/// 设计器将不能与此窗体关联的
/// 本地化资源正确交互。
/// </summary>
public __gc class DetailQuery : public System::Windows::Forms::Form
{
//--------------------成员声明------------------------
private:
LinkDataBase* MyDataBase; //数据库连接类
DataSet* ds;
String* strSQL;
SqlDataAdapter* DetailAdapter;
SqlDataAdapter* SubjectAdapter;
DataView* DetailView;
private: System::Windows::Forms::ImageList * imageList1;
String* SubjectName;
//-------------------成员声明结束-----------------------
public:
DetailQuery(void)
{
InitializeComponent();
this->MyDataBase = new LinkDataBase();
this->DetailAdapter = new SqlDataAdapter();
this->SubjectAdapter = new SqlDataAdapter();
this->DetailView = new DataView();
this->ds = new DataSet();
this->strSQL = S"SELECT 科目表.科目名称,本期明细帐簿.* FROM 本期明细帐簿,科目表 WHERE 本期明细帐簿.科目代码 = 科目表.科目代码";
this->MyDataBase->SelectDataBase(this->DetailAdapter,this->ds,this->strSQL,S"本期明细帐簿");
this->strSQL = S"SELECT 科目名称 FROM 科目表";
this->MyDataBase->SelectDataBase(this->SubjectAdapter,this->ds,this->strSQL,S"科目表");
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::GroupBox * groupBox2;
private: System::Windows::Forms::Button * btnSearch;
private: System::Windows::Forms::Label * label10;
private: System::Windows::Forms::TextBox * tBoxSubjectCode;
private: System::Windows::Forms::GroupBox * groupBox1;
private: System::Windows::Forms::ComboBox * cmbProject;
private: System::Windows::Forms::DataGrid * dgrdDetail;
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::DetailQuery));
this->groupBox2 = new System::Windows::Forms::GroupBox();
this->btnSearch = new System::Windows::Forms::Button();
this->imageList1 = new System::Windows::Forms::ImageList(this->components);
this->label10 = new System::Windows::Forms::Label();
this->tBoxSubjectCode = new System::Windows::Forms::TextBox();
this->groupBox1 = new System::Windows::Forms::GroupBox();
this->cmbProject = new System::Windows::Forms::ComboBox();
this->dgrdDetail = new System::Windows::Forms::DataGrid();
this->groupBox2->SuspendLayout();
this->groupBox1->SuspendLayout();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdDetail))->BeginInit();
this->SuspendLayout();
//
// groupBox2
//
this->groupBox2->Controls->Add(this->btnSearch);
this->groupBox2->Controls->Add(this->label10);
this->groupBox2->Controls->Add(this->tBoxSubjectCode);
this->groupBox2->Location = System::Drawing::Point(0, 0);
this->groupBox2->Name = S"groupBox2";
this->groupBox2->Size = System::Drawing::Size(392, 88);
this->groupBox2->TabIndex = 6;
this->groupBox2->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(24, 40);
this->btnSearch->Name = S"btnSearch";
this->btnSearch->Size = System::Drawing::Size(88, 24);
this->btnSearch->TabIndex = 37;
this->btnSearch->Text = S"查询";
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;
//
// label10
//
this->label10->Location = System::Drawing::Point(136, 46);
this->label10->Name = S"label10";
this->label10->Size = System::Drawing::Size(56, 16);
this->label10->TabIndex = 32;
this->label10->Text = S"凭证编号";
//
// tBoxSubjectCode
//
this->tBoxSubjectCode->Location = System::Drawing::Point(200, 40);
this->tBoxSubjectCode->Name = S"tBoxSubjectCode";
this->tBoxSubjectCode->Size = System::Drawing::Size(168, 21);
this->tBoxSubjectCode->TabIndex = 27;
this->tBoxSubjectCode->Text = S"";
//
// groupBox1
//
this->groupBox1->Controls->Add(this->cmbProject);
this->groupBox1->Location = System::Drawing::Point(392, 0);
this->groupBox1->Name = S"groupBox1";
this->groupBox1->Size = System::Drawing::Size(368, 88);
this->groupBox1->TabIndex = 7;
this->groupBox1->TabStop = false;
this->groupBox1->Text = S"选择显示的项目";
//
// cmbProject
//
this->cmbProject->ItemHeight = 12;
this->cmbProject->Location = System::Drawing::Point(64, 40);
this->cmbProject->Name = S"cmbProject";
this->cmbProject->Size = System::Drawing::Size(232, 20);
this->cmbProject->TabIndex = 0;
this->cmbProject->SelectedIndexChanged += new System::EventHandler(this, cmbProject_SelectedIndexChanged);
//
// dgrdDetail
//
this->dgrdDetail->AllowNavigation = false;
this->dgrdDetail->DataMember = S"";
this->dgrdDetail->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dgrdDetail->Location = System::Drawing::Point(0, 88);
this->dgrdDetail->Name = S"dgrdDetail";
this->dgrdDetail->ReadOnly = true;
this->dgrdDetail->Size = System::Drawing::Size(768, 328);
this->dgrdDetail->TabIndex = 11;
//
// DetailQuery
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(752, 421);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->dgrdDetail);
this->Name = S"DetailQuery";
this->Text = S"明细账查询";
this->Load += new System::EventHandler(this, DetailQuery_Load);
this->groupBox2->ResumeLayout(false);
this->groupBox1->ResumeLayout(false);
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdDetail))->EndInit();
this->ResumeLayout(false);
}
private: System::Void DetailQuery_Load(System::Object * sender, System::EventArgs * e)
{
this->DetailView->Table = this->ds->Tables->Item[S"本期明细帐簿"];
this->dgrdDetail->DataSource = this->DetailView;
this->DataGridStateControl();
DataRow* row = this->ds->Tables->Item[S"科目表"]->NewRow();
row->set_Item(S"科目名称",S"全部项目");
this->ds->Tables->Item[S"科目表"]->Rows->InsertAt(row,0);
this->ds->Tables->Item[S"科目表"]->AcceptChanges();
this->cmbProject->DataSource = this->ds->Tables->Item[S"科目表"];
this->cmbProject->DisplayMember = S"科目名称";
}
//------------------设置表格样式----------------------
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->dgrdDetail->TableStyles->Add(ts);
}
private: System::Void btnSearch_Click(System::Object * sender, System::EventArgs * e)
{
this->ds->Tables->Item[S"本期明细帐簿"]->Clear();
this->strSQL = String::Format(S"SELECT 科目表.科目名称,本期明细帐簿.* FROM 本期明细帐簿,科目表 WHERE 本期明细帐簿.科目代码 = 科目表.科目代码 AND 本期明细帐簿.凭证编号 LIKE '{0}'",this->tBoxSubjectCode->Text);
this->MyDataBase->SelectDataBase(this->DetailAdapter,this->ds,this->strSQL,S"本期明细帐簿");
}
private: System::Void cmbProject_SelectedIndexChanged(System::Object * sender, System::EventArgs * e)
{
if(this->cmbProject->Text->Equals(S"全部项目"))
{
this->DetailView->RowFilter = "";
}
else
{
this->DetailView->RowFilter = String::Format(S"科目名称 = '{0}'",this->cmbProject->Text);
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -