📄 managequeryform.h
字号:
this->查询Button->TabIndex = 54;
this->查询Button->Text = L"查询";
this->查询Button->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->查询Button->TextImageRelation = System::Windows::Forms::TextImageRelation::ImageBeforeText;
this->查询Button->UseVisualStyleBackColor = true;
this->查询Button->Click += gcnew System::EventHandler(this, &ManageQueryForm::查询Button_Click);
//
// 计费月份ComboBox
//
this->计费月份ComboBox->FormattingEnabled = true;
this->计费月份ComboBox->Location = System::Drawing::Point(248, 8);
this->计费月份ComboBox->Name = L"计费月份ComboBox";
this->计费月份ComboBox->Size = System::Drawing::Size(75, 20);
this->计费月份ComboBox->TabIndex = 53;
this->计费月份ComboBox->Text = L"全年";
//
// 计费月份Label
//
this->计费月份Label->AutoSize = true;
this->计费月份Label->Location = System::Drawing::Point(175, 13);
this->计费月份Label->Name = L"计费月份Label";
this->计费月份Label->Size = System::Drawing::Size(65, 12);
this->计费月份Label->TabIndex = 52;
this->计费月份Label->Text = L"计费月份:";
//
// 计费年份ComboBox
//
this->计费年份ComboBox->FormattingEnabled = true;
this->计费年份ComboBox->Location = System::Drawing::Point(73, 8);
this->计费年份ComboBox->Name = L"计费年份ComboBox";
this->计费年份ComboBox->Size = System::Drawing::Size(95, 20);
this->计费年份ComboBox->TabIndex = 51;
this->计费年份ComboBox->Text = L"2006";
//
// 计费年份Label
//
this->计费年份Label->AutoSize = true;
this->计费年份Label->Location = System::Drawing::Point(8, 13);
this->计费年份Label->Name = L"计费年份Label";
this->计费年份Label->Size = System::Drawing::Size(65, 12);
this->计费年份Label->TabIndex = 50;
this->计费年份Label->Text = L"计费年份:";
//
// ManageQueryForm
//
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(this->打印Button);
this->Controls->Add(this->费用状态ComboBox);
this->Controls->Add(this->费用状态Label);
this->Controls->Add(this->业主姓名ComboBox);
this->Controls->Add(this->业主姓名Label);
this->Controls->Add(this->楼栋名称ComboBox);
this->Controls->Add(this->楼栋名称Label);
this->Controls->Add(this->查询Button);
this->Controls->Add(this->计费月份ComboBox);
this->Controls->Add(this->计费月份Label);
this->Controls->Add(this->计费年份ComboBox);
this->Controls->Add(this->计费年份Label);
this->Name = L"ManageQueryForm";
this->ShowInTaskbar = false;
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"费用管理[物管费用查询]";
this->Load += gcnew System::EventHandler(this, &ManageQueryForm::ManageQueryForm_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->物管费用DataGridView))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
public:String^ MyCommunity;
public:String^ MySQLConnectionString;
private:System::Data::DataTable^ MyTable;
private: System::Void ManageQueryForm_Load(System::Object^ sender, System::EventArgs^ e)
{
MyTable = gcnew System::Data::DataTable();
for (int i = 2006; i <= 2030; i++)
{
this->计费年份ComboBox->Items->Add(i.ToString());
}
this->计费月份ComboBox->Items->Add("全年");
for (int i = 1; i <= 12; i++)
{
this->计费月份ComboBox->Items->Add(i.ToString());
}
this->楼栋名称ComboBox->Items->Add("全部");
String^ MySQL = "SELECT * FROM [楼栋信息]";
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
System::Data::DataTable^ ItemTable = gcnew System::Data::DataTable();
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(ItemTable);
for each (System::Data::DataRow^ MyRow in ItemTable->Rows)
{
this->楼栋名称ComboBox->Items->Add(MyRow["楼栋名称"]->ToString());
}
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
this->业主姓名ComboBox->Items->Add("全部");
this->费用状态ComboBox->Items->Add("全部");
this->费用状态ComboBox->Items->Add("已交费");
this->费用状态ComboBox->Items->Add("未交费");
}
private: System::Void 查询Button_Click(System::Object^ sender, System::EventArgs^ e)
{//查询物管费信息
MyTable = gcnew System::Data::DataTable();
String^ MySQL = "Select * FROM 物管费用 WHERE (登记标志='完成登记') AND (计费年份= " + this->计费年份ComboBox->Text + ")";
if (this->计费月份ComboBox->Text == "全年")
MySQL += "";
else
MySQL += " AND (计费月份=" + this->计费月份ComboBox->Text + ")";
if (this->楼栋名称ComboBox->Text == "全部")
MySQL += "";
else
MySQL += " AND (楼栋名称='" + this->楼栋名称ComboBox->Text + "')";
if (this->业主姓名ComboBox->Text == "全部")
MySQL += "";
else
MySQL += " AND (业主姓名='" + this->业主姓名ComboBox->Text + "')";
if (this->费用状态ComboBox->Text == "全部")
MySQL += "";
else
MySQL += " AND (费用状态='" + this->费用状态ComboBox->Text + "')";
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
SqlDataAdapter^ MyAdatper = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdatper->Fill(MyTable);
this->物管费用DataGridView->DataSource = MyTable;
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
private: System::Void 打印Button_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)(MyTable->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 MyTable->Columns)
{
MyData[0, Count] = MyNewColumn->ColumnName;
Count = Count + 1;
}
j = 1;
//输出数据库记录
for each (DataRow^ MyRow in MyTable->Rows)
{
for (i = 0; i < MyTable->Columns->Count; i++)
{
MyData[j, i] = MyRow[i]->ToString();
}
j++;
}
MyRange = MyRange->Resize[MyTable->Rows->Count + 1, MyTable->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();
}
private: System::Void 楼栋名称ComboBox_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
{
this->业主姓名ComboBox->Items->Clear();
this->业主姓名ComboBox->Items->Add("全部");
String^ MySQL = "SELECT * FROM [业主信息] WHERE ([楼栋名称] ='" + this->楼栋名称ComboBox->Text+ "')";
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
System::Data::DataTable^ ItemTable = gcnew System::Data::DataTable();
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(ItemTable);
for each (System::Data::DataRow^ MyRow in ItemTable->Rows)
{
this->业主姓名ComboBox->Items->Add(MyRow["业主姓名"]->ToString());
}
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -