📄 storagesearch.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>
/// StorageSearch 摘要
///
/// 警告: 如果您更改该类的名称,则将需要更改
/// 与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。 否则,
/// 设计器将不能与此窗体关联的
/// 本地化资源正确交互。
/// </summary>
public __gc class StorageSearch : public System::Windows::Forms::Form
{
//--------------------成员声明------------------------
LinkDataBase* MyDataBase;
DataSet* ds;
DataView* dv;
//------------------成员声明结束----------------------
public:
StorageSearch(void)
{
InitializeComponent();
this->MyDataBase = new LinkDataBase();
String* tempSQL = new String("select 库存库.货号,商品清单.拼音编码,商品清单.品名,商品清单.单位,库存库.仓库,库存库.库存数量,库存库.库存单价,库存库.库存金额 from 库存库,商品清单 where 库存库.货号 = 商品清单.货号");
String* tempTableName = new String("库存商品");
this->ds = this->MyDataBase->SelectDataBase(tempSQL,tempTableName);
this->dv = new DataView(this->ds->Tables->Item[0]);
this->dgrdStorageSearch->DataSource = this->dv;
this->MyDataBase->SelectDataBase(this->ds,S"select 仓库号,仓库名 from 仓库清单",S"仓库");
DataRow* row = this->ds->Tables->Item[S"仓库"]->NewRow();
row->Item[0] = S"-1";
row->Item[1] = S"请选择仓库";
this->ds->Tables->Item[S"仓库"]->Rows->InsertAt(row,0);
//在组合框中添加内容
this->cmbDepot->DataSource = this->ds->Tables->Item[S"仓库"];
this->cmbDepot->DisplayMember = S"仓库名";
this->cmbDepot->ValueMember = S"仓库号";
this->cmbDepot->SelectedIndex = -1;
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::GroupBox * groupBox1;
private: System::Windows::Forms::Label * label1;
private: System::Windows::Forms::TextBox * tBoxWareID;
private: System::Windows::Forms::DataGrid * dgrdStorageSearch;
private: System::Windows::Forms::Label * label2;
private: System::Windows::Forms::Label * label3;
private: System::Windows::Forms::TextBox * tBoxWareName;
private: System::Windows::Forms::ComboBox * cmbDepot;
private: System::Windows::Forms::Button * btnSearch;
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container* components;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
void InitializeComponent(void)
{
this->groupBox1 = new System::Windows::Forms::GroupBox();
this->btnSearch = new System::Windows::Forms::Button();
this->cmbDepot = new System::Windows::Forms::ComboBox();
this->label3 = new System::Windows::Forms::Label();
this->tBoxWareName = new System::Windows::Forms::TextBox();
this->label2 = new System::Windows::Forms::Label();
this->tBoxWareID = new System::Windows::Forms::TextBox();
this->label1 = new System::Windows::Forms::Label();
this->dgrdStorageSearch = new System::Windows::Forms::DataGrid();
this->groupBox1->SuspendLayout();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdStorageSearch))->BeginInit();
this->SuspendLayout();
//
// groupBox1
//
this->groupBox1->Controls->Add(this->btnSearch);
this->groupBox1->Controls->Add(this->cmbDepot);
this->groupBox1->Controls->Add(this->label3);
this->groupBox1->Controls->Add(this->tBoxWareName);
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Controls->Add(this->tBoxWareID);
this->groupBox1->Controls->Add(this->label1);
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(600, 64);
this->groupBox1->TabIndex = 0;
this->groupBox1->TabStop = false;
//
// btnSearch
//
this->btnSearch->Location = System::Drawing::Point(512, 21);
this->btnSearch->Name = S"btnSearch";
this->btnSearch->Size = System::Drawing::Size(72, 24);
this->btnSearch->TabIndex = 6;
this->btnSearch->Text = S"查询";
this->btnSearch->Click += new System::EventHandler(this, btnSearch_Click);
//
// cmbDepot
//
this->cmbDepot->Location = System::Drawing::Point(400, 24);
this->cmbDepot->Name = S"cmbDepot";
this->cmbDepot->Size = System::Drawing::Size(96, 20);
this->cmbDepot->TabIndex = 5;
this->cmbDepot->Text = S"请选择仓库";
//
// label3
//
this->label3->Location = System::Drawing::Point(360, 24);
this->label3->Name = S"label3";
this->label3->Size = System::Drawing::Size(32, 24);
this->label3->TabIndex = 4;
this->label3->Text = S"仓库";
this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// tBoxWareName
//
this->tBoxWareName->Location = System::Drawing::Point(256, 24);
this->tBoxWareName->Name = S"tBoxWareName";
this->tBoxWareName->Size = System::Drawing::Size(80, 21);
this->tBoxWareName->TabIndex = 3;
this->tBoxWareName->Text = S"";
//
// label2
//
this->label2->Location = System::Drawing::Point(184, 24);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing::Size(56, 24);
this->label2->TabIndex = 2;
this->label2->Text = S"商品拼音";
this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// tBoxWareID
//
this->tBoxWareID->Location = System::Drawing::Point(80, 24);
this->tBoxWareID->Name = S"tBoxWareID";
this->tBoxWareID->Size = System::Drawing::Size(80, 21);
this->tBoxWareID->TabIndex = 1;
this->tBoxWareID->Text = S"";
//
// label1
//
this->label1->Location = System::Drawing::Point(24, 24);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing::Size(40, 24);
this->label1->TabIndex = 0;
this->label1->Text = S"货号";
this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// dgrdStorageSearch
//
this->dgrdStorageSearch->DataMember = S"";
this->dgrdStorageSearch->Dock = System::Windows::Forms::DockStyle::Fill;
this->dgrdStorageSearch->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dgrdStorageSearch->Location = System::Drawing::Point(0, 64);
this->dgrdStorageSearch->Name = S"dgrdStorageSearch";
this->dgrdStorageSearch->Size = System::Drawing::Size(600, 262);
this->dgrdStorageSearch->TabIndex = 1;
//
// StorageSearch
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(600, 326);
this->Controls->Add(this->dgrdStorageSearch);
this->Controls->Add(this->groupBox1);
this->Name = S"StorageSearch";
this->Text = S"StorageSearch";
this->groupBox1->ResumeLayout(false);
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdStorageSearch))->EndInit();
this->ResumeLayout(false);
}
//--------------------成员方法------------------------
private:
//------------------设置表格样式----------------------
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->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->dgrdStorageSearch->TableStyles->Add(ts);
}
//--------------------查询库存--------------------
private:
System::Void btnSearch_Click(System::Object * sender, System::EventArgs * e)
{
//if(this->tBoxWareName->Text == String::Empty || this->tBoxWareID == String::Empty )
//return;
String* strRowFilter = S"";
String* strWareIDFilter = String::Format(S"货号 like '{0}%'",this->tBoxWareID->Text);
String* strWareNumFilter = String::Format(S"拼音编码 like '{0}%'",this->tBoxWareName->Text);
String* strDepotFilter = String::Format(S"仓库 like '{0}'",this->cmbDepot->Text->Trim());
if(String::Compare(this->tBoxWareID->Text->Trim(),String::Empty) != 0)
strRowFilter = String::Format("{0}{1} and ",strRowFilter,strWareIDFilter);
if(String::Compare(this->tBoxWareName->Text->Trim(),String::Empty) != 0)
strRowFilter = String::Format("{0}{1} and ",strRowFilter,strWareNumFilter);
if(this->cmbDepot->SelectedIndex != 0)
strRowFilter = String::Format("{0}{1} and ",strRowFilter,strDepotFilter);
if(strRowFilter != S"")
{
strRowFilter = strRowFilter->Substring(0,strRowFilter->Length - 5);
}
this->dv->RowFilter = strRowFilter;
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -