📄 trainingform.h
字号:
// 开始时间DateTimePicker
//
this->开始时间DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->培训记录BindingSource, L"开始时间",
true)));
this->开始时间DateTimePicker->Location = System::Drawing::Point(228, 126);
this->开始时间DateTimePicker->Name = L"开始时间DateTimePicker";
this->开始时间DateTimePicker->Size = System::Drawing::Size(110, 21);
this->开始时间DateTimePicker->TabIndex = 56;
//
// 结束时间DateTimePicker
//
this->结束时间DateTimePicker->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Value", this->培训记录BindingSource, L"结束时间",
true)));
this->结束时间DateTimePicker->Location = System::Drawing::Point(228, 153);
this->结束时间DateTimePicker->Name = L"结束时间DateTimePicker";
this->结束时间DateTimePicker->Size = System::Drawing::Size(110, 21);
this->结束时间DateTimePicker->TabIndex = 58;
//
// 培训单位TextBox
//
this->培训单位TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->培训记录BindingSource, L"培训单位", true)));
this->培训单位TextBox->Location = System::Drawing::Point(228, 180);
this->培训单位TextBox->Name = L"培训单位TextBox";
this->培训单位TextBox->Size = System::Drawing::Size(110, 21);
this->培训单位TextBox->TabIndex = 60;
//
// 培训地点TextBox
//
this->培训地点TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->培训记录BindingSource, L"培训地点", true)));
this->培训地点TextBox->Location = System::Drawing::Point(406, 126);
this->培训地点TextBox->Name = L"培训地点TextBox";
this->培训地点TextBox->Size = System::Drawing::Size(131, 21);
this->培训地点TextBox->TabIndex = 62;
//
// 培训内容TextBox
//
this->培训内容TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->培训记录BindingSource, L"培训内容", true)));
this->培训内容TextBox->Location = System::Drawing::Point(406, 153);
this->培训内容TextBox->Name = L"培训内容TextBox";
this->培训内容TextBox->Size = System::Drawing::Size(131, 21);
this->培训内容TextBox->TabIndex = 64;
//
// 培训经费TextBox
//
this->培训经费TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->培训记录BindingSource, L"培训经费", true)));
this->培训经费TextBox->Location = System::Drawing::Point(406, 180);
this->培训经费TextBox->Name = L"培训经费TextBox";
this->培训经费TextBox->Size = System::Drawing::Size(131, 21);
this->培训经费TextBox->TabIndex = 66;
//
// 证书名称TextBox
//
this->证书名称TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->培训记录BindingSource, L"证书名称", true)));
this->证书名称TextBox->Location = System::Drawing::Point(68, 207);
this->证书名称TextBox->Name = L"证书名称TextBox";
this->证书名称TextBox->Size = System::Drawing::Size(164, 21);
this->证书名称TextBox->TabIndex = 68;
//
// 说明TextBox
//
this->说明TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->培训记录BindingSource, L"说明", true)));
this->说明TextBox->Location = System::Drawing::Point(277, 207);
this->说明TextBox->Name = L"说明TextBox";
this->说明TextBox->Size = System::Drawing::Size(260, 21);
this->说明TextBox->TabIndex = 70;
//
// 基本档案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::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->基本档案DataGridView->BackgroundColor = System::Drawing::SystemColors::ActiveCaption;
this->基本档案DataGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->基本档案DataGridView->Location = System::Drawing::Point(4, 28);
this->基本档案DataGridView->MultiSelect = false;
this->基本档案DataGridView->Name = L"基本档案DataGridView";
this->基本档案DataGridView->ReadOnly = true;
this->基本档案DataGridView->RowHeadersVisible = false;
dataGridViewCellStyle1->BackColor = System::Drawing::Color::Green;
dataGridViewCellStyle1->ForeColor = System::Drawing::Color::Yellow;
this->基本档案DataGridView->RowsDefaultCellStyle = dataGridViewCellStyle1;
this->基本档案DataGridView->RowTemplate->Height = 23;
this->基本档案DataGridView->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
this->基本档案DataGridView->Size = System::Drawing::Size(533, 93);
this->基本档案DataGridView->TabIndex = 48;
this->基本档案DataGridView->SelectionChanged += gcnew System::EventHandler(this, &TrainingForm::基本档案DataGridView_SelectionChanged);
this->基本档案DataGridView->Click += gcnew System::EventHandler(this, &TrainingForm::基本档案DataGridView_Click);
//
// 培训记录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->BackgroundColor = System::Drawing::SystemColors::ActiveCaption;
this->培训记录DataGridView->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(11) {this->dataGridViewTextBoxColumn1,
this->dataGridViewTextBoxColumn2, this->dataGridViewTextBoxColumn3, this->dataGridViewTextBoxColumn4, this->dataGridViewTextBoxColumn5,
this->dataGridViewTextBoxColumn6, this->dataGridViewTextBoxColumn7, this->dataGridViewTextBoxColumn8, this->dataGridViewTextBoxColumn9,
this->dataGridViewTextBoxColumn10, this->dataGridViewTextBoxColumn11});
this->培训记录DataGridView->DataSource = this->培训记录BindingSource;
dataGridViewCellStyle2->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
dataGridViewCellStyle2->BackColor = System::Drawing::Color::Green;
dataGridViewCellStyle2->Font = (gcnew System::Drawing::Font(L"宋体", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(134)));
dataGridViewCellStyle2->ForeColor = System::Drawing::Color::Yellow;
dataGridViewCellStyle2->SelectionBackColor = System::Drawing::SystemColors::Highlight;
dataGridViewCellStyle2->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
dataGridViewCellStyle2->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
this->培训记录DataGridView->DefaultCellStyle = dataGridViewCellStyle2;
this->培训记录DataGridView->Location = System::Drawing::Point(4, 233);
this->培训记录DataGridView->MultiSelect = false;
this->培训记录DataGridView->Name = L"培训记录DataGridView";
this->培训记录DataGridView->RowHeadersVisible = false;
this->培训记录DataGridView->RowTemplate->Height = 23;
this->培训记录DataGridView->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
this->培训记录DataGridView->Size = System::Drawing::Size(533, 179);
this->培训记录DataGridView->TabIndex = 47;
//
// TrainingForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(192)));
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->员工姓名TextBox);
this->Controls->Add(开始时间Label);
this->Controls->Add(this->开始时间DateTimePicker);
this->Controls->Add(结束时间Label);
this->Controls->Add(this->结束时间DateTimePicker);
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(培训经费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->基本档案DataGridView);
this->Controls->Add(this->培训记录DataGridView);
this->Controls->Add(this->培训记录BindingNavigator);
this->Name = L"TrainingForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"员工培训记录维护";
this->Load += gcnew System::EventHandler(this, &TrainingForm::TrainingForm_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->MyPersonnelDataSet))->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->培训记录DataGridView))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: static String^ MyPersonnelConnectionString= L"Data Source=.;Initial Catalog=MyPersonnel;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->MyPersonnelDataSet->培训记录);
}
private: System::Void TrainingForm_Load(System::Object^ sender, System::EventArgs^ e) {
// TODO: 这行代码将数据加载到表“MyPersonnelDataSet.培训记录”中。您可以根据需要移动或移除它。
//this->培训记录TableAdapter->Fill(this->MyPersonnelDataSet->培训记录);
}
private: System::Void 查询ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e) {
String^ MySQLConnectionString = MyPersonnelConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
String^ MySQL = "Select * From 基本档案 Where 姓名 LIKE '" + this->员工姓名ToolStripTextBox->Text + "' AND (员工编号 NOT IN(SELECT 员工编号 FROM 离职管理))";
System::Data::DataTable^ MyPersonnelTable = gcnew System::Data::DataTable();
SqlDataAdapter^ MyDataAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter->Fill(MyPersonnelTable);
this->基本档案DataGridView->DataSource = MyPersonnelTable;
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
private: System::Void bindingNavigatorAddNewItem_Click(System::Object^ sender, System::EventArgs^ e) {
//自动计算培训记录自编号
String^ MySQLConnectionString = MyPersonnelConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
SqlCommand^ MyCommand = MyConnection->CreateCommand();
MyCommand->CommandText = "Select max(自编号) 最大编号 From 培训记录";
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 = "PX0000000" + MyID.ToString();
break;
case 2:
MyNewID = "PX000000" + MyID.ToString();
break;
case 3:
MyNewID = "PX00000" + MyID.ToString();
break;
case 4:
MyNewID = "PX0000" + MyID.ToString();
break;
case 5:
MyNewID = "PX000" + MyID.ToString();
break;
case 6:
MyNewID = "PX00" + MyID.ToString();
break;
case 7:
MyNewID = "PX0" + MyID.ToString();
break;
}
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
this->自编号TextBox->Text = MyNewID;
}
private: System::Void 基本档案DataGridView_Click(System::Object^ sender, System::EventArgs^ e) {
this->员工编号TextBox->Text = this->基本档案DataGridView->CurrentRow->Cells[1]->Value->ToString();
this->员工姓名TextBox->Text = this->基本档案DataGridView->CurrentRow->Cells[3]->Value->ToString();
}
private: System::Void 基本档案DataGridView_SelectionChanged(System::Object^ sender, System::EventArgs^ e) {
String^ My员工姓名 = this->基本档案DataGridView->CurrentRow->Cells[3]->Value->ToString();
try
{
this->培训记录TableAdapter->FillBy(this->MyPersonnelDataSet->培训记录, My员工姓名);
}
catch (System::Exception^ ex)
{
System::Windows::Forms::MessageBox::Show(ex->Message);
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -