Exemple #1
0
        private void btnSum_Click(object sender, EventArgs e)
        {
            clsHISReportZy_Supported_Svc svc = (clsHISReportZy_Supported_Svc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsHISReportZy_Supported_Svc));

            DataTable dt01  = svc.GetRptCross("201701");
            DataTable dt02  = svc.GetRptCross("201702");
            DataTable dt03  = svc.GetRptCross("201703");
            DataTable dt04  = svc.GetRptCross("201704");
            DataTable dt05  = svc.GetRptCross("201705");
            DataTable dt06  = svc.GetRptCross("201706");
            DataTable dt07  = svc.GetRptCross("201707");
            DataTable dt08  = svc.GetRptCross("201708");
            DataTable dt09  = svc.GetRptCross("201709");
            DataTable dt10  = svc.GetRptCross("201710");
            DataTable dt11  = svc.GetRptCross("201711");
            DataTable dt12  = svc.GetRptCross("201712");
            DataTable dtSum = svc.GetRptCross("");

            string        deptCode    = string.Empty;
            List <string> lstDeptCode = new List <string>();
            decimal       totalsum    = 0;

            DataRow[]        drr      = null;
            DataRow[]        drrDept  = null;
            List <DataTable> lstTable = new List <DataTable>()
            {
                dt01, dt02, dt03, dt04, dt05, dt06, dt07, dt08, dt09, dt10, dt11, dt12
            };

            foreach (DataTable dt in lstTable)
            {
                if (dt.Rows.Count == 0)
                {
                    continue;
                }
                lstDeptCode.Clear();

                foreach (DataRow dr in dt.Rows)
                {
                    deptCode = dr["shortno_chr"].ToString();
                    if (lstDeptCode.IndexOf(deptCode) < 0)
                    {
                        lstDeptCode.Add(deptCode);
                    }
                }

                foreach (string _deptCode in lstDeptCode)
                {
                    drrDept  = dt.Select("shortno_chr = '" + _deptCode + "'");
                    totalsum = Convert.ToDecimal(drrDept[0]["totalsum"]);
                    drr      = dtSum.Select("shortno_chr = '" + _deptCode + "'");
                    if (drr != null && drr.Length > 0)
                    {
                        totalsum += Convert.ToDecimal(drr[0]["totalsum"]);
                        foreach (DataRow dr2 in drr)
                        {
                            dr2["totalsum"] = totalsum;
                        }
                        foreach (DataRow dr2 in drrDept)
                        {
                            DataRow[] drrCat = dtSum.Select("shortno_chr = '" + _deptCode + "' and groupid_chr = '" + dr2["groupid_chr"].ToString() + "'");
                            if (drrCat != null && drrCat.Length > 0)
                            {
                                drrCat[0]["catsum"] = Convert.ToDecimal(drrCat[0]["catsum"]) + Convert.ToDecimal(dr2["catsum"]);
                            }
                            else
                            {
                                dtSum.LoadDataRow(new object[6] {
                                    _deptCode, dr2["deptname_vchr"].ToString(), totalsum, dr2["groupid_chr"].ToString(), dr2["groupname_chr"].ToString(), Convert.ToDecimal(dr2["catsum"])
                                }, true);
                            }
                        }
                    }
                    else
                    {
                        foreach (DataRow dr2 in drrDept)
                        {
                            dtSum.LoadDataRow(new object[6] {
                                _deptCode, dr2["deptname_vchr"].ToString(), totalsum, dr2["groupid_chr"].ToString(), dr2["groupname_chr"].ToString(), Convert.ToDecimal(dr2["catsum"])
                            }, true);
                        }
                    }
                }
            }

            svc.SaveCrossSum(dtSum);
            string sql = @"select shortno_chr,
                                       deptname_vchr,
                                       totalsum,
                                       groupid_chr,
                                       groupname_chr,
                                       catsum
                                  from t_rpt_cross2017";

            dwRep.SetSqlSelect(sql);
            dwRep.Retrieve();
            dwRep.Modify("t_date.text = '统计时间: " + "2017-01-01 00:00:00 - 2017-12-31 23:59:59'");
        }