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

📄 employeedlg.cpp

📁 在VC6.0下开发的员工管理系统源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		AfxMessageBox("开始工作时间最小不小于2个字符!");
		return;
	}
	memcpy(employee.stime,s,s.GetLength());
	// 从文本框中提取数据
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_WORK);
	pEdit->GetWindowText(s);
	// 对职务的长度进行判断
	if(s.GetLength()>sizeof(employee.work))
	{
		AfxMessageBox("职务最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("职务最小不小于2个字符!");
		return;
	}
	memcpy(employee.work,s,s.GetLength());
	// 从文本框中提取数据
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_AGE);
	pEdit->GetWindowText(s);
	// 对年龄的长度进行判断
	if(s.GetLength()>sizeof(employee.age))
	{
		AfxMessageBox("年龄最多不超过12个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("年龄最小不小于2个字符!");
		return;
	}
	memcpy(employee.age,s,s.GetLength());
	// 从文本框中提取数据
	pEdit=(CEdit*)GetDlgItem(IDC_COMBO4);
	pEdit->GetWindowText(s);
	// 对性别的长度进行判断
	if(s.GetLength()>sizeof(employee.sex))
	{
		AfxMessageBox("性别最多不超过4个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("性别最小不小于2个字符!");
		return;
	}
	memcpy(employee.sex,s,s.GetLength());
	// 从文本框中提取数据
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_BIRTH);
	pEdit->GetWindowText(s);
	// 对生日的长度进行判断
	if(s.GetLength()>sizeof(employee.birth))
	{
		AfxMessageBox("生日最多不超过12个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("生日最小不小于2个字符!");
		return;
	}
	memcpy(employee.birth,s,s.GetLength());
	// 从文本框中提取数据
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_GRADUATE);
	pEdit->GetWindowText(s);
	// 对学历的长度进行判断
	if(s.GetLength()>sizeof(employee.graduate))
	{
		AfxMessageBox("学历最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("学历最小不小于2个字符!");
		return;
	}
	memcpy(employee.graduate,s,s.GetLength());
	// 从文本框中提取数据
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ADDR);
	pEdit->GetWindowText(s);
	// 对住址的长度进行判断
	if(s.GetLength()>sizeof(employee.addr))
	{
		AfxMessageBox("住址最多不超过50个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("住址最小不小于2个字符!");
		return;
	}
	memcpy(employee.addr,s,s.GetLength());
	// 从文本框中提取数据
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_TEL);
	pEdit->GetWindowText(s);
	// 对电话的长度进行判断
	if(s.GetLength()>sizeof(employee.tel))
	{
		AfxMessageBox("电话最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("电话最小不小于2个字符!");
		return;
	}
	memcpy(employee.tel,s,s.GetLength());
	// 从文本框中提取数据
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_MONEY);
	pEdit->GetWindowText(s);
	// 对工资的长度进行判断
	if(s.GetLength()>sizeof(employee.money))
	{
		AfxMessageBox("工资最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("工资最小不小于2个字符!");
		return;
	}
	memcpy(employee.money,s,s.GetLength());

	// 如果没有打开文件则添加失败
	if(!m_manager.Add(&employee))
	{
		AfxMessageBox("添加失败!");
		return;
	}

	// 显示添加的数据
	ShowData();

	// 对文本框清空处理
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_NAME);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_DEP);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_STIME);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_WORK);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_AGE);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_COMBO4);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_BIRTH);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_GRADUATE);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ADDR);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_TEL);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_MONEY);
	pEdit->SetWindowText("");
}
void CEmployeeDlg::OnButtonChange() 
{
	if(m_list.GetSelectedCount()<1) 
		return;
	int n = m_list.GetSelectionMark();
	DWORD i=m_list.GetItemData(n);
	AEmployee employee;
	POSITION pos=m_manager.GetPositionWithIndex(i);
	CString s;
	CEdit* pEdit=(CEdit*)GetDlgItem(IDC_EDIT_NAME);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.name))
	{
		AfxMessageBox("姓名最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("姓名最小不小于2个字符!");
		return;
	}
	memcpy(employee.name,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_DEP);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.dep))
	{
		AfxMessageBox("部门最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("部门最小不小于2个字符!");
		return;
	}
	memcpy(employee.dep,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_STIME);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.stime))
	{
		AfxMessageBox("开始工作时间最多不超过12个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("开始工作时间最小不小于2个字符!");
		return;
	}
	memcpy(employee.stime,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_WORK);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.work))
	{
		AfxMessageBox("职务最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("职务最小不小于2个字符!");
		return;
	}
	memcpy(employee.work,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_AGE);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.age))
	{
		AfxMessageBox("年龄最多不超过12个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("年龄最小不小于2个字符!");
		return;
	}
	memcpy(employee.age,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_COMBO4);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.sex))
	{
		AfxMessageBox("性别最多不超过4个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("性别最小不小于2个字符!");
		return;
	}
	memcpy(employee.sex,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_BIRTH);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.birth))
	{
		AfxMessageBox("生日最多不超过12个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("生日最小不小于2个字符!");
		return;
	}
	memcpy(employee.birth,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_GRADUATE);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.graduate))
	{
		AfxMessageBox("学历最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("学历最小不小于2个字符!");
		return;
	}
	memcpy(employee.graduate,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ADDR);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.addr))
	{
		AfxMessageBox("住址最多不超过50个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("住址最小不小于2个字符!");
		return;
	}
	memcpy(employee.addr,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_TEL);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.tel))
	{
		AfxMessageBox("电话最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("电话最小不小于2个字符!");
		return;
	}
	memcpy(employee.tel,s,s.GetLength());
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_MONEY);
	pEdit->GetWindowText(s);
	if(s.GetLength()>sizeof(employee.money))
	{
		AfxMessageBox("工资最多不超过20个字符!");
		return;
	}
	if(s.GetLength()<2)
	{
		AfxMessageBox("工资最小不小于2个字符!");
		return;
	}
	memcpy(employee.money,s,s.GetLength());
	AEmployee *pemployee=(AEmployee*)m_manager.myList.GetAt(pos); 
	memcpy(pemployee,&employee,sizeof(AEmployee)); 
	ShowData();
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_NAME);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_DEP);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_STIME);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_WORK);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_AGE);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_COMBO4);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_BIRTH);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_GRADUATE);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ADDR);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_TEL);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_MONEY);
	pEdit->SetWindowText("");
}
void CEmployeeDlg::OnButtonDelete() 
{
	if(m_list.GetSelectedCount()<1) 
		return;
	int n=m_list.GetSelectionMark();
	DWORD i=m_list.GetItemData(n);
	m_manager.Delete(m_manager.GetPositionWithIndex(i));
	ShowData();	
}
void CEmployeeDlg::OnButtonClose()
{
	m_manager.CloseFile();
	ShowData();
	CEdit* pEdit=(CEdit*)GetDlgItem(IDC_EDIT_NAME);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_DEP);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_STIME);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_WORK);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_AGE);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_COMBO4);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_BIRTH);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_GRADUATE);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ADDR);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_TEL);
	pEdit->SetWindowText("");
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_MONEY);
	pEdit->SetWindowText("");
}
void CEmployeeDlg::OnClickListMain(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if(m_list.GetSelectedCount()<1) 
		return;
	int n=m_list.GetSelectionMark();
	DWORD i=m_list.GetItemData(n);
	POSITION pos=m_manager.myList.GetHeadPosition();
	for(DWORD j=0;j<i;j++)
		m_manager.myList.GetNext(pos);

	AEmployee *employee = (AEmployee *) m_manager.myList.GetAt(pos);
	CEdit* pEdit=(CEdit*)GetDlgItem(IDC_EDIT_NAME);
	pEdit->SetWindowText(employee->name);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_DEP);
	pEdit->SetWindowText(employee->dep);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_STIME);
	pEdit->SetWindowText(employee->stime);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_WORK);
	pEdit->SetWindowText(employee->work);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_AGE);
	pEdit->SetWindowText(employee->age);
	pEdit=(CEdit*)GetDlgItem(IDC_COMBO4);
	pEdit->SetWindowText(employee->sex);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_BIRTH);
	pEdit->SetWindowText(employee->birth);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_GRADUATE);
	pEdit->SetWindowText(employee->graduate);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_ADDR);
	pEdit->SetWindowText(employee->addr);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_TEL);
	pEdit->SetWindowText(employee->tel);
	pEdit=(CEdit*)GetDlgItem(IDC_EDIT_MONEY);
	pEdit->SetWindowText(employee->money);
	*pResult = 0;
}

⌨️ 快捷键说明

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