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

📄 amendstafferinfo.h

📁 Visual C++.net数据库开发经典案例
💻 H
📖 第 1 页 / 共 3 页
字号:
			this->label1->Name = S"label1";
			this->label1->Size = System::Drawing::Size(56, 16);
			this->label1->TabIndex = 9;
			this->label1->Text = S"职员编号";
			// 
			// tBoxStaffEducation
			// 
			this->tBoxStaffEducation->Location = System::Drawing::Point(176, 88);
			this->tBoxStaffEducation->Name = S"tBoxStaffEducation";
			this->tBoxStaffEducation->Size = System::Drawing::Size(136, 21);
			this->tBoxStaffEducation->TabIndex = 8;
			this->tBoxStaffEducation->Text = S"";
			// 
			// tBoxStaffAge
			// 
			this->tBoxStaffAge->Location = System::Drawing::Point(104, 88);
			this->tBoxStaffAge->Name = S"tBoxStaffAge";
			this->tBoxStaffAge->Size = System::Drawing::Size(64, 21);
			this->tBoxStaffAge->TabIndex = 7;
			this->tBoxStaffAge->Text = S"";
			// 
			// tBoxStafBirthDay
			// 
			this->tBoxStafBirthDay->Location = System::Drawing::Point(8, 88);
			this->tBoxStafBirthDay->Name = S"tBoxStafBirthDay";
			this->tBoxStafBirthDay->Size = System::Drawing::Size(88, 21);
			this->tBoxStafBirthDay->TabIndex = 6;
			this->tBoxStafBirthDay->Text = S"";
			// 
			// cmbStaffNativePlace
			// 
			System::Object* __mcTemp__2[] = new System::Object*[6];
			__mcTemp__2[0] = S"北京";
			__mcTemp__2[1] = S"广东";
			__mcTemp__2[2] = S"安徽";
			__mcTemp__2[3] = S"江西";
			__mcTemp__2[4] = S"山东";
			__mcTemp__2[5] = S"其它";
			this->cmbStaffNativePlace->Items->AddRange(__mcTemp__2);
			this->cmbStaffNativePlace->Location = System::Drawing::Point(432, 40);
			this->cmbStaffNativePlace->Name = S"cmbStaffNativePlace";
			this->cmbStaffNativePlace->Size = System::Drawing::Size(192, 20);
			this->cmbStaffNativePlace->TabIndex = 5;
			// 
			// cmbStaffNation
			// 
			System::Object* __mcTemp__3[] = new System::Object*[7];
			__mcTemp__3[0] = S"汉族";
			__mcTemp__3[1] = S"维吾尔族";
			__mcTemp__3[2] = S"蒙古族";
			__mcTemp__3[3] = S"满族";
			__mcTemp__3[4] = S"藏族";
			__mcTemp__3[5] = S"彝族";
			__mcTemp__3[6] = S"其它";
			this->cmbStaffNation->Items->AddRange(__mcTemp__3);
			this->cmbStaffNation->Location = System::Drawing::Point(328, 40);
			this->cmbStaffNation->Name = S"cmbStaffNation";
			this->cmbStaffNation->Size = System::Drawing::Size(96, 20);
			this->cmbStaffNation->TabIndex = 4;
			// 
			// cmbStaffSex
			// 
			System::Object* __mcTemp__4[] = new System::Object*[2];
			__mcTemp__4[0] = S"男";
			__mcTemp__4[1] = S"女";
			this->cmbStaffSex->Items->AddRange(__mcTemp__4);
			this->cmbStaffSex->Location = System::Drawing::Point(272, 40);
			this->cmbStaffSex->Name = S"cmbStaffSex";
			this->cmbStaffSex->Size = System::Drawing::Size(48, 20);
			this->cmbStaffSex->TabIndex = 3;
			// 
			// tBoxStaffNameCode
			// 
			this->tBoxStaffNameCode->Location = System::Drawing::Point(184, 40);
			this->tBoxStaffNameCode->Name = S"tBoxStaffNameCode";
			this->tBoxStaffNameCode->Size = System::Drawing::Size(80, 21);
			this->tBoxStaffNameCode->TabIndex = 2;
			this->tBoxStaffNameCode->Text = S"";
			// 
			// tBoxStaffName
			// 
			this->tBoxStaffName->Location = System::Drawing::Point(96, 40);
			this->tBoxStaffName->Name = S"tBoxStaffName";
			this->tBoxStaffName->Size = System::Drawing::Size(80, 21);
			this->tBoxStaffName->TabIndex = 1;
			this->tBoxStaffName->Text = S"";
			// 
			// tBoxStaffID
			// 
			this->tBoxStaffID->Location = System::Drawing::Point(8, 40);
			this->tBoxStaffID->Name = S"tBoxStaffID";
			this->tBoxStaffID->Size = System::Drawing::Size(80, 21);
			this->tBoxStaffID->TabIndex = 0;
			this->tBoxStaffID->Text = S"";
			// 
			// AmendStafferInfo
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(664, 421);
			this->Controls->Add(this->groupBox1);
			this->Controls->Add(this->dgrdStafferInfo);
			this->Controls->Add(this->toolBar1);
			this->Name = S"AmendStafferInfo";
			this->Text = S"职员信息管理";
			this->Load += new System::EventHandler(this, AmendStafferInfo_Load);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdStafferInfo))->EndInit();
			this->groupBox1->ResumeLayout(false);
			this->ResumeLayout(false);

		}		
	private: System::Void label15_Click(System::Object *  sender, System::EventArgs *  e)
			 {
			 }

private: System::Void AmendStafferInfo_Load(System::Object *  sender, System::EventArgs *  e)
		 {
			this->cmAmend = __try_cast<CurrencyManager*>(this->BindingContext->Item[this->ds->Tables->Item[S"职员基本信息表"]]);
			//查询组织机构信息
			String* tempSQL = new String("Select * from 组织机构编码表 order by 单位编号");			
			String* tempTableName = new String("组织机构编码表");
			this->OrgInfoAdapter = new SqlDataAdapter();		
			this->MyDataBase->SelectDataBase(this->OrgInfoAdapter,this->ds,tempSQL,tempTableName);			
			
			 this->dgrdStafferInfo->DataSource = this->ds->Tables->Item[S"职员基本信息表"];
			 this->DataGridStateControl();
			 this->DataBidings();
		 }

		//------------------设置表格样式----------------------
		void DataGridStateControl()
		{
			DataGridTableStyle* ts = new DataGridTableStyle();
			DataGridNoActiveCellColumn* aTextColumn;
			ts->AlternatingBackColor = Color::LightGray;
			ts->MappingName = this->ds->Tables->Item[S"职员基本信息表"]->TableName;

			int numCols = this->ds->Tables->Item[S"职员基本信息表"]->Columns->Count;
			for(int i = 0;i < numCols;i++)
			{
				aTextColumn = new DataGridNoActiveCellColumn();
				aTextColumn->get_TextBox()->Enabled = false;
				aTextColumn->MappingName = this->ds->Tables->Item[S"职员基本信息表"]->Columns->Item[i]->ColumnName;
				aTextColumn->HeaderText = this->ds->Tables->Item[S"职员基本信息表"]->Columns->Item[i]->ColumnName;
				aTextColumn->NullText = S"";
				aTextColumn->Format = S"D";
				ts->GridColumnStyles->Add(aTextColumn);
			}
			this->dgrdStafferInfo->TableStyles->Add(ts);
			this->dgrdStafferInfo->Select(0);
		}
		//------------------设置数据绑定----------------------
        void DataBidings()
		{
			this->tBoxStaffID->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"职员编号");
			this->tBoxStaffName->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"姓名");
			this->tBoxStaffNameCode->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"姓名简码");
			this->tBoxStafBirthDay->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"出生日期");
			this->tBoxStaffAge->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"年龄");
			this->tBoxStaffEducation->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"文化程度");
			this->tBoxStaffGraduatedSchool->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"毕业学校");
			this->tBoxStaffHealth->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"健康状况");
			this->tBoxStaffMarriage->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"婚姻状况");
			this->tBoxStaffIndividualID->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"身份证号码");
			this->tBoxStaffFamilyNumber->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"家庭电话");
			this->tBoxStaffOfficeNumber->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"办公电话");
			this->tBoxStaffMobileNumber->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"手机");
			this->tBoxStaffEmail->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"电子邮件地址");
			this->tBoxStaffAccount->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"职工账号");
			this->tBoxStaffMemo->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"备注");
			this->cmbStaffSex->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"性别");
			this->cmbStaffNation->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"民族");
			this->cmbStaffNativePlace->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"籍贯");
			this->cmbStaffDepartmentID->DataBindings->Add("Text",this->ds->Tables->Item[S"职员基本信息表"],"单位编号");			

			this->cmbStaffDepartmentID->DataSource = this->ds->Tables->Item[S"组织机构编码表"];
			this->cmbStaffDepartmentID->DisplayMember = S"单位编号";
			this->cmbStaffDepartmentID->ValueMember = S"单位编号";
		}
private: System::Void cmbStaffDepartmentID_TextChanged(System::Object *  sender, System::EventArgs *  e)
		 {
			 String* Filter = String::Format(S"单位编号 = '{0}'",this->cmbStaffDepartmentID->Text);
			 DataRow* row[] = this->ds->Tables->Item[S"组织机构编码表"]->Select(Filter);
			 if(row->Length > 0)
			 {
				 this->tBoxStaffDepartment->Text = row[0]->Item[S"单位名称"]->ToString()->Trim();
			 }
		 }

private: System::Void toolBar1_ButtonClick(System::Object *  sender, System::Windows::Forms::ToolBarButtonClickEventArgs *  e)
		 {
			 if(String::Compare(e->Button->ToolTipText->Trim(),S"首记录") == 0)
			 {
				 this->dgrdStafferInfo->UnSelect(this->cmAmend->Position);
				 this->cmAmend->Position = 0;
				 this->dgrdStafferInfo->Select(this->cmAmend->Position);
				 this->dgrdStafferInfo->CurrentRowIndex = this->cmAmend->Position;
			 }
			 else if(String::Compare(e->Button->ToolTipText->Trim(),S"上一记录") == 0)
			 {
				 if(this->cmAmend->Position > 0)
				 {
					 this->dgrdStafferInfo->UnSelect(this->cmAmend->Position);
					 this->cmAmend->Position--;
					 this->dgrdStafferInfo->Select(this->cmAmend->Position);
					 this->dgrdStafferInfo->CurrentRowIndex = this->cmAmend->Position;
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText->Trim(),S"下一记录") == 0)
			 {
				 if(this->cmAmend->Position < this->cmAmend->Count - 1)
				 {
					 this->dgrdStafferInfo->UnSelect(this->cmAmend->Position);
					 this->cmAmend->Position++;
					 this->dgrdStafferInfo->Select(this->cmAmend->Position);
					 this->dgrdStafferInfo->CurrentRowIndex = this->cmAmend->Position;
				 }
			 }
			 else if(String::Compare(e->Button->ToolTipText->Trim(),S"尾记录") == 0)
			 {
				 this->dgrdStafferInfo->UnSelect(this->cmAmend->Position);
				 this->cmAmend->Position = this->cmAmend->Count - 1;
				 this->dgrdStafferInfo->Select(this->cmAmend->Position);
				 this->dgrdStafferInfo->CurrentRowIndex = this->cmAmend->Position;
			 }
			 else if(String::Compare(e->Button->ToolTipText->Trim(),S"新增记录") == 0)
			 {
				 //检查新记录
				 if(this->tBoxStaffID->Text->Trim() == S"")
				 {
					 MessageBox::Show(S"职员编号不能为空",S"提示");
					 return;
				 }
				 if(this->tBoxStaffName->Text->Trim() == S"")
				 {
					 MessageBox::Show(S"职员姓名不能为空",S"提示");
					 return;
				 }
				 //提交修改
				 this->cmAmend->AddNew();
				 //更新数据库
				 this->MyDataBase->UpdateDataBase(this->ds,S"职员基本信息表");
			 }
			 else if(String::Compare(e->Button->ToolTipText->Trim(),S"删除记录") == 0)
			 {
				 //修改数据库
				 String* tempSQL = String::Format(S"Delete from 工资发放历史表 where 职员编号 = '{0}'",this->tBoxStaffID->Text);
				 this->MyDataBase->SQLOperate(tempSQL);

				 tempSQL = String::Format(S"Delete from 月工资统计表 where 职员编号 = '{0}'",this->tBoxStaffID->Text);
				 this->MyDataBase->SQLOperate(tempSQL);

				 tempSQL = String::Format(S"Delete from 职员惩罚表 where 职员编号 = '{0}'",this->tBoxStaffID->Text);
				 this->MyDataBase->SQLOperate(tempSQL);

				 tempSQL = String::Format(S"Delete from 职员奖励表 where 职员编号 = '{0}'",this->tBoxStaffID->Text);
				 this->MyDataBase->SQLOperate(tempSQL);

				 tempSQL = String::Format(S"Delete from 职员基本信息表 where 姓名 = '{0}' AND 职员编号 = '{1}'",this->tBoxStaffName->Text,this->tBoxStaffID->Text);
				 this->MyDataBase->SQLOperate(tempSQL);
				 //修改数据集
				 this->cmAmend->RemoveAt(this->cmAmend->Position);
			 }
			 else if(String::Compare(e->Button->ToolTipText->Trim(),S"保存修改") == 0)
			 {
				 //检查新记录
				 if(this->tBoxStaffID->Text->Trim() == S"")
				 {
					 MessageBox::Show(S"职员编号不能为空",S"提示");
					 return;
				 }
				 if(this->tBoxStaffName->Text->Trim() == S"")
				 {
					 MessageBox::Show(S"职员姓名不能为空",S"提示");
					 return;
				 }
				 //提交修改
				 this->cmAmend->EndCurrentEdit();
				 //更新数据库
				 this->MyDataBase->UpdateDataBase(this->ds,S"职员基本信息表");
			 }
			 else if(String::Compare(e->Button->ToolTipText->Trim(),S"取消修改") == 0)
			 {
				 this->cmAmend->CancelCurrentEdit();
			 }
			 else if(String::Compare(e->Button->ToolTipText->Trim(),S"退出") == 0)
			 {
				 this->Close();
			 }
		 }

};
}

⌨️ 快捷键说明

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