📄 printdepreciationform.h
字号:
this->dataGridViewTextBoxColumn31->Name = L"dataGridViewTextBoxColumn31";
this->dataGridViewTextBoxColumn31->ReadOnly = true;
//
// dataGridViewTextBoxColumn32
//
this->dataGridViewTextBoxColumn32->DataPropertyName = L"预计净残值";
this->dataGridViewTextBoxColumn32->HeaderText = L"预计净残值";
this->dataGridViewTextBoxColumn32->Name = L"dataGridViewTextBoxColumn32";
this->dataGridViewTextBoxColumn32->ReadOnly = true;
//
// dataGridViewTextBoxColumn33
//
this->dataGridViewTextBoxColumn33->DataPropertyName = L"说明";
this->dataGridViewTextBoxColumn33->HeaderText = L"说明";
this->dataGridViewTextBoxColumn33->Name = L"dataGridViewTextBoxColumn33";
this->dataGridViewTextBoxColumn33->ReadOnly = true;
//
// PrintDepreciationForm
//
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->groupBox2);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->累计折旧查询视图BindingNavigator);
this->Name = L"PrintDepreciationForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"打印固定资产累计折旧";
this->Load += gcnew System::EventHandler(this, &PrintDepreciationForm::PrintDepreciationForm_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->MyAssetsDataSet))->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();
this->groupBox2->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->累计折旧DataGridView))->EndInit();
this->groupBox1->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->固定资产明细DataGridView))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
public: String^ MyCompany;
private: System::Data::DataTable^ MyQueryTable;
private: static String^ MyAssetsConnectionString= L"Data Source=.;Initial Catalog=MyAssets;Integrated Security=True;Pooling=False";
private: System::Void PrintDepreciationForm_Load(System::Object^ sender, System::EventArgs^ e) {
// TODO: 这行代码将数据加载到表“MyAssetsDataSet.固定资产明细”中。您可以根据需要移动或移除它。
this->固定资产明细TableAdapter->Fill(this->MyAssetsDataSet->固定资产明细);
};
private: System::Void 查询ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e) {
String^ My名称 = this->资产名称ToolStripTextBox->Text;
String^ MySQLConnectionString = MyAssetsConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
System::Data::DataTable^ MyAssetsTable = gcnew System::Data::DataTable();
String^ MySQL = "SELECT * FROM 固定资产明细 WHERE 名称 LIKE '" + My名称 + "'";
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyAssetsTable);
this->固定资产明细DataGridView->DataSource = MyAssetsTable;
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
private: System::Void 固定资产明细DataGridView_SelectionChanged(System::Object^ sender, System::EventArgs^ e) {
this->groupBox2->Text = this->固定资产明细DataGridView->CurrentRow->Cells[2]->Value->ToString() + "计提的累计折旧明细表";
String^ My资产编号 = this->固定资产明细DataGridView->CurrentRow->Cells[1]->Value->ToString();
String^ MySQLConnectionString = MyAssetsConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
MyQueryTable = gcnew System::Data::DataTable();
String^ MySQL = "SELECT 折旧年份,折旧月份,折旧方法,月度折旧额 FROM 计提累计折旧 WHERE 资产编号='" + My资产编号 + "'";
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyQueryTable);
this->累计折旧DataGridView->DataSource = MyQueryTable;
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
private: System::Void 打印ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e) {
if (this->MyQueryTable->Rows->Count < 1)
{
return;
}
//导出Excel表格数据文件
ApplicationClass^ MyExcel;
Workbooks^ MyWorkBooks;
Workbook^ MyWorkBook;
Worksheet^ MyWorkSheet;
char MyColumns;
Range^ MyRange;
array<System::Object^,2>^ MyData=gcnew array<System::Object^,2>(5000,30);
int Count, i, j;
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];
switch(this->MyQueryTable->Columns->Count+ 64)
{
case 64:
MyRange=MyWorkSheet->Range["A5","A5"];
break;
case 65:
MyRange=MyWorkSheet->Range["A5","B5"];
break;
case 66:
MyRange=MyWorkSheet->Range["A5","C5"];
break;
case 67:
MyRange=MyWorkSheet->Range["A5","D5"];
break;
case 68:
MyRange=MyWorkSheet->Range["A5","E5"];
break;
case 69:
MyRange=MyWorkSheet->Range["A5","F5"];
break;
case 70:
MyRange=MyWorkSheet->Range["A5","G5"];
break;
case 71:
MyRange=MyWorkSheet->Range["A5","H5"];
break;
case 72:
MyRange=MyWorkSheet->Range["A5","I5"];
break;
case 73:
MyRange=MyWorkSheet->Range["A5","J5"];
break;
case 74:
MyRange=MyWorkSheet->Range["A5","K5"];
break;
case 75:
MyRange=MyWorkSheet->Range["A5","L5"];
break;
case 76:
MyRange=MyWorkSheet->Range["A5","M5"];
break;
case 77:
MyRange=MyWorkSheet->Range["A5","N5"];
break;
case 78:
MyRange=MyWorkSheet->Range["A5","O5"];
break;
case 79:
MyRange=MyWorkSheet->Range["A5","P5"];
break;
case 80:
MyRange=MyWorkSheet->Range["A5","Q5"];
break;
case 81:
MyRange=MyWorkSheet->Range["A5","R5"];
break;
case 82:
MyRange=MyWorkSheet->Range["A5","S5"];
break;
case 83:
MyRange=MyWorkSheet->Range["A5","T5"];
break;
case 84:
MyRange=MyWorkSheet->Range["A5","U5"];
break;
case 85:
MyRange=MyWorkSheet->Range["A5","V5"];
break;
case 86:
MyRange=MyWorkSheet->Range["A5","W5"];
break;
case 87:
MyRange=MyWorkSheet->Range["A5","X5"];
break;
case 88:
MyRange=MyWorkSheet->Range["A5","Y5"];
break;
case 89:
MyRange=MyWorkSheet->Range["A5","Z5"];
break;
}
Count = 0;
for each (DataColumn^ MyNewColumn in this->MyQueryTable->Columns)
{
MyData[0, Count] = MyNewColumn->ColumnName;
Count = Count + 1;
}
j = 1;
//输出数据库记录
for each (DataRow^ MyRow in this->MyQueryTable->Rows)
{
for (i = 0; i < this->MyQueryTable->Columns->Count; i++)
{
MyData[j, i] = MyRow[i]->ToString();
}
j++;
}
MyRange = MyRange->Resize[this->MyQueryTable->Rows->Count + 1, this->MyQueryTable->Columns->Count];
MyRange->Value2 = MyData;
MyRange->EntireColumn->AutoFit();
MyWorkSheet->Cells[2, 2] = this->MyCompany + "固定资产累计折旧明细表";
MyWorkSheet->Cells[4, 1] = "资产编号:" + this->固定资产明细DataGridView->CurrentRow->Cells[1]->Value->ToString() +
" 名称:" + this->固定资产明细DataGridView->CurrentRow->Cells[2]->Value->ToString() +
//" 原值:"+this->固定资产明细DataGridView->CurrentRow->Cells[16]->Value->ToString()+
//" 累计折旧:"+this->固定资产明细DataGridView->CurrentRow->Cells[17]->Value->ToString()+
" 折旧月数:" + this->固定资产明细DataGridView->CurrentRow->Cells[19]->Value->ToString() +
" 已提月数:" + this->固定资产明细DataGridView->CurrentRow->Cells[20]->Value->ToString();
//" 预计净残值:"+this->固定资产明细DataGridView->CurrentRow->Cells[22]->Value->ToString();
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -