📄 querycheckform.h
字号:
this->dataGridViewTextBoxColumn11->HeaderText = L"8";
this->dataGridViewTextBoxColumn11->Name = L"dataGridViewTextBoxColumn11";
this->dataGridViewTextBoxColumn11->ReadOnly = true;
this->dataGridViewTextBoxColumn11->Width = 20;
//
// dataGridViewTextBoxColumn12
//
this->dataGridViewTextBoxColumn12->DataPropertyName = L"9";
this->dataGridViewTextBoxColumn12->HeaderText = L"9";
this->dataGridViewTextBoxColumn12->Name = L"dataGridViewTextBoxColumn12";
this->dataGridViewTextBoxColumn12->ReadOnly = true;
this->dataGridViewTextBoxColumn12->Width = 20;
//
// dataGridViewTextBoxColumn13
//
this->dataGridViewTextBoxColumn13->DataPropertyName = L"10";
this->dataGridViewTextBoxColumn13->HeaderText = L"10";
this->dataGridViewTextBoxColumn13->Name = L"dataGridViewTextBoxColumn13";
this->dataGridViewTextBoxColumn13->ReadOnly = true;
this->dataGridViewTextBoxColumn13->Width = 20;
//
// dataGridViewTextBoxColumn14
//
this->dataGridViewTextBoxColumn14->DataPropertyName = L"11";
this->dataGridViewTextBoxColumn14->HeaderText = L"11";
this->dataGridViewTextBoxColumn14->Name = L"dataGridViewTextBoxColumn14";
this->dataGridViewTextBoxColumn14->ReadOnly = true;
this->dataGridViewTextBoxColumn14->Width = 20;
//
// dataGridViewTextBoxColumn15
//
this->dataGridViewTextBoxColumn15->DataPropertyName = L"12";
this->dataGridViewTextBoxColumn15->HeaderText = L"12";
this->dataGridViewTextBoxColumn15->Name = L"dataGridViewTextBoxColumn15";
this->dataGridViewTextBoxColumn15->ReadOnly = true;
this->dataGridViewTextBoxColumn15->Width = 20;
//
// dataGridViewTextBoxColumn28
//
this->dataGridViewTextBoxColumn28->DataPropertyName = L"25";
this->dataGridViewTextBoxColumn28->HeaderText = L"25";
this->dataGridViewTextBoxColumn28->Name = L"dataGridViewTextBoxColumn28";
this->dataGridViewTextBoxColumn28->ReadOnly = true;
this->dataGridViewTextBoxColumn28->Width = 20;
//
// dataGridViewTextBoxColumn29
//
this->dataGridViewTextBoxColumn29->DataPropertyName = L"26";
this->dataGridViewTextBoxColumn29->HeaderText = L"26";
this->dataGridViewTextBoxColumn29->Name = L"dataGridViewTextBoxColumn29";
this->dataGridViewTextBoxColumn29->ReadOnly = true;
this->dataGridViewTextBoxColumn29->Width = 20;
//
// 打印个人年度考勤ToolStripButton
//
this->打印个人年度考勤ToolStripButton->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"打印个人年度考勤ToolStripButton.Image")));
this->打印个人年度考勤ToolStripButton->ImageTransparentColor = System::Drawing::Color::Magenta;
this->打印个人年度考勤ToolStripButton->Name = L"打印个人年度考勤ToolStripButton";
this->打印个人年度考勤ToolStripButton->Size = System::Drawing::Size(121, 22);
this->打印个人年度考勤ToolStripButton->Text = L"打印个人年度考勤";
this->打印个人年度考勤ToolStripButton->Click += gcnew System::EventHandler(this, &QueryCheckForm::打印个人年度考勤ToolStripButton_Click);
//
// 查询个人年度考勤ToolStripButton
//
this->查询个人年度考勤ToolStripButton->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"查询个人年度考勤ToolStripButton.Image")));
this->查询个人年度考勤ToolStripButton->ImageTransparentColor = System::Drawing::Color::Magenta;
this->查询个人年度考勤ToolStripButton->Name = L"查询个人年度考勤ToolStripButton";
this->查询个人年度考勤ToolStripButton->Size = System::Drawing::Size(121, 22);
this->查询个人年度考勤ToolStripButton->Text = L"查询个人年度考勤";
this->查询个人年度考勤ToolStripButton->Click += gcnew System::EventHandler(this, &QueryCheckForm::查询个人年度考勤ToolStripButton_Click);
//
// 考勤年份ToolStripComboBox
//
this->考勤年份ToolStripComboBox->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
this->考勤年份ToolStripComboBox->Name = L"考勤年份ToolStripComboBox";
this->考勤年份ToolStripComboBox->Size = System::Drawing::Size(75, 25);
//
// toolStripLabel1
//
this->toolStripLabel1->Name = L"toolStripLabel1";
this->toolStripLabel1->Size = System::Drawing::Size(65, 22);
this->toolStripLabel1->Text = L"员工编号:";
//
// toolStrip1
//
this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(6) {this->toolStripLabel1,
this->员工编号ToolStripTextBox, this->toolStripLabel2, this->考勤年份ToolStripComboBox, this->查询个人年度考勤ToolStripButton, this->打印个人年度考勤ToolStripButton});
this->toolStrip1->Location = System::Drawing::Point(0, 0);
this->toolStrip1->Name = L"toolStrip1";
this->toolStrip1->Size = System::Drawing::Size(542, 25);
this->toolStrip1->TabIndex = 2;
this->toolStrip1->Text = L"toolStrip1";
//
// 员工编号ToolStripTextBox
//
this->员工编号ToolStripTextBox->Name = L"员工编号ToolStripTextBox";
this->员工编号ToolStripTextBox->Size = System::Drawing::Size(60, 25);
this->员工编号ToolStripTextBox->Text = L"%A000001%";
//
// toolStripLabel2
//
this->toolStripLabel2->Name = L"toolStripLabel2";
this->toolStripLabel2->Size = System::Drawing::Size(65, 22);
this->toolStripLabel2->Text = L"考勤年份:";
//
// QueryCheckForm
//
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(this->考勤记录DataGridView);
this->Controls->Add(this->toolStrip1);
this->Name = L"QueryCheckForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"查询个人年度考勤";
this->Load += gcnew System::EventHandler(this, &QueryCheckForm::QueryCheckForm_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->考勤记录DataGridView))->EndInit();
this->toolStrip1->ResumeLayout(false);
this->toolStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: static String^ MyPersonnelConnectionString= L"Data Source=.;Initial Catalog=MyPersonnel;Integrated Security=True;Pooling=False";
public: String^ MyCompany;
private: String^ My员工姓名;
private: System::Data::DataTable^ MyQueryTable;
private: System::Void 考勤记录BindingNavigatorSaveItem_Click(System::Object^ sender, System::EventArgs^ e) {
this->Validate();
this->考勤记录BindingSource->EndEdit();
this->考勤记录TableAdapter->Update(this->MyPersonnelDataSet->考勤记录);
}
private: System::Void QueryCheckForm_Load(System::Object^ sender, System::EventArgs^ e) {
// TODO: 这行代码将数据加载到表“MyPersonnelDataSet.考勤记录”中。您可以根据需要移动或移除它。
this->考勤记录TableAdapter->Fill(this->MyPersonnelDataSet->考勤记录);
for (int i = 2006; i < 2100; i++)
{
this->考勤年份ToolStripComboBox->Items->Add(i.ToString() );
}
}
private: System::Void 查询个人年度考勤ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e) {
this->考勤记录DataGridView->DataSource = nullptr;
String^ MySQLConnectionString =MyPersonnelConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
MyQueryTable = gcnew System::Data::DataTable();
String^ MySQL = "SELECT 员工姓名,考勤月份, [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [21], [22], [23], [24], [25], [26], [27], [28], [29], [30], [31] FROM 考勤记录 WHERE (员工编号 LIKE '" + this->员工编号ToolStripTextBox->Text + "') AND (考勤年份="+ this->考勤年份ToolStripComboBox->Text +") ORDER BY 考勤月份";
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyQueryTable);
this->My员工姓名 = MyQueryTable->Rows[1][0]->ToString();
this->Text = "查询个人年度考勤-" + this->My员工姓名;
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
this->考勤记录DataGridView->DataSource = MyQueryTable;
}
private: System::Void 打印个人年度考勤ToolStripButton_Click(System::Object^ sender, System::EventArgs^ e) {
if (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>(500,35);
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];
MyRange = MyWorkSheet->Range["A5", "AF5"];
MyData[0, 0] = "月份";
for (i = 1; i < 32; i++)
{
MyData[0, i] = i.ToString();
}
j = 1;
//输出数据库记录
for each (DataRow^ MyRow in MyQueryTable->Rows)
{
for (i = 1; i < MyQueryTable->Columns->Count - 1; i++)
{
MyData[j, i - 1] = MyRow[i]->ToString();
}
j++;
}
MyRange = MyRange->Resize[MyQueryTable->Rows->Count + 1, 32];
MyRange->Value2 = MyData;
MyRange->EntireColumn->AutoFit();
MyWorkSheet->Cells[2, 2] = this->MyCompany + "个人年度考勤表";
MyWorkSheet->Cells[4, 1] ="姓名:"+this->My员工姓名 + " 考勤年度:" + this->考勤年份ToolStripComboBox->Text + "年" ;
MyWorkSheet->Cells[MyQueryTable->Rows->Count + 7, 1] = "考勤符号说明:出勤 /, 迟到>, 早退<, 产假√,事假#,病假+,婚假△,旷工×";
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -