📄 selectstorage.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>
/// SelectStorage 摘要
///
/// 警告: 如果您更改该类的名称,则将需要更改
/// 与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。 否则,
/// 设计器将不能与此窗体关联的
/// 本地化资源正确交互。
/// </summary>
public __gc class SelectStorage : public System::Windows::Forms::Form
{
//--------------------成员声明------------------------
public:
String* SendStorageID;
String* SendStorage;
String* Export;
String* Import;
//LinkDataBase* MyDataBase; //数据库连接类
DataView* View;
DataTable* Table;
String* strSQL;
System::Windows::Forms::NumericUpDown * nnupExPort;
System::Windows::Forms::NumericUpDown * nnupImport;
System::Windows::Forms::Label * label1;
System::Windows::Forms::Label * label2;
//-------------------成员声明结束-----------------------
public:
SelectStorage(DataTable* table,String* WareID)
{
InitializeComponent();
this->View = new DataView(table);
this->dgrdStorageData->DataSource = this->View;
this->DataGridStateControl();
String* Filter = String::Format("货号 = '{0}'",WareID);
this->View->RowFilter = Filter;
this->nnupExPort->Text = S"0";
this->nnupExPort->Value = 0;
this->nnupExPort->Minimum = 1;
this->nnupImport->Text = S"0";
this->nnupImport->Value = 0;
this->nnupImport->Minimum = 0;
int intCurrentRowNumber = this->dgrdStorageData->CurrentCell.RowNumber;
String* temp = this->View->get_Item(intCurrentRowNumber)->Item[S"库存数量"]->ToString()->Trim();
if((int)System::Double::Parse(temp) == 0)
{
this->nnupExPort->Maximum = (int)System::Double::Parse(temp) + 1;
}
else
{
this->nnupExPort->Maximum = (int)System::Double::Parse(temp);
}
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Button * button1;
private: System::Windows::Forms::ToolBarButton * tbarDelete;
private: System::Windows::Forms::DataGrid * dgrdStorageData;
private: System::Windows::Forms::Button * btnOK;
;
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container* components;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
void InitializeComponent(void)
{
this->dgrdStorageData = new System::Windows::Forms::DataGrid();
this->button1 = new System::Windows::Forms::Button();
this->btnOK = new System::Windows::Forms::Button();
this->nnupExPort = new System::Windows::Forms::NumericUpDown();
this->nnupImport = new System::Windows::Forms::NumericUpDown();
this->label1 = new System::Windows::Forms::Label();
this->label2 = new System::Windows::Forms::Label();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdStorageData))->BeginInit();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->nnupExPort))->BeginInit();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->nnupImport))->BeginInit();
this->SuspendLayout();
//
// dgrdStorageData
//
this->dgrdStorageData->DataMember = S"";
this->dgrdStorageData->Dock = System::Windows::Forms::DockStyle::Top;
this->dgrdStorageData->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dgrdStorageData->Location = System::Drawing::Point(0, 0);
this->dgrdStorageData->Name = S"dgrdStorageData";
this->dgrdStorageData->Size = System::Drawing::Size(704, 296);
this->dgrdStorageData->TabIndex = 1;
this->dgrdStorageData->Click += new System::EventHandler(this, dgrdStorageData_Click);
this->dgrdStorageData->DoubleClick += new System::EventHandler(this, dgrdStorageData_DoubleClick);
//
// button1
//
this->button1->DialogResult = System::Windows::Forms::DialogResult::Cancel;
this->button1->Location = System::Drawing::Point(392, 344);
this->button1->Name = S"button1";
this->button1->Size = System::Drawing::Size(88, 32);
this->button1->TabIndex = 3;
this->button1->Text = S"取消";
//
// btnOK
//
this->btnOK->Location = System::Drawing::Point(272, 344);
this->btnOK->Name = S"btnOK";
this->btnOK->Size = System::Drawing::Size(88, 32);
this->btnOK->TabIndex = 2;
this->btnOK->Text = S"确定";
this->btnOK->Click += new System::EventHandler(this, btnOK_Click);
//
// nnupExPort
//
this->nnupExPort->Location = System::Drawing::Point(80, 312);
this->nnupExPort->Name = S"nnupExPort";
this->nnupExPort->Size = System::Drawing::Size(128, 21);
this->nnupExPort->TabIndex = 4;
//
// nnupImport
//
this->nnupImport->Location = System::Drawing::Point(576, 312);
this->nnupImport->Name = S"nnupImport";
this->nnupImport->Size = System::Drawing::Size(128, 21);
this->nnupImport->TabIndex = 4;
//
// label1
//
this->label1->Location = System::Drawing::Point(8, 316);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing::Size(64, 16);
this->label1->TabIndex = 5;
this->label1->Text = S"出库数量";
//
// label2
//
this->label2->Location = System::Drawing::Point(504, 315);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing::Size(64, 16);
this->label2->TabIndex = 5;
this->label2->Text = S"入库数量";
//
// SelectStorage
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(704, 389);
this->Controls->Add(this->label1);
this->Controls->Add(this->nnupExPort);
this->Controls->Add(this->button1);
this->Controls->Add(this->dgrdStorageData);
this->Controls->Add(this->btnOK);
this->Controls->Add(this->nnupImport);
this->Controls->Add(this->label2);
this->Name = S"SelectStorage";
this->Text = S"选择仓库";
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdStorageData))->EndInit();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->nnupExPort))->EndInit();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->nnupImport))->EndInit();
this->ResumeLayout(false);
}
public:
/*SelectStorage(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->dgrdStorageData->DataSource = ds->Tables->Item[0];
}*/
void DataGridStateControl()
{
DataGridTableStyle* ts = new DataGridTableStyle();
ts->AlternatingBackColor = Color::LightGray;
ts->MappingName = S"View->Item";
ts->AllowSorting = true;
int numCols = this->View->Table->Columns->Count;
for(int i = 0;i < numCols;i++)
{
DataGridNoActiveCellColumn* aNoActiveCellColumn = new DataGridNoActiveCellColumn();
aNoActiveCellColumn->MappingName = this->View->Table->Columns->Item[i]->ColumnName;
aNoActiveCellColumn->NullText = String::Empty;
aNoActiveCellColumn->Format = S"F";
ts->GridColumnStyles->Add(aNoActiveCellColumn);
}
this->dgrdStorageData->TableStyles->Add(ts);
}
private: System::Void dgrdStorageData_DoubleClick(System::Object * sender, System::EventArgs * e)
{
int intCurrentRowNumber = this->dgrdStorageData->CurrentCell.RowNumber;
SendStorageID = this->View->Item[intCurrentRowNumber]->Item[S"仓库"]->ToString()->Trim();
//数量为1
if(this->nnupExPort->Value == 0)
this->nnupExPort->Value = 1;
this->Export = this->nnupExPort->Text;
this->Import = this->nnupImport->Text;
SendStorage = this->View->get_Item(intCurrentRowNumber)->Item[S"库存数量"]->ToString()->Trim();
this->DialogResult = DialogResult::OK;
}
private: System::Void btnOK_Click(System::Object * sender, System::EventArgs * e)
{
int intCurrentRowNumber = this->dgrdStorageData->CurrentCell.RowNumber;
SendStorageID = this->View->Item[intCurrentRowNumber]->Item[S"仓库"]->ToString()->Trim();
//数量为1
if(this->nnupExPort->Value == 0)
this->nnupExPort->Value = 1;
this->Export = this->nnupExPort->Text;
this->Import = this->nnupImport->Text;
SendStorage = this->View->get_Item(intCurrentRowNumber)->Item[S"库存数量"]->ToString()->Trim();
this->DialogResult = DialogResult::OK;
}
private: System::Void dgrdStorageData_Click(System::Object * sender, System::EventArgs * e)
{
int intCurrentRowNumber = this->dgrdStorageData->CurrentCell.RowNumber;
String* temp = this->View->get_Item(intCurrentRowNumber)->Item[S"库存数量"]->ToString()->Trim();
this->nnupExPort->Maximum = (int)System::Double::Parse(temp);
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -