📄 stationform.h
字号:
this->业主编号TextBox->Size = System::Drawing::Size(105, 21);
this->业主编号TextBox->TabIndex = 44;
//
// 业主姓名ComboBox
//
this->业主姓名ComboBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->车位使用BindingSource, L"业主姓名", true)));
this->业主姓名ComboBox->DataSource = this->业主信息BindingSource;
this->业主姓名ComboBox->DisplayMember = L"业主姓名";
this->业主姓名ComboBox->FormattingEnabled = true;
this->业主姓名ComboBox->Location = System::Drawing::Point(240, 51);
this->业主姓名ComboBox->Name = L"业主姓名ComboBox";
this->业主姓名ComboBox->Size = System::Drawing::Size(85, 20);
this->业主姓名ComboBox->TabIndex = 46;
this->业主姓名ComboBox->ValueMember = L"业主编号";
this->业主姓名ComboBox->SelectedIndexChanged += gcnew System::EventHandler(this, &StationForm::业主姓名ComboBox_SelectedIndexChanged);
//
// 业主信息BindingSource
//
this->业主信息BindingSource->DataMember = L"业主信息";
this->业主信息BindingSource->DataSource = this->DBCommunityDataSet;
//
// 启用日期DateTimePicker
//
this->启用日期DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->车位使用BindingSource, L"启用日期",
true)));
this->启用日期DateTimePicker->Location = System::Drawing::Point(396, 50);
this->启用日期DateTimePicker->Name = L"启用日期DateTimePicker";
this->启用日期DateTimePicker->Size = System::Drawing::Size(141, 21);
this->启用日期DateTimePicker->TabIndex = 48;
//
// 停用日期DateTimePicker
//
this->停用日期DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->车位使用BindingSource, L"停用日期",
true)));
this->停用日期DateTimePicker->Location = System::Drawing::Point(65, 75);
this->停用日期DateTimePicker->Name = L"停用日期DateTimePicker";
this->停用日期DateTimePicker->Size = System::Drawing::Size(142, 21);
this->停用日期DateTimePicker->TabIndex = 50;
//
// 楼栋信息TableAdapter
//
this->楼栋信息TableAdapter->ClearBeforeFill = true;
//
// 业主信息TableAdapter
//
this->业主信息TableAdapter->ClearBeforeFill = true;
//
// StationForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(542, 416);
this->Controls->Add(this->车位使用DataGridView);
this->Controls->Add(自动编号Label);
this->Controls->Add(车位编号Label);
this->Controls->Add(车位面积Label);
this->Controls->Add(楼栋名称Label);
this->Controls->Add(业主编号Label);
this->Controls->Add(业主姓名Label);
this->Controls->Add(启用日期Label);
this->Controls->Add(停用日期Label);
this->Controls->Add(费用金额Label);
this->Controls->Add(this->费用金额TextBox);
this->Controls->Add(管理人员Label);
this->Controls->Add(this->管理人员TextBox);
this->Controls->Add(补充说明Label);
this->Controls->Add(this->补充说明TextBox);
this->Controls->Add(this->自动编号TextBox);
this->Controls->Add(this->车位编号TextBox);
this->Controls->Add(this->车位面积TextBox);
this->Controls->Add(this->楼栋名称ComboBox);
this->Controls->Add(this->业主编号TextBox);
this->Controls->Add(this->业主姓名ComboBox);
this->Controls->Add(this->启用日期DateTimePicker);
this->Controls->Add(this->停用日期DateTimePicker);
this->Controls->Add(this->车位使用BindingNavigator);
this->Name = L"StationForm";
this->ShowInTaskbar = false;
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"物业管理[车位使用管理]";
this->Load += gcnew System::EventHandler(this, &StationForm::StationForm_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->DBCommunityDataSet))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->车位使用BindingSource))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->车位使用BindingNavigator))->EndInit();
this->车位使用BindingNavigator->ResumeLayout(false);
this->车位使用BindingNavigator->PerformLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->车位使用DataGridView))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->楼栋信息BindingSource))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->业主信息BindingSource))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
public: String^ MyCommunity;
private: System::Void 车位使用BindingNavigatorSaveItem_Click(System::Object^ sender, System::EventArgs^ e)
{
this->Validate();
this->车位使用BindingSource->EndEdit();
this->车位使用TableAdapter->Update(this->DBCommunityDataSet->车位使用);
}
private: System::Void FillToolStripButton_Click(System::Object^ sender, System::EventArgs^ e)
{
try
{
this->车位使用TableAdapter->Fill(this->DBCommunityDataSet->车位使用, 车位编号ToolStripTextBox->Text);
}
catch (System::Exception^ ex)
{
System::Windows::Forms::MessageBox::Show(ex->Message);
}
}
private: System::Void 查询ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e)
{
try
{
this->车位使用TableAdapter->Fill(this->DBCommunityDataSet->车位使用, 车位编号ToolStripTextBox->Text);
}
catch (System::Exception^ ex)
{
System::Windows::Forms::MessageBox::Show(ex->Message);
}
}
private: System::Void StationForm_Load(System::Object^ sender, System::EventArgs^ e)
{// TODO: 这行代码将数据加载到表“DBCommunityDataSet.楼栋信息”中
this->楼栋信息TableAdapter->Fill(this->DBCommunityDataSet->楼栋信息);
try
{
this->车位使用TableAdapter->Fill(this->DBCommunityDataSet->车位使用, 车位编号ToolStripTextBox->Text);
}
catch (System::Exception^ ex)
{
System::Windows::Forms::MessageBox::Show(ex->Message);
}
}
private: System::Void 楼栋名称ComboBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
{//获取指定楼栋的业主姓名
this->业主信息TableAdapter->FillLiveBy(this->DBCommunityDataSet->业主信息, 楼栋名称ComboBox->Text);
}
private: System::Void 业主姓名ComboBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
{//获取指定业主的编号
if (this->业主姓名ComboBox->SelectedValue->ToString() != "System.Data.DataRowView")
{
this->业主编号TextBox->Text = this->业主姓名ComboBox->SelectedValue->ToString();
}
}
private: System::Void 打印ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e)
{//打印车位使用信息
ApplicationClass^ MyExcel;
Workbooks^ MyWorkBooks;
Workbook^ MyWorkBook;
Worksheet^ MyWorkSheet;
char MyColumns;
int Count,i,j;
Range^ MyRange;
array<System::Object^,2>^ MyData=gcnew array<System::Object^,2>(5000,30);
MyExcel = gcnew ApplicationClass();
MyExcel->Visible = true;
if (MyExcel == nullptr)
{
MessageBox::Show("Excel程序无法启动!", "信息提示", MessageBoxButtons::OK, MessageBoxIcon::Information);
return;
}
MyWorkBooks = MyExcel->Workbooks;
MyWorkBook = MyWorkBooks->Add(Missing::Value);
MyWorkSheet = (Worksheet^)MyWorkBook->Worksheets[1];
MyColumns = (char)(this->DBCommunityDataSet->车位使用->Columns->Count + 64);
array<System::Byte>^ MyBytes =gcnew array<System::Byte> {MyColumns};
System::Text::UTF8Encoding^ MyEncoding=gcnew System::Text::UTF8Encoding();
MyRange = MyWorkSheet->Range["A5", MyEncoding->GetString(MyBytes) + "5"];
Count = 0;
for each (DataColumn^ MyNewColumn in this->DBCommunityDataSet->车位使用->Columns)
{
MyData[0, Count] = MyNewColumn->ColumnName;
Count = Count + 1;
}
j = 1;
//输出数据库记录
for each (DataRow^ MyRow in this->DBCommunityDataSet->车位使用->Rows)
{
for (i = 0; i < this->DBCommunityDataSet->车位使用->Columns->Count; i++)
{
if ((i == 6) ||( i == 7))
{
MyData[j, i] = DateTime::Parse(MyRow[i]->ToString()).ToShortDateString();
}
else
{
MyData[j, i] = MyRow[i]->ToString();
}
}
j++;
}
MyRange = MyRange->Resize[this->DBCommunityDataSet->车位使用->Rows->Count + 1, this->DBCommunityDataSet->车位使用->Columns->Count];
MyRange->Value2 = MyData;
MyRange->EntireColumn->AutoFit();
MyWorkSheet->Cells[2, 2] = this->MyCommunity+ "车位信息表";
Range^ MyRange22 = MyWorkSheet->Range["B2", "B2"];
MyRange22->Font->Bold = true;
MyRange22->Font->Size = "20";
MyWorkSheet->Cells[4, 1] = "打印日期:" + DateTime::Now.ToShortDateString();
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -