📄 expensesform.h
字号:
费用名称Label->Text = L"费用名称:";
//
// 费用名称TextBox
//
this->费用名称TextBox->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->费用名称TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->车辆费用管理BindingSource, L"费用名称", true)));
this->费用名称TextBox->Location = System::Drawing::Point(418, 29);
this->费用名称TextBox->Name = L"费用名称TextBox";
this->费用名称TextBox->Size = System::Drawing::Size(120, 21);
this->费用名称TextBox->TabIndex = 23;
//
// 费用金额TextBox
//
this->费用金额TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->车辆费用管理BindingSource, L"费用金额", true)));
this->费用金额TextBox->Location = System::Drawing::Point(68, 55);
this->费用金额TextBox->Name = L"费用金额TextBox";
this->费用金额TextBox->Size = System::Drawing::Size(105, 21);
this->费用金额TextBox->TabIndex = 25;
//
// 经办人TextBox
//
this->经办人TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->车辆费用管理BindingSource, L"经办人", true)));
this->经办人TextBox->Location = System::Drawing::Point(234, 55);
this->经办人TextBox->Name = L"经办人TextBox";
this->经办人TextBox->Size = System::Drawing::Size(71, 21);
this->经办人TextBox->TabIndex = 27;
//
// 日期DateTimePicker
//
this->日期DateTimePicker->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->日期DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->车辆费用管理BindingSource, L"日期",
true)));
this->日期DateTimePicker->Location = System::Drawing::Point(352, 55);
this->日期DateTimePicker->Name = L"日期DateTimePicker";
this->日期DateTimePicker->Size = System::Drawing::Size(186, 21);
this->日期DateTimePicker->TabIndex = 29;
//
// 说明TextBox
//
this->说明TextBox->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->说明TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->车辆费用管理BindingSource, L"说明", true)));
this->说明TextBox->Location = System::Drawing::Point(44, 82);
this->说明TextBox->Name = L"说明TextBox";
this->说明TextBox->Size = System::Drawing::Size(494, 21);
this->说明TextBox->TabIndex = 31;
//
// bindingNavigatorDeleteItem
//
this->bindingNavigatorDeleteItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorDeleteItem.Image")));
this->bindingNavigatorDeleteItem->Name = L"bindingNavigatorDeleteItem";
this->bindingNavigatorDeleteItem->RightToLeftAutoMirrorImage = true;
this->bindingNavigatorDeleteItem->Size = System::Drawing::Size(49, 22);
this->bindingNavigatorDeleteItem->Text = L"删除";
//
// bindingNavigatorAddNewItem
//
this->bindingNavigatorAddNewItem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"bindingNavigatorAddNewItem.Image")));
this->bindingNavigatorAddNewItem->Name = L"bindingNavigatorAddNewItem";
this->bindingNavigatorAddNewItem->RightToLeftAutoMirrorImage = true;
this->bindingNavigatorAddNewItem->Size = System::Drawing::Size(49, 22);
this->bindingNavigatorAddNewItem->Text = L"新增";
this->bindingNavigatorAddNewItem->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &ExpensesForm::bindingNavigatorAddNewItem_MouseUp);
//
// 开始日期ToolStripTextBox
//
this->开始日期ToolStripTextBox->Name = L"开始日期ToolStripTextBox";
this->开始日期ToolStripTextBox->Size = System::Drawing::Size(100, 25);
this->开始日期ToolStripTextBox->Text = L"2000-1-1";
//
// toolStripLabel1
//
this->toolStripLabel1->Name = L"toolStripLabel1";
this->toolStripLabel1->Size = System::Drawing::Size(59, 22);
this->toolStripLabel1->Text = L"开始日期:";
//
// 费用金额Label
//
费用金额Label->AutoSize = true;
费用金额Label->Location = System::Drawing::Point(3, 58);
费用金额Label->Name = L"费用金额Label";
费用金额Label->Size = System::Drawing::Size(59, 12);
费用金额Label->TabIndex = 24;
费用金额Label->Text = L"费用金额:";
//
// 经办人Label
//
经办人Label->AutoSize = true;
经办人Label->Location = System::Drawing::Point(181, 58);
经办人Label->Name = L"经办人Label";
经办人Label->Size = System::Drawing::Size(47, 12);
经办人Label->TabIndex = 26;
经办人Label->Text = L"经办人:";
//
// 日期Label
//
日期Label->AutoSize = true;
日期Label->Location = System::Drawing::Point(311, 58);
日期Label->Name = L"日期Label";
日期Label->Size = System::Drawing::Size(35, 12);
日期Label->TabIndex = 28;
日期Label->Text = L"日期:";
//
// 说明Label
//
说明Label->AutoSize = true;
说明Label->Location = System::Drawing::Point(3, 85);
说明Label->Name = L"说明Label";
说明Label->Size = System::Drawing::Size(35, 12);
说明Label->TabIndex = 30;
说明Label->Text = L"说明:";
//
// 车辆费用管理DataGridView
//
this->车辆费用管理DataGridView->AllowUserToAddRows = false;
this->车辆费用管理DataGridView->AllowUserToDeleteRows = false;
this->车辆费用管理DataGridView->AllowUserToResizeRows = false;
this->车辆费用管理DataGridView->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->车辆费用管理DataGridView->AutoGenerateColumns = false;
this->车辆费用管理DataGridView->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(7) {this->dataGridViewTextBoxColumn1,
this->dataGridViewTextBoxColumn2, this->dataGridViewTextBoxColumn3, this->dataGridViewTextBoxColumn4, this->dataGridViewTextBoxColumn5,
this->dataGridViewTextBoxColumn6, this->dataGridViewTextBoxColumn7});
this->车辆费用管理DataGridView->DataSource = this->车辆费用管理BindingSource;
this->车辆费用管理DataGridView->Location = System::Drawing::Point(5, 109);
this->车辆费用管理DataGridView->MultiSelect = false;
this->车辆费用管理DataGridView->Name = L"车辆费用管理DataGridView";
this->车辆费用管理DataGridView->ReadOnly = true;
this->车辆费用管理DataGridView->RowHeadersVisible = false;
this->车辆费用管理DataGridView->RowTemplate->Height = 23;
this->车辆费用管理DataGridView->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
this->车辆费用管理DataGridView->Size = System::Drawing::Size(533, 302);
this->车辆费用管理DataGridView->TabIndex = 17;
//
// 车辆费用管理BindingNavigator
//
this->车辆费用管理BindingNavigator->AddNewItem = this->bindingNavigatorAddNewItem;
this->车辆费用管理BindingNavigator->BindingSource = this->车辆费用管理BindingSource;
this->车辆费用管理BindingNavigator->CountItem = nullptr;
this->车辆费用管理BindingNavigator->DeleteItem = this->bindingNavigatorDeleteItem;
this->车辆费用管理BindingNavigator->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(9) {this->toolStripLabel1,
this->开始日期ToolStripTextBox, this->toolStripLabel2, this->结束日期ToolStripTextBox, this->查询ToolStripButton, this->bindingNavigatorSeparator2,
this->bindingNavigatorAddNewItem, this->bindingNavigatorDeleteItem, this->车辆费用管理BindingNavigatorSaveItem});
this->车辆费用管理BindingNavigator->Location = System::Drawing::Point(0, 0);
this->车辆费用管理BindingNavigator->MoveFirstItem = nullptr;
this->车辆费用管理BindingNavigator->MoveLastItem = nullptr;
this->车辆费用管理BindingNavigator->MoveNextItem = nullptr;
this->车辆费用管理BindingNavigator->MovePreviousItem = nullptr;
this->车辆费用管理BindingNavigator->Name = L"车辆费用管理BindingNavigator";
this->车辆费用管理BindingNavigator->PositionItem = nullptr;
this->车辆费用管理BindingNavigator->Size = System::Drawing::Size(542, 25);
this->车辆费用管理BindingNavigator->TabIndex = 16;
this->车辆费用管理BindingNavigator->Text = L"bindingNavigator1";
//
// ExpensesForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(542, 416);
this->Controls->Add(自编号Label);
this->Controls->Add(this->自编号TextBox);
this->Controls->Add(车牌号Label);
this->Controls->Add(this->车牌号ComboBox);
this->Controls->Add(费用名称Label);
this->Controls->Add(this->费用名称TextBox);
this->Controls->Add(this->费用金额TextBox);
this->Controls->Add(this->经办人TextBox);
this->Controls->Add(this->日期DateTimePicker);
this->Controls->Add(this->说明TextBox);
this->Controls->Add(费用金额Label);
this->Controls->Add(经办人Label);
this->Controls->Add(日期Label);
this->Controls->Add(说明Label);
this->Controls->Add(this->车辆费用管理DataGridView);
this->Controls->Add(this->车辆费用管理BindingNavigator);
this->Name = L"ExpensesForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"车辆费用管理";
this->Load += gcnew System::EventHandler(this, &ExpensesForm::ExpensesForm_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->MyOfficeDataSet))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->车辆费用管理BindingSource))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->车辆费用管理DataGridView))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->车辆费用管理BindingNavigator))->EndInit();
this->车辆费用管理BindingNavigator->ResumeLayout(false);
this->车辆费用管理BindingNavigator->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: static String^ MyOfficeConnectionString= L"Data Source=.;Initial Catalog=MyOffice;Integrated Security=True;Pooling=False";
private: System::Void 车辆费用管理BindingNavigatorSaveItem_Click(System::Object^ sender, System::EventArgs^ e) {
this->Validate();
this->车辆费用管理BindingSource->EndEdit();
this->车辆费用管理TableAdapter->Update(this->MyOfficeDataSet->车辆费用管理);
}
private: System::Void ExpensesForm_Load(System::Object^ sender, System::EventArgs^ e) {
// TODO: 这行代码将数据加载到表“MyOfficeDataSet.车辆费用管理”中。您可以根据需要移动或移除它。
this->车辆费用管理TableAdapter->Fill(this->MyOfficeDataSet->车辆费用管理);
String^ MySQLConnectionString = MyOfficeConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
System::Data::DataTable^ MyQueryTable = gcnew System::Data::DataTable();
String^ MySQL = "SELECT 车牌号 FROM 车辆登记管理";
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyQueryTable);
this->车牌号ComboBox->DataSource = MyQueryTable;
this->车牌号ComboBox->DisplayMember = "车牌号";
this->车牌号ComboBox->ValueMember = "车牌号";
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
private: System::Void 查询ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e)
{
try
{
this->车辆费用管理TableAdapter->FillBy(this->MyOfficeDataSet->车辆费用管理, System::Nullable<System::DateTime >((*cli::safe_cast<System::DateTime^>(System::Convert::ChangeType(开始日期ToolStripTextBox->Text,
System::DateTime::typeid)))), System::Nullable<System::DateTime >((*cli::safe_cast<System::DateTime^>(System::Convert::ChangeType(结束日期ToolStripTextBox->Text, System::DateTime::typeid)))));
}
catch (System::Exception^ ex)
{
System::Windows::Forms::MessageBox::Show(ex->Message);
}
}
private: System::Void bindingNavigatorAddNewItem_MouseUp(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
//自动计算自编号
String^ MySQLConnectionString = MyOfficeConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
String^ MySQL = "Select max(自编号) 自编号 From 车辆费用管理";
SqlCommand^ MyCommand = gcnew SqlCommand(MySQL, MyConnection);
System::Object^ MyResult = MyCommand->ExecuteScalar();
System::Int64 MyID = 1;
if (MyResult != System::DBNull::Value)
{
String^ MyMaxID = MyResult->ToString()->Trim();
MyMaxID = MyMaxID->Substring(2, MyMaxID->Length - 2);
MyID = Convert::ToInt64(MyMaxID) + 1;
}
int MyLength = MyID.ToString()->Length;
String^ MyNewID = "";
switch (MyLength)
{
case 1:
MyNewID = "FY0000000" + MyID.ToString();
break;
case 2:
MyNewID = "FY000000" + MyID.ToString();
break;
case 3:
MyNewID = "FY00000" + MyID.ToString();
break;
case 4:
MyNewID = "FY0000" + MyID.ToString();
break;
case 5:
MyNewID = "FY000" + MyID.ToString();
break;
case 6:
MyNewID = "FY00" + MyID.ToString();
break;
case 7:
MyNewID = "FY0" + MyID.ToString();
break;
}
if(MyConnection->State==ConnectionState::Open)
{
MyConnection->Close();
}
this->自编号TextBox->Text = MyNewID;
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -