📄 leaveform.h
字号:
//
批准人Label->AutoSize = true;
批准人Label->Location = System::Drawing::Point(160, 159);
批准人Label->Name = L"批准人Label";
批准人Label->Size = System::Drawing::Size(47, 12);
批准人Label->TabIndex = 51;
批准人Label->Text = L"批准人:";
//
// 批准人TextBox
//
this->批准人TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->离职管理BindingSource, L"批准人", true)));
this->批准人TextBox->Location = System::Drawing::Point(225, 156);
this->批准人TextBox->Name = L"批准人TextBox";
this->批准人TextBox->Size = System::Drawing::Size(114, 21);
this->批准人TextBox->TabIndex = 52;
//
// 说明Label
//
说明Label->AutoSize = true;
说明Label->Location = System::Drawing::Point(160, 186);
说明Label->Name = L"说明Label";
说明Label->Size = System::Drawing::Size(35, 12);
说明Label->TabIndex = 53;
说明Label->Text = L"说明:";
//
// 说明TextBox
//
this->说明TextBox->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text", this->离职管理BindingSource, L"说明", true)));
this->说明TextBox->Location = System::Drawing::Point(225, 183);
this->说明TextBox->Name = L"说明TextBox";
this->说明TextBox->Size = System::Drawing::Size(114, 21);
this->说明TextBox->TabIndex = 54;
//
// 基本档案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 = 40;
this->基本档案DataGridView->SelectionChanged += gcnew System::EventHandler(this, &LeaveForm::基本档案DataGridView_SelectionChanged);
this->基本档案DataGridView->Click += gcnew System::EventHandler(this, &LeaveForm::基本档案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^ >(7) {this->dataGridViewTextBoxColumn1,
this->dataGridViewTextBoxColumn2, this->dataGridViewTextBoxColumn3, this->dataGridViewTextBoxColumn4, this->dataGridViewTextBoxColumn5,
this->dataGridViewTextBoxColumn6, this->dataGridViewTextBoxColumn7});
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, 206);
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, 208);
this->离职管理DataGridView->TabIndex = 39;
//
// LeaveForm
//
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->离职原因RichTextBox);
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"LeaveForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"离职辞职人员维护";
this->Load += gcnew System::EventHandler(this, &LeaveForm::LeaveForm_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 LeaveForm_Load(System::Object^ sender, System::EventArgs^ e) {
// TODO: 这行代码将数据加载到表“MyPersonnelDataSet.离职管理”中。您可以根据需要移动或移除它。
this->离职管理TableAdapter->Fill(this->MyPersonnelDataSet->离职管理);
}
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 = "LZ0000000" + MyID.ToString();
break;
case 2:
MyNewID = "LZ000000" + MyID.ToString();
break;
case 3:
MyNewID = "LZ00000" + MyID.ToString();
break;
case 4:
MyNewID = "LZ0000" + MyID.ToString();
break;
case 5:
MyNewID = "LZ000" + MyID.ToString();
break;
case 6:
MyNewID = "LZ00" + MyID.ToString();
break;
case 7:
MyNewID = "LZ0" + MyID.ToString();
break;
}
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
this->自编号TextBox->Text = MyNewID;
}
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 基本档案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 + -