コード例 #1
0
        private void btn_hz_Click(object sender, EventArgs e)
        {
            if (txtDw.Text.Trim() == "")
            {
                MessageBox.Show("请选择体检单位!", "提示");
                txtDw.Tag = "";
                return;
            }

            #region 日志记录
            loginbiz.WriteLog(this.Name.Trim(), "【" + Program.username + "】" + "在电脑【" + ma.HostName() + "】上生成职业健康汇总报告!IP:" + Program.hostip, Program.username);
            #endregion

            DataTable dt1 = new DataTable(); //组合项目

            dt1 = xtbiz.GetTjZhXm(txtDw.Tag.ToString(), comn.DateTimeChange(dtpFrom.Value.AddDays(-1)) + " 23:59:59",
                comn.DateTimeChange(dtpTo.Value) + " 23:59:59");
            if (dt1.Rows.Count <= 0)
            {
                Clear();
                return;
            }
            StringBuilder zhxm = new StringBuilder("问诊");
            for (int i = 0; i < dt1.Rows.Count; i++)
            {
                zhxm.Append("、" + dt1.Rows[i][0].ToString().Trim());
            }
            txtTjxm.Text = zhxm.ToString();

            ////////////////////////////////////////////////
            DataTable dt2 = new DataTable(); //体检人数,人员类别

            dt2 = xtbiz.GetTjRsLb(txtDw.Tag.ToString(), comn.DateTimeChange(dtpFrom.Value.AddDays(-1)) + " 23:59:59",
                comn.DateTimeChange(dtpTo.Value) + " 23:59:59");
            if (dt2.Rows.Count <= 0)
            {
                Clear();
                return;
            }

            txtTjrs.Text = dt2.Rows[0]["tjrs"].ToString().Trim();
            cmbRylb.Text = dt2.Rows[0]["rylb"].ToString().Trim();

            ////////////////////////////////////////////////
            DataTable dt3 = new DataTable(); //健康异常汇总

            dt3 = xtbiz.GetTjJkYcHz(txtDw.Tag.ToString(), comn.DateTimeChange(dtpFrom.Value.AddDays(-1)) + " 23:59:59",
                comn.DateTimeChange(dtpTo.Value) + " 23:59:59");
            if (dt3.Rows.Count <= 0)
            {
                Clear();
                return;
            }
            StringBuilder tjjg = new StringBuilder();
            StringBuilder tjjl = new StringBuilder("本次在岗期间职业健康体检,");
            StringBuilder xm = new StringBuilder();
            string str_wjkyc="";
            string str_wzyjkyc="";
            DataRow row;
            for (int i = 0; i < dt3.Rows.Count; i++)
            {
                row = dtTjhz.NewRow();
                row["gz"] = dt3.Rows[i]["gz"].ToString().Trim();
                row["rs"] = dt3.Rows[i]["zrs"].ToString().Trim();
                row["ycrs"] = dt3.Rows[i]["jkycrs"].ToString().Trim();
                row["zyjkyc"] = dt3.Rows[i]["zyjkycrs"].ToString().Trim();
                row["whys"] = dt3.Rows[i]["whysmc"].ToString().Trim();
                dtTjhz.Rows.Add(row);

                int k = 0;
                k = i + 1;
                //体检结果处理
                if(row["ycrs"].ToString()=="0") 
                {
                    str_wjkyc="无健康异常";
                    tjjg.Append("    " + k.ToString() + "、" + row["gz"] + "共" + row["rs"] + "人," + str_wjkyc+",");

                   // tjjl.Append(dt3.Rows[i]["gz"].ToString().Trim() + "共" + dt3.Rows[i]["zrs"]
                   //+ "人,接触的主要职业病危害因素是" + dt3.Rows[i]["whysmc"].ToString().Trim() + ","+str_wjkyc+",");

                }
                else
                {
                    tjjg.Append("    "+k.ToString()+"、"+row["gz"]+"共"+row["rs"]+"人,健康异常"+row["ycrs"]+"人,");
                   // tjjl.Append(dt3.Rows[i]["gz"].ToString().Trim() + "共" + dt3.Rows[i]["zrs"]
                   //+ "人,接触的主要职业病危害因素是" + dt3.Rows[i]["whysmc"].ToString().Trim() + ",健康异常" + row["ycrs"].ToString()+"人,");
                }
                if(row["zyjkyc"].ToString()=="0") 
                {
                    str_wzyjkyc = "无职业健康异常。\n";
                    tjjg.Append(str_wzyjkyc);          //体检结果
                }
                else
                {
                    tjjg.Append("职业相关健康异常" + row["zyjkyc"] + "人。\n"); //体检结果

                    DataTable dtxm =xtbiz.GetJkycXm(row["gz"].ToString(), row["whys"].ToString(), txtDw.Tag.ToString(), comn.DateTimeChange(dtpFrom.Value.AddDays(-1)) + " 23:59:59",
                comn.DateTimeChange(dtpTo.Value) + " 23:59:59");
                    if (dtxm.Rows.Count < 1)
                    {
                        tjjl.Append(dt3.Rows[i]["gz"].ToString().Trim() + "共" + dt3.Rows[i]["zrs"]
                      + "人,接触的主要职业病危害因素是" + dt3.Rows[i]["whysmc"].ToString().Trim() + ",职业相关健康异常" + row["zyjkyc"] + "人");  //体检结论
                    }
                    if (dtxm.Rows.Count == 1)
                    {
                        tjjl.Append(dt3.Rows[i]["gz"].ToString().Trim() + "共" + dt3.Rows[i]["zrs"]
                      + "人,接触的主要职业病危害因素是" + dt3.Rows[i]["whysmc"].ToString().Trim() + ",职业相关健康异常" + row["zyjkyc"] + "人(" + dtxm.Rows[0]["xm"].ToString().Trim() + ");");   //体检结论
                    }
                    if (dtxm.Rows.Count > 1)
                    {
                        for (int j = 0; j < dtxm.Rows.Count; j++)
                        {
                            xm.Append(dtxm.Rows[j]["xm"].ToString().Trim() + "、");
                        }
                        tjjl.Append(dt3.Rows[i]["gz"].ToString().Trim() + "共" + dt3.Rows[i]["zrs"]
                      + "人,接触的主要职业病危害因素是" + dt3.Rows[i]["whysmc"].ToString().Trim() + ",职业相关健康异常" + row["zyjkyc"] + "人(" + xm.ToString().Substring(0,xm.ToString().Length-1) + ");");   //体检结论
                    }
                          
                }

                gzjwhys.Append(dt3.Rows[i]["gz"].ToString().Trim() + "共" + dt3.Rows[i]["zrs"]
                   + "人,接触的主要职业病危害因素是" + dt3.Rows[i]["whysmc"].ToString().Trim() + ";");

                dtTjhz.AcceptChanges();
            }

            dgvTjhz.DataSource = dtTjhz;
            ///////////////////////////////////////////////
            tjrq = DateTime.Now.ToString("yyyy年MM月dd日");
            DataTable dtTjrq = tzs.GetTjrq_new(txtDw.Tag.ToString(), dtpFrom.Value.AddDays(-1).ToString("yyyy-MM-dd") + " 23:59:59",
                dtpTo.Value.ToString("yyyy-MM-dd") + " 23:59:59");
            if (dtTjrq.Rows.Count > 0)
            {
                DateTime mindate = Convert.ToDateTime(dtTjrq.Rows[0]["mindate"].ToString().Trim());
                DateTime maxdate = Convert.ToDateTime(dtTjrq.Rows[0]["maxdate"].ToString().Trim());
                string date1 = mindate.ToString("yyyy年MM月dd日");
                string date2 = maxdate.ToString("yyyy年MM月dd日");
                if (date1 == date2)
                {
                    tjrq = date1;
                }
                else
                {
                    tjrq = date1 + "—" + date2;
                }
            }
            string str_sqlhead = "     "+txtDw.Text.Trim() + "职业健康体检报告\n"+txtDw.Text.Trim()+":\n";
            string str_sql = ","+Program.sys_reportname+"对贵单位接触有毒有害作业人员进行了" + cmbRylb.Text.Trim() + "职业健康体检,参加本次体检的共" + txtTjrs.Text.Trim() + "人," + gzjwhys.ToString();
            string str_sql2 = "    " + tjrq + str_sql+"\n";
            string str_sql3 = "    根据所接触的职业危害因素类别,本次职业健康体检项目包括:" + zhxm.ToString()+"\n";
            string str_sql4 = "    现将本次体检结果报告如下:\n" + 
                              "    一、体检结果:\n" + tjjg.ToString()+"    \n详细体检结果见《职业健康体检检查表》的个人体检结果报告。\n";
            string str_sql5 = "    二、体检结论:\n    1、" + tjjl.ToString() + "\n    2、临床健康异常依照《职业健康检查结果通知书》作相关处理。" + "\n    3、详细体检结果见《职业健康检查结果通知书》\n";
            string str_sql6 = "    三、建议:\n" + "    1、请按相关法律法规要求对接触有毒有害作业人员进行定期职业健康体检。\n" + "    2、对有毒有害的工作场所应定期监测,了解其是否符合国家有关职业卫生标准。\n" +
                "    3、请劳动者在职业场所加强个人劳动保护,请需要复查者及时复查,以减少或避免职业病的发生,保护自己的身体健康。\n"+// +"    4、接触噪声作业人员在工作中应加强个人听力防护,不用有损听力的耳机等。\n" +
                "    4、请贵单位必须把体检结果以书面形式告知本人。";
            string str_sql7 = "\n\n\n               "+Program.sys_reportname+"\n" + 
                "                      " + tzs.ChangeTime(xtbiz.GetDataNow());
            richTextBox1.Text = str_sqlhead + str_sql2 + str_sql3 + str_sql4 + str_sql5 + str_sql6 + str_sql7;


            
        }