📄 regquery.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>
/// RegQuery 摘要
///
/// 警告: 如果您更改该类的名称,则将需要更改
/// 与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。 否则,
/// 设计器将不能与此窗体关联的
/// 本地化资源正确交互。
/// </summary>
public __gc class RegQuery : public System::Windows::Forms::Form
{
//--------------------成员声明------------------------
private:
LinkDataBase* MyDataBase; //数据库连接类
SqlDataAdapter* RegistAdapter;
DataSet* ds;
String* strTableName;
String* strSQL;
protected: System::Windows::Forms::ImageList * imageList1;
//-------------------成员声明结束-----------------------
public:
RegQuery(void)
{
InitializeComponent();
//初始化
this->MyDataBase = new LinkDataBase();
this->ds = new DataSet();
this->RegistAdapter = new SqlDataAdapter();
//查询门诊挂号
this->strSQL = S"SELECT 挂号科室,Count(编号) As 人数,Sum(挂号费用) As 挂号金额 From 门诊挂号 Where (时间 > '1990-1-1') And (时间 < '2010-1-1') Group By 挂号科室";
this->strTableName = S"门诊挂号";
this->MyDataBase->SelectDataBase(this->RegistAdapter,this->ds,this->strSQL,this->strTableName);
//设置DataGrid
this->dgrdPrice->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::Label * label4;
private: System::Windows::Forms::TextBox * tBoxStartTime;
private: System::Windows::Forms::TextBox * tBoxEndTime;
private: System::Windows::Forms::Label * label9;
private: System::Windows::Forms::DataGrid * dgrdPrice;
private: System::Windows::Forms::GroupBox * groupBox1;
private: System::Windows::Forms::Button * btnSearch;
private: System::Windows::Forms::Label * label2;
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::RegQuery));
this->groupBox1 = new System::Windows::Forms::GroupBox();
this->label9 = new System::Windows::Forms::Label();
this->tBoxEndTime = new System::Windows::Forms::TextBox();
this->label4 = new System::Windows::Forms::Label();
this->tBoxStartTime = new System::Windows::Forms::TextBox();
this->label2 = new System::Windows::Forms::Label();
this->btnSearch = new System::Windows::Forms::Button();
this->imageList1 = new System::Windows::Forms::ImageList(this->components);
this->dgrdPrice = new System::Windows::Forms::DataGrid();
this->groupBox1->SuspendLayout();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdPrice))->BeginInit();
this->SuspendLayout();
//
// groupBox1
//
this->groupBox1->Controls->Add(this->label9);
this->groupBox1->Controls->Add(this->tBoxEndTime);
this->groupBox1->Controls->Add(this->label4);
this->groupBox1->Controls->Add(this->tBoxStartTime);
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Controls->Add(this->btnSearch);
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(368, 128);
this->groupBox1->TabIndex = 1;
this->groupBox1->TabStop = false;
//
// label9
//
this->label9->Location = System::Drawing::Point(88, 56);
this->label9->Name = S"label9";
this->label9->Size = System::Drawing::Size(112, 11);
this->label9->TabIndex = 9;
this->label9->Text = S"格式如:2005-1-1";
//
// tBoxEndTime
//
this->tBoxEndTime->Location = System::Drawing::Point(88, 80);
this->tBoxEndTime->Name = S"tBoxEndTime";
this->tBoxEndTime->Size = System::Drawing::Size(120, 21);
this->tBoxEndTime->TabIndex = 8;
this->tBoxEndTime->Text = S"";
//
// label4
//
this->label4->Location = System::Drawing::Point(24, 88);
this->label4->Name = S"label4";
this->label4->Size = System::Drawing::Size(56, 11);
this->label4->TabIndex = 7;
this->label4->Text = S"结束时间";
//
// tBoxStartTime
//
this->tBoxStartTime->Location = System::Drawing::Point(88, 24);
this->tBoxStartTime->Name = S"tBoxStartTime";
this->tBoxStartTime->Size = System::Drawing::Size(120, 21);
this->tBoxStartTime->TabIndex = 4;
this->tBoxStartTime->Text = S"";
//
// label2
//
this->label2->Location = System::Drawing::Point(24, 32);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing::Size(56, 11);
this->label2->TabIndex = 3;
this->label2->Text = S"开始时间";
//
// btnSearch
//
this->btnSearch->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->btnSearch->ImageIndex = 6;
this->btnSearch->ImageList = this->imageList1;
this->btnSearch->Location = System::Drawing::Point(248, 48);
this->btnSearch->Name = S"btnSearch";
this->btnSearch->Size = System::Drawing::Size(56, 24);
this->btnSearch->TabIndex = 0;
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;
//
// dgrdPrice
//
this->dgrdPrice->DataMember = S"";
this->dgrdPrice->Dock = System::Windows::Forms::DockStyle::Fill;
this->dgrdPrice->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dgrdPrice->Location = System::Drawing::Point(0, 128);
this->dgrdPrice->Name = S"dgrdPrice";
this->dgrdPrice->Size = System::Drawing::Size(368, 229);
this->dgrdPrice->TabIndex = 2;
//
// RegQuery
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(368, 357);
this->Controls->Add(this->dgrdPrice);
this->Controls->Add(this->groupBox1);
this->Name = S"RegQuery";
this->Text = S"科室挂号量";
this->groupBox1->ResumeLayout(false);
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdPrice))->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->dgrdPrice->TableStyles->Add(ts);
}
//按条件查询
private: System::Void btnSearch_Click(System::Object * sender, System::EventArgs * e)
{
String* strStartTime = this->tBoxStartTime->Text->Trim();
String* strEndTime = this->tBoxEndTime->Text->Trim();
String* Filter = S"";
if(String::Compare(strStartTime,String::Empty) != 0)
{
Filter = String::Format(S"{0} AND (时间 >= '{1}')",Filter,strStartTime);
}
if(String::Compare(strEndTime,String::Empty) != 0)
{
Filter = String::Format(S"{0} AND (时间 <= '{1}')",Filter,strEndTime);
}
this->ds->Tables->Item[S"门诊挂号"]->Clear();
if(String::Compare(Filter,String::Empty) != 0)
{
Filter = Filter->Substring(5,Filter->Length - 5);
this->strSQL = String::Format(S"SELECT 挂号科室,Count(编号) As 人数,Sum(挂号费用) As 挂号金额 From 门诊挂号 Where {0} Group By 挂号科室",Filter);
this->strTableName = S"门诊挂号";
this->MyDataBase->SelectDataBase(this->RegistAdapter,this->ds,this->strSQL,this->strTableName);
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -