📄 incidentform.h
字号:
this->dataGridViewTextBoxColumn7->DataPropertyName = L"说明";
this->dataGridViewTextBoxColumn7->HeaderText = L"说明";
this->dataGridViewTextBoxColumn7->Name = L"dataGridViewTextBoxColumn7";
this->dataGridViewTextBoxColumn7->ReadOnly = true;
//
// dataGridViewTextBoxColumn2
//
this->dataGridViewTextBoxColumn2->DataPropertyName = L"事故主题";
this->dataGridViewTextBoxColumn2->HeaderText = L"事故主题";
this->dataGridViewTextBoxColumn2->Name = L"dataGridViewTextBoxColumn2";
this->dataGridViewTextBoxColumn2->ReadOnly = true;
//
// dataGridViewTextBoxColumn3
//
this->dataGridViewTextBoxColumn3->DataPropertyName = L"发生日期";
this->dataGridViewTextBoxColumn3->HeaderText = L"发生日期";
this->dataGridViewTextBoxColumn3->Name = L"dataGridViewTextBoxColumn3";
this->dataGridViewTextBoxColumn3->ReadOnly = true;
//
// dataGridViewTextBoxColumn4
//
this->dataGridViewTextBoxColumn4->DataPropertyName = L"发生地点";
this->dataGridViewTextBoxColumn4->HeaderText = L"发生地点";
this->dataGridViewTextBoxColumn4->Name = L"dataGridViewTextBoxColumn4";
this->dataGridViewTextBoxColumn4->ReadOnly = true;
//
// 自编号TextBox
//
this->自编号TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->突发事故管理BindingSource, L"自编号", true)));
this->自编号TextBox->Location = System::Drawing::Point(57, 26);
this->自编号TextBox->Name = L"自编号TextBox";
this->自编号TextBox->ReadOnly = true;
this->自编号TextBox->Size = System::Drawing::Size(114, 21);
this->自编号TextBox->TabIndex = 19;
//
// 事故主题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(237, 26);
this->事故主题TextBox->Name = L"事故主题TextBox";
this->事故主题TextBox->Size = System::Drawing::Size(300, 21);
this->事故主题TextBox->TabIndex = 21;
//
// 发生日期DateTimePicker
//
this->发生日期DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->突发事故管理BindingSource, L"发生日期",
true)));
this->发生日期DateTimePicker->Location = System::Drawing::Point(69, 53);
this->发生日期DateTimePicker->Name = L"发生日期DateTimePicker";
this->发生日期DateTimePicker->Size = System::Drawing::Size(123, 21);
this->发生日期DateTimePicker->TabIndex = 23;
//
// 发生地点TextBox
//
this->发生地点TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->突发事故管理BindingSource, L"发生地点", true)));
this->发生地点TextBox->Location = System::Drawing::Point(263, 54);
this->发生地点TextBox->Name = L"发生地点TextBox";
this->发生地点TextBox->Size = System::Drawing::Size(75, 21);
this->发生地点TextBox->TabIndex = 25;
//
// 主要人员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(407, 54);
this->主要人员TextBox->Name = L"主要人员TextBox";
this->主要人员TextBox->Size = System::Drawing::Size(130, 21);
this->主要人员TextBox->TabIndex = 27;
//
// 事故详情TextBox
//
this->事故详情TextBox->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->事故详情TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->突发事故管理BindingSource, L"事故详情", true)));
this->事故详情TextBox->Location = System::Drawing::Point(69, 107);
this->事故详情TextBox->Multiline = true;
this->事故详情TextBox->Name = L"事故详情TextBox";
this->事故详情TextBox->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
this->事故详情TextBox->Size = System::Drawing::Size(468, 114);
this->事故详情TextBox->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(45, 80);
this->说明TextBox->Name = L"说明TextBox";
this->说明TextBox->Size = System::Drawing::Size(492, 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, &IncidentForm::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"开始日期:";
//
// 突发事故管理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::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(4, 227);
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, 184);
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";
//
// IncidentForm
//
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->事故主题TextBox);
this->Controls->Add(发生日期Label);
this->Controls->Add(this->发生日期DateTimePicker);
this->Controls->Add(this->发生地点TextBox);
this->Controls->Add(this->主要人员TextBox);
this->Controls->Add(this->事故详情TextBox);
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"IncidentForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"突发事故管理";
this->Load += gcnew System::EventHandler(this, &IncidentForm::IncidentForm_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 IncidentForm_Load(System::Object^ sender, System::EventArgs^ e) {
// TODO: 这行代码将数据加载到表“MyOfficeDataSet.突发事故管理”中。您可以根据需要移动或移除它。
this->突发事故管理TableAdapter->Fill(this->MyOfficeDataSet->突发事故管理);
}
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 = "TF0000000" + MyID.ToString();
break;
case 2:
MyNewID = "TF000000" + MyID.ToString();
break;
case 3:
MyNewID = "TF00000" + MyID.ToString();
break;
case 4:
MyNewID = "TF0000" + MyID.ToString();
break;
case 5:
MyNewID = "TF000" + MyID.ToString();
break;
case 6:
MyNewID = "TF00" + MyID.ToString();
break;
case 7:
MyNewID = "TF0" + MyID.ToString();
break;
}
if(MyConnection->State==ConnectionState::Open)
{
MyConnection->Close();
}
this->自编号TextBox->Text = MyNewID;
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -