adddialog.cpp

来自「这是一个简单的体检管理系统」· C++ 代码 · 共 911 行 · 第 1/2 页

CPP
911
字号
	m_cggysyj.AddString("正常");
	m_cggysyj.AddString("不正常");
	m_cggysyj.SetCurSel(0);

	//体检结论
	m_ctjjldm.AddString("正常");
	m_ctjjldm.AddString("不正常");
	m_ctjjldm.SetCurSel(0);

	CEdit* pEdit = (CEdit*)GetDlgItem(IDC_TJXH);
	pEdit->SetWindowText(getTjxh());

	//GetDlgItem(IDC_LYSLZ)->SetWindowText("0");
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAddDialog::OnImport() 
{
	// TODO: Add your control notification handler code here
	CString m_strSQL;
	CStuInfoSet m_recordset;
	CTiJSet m_tjSet;
	CString m_strBirth;
	CString str;
	UpdateData(TRUE);
	if(m_ksh.IsEmpty())
	{
		AfxMessageBox("请输入考生号!");
		m_cksh.SetFocus();
		return;
	}
    if(m_ksh.GetLength()!=3)
	{
		AfxMessageBox("对不起,考生号格式不对,请重新输入3位数考生号!");
		return;
	}
	m_strSQL.Format("select * from bjk where ksh='%s'",m_ksh);
	if(!m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,m_strSQL))
	{
		MessageBox("连接数据库失败!","数据库错误",MB_OK);
		return;
	}
	if(m_recordset.GetRecordCount()==0)
	{
		m_recordset.Close();
		MessageBox("该学生号不存在,请重新输入!");
		m_ksh="";
		m_cksh.SetFocus();
		UpdateData(FALSE);
	}
	else 
	{
		m_strSQL.Format("select * from tjk where ksh='%s'",m_ksh);
		if(!m_tjSet.Open(AFX_DB_USE_DEFAULT_TYPE,m_strSQL))
		{
            MessageBox("连接数据库失败!","数据库错误",MB_OK);
		    return;
		}
		else if(m_tjSet.GetRecordCount()!=0)
		{
			
			MessageBox("该学生已经参加过体检,你可以现在对该学生的体检信息进行修改和删除操作!","警告",MB_OK);
			return;
		}
		else
		{
		   m_xm=m_recordset.m_xm;
		   m_xb=m_recordset.m_xbdm;
		   m_mz=m_recordset.m_mzdm;
		   m_strBirth.Format("%d-%d-%d",m_recordset.m_csrq.GetYear(),m_recordset.m_csrq.GetMonth(),m_recordset.m_csrq.GetDay());
		   m_csrq=m_strBirth;
		   m_byxx=m_recordset.m_byxxmc;
           m_sfzh=m_recordset.m_sfzh;
		   UpdateData(FALSE);
		   m_recordset.Close();
		}
	}
}

void CAddDialog::OnAddinfo() 
{
	// TODO: Add your control notification handler code here
	CString m_strSQL;
	CTiJSet m_recordset;
	UpdateData(TRUE);
	if(m_ksh.IsEmpty())
	{
        AfxMessageBox("考生号不能为空!");
        m_cksh.SetFocus();
		return;    
	}
	m_strSQL.Format("select * from tjk where ksh='%s'",m_ksh);
    if(!m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,m_strSQL))
	{
        MessageBox("连接数据库失败!","数据库错误",MB_OK);
		return;
	}
    if(m_recordset.GetRecordCount()!=0)
	{
			
	    MessageBox("该学生已经参加过体检,你可以现在对该学生的体检信息进行修改和删除操作!","警告",MB_OK);
		return;
	}
	if(m_jwbs=="有"&&m_jwbsT.IsEmpty())
	{
		AfxMessageBox("由于你选择了该学生有既往病史,所以请填写其既往病史!");
        m_cjwbsT.SetFocus();
		return;
	}
	if(m_lyslz=="0")
	{
		AfxMessageBox("请输入该学生的左眼的裸眼视力!");
	    m_clyslz.SetFocus();
		return;
	}
	if(m_lysly=="0")
	{
		AfxMessageBox("请输入该学生的右眼的裸眼视力!");
		m_clysly.SetFocus();
		return;
	}
    if(m_jzslz=="0")
	{
		AfxMessageBox("请输入该学生的左眼的矫正视力!");
		m_cjzslz.SetFocus();
		return;
	}
	if(m_jzsly=="0")
	{
		AfxMessageBox("请输入该学生的右眼的矫正视力!");
		m_cjzsly.SetFocus();
		return;
	}
	if(m_jzdsz=="0")
	{
		AfxMessageBox("请输入该学生的左眼的矫正度数!");
		m_cjzdsz.SetFocus();
		return;
	}
	if(m_jzdsy=="0")
	{
		AfxMessageBox("请输入该学生的右眼的矫正度数!");
		m_cjzdsy.SetFocus();
		return;
	}
	if(m_ykysyj=="不正常"&&m_yb.IsEmpty())
	{
		AfxMessageBox("由于您选择该学生的眼睛不正常,请填写其眼睛的详细病症!");
		m_cyb.SetFocus();
		return;
	}
    if(m_nzssy=="0")
	{
		AfxMessageBox("请输入该学生的内脏收缩压!");
		m_cnzssy.SetFocus();
		return;
	}
	if(m_gan=="0")
	{
		AfxMessageBox("请输入该学生的肝长度!");
		m_cgan.SetFocus();
		return;
	}
	if(m_pi=="0")
	{
		AfxMessageBox("请输入该学生的脾长度!");
		m_cpi.SetFocus();
		return;
	}
	if(m_nzszy=="0")
	{
		AfxMessageBox("请输入该学生的内脏舒张压!");
		m_cnzszy.SetFocus();
		return;
	}
    if(m_nkysyj=="不正常"&&m_nk.IsEmpty())
	{
		AfxMessageBox("由于您选择该学生的内科不正常,请填写其内科的详细病症!");
		m_cnk.SetFocus();
		return;
	}
	if(m_sg=="0")
	{
		AfxMessageBox("请输入该学生的身高!");
		m_csg.SetFocus();
		return;
	}
	if(m_tz=="0")
	{
		AfxMessageBox("请输入该学生的体重!");
		m_ctz.SetFocus();
		return;
	}
	if(m_wkysyj=="不正常"&&m_yk.IsEmpty())
	{
		AfxMessageBox("由于您选择该学生的外科不正常,请填写其外科的详细病症!");
		m_cyk.SetFocus();
		return;
	}
	if(m_ztl=="0")
	{
		AfxMessageBox("请输入该学生左耳的听力范围!");
		m_cztl.SetFocus();
		return;
	}
	if(m_ytl=="0")
	{
		AfxMessageBox("请输入该学生右耳的听力范围!");
		m_cytl.SetFocus();
		return;
	}
	if(m_ebysyj=="不正常"&&m_eb.IsEmpty())
	{
		AfxMessageBox("由于您选择该学生的耳鼻喉不正常,请填写其耳鼻喉的详细病症!");
		m_ceb.SetFocus();
		return;
	}
	if(m_kqysyj=="不正常"&&m_kq.IsEmpty())
	{
		AfxMessageBox("由于您选择该学生的口腔不正常,请填写其口腔的详细病症!");
		m_ckq.SetFocus();
		return;
	}
	if(m_xtysyj=="不正常"&&m_xt.IsEmpty())
	{
		AfxMessageBox("由于您选择该学生的胸透不正常,请填写其胸透的详细病症!");
		m_cxtT.SetFocus();
		return;
	}
    if(m_ggysyj=="不正常"&&m_gg.IsEmpty())
	{
		AfxMessageBox("由于您选择该学生的肝功不正常,请填写其肝功的详细病症!");
		m_cgg.SetFocus();
		return;
	}
    if(m_tjjldm=="不正常"&&m_tjjl.IsEmpty())
	{
		AfxMessageBox("由于您选择该学生的体检结论不正常,请填写其详细的体检结论!");
		m_ctjjl.SetFocus();
		return;
	}
	m_recordset.Close();
	if(!m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE))
	{
		MessageBox("打开数据库失败","连接失败",MB_OK);
		return;
	}
	m_recordset.AddNew();
	m_recordset.m_ksh=m_ksh;
	m_recordset.m_xm=m_xm;
	m_recordset.m_xb=m_xb;
	m_recordset.m_byxxmc=m_byxx;
	m_recordset.m_tjxh=m_tjxh;
	m_recordset.m_jwbs=m_jwbsT;
	m_recordset.m_jwbsbz=m_jwbs;
	m_recordset.m_yk_lysly=atof(m_lysly);
	m_recordset.m_yk_lyslz=atof(m_lyslz);
	m_recordset.m_yk_jzsly=atof(m_jzsly);
	m_recordset.m_yk_jzslz=atof(m_jzslz);
	m_recordset.m_yk_jzdsy=m_jzdsy;
	m_recordset.m_yk_jzdsz=m_jzdsz;
	m_recordset.m_yk_sjjc=m_sjjc;
	m_recordset.m_yk_sjjct=m_sjjct;
	m_recordset.m_yk_sjds1=m_red;
    m_recordset.m_yk_sjds2=m_green;
	m_recordset.m_yk_sjds3=m_pink;
	m_recordset.m_yk_sjds4=m_blue;
	m_recordset.m_yk_sjds5=m_yellow;
	m_recordset.m_yk_ysyj=m_ykysyj;
	m_recordset.m_yk_yb=m_yb;
	m_recordset.m_nk_xyssy=m_nzssy;
	m_recordset.m_nk_xyszy=m_nzszy;
	m_recordset.m_nk_fyqk=m_fyqk;
	m_recordset.m_nk_xzjxg=m_xzjxg;
	m_recordset.m_nk_hxxt=m_hxxt;
	m_recordset.m_nk_sjxt=m_sjxt;
	m_recordset.m_nk_g=m_gan;
	m_recordset.m_nk_gxz=m_gxz;
	m_recordset.m_nk_p=m_pi;
	m_recordset.m_nk_pxz=m_pxz;
	m_recordset.m_nk_ysyj=m_nkysyj;
	m_recordset.m_nk_qt=m_nk;
    m_recordset.m_wk_sg=atof(m_sg);
	m_recordset.m_wk_tz=atof(m_tz);
	m_recordset.m_wk_pf=m_pf;
	m_recordset.m_wk_mb=m_mb;
	m_recordset.m_wk_jb=m_jb;
	m_recordset.m_wk_jz=m_jz;
	m_recordset.m_wk_sz=m_sz;
    m_recordset.m_wk_gj=m_gj;
    m_recordset.m_wk_ysyj=m_wkysyj;
    m_recordset.m_wk_qt=m_yk;
	m_recordset.m_eb_zetl=atof(m_ztl);
	m_recordset.m_eb_yetl=atof(m_ytl);
	m_recordset.m_eb_xj=m_xj;
	m_recordset.m_eb_ysyj=m_ebysyj;
	m_recordset.m_eb_ebyh=m_ebyh;
	m_recordset.m_eb_ebyh_bz=m_eb;
    m_recordset.m_kq_ce=m_ce;
	m_recordset.m_kq_sfkc=m_sfkc;
	m_recordset.m_kq_yc=m_yc;
    m_recordset.m_kq_ysyj=m_kqysyj;
	m_recordset.m_kq_qt=m_kq;
	m_recordset.m_xt=m_xtT;
	m_recordset.m_xt_ysyj=m_xtT;
	m_recordset.m_xt_qt=m_xt;
	m_recordset.m_gg_zam=m_zam;
	m_recordset.m_gg_ygky=m_ygky;
	m_recordset.m_gg_ysyj=m_ggysyj;
	m_recordset.m_gg_qt=m_gg;
	m_recordset.m_zysxdm1=m_sxzy1;
    m_recordset.m_zysxdm2=m_sxzy2;
    m_recordset.m_zysxdm3=m_sxzy3;
	m_recordset.m_zysxdm4=m_sxzy4;
	m_recordset.m_zysxdm5=m_sxzy5;
	m_recordset.m_zysxdm6=m_sxzy6;
    m_recordset.m_tjjldm=m_tjjldm;
	m_recordset.m_bz=m_tjjl;
	m_recordset.Update();
	m_recordset.Close();
	AfxMessageBox("体检信息保存成功!");
	CDialog::OnOK();
}

void CAddDialog::OnDelete() 
{
	// TODO: Add your control notification handler code here
	CString m_strSQL;
	CTiJSet m_recordset;
	UpdateData(TRUE);
	if(m_ksh.IsEmpty())
	{
		AfxMessageBox("请输入要删除的考生的考号!");
		return;
	}
	m_strSQL.Format("select * from tjk where ksh='%s'",m_ksh);
	if(!m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,m_strSQL))
	{
		MessageBox("打开数据库失败","连接失败",MB_OK);
		return;
	}
	if(m_recordset.GetRecordCount()==0)
	{
		AfxMessageBox("该学生还没有体检信息!");
		return;
	}
	else
	{
		if (MessageBox("是否删除该记录?","请确认", MB_YESNO) == IDYES)
		{
			m_recordset.Close();
            m_strSQL.Format("select * from tjk where ksh='%s'",m_ksh);
		    if(!m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,m_strSQL))
			{
		        MessageBox("打开数据库失败","连接失败",MB_OK);
		        return;
			}
		    m_recordset.Delete();
		    m_recordset.Close();
		    AfxMessageBox("成功删除该学生的体检信息!");
			CDialog::OnOK();
		}
	}
}

void CAddDialog::OnSearchall() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnOK();
	CSearchDlg dlg;
	dlg.DoModal();
}

void CAddDialog::OnModify() 
{
	// TODO: Add your control notification handler code here
	CString m_strSQL;
	CString m_strBirth;
	CTiJSet m_recordset;
	CStuInfoSet m_stuSet;
	UpdateData(TRUE);
	if(m_ksh.IsEmpty())
	{
		AfxMessageBox("请输入要修改的考生的考号!");
		m_cksh.SetFocus();
		return;
	}
	m_strSQL.Format("select * from tjk where ksh='%s'",m_ksh);
	if(!m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,m_strSQL))
	{
		MessageBox("打开数据库失败","连接失败",MB_OK);
		return;
	}
	if(m_recordset.GetRecordCount()==0)
	{
		AfxMessageBox("该学生还没有体检信息,请重新输入!");
		return;
	}
	else
	{
		CHealManageApp*  ptheApp = (CHealManageApp *) AfxGetApp();
	    ptheApp->m_ksId=m_ksh;
		CDialog::OnOK();
        m_strSQL.Format("select * from bjk where ksh='%s'",m_ksh);
		if(!m_stuSet.Open(AFX_DB_USE_DEFAULT_TYPE,m_strSQL))
		{
		   MessageBox("打开数据库失败","连接失败",MB_OK);
		   return;
		}
		CModDlg dlg=new CModDlg();
		dlg.m_tjxh=m_recordset.m_tjxh;
		dlg.m_ksh=m_stuSet.m_ksh;
        dlg.m_xm=m_stuSet.m_xm;
		dlg.m_xb=m_stuSet.m_xbdm;
		m_strBirth.Format("%d-%d-%d",m_stuSet.m_csrq.GetYear(),m_stuSet.m_csrq.GetMonth(),m_stuSet.m_csrq.GetDay());
		dlg.m_cerq=m_strBirth;
		dlg.m_mz=m_stuSet.m_mzdm;
		dlg.m_sfzh=m_stuSet.m_sfzh;
		dlg.m_byxx=m_stuSet.m_byxxdm;
		dlg.m_jwbsT=m_recordset.m_jwbs;
		dlg.m_lyslz.Format("%.1f",m_recordset.m_yk_lyslz);
		dlg.m_lysly.Format("%.1f",m_recordset.m_yk_lysly);
		dlg.m_jzslz.Format("%.1f",m_recordset.m_yk_jzslz);
		dlg.m_jzsly.Format("%.1f",m_recordset.m_yk_jzsly);
		dlg.m_jzdsz=m_recordset.m_yk_jzdsz;
		dlg.m_jzdsy=m_recordset.m_yk_jzdsy;
		dlg.m_yb=m_recordset.m_yk_yb;
		dlg.m_sg.Format("%.1f",m_recordset.m_wk_sg);
		dlg.m_tz.Format("%.1f",m_recordset.m_wk_tz);
		dlg.m_nzssy=m_recordset.m_nk_xyssy;
		dlg.m_nzszy=m_recordset.m_nk_xyszy;
		dlg.m_gan=m_recordset.m_nk_g;
		dlg.m_pi=m_recordset.m_nk_p;
		dlg.m_nk=m_recordset.m_nk_qt;
		dlg.m_wk=m_recordset.m_wk_qt;
		dlg.m_ztl.Format("%.1f",m_recordset.m_eb_zetl);
		dlg.m_ytl.Format("%.1f",m_recordset.m_eb_yetl);
		dlg.m_eb=m_recordset.m_eb_ebyh_bz;
		dlg.m_kq=m_recordset.m_kq_qt;
		dlg.m_xt=m_recordset.m_xt_qt;
		dlg.m_gg=m_recordset.m_gg_qt;
        dlg.m_sxzy1=m_recordset.m_zysxdm1;
		dlg.m_sxzy2=m_recordset.m_zysxdm2;
		dlg.m_sxzy3=m_recordset.m_zysxdm3;
		dlg.m_sxzy4=m_recordset.m_zysxdm4;
		dlg.m_sxzy5=m_recordset.m_zysxdm5;
		dlg.m_sxzy6=m_recordset.m_zysxdm6;
		dlg.m_tjjl=m_recordset.m_bz;
		dlg.DoModal();
        m_stuSet.Close();
		m_recordset.Close();
	}
}

⌨️ 快捷键说明

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