예제 #1
0
        /// <summary>
        /// 执法证统计
        /// </summary>
        /// <returns></returns>
        public PageJqDatagrid <DataTable> GetCertificateReport(string CardType, string Deptid, string LYTimeStart, string LYTimeEnd, string NJTimeStart, string NJTimeEnd, string HZTimeStart, string HZTimeEnd, int pageSize = 35, int pageIndex = 1)
        {
            int totalRecords = 1;
            var totalPage    = (totalRecords + pageSize - 1) / pageSize;
            var data         = new BaseCertificateDal().GetCertificateData(CardType, Deptid, LYTimeStart, LYTimeEnd, NJTimeStart, NJTimeEnd, HZTimeStart, HZTimeEnd, pageIndex, pageSize, out totalRecords);

            totalRecords = 35;
            var finalData = data.Clone();   //克隆一个数据表结构
            int sumJD = 0, sumZF = 0, sumZJ = 0;

            for (var i = 0; i < data.Rows.Count; i++)
            {
                var row       = data.Rows[i];
                var Companyid = row["Companyid"].ToString();      //部门Id
                var jd        = int.Parse(row["JDCounts"].ToString());
                var zf        = int.Parse(row["ZFCounts"].ToString());
                var zj        = int.Parse(row["counts"].ToString());

                finalData.Rows.Add(row.ItemArray);

                if (i < data.Rows.Count - 1)
                {
                    var nextCompanyid = data.Rows[i + 1]["Companyid"].ToString();    //下一条数据的部门编号
                    if (Companyid.Equals(nextCompanyid))
                    {
                        sumJD += jd;
                        sumZF += zf;
                        sumZJ += zj;
                    }
                    else
                    {
                        sumJD += jd;
                        sumZF += zf;
                        sumZJ += zj;

                        #region 计算合计

                        var          CompanyName = row["CompanyName"].ToString();
                        const string deptName    = "合计";

                        var nRow = finalData.NewRow();
                        nRow["CompanyName"]    = CompanyName;
                        nRow["DepartmentName"] = deptName;
                        nRow["Companyid"]      = Companyid;
                        nRow["JDCounts"]       = sumJD;
                        nRow["ZFCounts"]       = sumZF;
                        nRow["counts"]         = sumZJ;

                        sumJD = 0;
                        sumZF = 0;
                        sumZJ = 0;
                        finalData.Rows.Add(nRow);     //添加合计数据至表
                        #endregion
                    }
                }
                else
                {
                    sumJD += jd;
                    sumZF += zf;
                    sumZJ += zj;

                    #region 计算合计
                    var          CompanyName = row["CompanyName"].ToString();
                    const string deptName    = "合计";

                    var nRow = finalData.NewRow();
                    nRow["CompanyName"]    = CompanyName;
                    nRow["DepartmentName"] = deptName;
                    nRow["Companyid"]      = Companyid;
                    nRow["JDCounts"]       = sumJD;
                    nRow["ZFCounts"]       = sumZF;
                    nRow["counts"]         = sumZJ;

                    sumJD = 0;
                    sumZF = 0;
                    sumZJ = 0;
                    finalData.Rows.Add(nRow);     //添加合计数据至表

                    #endregion
                }
            }
            return(new PageJqDatagrid <DataTable>
            {
                page = pageIndex,
                rows = finalData,
                total = totalPage,
                records = totalRecords,
            });
        }
예제 #2
0
 public BaseCertificateBll()
 {
     BaseDal = new BaseCertificateDal();
 }