⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkform.h

📁 这是一个用VC++编写的人事工资管理系统,开发平台为VS2005,是开发企业管理程序的程序员的很好参考!
💻 H
📖 第 1 页 / 共 4 页
字号:
			this->toolStrip1->ResumeLayout(false);
			this->toolStrip1->PerformLayout();
			(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";
		public: String^ MyCompany;
		private: System::Void 考勤记录BindingNavigatorSaveItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 this->Validate();
			 this->考勤记录BindingSource->EndEdit();
			 this->考勤记录TableAdapter->Update(this->MyPersonnelDataSet->考勤记录);
		 }
		private: System::Void CheckForm_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());
            }
            for (int i = 1; i < 13; i++)
            {
                this->月份ToolStripComboBox->Items->Add(i.ToString());
            }
            //获取公司的部门信息            
            String^ MySQLConnectionString = MyPersonnelConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            System::Data::DataTable^ MyDepartmentTable = gcnew System::Data::DataTable();
            String^ MySQL = "Select 部门名称 From 公司部门";
            SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
            MyAdapter->Fill(MyDepartmentTable);
            for each(DataRow^ MyRow in MyDepartmentTable->Rows)
            {
                this->部门ToolStripComboBox->Items->Add(MyRow[0]->ToString());
            }
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
		 }
		private: System::Void 查询ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if (this->考勤年份ToolStripComboBox->Text->Length < 1 || this->月份ToolStripComboBox->Text->Length < 1 || this->部门ToolStripComboBox->Text->Length < 1)
            {
                return;
            }
            try
            {
				this->考勤记录TableAdapter->FillBy(this->MyPersonnelDataSet->考勤记录, Convert::ToInt16(this->考勤年份ToolStripComboBox->Text),Convert::ToInt16(this->月份ToolStripComboBox->Text), this->部门ToolStripComboBox->Text);
            }
            catch (System::Exception^ ex)
            {
				System::Windows::Forms::MessageBox::Show(ex->Message);
            }
            if (this->MyPersonnelDataSet->考勤记录->Rows->Count < 1)
            {                          
                String^ MySQLConnectionString = MyPersonnelConnectionString;
                SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
                MyConnection->Open();
                System::Data::DataTable^ MyQueryTable = gcnew System::Data::DataTable();
                String^ MySQL = "Select * From 在职员工视图 WHERE 部门='" + this->部门ToolStripComboBox->Text + "'";
                SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
                MyAdapter->Fill(MyQueryTable);
                for each (DataRow^ MyRow in MyQueryTable->Rows)
                {
                    String^ My自编号=this->GetMyID();
                    String^ My员工编号=MyRow[1]->ToString();
                    String^ My员工姓名=MyRow[3]->ToString();
                    int My考勤年份 = Convert::ToInt16(this->考勤年份ToolStripComboBox->Text);
                    int My考勤月份 = Convert::ToInt16(this->月份ToolStripComboBox->Text);
                    MySQL = "INSERT INTO 考勤记录([自编号] ,[员工编号], [员工姓名], [考勤年份], [考勤月份]) VALUES (@自编号 ,@员工编号, @员工姓名, @考勤年份, @考勤月份)";
                    MyConnection = gcnew SqlConnection(MySQLConnectionString);
                    MyConnection->Open();
                    SqlCommand^ MyCommand = MyConnection->CreateCommand();
                    MyCommand->CommandText = MySQL;
                    MyCommand->Parameters->Add(gcnew SqlParameter("@自编号", SqlDbType::VarChar));
                    MyCommand->Parameters->Add(gcnew SqlParameter("@员工编号", SqlDbType::VarChar));
                    MyCommand->Parameters->Add(gcnew SqlParameter("@员工姓名", SqlDbType::VarChar));
                    MyCommand->Parameters->Add(gcnew SqlParameter("@考勤年份", SqlDbType::Int));
                    MyCommand->Parameters->Add(gcnew SqlParameter("@考勤月份", SqlDbType::Int));
                    MyCommand->Parameters["@自编号"]->Value = My自编号;
                    MyCommand->Parameters["@员工编号"]->Value = My员工编号;
                    MyCommand->Parameters["@员工姓名"]->Value = My员工姓名;
                    MyCommand->Parameters["@考勤年份"]->Value = My考勤年份;
                    MyCommand->Parameters["@考勤月份"]->Value = My考勤月份;
                    MyCommand->ExecuteNonQuery();
                }
                if (MyConnection->State == ConnectionState::Open)
                {
                    MyConnection->Close();
                }
                查询ToolStripButton_Click(nullptr, nullptr);
            }
		}
		private: String^ GetMyID()
        {
            //自动计算自编号
            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 = "KQ0000000" + MyID.ToString();
                    break;
                case 2:
                    MyNewID = "KQ000000" + MyID.ToString();
                    break;
                case 3:
                    MyNewID = "KQ00000" + MyID.ToString();
                    break;
                case 4:
                    MyNewID = "KQ0000" + MyID.ToString();
                    break;
                case 5:
                    MyNewID = "KQ000" + MyID.ToString();
                    break;
                case 6:
                    MyNewID = "KQ00" + MyID.ToString();
                    break;
                case 7:
                    MyNewID = "KQ0" + MyID.ToString();
                    break;
            }
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            return  MyNewID;          
        }
		private: System::Void 出勤ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if ((this->考勤记录DataGridView->CurrentCell->ColumnIndex == 2) || (this->考勤记录DataGridView->CurrentCell->ColumnIndex == 1))
                return;
            this->考勤记录DataGridView->CurrentCell->Value = "/";
		}
		private: System::Void 迟到ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if ((this->考勤记录DataGridView->CurrentCell->ColumnIndex == 2) || (this->考勤记录DataGridView->CurrentCell->ColumnIndex == 1))
                return;
            this->考勤记录DataGridView->CurrentCell->Value = ">";
		 }
		private: System::Void 早退ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if ((this->考勤记录DataGridView->CurrentCell->ColumnIndex == 2) || (this->考勤记录DataGridView->CurrentCell->ColumnIndex == 1))
                return;
            this->考勤记录DataGridView->CurrentCell->Value = "<";
		 }
		private: System::Void 产假ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if ((this->考勤记录DataGridView->CurrentCell->ColumnIndex == 2) || (this->考勤记录DataGridView->CurrentCell->ColumnIndex == 1))
                return;
            this->考勤记录DataGridView->CurrentCell->Value = "√";
		 }
		private: System::Void 事假ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if ((this->考勤记录DataGridView->CurrentCell->ColumnIndex == 2) || (this->考勤记录DataGridView->CurrentCell->ColumnIndex == 1))
                return;
            this->考勤记录DataGridView->CurrentCell->Value = "#";
		 }
		private: System::Void 病假ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if ((this->考勤记录DataGridView->CurrentCell->ColumnIndex == 2) || (this->考勤记录DataGridView->CurrentCell->ColumnIndex == 1))
                return;
            this->考勤记录DataGridView->CurrentCell->Value = "+";
		 }
		private: System::Void 婚假ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if ((this->考勤记录DataGridView->CurrentCell->ColumnIndex == 2) || (this->考勤记录DataGridView->CurrentCell->ColumnIndex == 1))
                return;
            this->考勤记录DataGridView->CurrentCell->Value = "△";
		 }
		private: System::Void 旷工ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			if ((this->考勤记录DataGridView->CurrentCell->ColumnIndex == 2) || (this->考勤记录DataGridView->CurrentCell->ColumnIndex == 1))
                return;
            this->考勤记录DataGridView->CurrentCell->Value = "×";   
		 }
		private: System::Void 打印ToolStripButton_Click(System::Object^  sender, System::EventArgs^  e) {
			System::Data::DataTable^ MyQueryTable = gcnew System::Data::DataTable();
            MyQueryTable = this->MyPersonnelDataSet->考勤记录->Copy();
            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 = 2; i < MyQueryTable->Columns->Count - 1; i++)
                {
                    MyData[j, i - 2] = MyRow[i]->ToString();
                }
                j++;
            }
            MyRange = MyRange->Resize[MyQueryTable->Rows->Count+1, 32];
            MyRange->Value2 = MyData;
            MyRange->EntireColumn->AutoFit();
            MyWorkSheet->Cells[2, 2] = this->MyCompany + this->部门ToolStripComboBox->Text + "考勤表";
            MyWorkSheet->Cells[4, 1] = "考勤日期:" + this->考勤年份ToolStripComboBox->Text + "年"+this->月份ToolStripComboBox->Text+"月份";
            MyWorkSheet->Cells[MyQueryTable->Rows->Count + 7, 1] = "考勤符号说明:出勤 /, 迟到>, 早退<, 产假√,事假#,病假+,婚假△,旷工×";
		 }
	};
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -