Beispiel #1
0
        public static DataRow DataTableSum(DataTable dt, EnumerableRowCollection <DataRow> dtAs, List <string> listNot)
        {
            DataRow dr = dt.NewRow();

            if (dt.Columns[0].DataType.Name == "String")
            {
                dr[0] = "合计";
            }
            foreach (DataColumn dc in dt.Columns)
            {
                if (listNot != null && listNot.Contains(dc.ColumnName))
                {
                    continue;
                }
                switch (dc.DataType.Name)
                {
                case "Int":
                    dr[dc.ColumnName] = dtAs.Sum(t => t[dc.ColumnName] == DBNull.Value ? 0 : Convert.ToInt32(t[dc.ColumnName]));
                    break;

                case "Int64":
                    dr[dc.ColumnName] = dtAs.Sum(t => t[dc.ColumnName] == DBNull.Value ? 0 : Convert.ToInt64(t[dc.ColumnName]));
                    break;

                case "Double":
                    dr[dc.ColumnName] = dtAs.Sum(t => t[dc.ColumnName] == DBNull.Value ? 0 : Convert.ToDouble(t[dc.ColumnName]));
                    break;

                case "Decimal":
                    dr[dc.ColumnName] = dtAs.Sum(t => t[dc.ColumnName] == DBNull.Value ? 0 : Convert.ToDecimal(t[dc.ColumnName]));
                    break;
                }
            }
            return(dr);
        }
        /// <summary>
        /// Takes a collection of values from a set of rows and aggregates them
        /// </summary>
        /// <param name="values">The collection of values</param>
        private double Aggregate(EnumerableRowCollection <double> values)
        {
            // If there are no values, default to 0
            if (values.Count() > 0)
            {
                switch (view.Expression.Text)
                {
                case "Sum":
                    return(values.Sum());

                case "Average":
                    return(values.Average());

                case "Max":
                    return(values.Max());

                case "Min":
                    return(values.Min());

                default:
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
Beispiel #3
0
        private void ToolStripMenuItemCopyCongViec_Click(object sender, EventArgs e)
        {
            if (congviec.Count() > 0 && _IdCongViecTienCong != 0)
            {
                //Copy công việc (chia tiền công cho các thợ làm cùng công việc)
                decimal tiencong = congviec.Sum(m => m.Field <decimal>("TienCong"));

                SqlCommand cmd = new SqlCommand();

                cmd.CommandText = @"UPDATE ThoDichVu_TienCongThoTam
                                    SET TienCong = @TienCong WHERE IdTienCong = @IdTienCong AND IdBaoDuong = @IdBaoDuong";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@TienCong", tiencong / (congviec.Count() + 1));
                cmd.Parameters.AddWithValue("@IdTienCong", congviec.FirstOrDefault().Field <int>("IdTienCong"));
                cmd.Parameters.AddWithValue("@IdBaoDuong", txtID3.Text);

                Class.datatabase.ExcuteNonQuery(cmd);

                cmd.CommandText = @"INSERT INTO ThoDichVu_TienCongThoTam
                                            (IdTienCong, NgaySuaChua, IdCongTy, IdBaoDuong, NoiDungBD, TienCong, TienKhachTra)
                                            VALUES (@IdTienCong,@NgaySuaChua,@IdCongTy,@IdBaoDuong,@NoiDungBD,@TienCong,@TienKhachTra)";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@IdTienCong", congviec.FirstOrDefault().Field <int>("IdTienCong"));
                cmd.Parameters.AddWithValue("@NgaySuaChua", congviec.FirstOrDefault().Field <DateTime>("NgaySuaChua"));
                cmd.Parameters.AddWithValue("@IdCongTy", congviec.FirstOrDefault().Field <int>("IdCongTy"));
                cmd.Parameters.AddWithValue("@IdBaoDuong", congviec.FirstOrDefault().Field <int>("IdBaoDuong"));
                cmd.Parameters.AddWithValue("@NoiDungBD", congviec.FirstOrDefault().Field <string>("NoiDungBD"));
                cmd.Parameters.AddWithValue("@TienCong", tiencong / (congviec.Count() + 1));
                cmd.Parameters.AddWithValue("@TienKhachTra", 0);

                Class.datatabase.ExcuteNonQuery(cmd);

                cmd.CommandText = "select * from ThoDichVu_TienCongThoTam where IdCongTy=@IdCongTy and IdBaoDuong=@IdBaoDuong";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@IdCongTy", Class.CompanyInfo.idcongty);
                cmd.Parameters.AddWithValue("@IdBaoDuong", txtID3.Text);

                DtgBaoDuongTheoTien.DataSource = Class.datatabase.getData(cmd);
            }
        }
        public DataRow GET_ROW(string yt, DataRow dr1, System.Data.DataTable dt,
                               DataRow temp_rgsj_bz,
                               DataRow temp_rgsj_sz,
                               DataRow temp_rgsj_ssz,
                               DataRow temp_rgsj_sssz,
                               EnumerableRowCollection <DataRow> temp_cjba_bz,
                               EnumerableRowCollection <DataRow> temp_cjba_sz,
                               EnumerableRowCollection <DataRow> temp_cjba_ssz,
                               EnumerableRowCollection <DataRow> temp_cjba_sssz,
                               JP_JPXM_INFO item)
        {
            for (int j = 0; j < dt.Columns.Count; j++)
            {
                try
                {
                    #region 认购


                    if (Base_Config_Rgsj._认购数据.Contains(dt.Columns[j].ColumnName))
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case Base_Config_Rgsj.周_新开套数:
                        case Base_Config_Rgsj.周_新开销售套数:
                        case Base_Config_Rgsj.周_新开建面均价:
                        case Base_Config_Rgsj.周_新开套内均价:
                        case Base_Config_Rgsj.周_认购套数:
                        case Base_Config_Rgsj.周_认购套内体量:
                        case Base_Config_Rgsj.周_认购套内均价:
                        case Base_Config_Rgsj.周_认购建面体量:
                        case Base_Config_Rgsj.周_认购建面均价:
                        case Base_Config_Rgsj.周_认购金额:
                        {
                            if (temp_rgsj_sz != null)
                            {
                                dr1[dt.Columns[j].ColumnName] = temp_rgsj_sz[dt.Columns[j].ColumnName._ConfigRgsjMc()];
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Rgsj.本周_新开套数:
                        case Base_Config_Rgsj.本周_新开销售套数:
                        case Base_Config_Rgsj.本周_新开建面均价:
                        case Base_Config_Rgsj.本周_新开套内均价:
                        case Base_Config_Rgsj.本周_认购套数:
                        case Base_Config_Rgsj.本周_认购套内体量:
                        case Base_Config_Rgsj.本周_认购套内均价:
                        case Base_Config_Rgsj.本周_认购建面体量:
                        case Base_Config_Rgsj.本周_认购建面均价:
                        case Base_Config_Rgsj.本周_认购金额:
                        {
                            if (temp_rgsj_bz != null)
                            {
                                dr1[dt.Columns[j].ColumnName] = temp_rgsj_bz[dt.Columns[j].ColumnName._ConfigRgsjMc()];
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Rgsj.周_新开套数:
                        case Base_Config_Rgsj.周_新开销售套数:
                        case Base_Config_Rgsj.周_新开建面均价:
                        case Base_Config_Rgsj.周_新开套内均价:
                        case Base_Config_Rgsj.周_认购套数:
                        case Base_Config_Rgsj.周_认购套内体量:
                        case Base_Config_Rgsj.周_认购套内均价:
                        case Base_Config_Rgsj.周_认购建面体量:
                        case Base_Config_Rgsj.周_认购建面均价:
                        case Base_Config_Rgsj.周_认购金额:
                        {
                            if (temp_rgsj_ssz != null)
                            {
                                dr1[dt.Columns[j].ColumnName] = temp_rgsj_ssz[dt.Columns[j].ColumnName._ConfigRgsjMc()];
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Rgsj.周_新开套数:
                        case Base_Config_Rgsj.周_新开销售套数:
                        case Base_Config_Rgsj.周_新开建面均价:
                        case Base_Config_Rgsj.周_新开套内均价:
                        case Base_Config_Rgsj.周_认购套数:
                        case Base_Config_Rgsj.周_认购套内体量:
                        case Base_Config_Rgsj.周_认购套内均价:
                        case Base_Config_Rgsj.周_认购建面体量:
                        case Base_Config_Rgsj.周_认购建面均价:
                        case Base_Config_Rgsj.周_认购金额:
                        {
                            if (temp_rgsj_sssz != null)
                            {
                                dr1[dt.Columns[j].ColumnName] = temp_rgsj_ssz[dt.Columns[j].ColumnName._ConfigRgsjMc()];
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Rgsj.本周_认购套数环比: { dr1[dt.Columns[j].ColumnName] = temp_rgsj_sz["rgts"] != null && temp_rgsj_sz["rgts"].ints() != 0 ? ((temp_rgsj_bz["rgts"].ints() - temp_rgsj_sz["rgts"].ints()) / temp_rgsj_sz["rgts"].ints()).doubls().ss_bfb() : "0%"; }; break;

                        case Base_Config_Rgsj.本周_认购金额环比: { dr1[dt.Columns[j].ColumnName] = temp_rgsj_sz["rgje"] != null && temp_rgsj_sz["rgje"].ints() != 0 ? ((temp_rgsj_bz["rgts"].ints() - temp_rgsj_sz["rgts"].ints()) / temp_rgsj_sz["rgts"].ints()).doubls().ss_bfb() : "0%"; }; break;

                        case Base_Config_Rgsj.本周_认购建筑面积环比: { dr1[dt.Columns[j].ColumnName] = temp_rgsj_sz["rgjmtl"] != null && temp_rgsj_sz["rgjmtl"].ints() != 0 ? ((temp_rgsj_bz["rgjmtl"].ints() - temp_rgsj_sz["rgjmtl"].ints()) / temp_rgsj_sz["rgjmtl"].ints()).doubls().ss_bfb() : "0%"; }; break;

                        case Base_Config_Rgsj.本周_认购套内面积环比: { }; break;

                        case Base_Config_Rgsj.本周_认购建面均价环比: { dr1[dt.Columns[j].ColumnName] = temp_rgsj_sz["rgjmjj"] != null && temp_rgsj_sz["rgjmjj"].ints() != 0 ? ((temp_rgsj_bz["rgjmjj"].ints() - temp_rgsj_sz["rgjmjj"].ints()) / temp_rgsj_sz["rgjmjj"].ints()).doubls().ss_bfb() : "0%"; }; break;

                        case Base_Config_Rgsj.本周_认购套内均价环比: { }; break;

                        case Base_Config_Rgsj.本周_认购套均总价环比: { }; break;

                        default:
                        {
                            try
                            {
                                if (temp_rgsj_bz != null)
                                {
                                    dr1[dt.Columns[j].ColumnName] = temp_rgsj_bz[dt.Columns[j].ColumnName];
                                }
                                else
                                {
                                    dr1[dt.Columns[j].ColumnName] = "0";
                                }
                            }
                            catch (Exception)
                            {
                                dr1[dt.Columns[j].ColumnName] = "-";
                            }
                        }; break;
                        }
                    }
                    #endregion
                    #region 备案


                    else if (Base_Config_Cjba._备案数据.Contains(dt.Columns[j].ColumnName))
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                            #region 本周


                        case Base_Config_Cjba.本周_备案套数: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz != null?temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_备案套数._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.本周_成交金额: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz != null?temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()) : 0; }; break;

                        case Base_Config_Cjba.本周_建筑面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz != null?temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls()) : 0; }; break;

                        case Base_Config_Cjba.本周_套内面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz != null?temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.本周_建面均价:
                        {
                            if ((temp_cjba_bz != null && temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()) / temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Cjba.本周_套内均价:
                        {
                            if ((temp_cjba_bz != null && temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()) / temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;
                            #endregion
                            #region  周

                        case Base_Config_Cjba.周_备案套数: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz != null?temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.周_成交金额: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz != null?temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()) : 0; }; break;

                        case Base_Config_Cjba.周_建筑面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz != null?temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls()) : 0; }; break;

                        case Base_Config_Cjba.周_套内面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz != null?temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.周_建面均价:
                        {
                            if ((temp_cjba_sz != null && temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()) / temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Cjba.周_套内均价:
                        {
                            if ((temp_cjba_sz != null && temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()) / temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;
                            #endregion
                            #region   周


                        case Base_Config_Cjba.周_备案套数: { dr1[dt.Columns[j].ColumnName] = temp_cjba_ssz != null?temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.周_成交金额: { dr1[dt.Columns[j].ColumnName] = temp_cjba_ssz != null?temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()) : 0; }; break;

                        case Base_Config_Cjba.周_建筑面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_ssz != null?temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls()) : 0; }; break;

                        case Base_Config_Cjba.周_套内面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_ssz != null?temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.周_建面均价:
                        {
                            if ((temp_cjba_ssz != null && temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].longs()) / temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Cjba.周_套内均价:
                        {
                            if ((temp_cjba_ssz != null && temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].longs()) / temp_cjba_ssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                            #endregion
                            #region    周
                        case Base_Config_Cjba.周_备案套数: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sssz != null?temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.周_成交金额: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sssz != null?temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()) : 0; }; break;

                        case Base_Config_Cjba.周_建筑面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sssz != null?temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls()) : 0; }; break;

                        case Base_Config_Cjba.周_套内面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sssz != null?temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.周_建面均价:
                        {
                            if ((temp_cjba_sssz != null && temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].longs()) / temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Cjba.周_套内均价:
                        {
                            if ((temp_cjba_sssz != null && temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].longs()) / temp_cjba_sssz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;
                            #endregion

                            #region 其他


                        case Base_Config_Cjba.本周_备案套数环比:
                        {
                            dr1[dt.Columns[j].ColumnName] = ((temp_cjba_bz.Sum(m => m["ts"].ints()) - temp_cjba_sz.Sum(m => m["ts"].ints())) / temp_cjba_sz.Sum(m => m["ts"].ints())).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_套内均价环比:
                        {
                            long bz_cjje = temp_cjba_bz.Sum(m => m["cjje"].ints());
                            long bz_tnmj = temp_cjba_bz.Sum(m => m["tnmj"].ints());
                            long sz_cjje = temp_cjba_sz.Sum(m => m["cjje"].ints());
                            long sz_tnmj = temp_cjba_sz.Sum(m => m["tnmj"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje / bz_tnmj - sz_cjje / sz_tnmj) / (sz_cjje / sz_tnmj)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_套内面积环比:
                        {
                            long bz_tnmj = temp_cjba_bz.Sum(m => m["tnmj"].ints());
                            long sz_tnmj = temp_cjba_sz.Sum(m => m["tnmj"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_tnmj - sz_tnmj) / (sz_tnmj)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_套均总价环比:
                        {
                            long bz_cjje = temp_cjba_bz.Sum(m => m["cjje"].ints());
                            long bz_ts   = temp_cjba_bz.Sum(m => m["ts"].ints());
                            long sz_cjje = temp_cjba_sz.Sum(m => m["cjje"].ints());
                            long sz_ts   = temp_cjba_sz.Sum(m => m["ts"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje / bz_ts - sz_cjje / sz_ts) / (sz_cjje / sz_ts)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_建筑面积环比:
                        {
                            long bz_cjje = temp_cjba_bz.Sum(m => m["cjje"].ints());
                            long bz_jzmj = temp_cjba_bz.Sum(m => m["jzmj"].ints());
                            long sz_cjje = temp_cjba_sz.Sum(m => m["cjje"].ints());
                            long sz_jzmj = temp_cjba_sz.Sum(m => m["jzmj"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje / bz_jzmj - sz_cjje / sz_jzmj) / (sz_cjje / sz_jzmj)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_建面均价环比:
                        {
                            long bz_cjje = temp_cjba_bz.Sum(m => m["cjje"].ints());
                            long bz_jzmj = temp_cjba_bz.Sum(m => m["jzmj"].ints());
                            long sz_cjje = temp_cjba_sz.Sum(m => m["cjje"].ints());
                            long sz_jzmj = temp_cjba_sz.Sum(m => m["jzmj"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje / bz_jzmj - sz_cjje / sz_jzmj) / (sz_cjje / sz_jzmj)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_成交金额环比:
                        {
                            long bz_cjje = temp_cjba_bz.Sum(m => m["cjje"].ints());
                            long sz_cjje = temp_cjba_sz.Sum(m => m["cjje"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje - sz_cjje) / sz_cjje).doubls().ss_bfb();
                        }; break;
                            #endregion


                        default: { dr1[dt.Columns[j].ColumnName] = ""; }; break;
                        }
                    }
                    #endregion
                    #region 竞争格局

                    else if (Base_Config_Jzgj._竞争格局参数名称.Contains(dt.Columns[j].ColumnName))
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case Base_Config_Jzgj.项目名称:
                        {
                            dr1[dt.Columns[j].ColumnName] = item.lpcs[0];
                        }; break;

                        case Base_Config_Jzgj.业态:
                        {
                            dr1[dt.Columns[j].ColumnName] = yt;
                        }; break;

                        case Base_Config_Jzgj.组团:
                        {
                            dr1[dt.Columns[j].ColumnName] = item != null && item.ztcs != null?string.Join(",", item.ztcs) : "";
                        }; break;

                        case Base_Config_Jzgj.竞争格局_主力面积区间:
                        {
                            dr1[dt.Columns[j].ColumnName] = item.zlmjqj;
                        }; break;

                        case Base_Config_Jzgj.竞争格局名称:
                        {
                            dr1[dt.Columns[j].ColumnName] = item.jzgjmc;
                        }; break;
                        }
                    }

                    #endregion
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            return(dr1);
        }
        public DataRow GET_ROW_BA(string yt, DataRow dr1, System.Data.DataTable dt,
                                  DataRow temp_ba_bz,
                                  EnumerableRowCollection <DataRow> temp_cjba_bz,
                                  EnumerableRowCollection <DataRow> temp_cjba_sz,
                                  EnumerableRowCollection <DataRow> temp_cjba_ssz,
                                  EnumerableRowCollection <DataRow> temp_cjba_sssz,
                                  JP_JPXM_INFO item)
        {
            for (int j = 0; j < dt.Columns.Count; j++)
            {
                if (Base_Config_Rgsj._认购数据.Contains(dt.Columns[j].ColumnName))
                {
                    switch (dt.Columns[j].ColumnName)
                    {
                    case Base_Config_Rgsj.本周_新开销售套数:
                    case Base_Config_Rgsj.本周_新开套数:
                    case Base_Config_Rgsj.本周_认购套数:
                    case Base_Config_Rgsj.本周_认购套内均价:
                    case Base_Config_Rgsj.本周_认购建面均价:
                    case Base_Config_Rgsj.本周_认购套内体量:
                    case Base_Config_Rgsj.本周_认购建面体量:
                    case Base_Config_Rgsj.本周_认购金额:
                    {
                        if (temp_ba_bz != null)
                        {
                            dr1[dt.Columns[j].ColumnName] = temp_ba_bz[dt.Columns[j].ColumnName._ConfigRgsjMc()];
                        }
                        else
                        {
                            dr1[dt.Columns[j].ColumnName] = "";
                        }
                    }; break;

                    default:
                    {
                        if (temp_ba_bz != null)
                        {
                            dr1[dt.Columns[j].ColumnName] = temp_ba_bz[dt.Columns[j].ColumnName];
                        }
                        else
                        {
                            dr1[dt.Columns[j].ColumnName] = "";
                        }
                    }; break;
                    }
                }
                else if (Base_Config_Cjba._备案数据.Contains(dt.Columns[j].ColumnName))
                {
                    if (temp_cjba_bz != null)
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case Base_Config_Cjba.本周_备案套数: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_备案套数._ConfigCjbaMc()].ints()); }; break;

                        case Base_Config_Cjba.本周_成交金额: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()); }; break;

                        case Base_Config_Cjba.本周_建筑面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls()); }; break;

                        case Base_Config_Cjba.本周_套内面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].ints()); }; break;

                        case Base_Config_Cjba.本周_建面均价: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls()) != 0 ? (temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()) / temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls())).je_y() : 0; }; break;

                        case Base_Config_Cjba.本周_套内均价: { dr1[dt.Columns[j].ColumnName] = temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].doubls()) != 0 ? (temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()) / temp_cjba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].doubls())).je_y() : 0; }; break;
                        }
                    }

                    if (temp_cjba_sz != null)
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case Base_Config_Cjba.周_备案套数: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].ints()); }; break;

                        case Base_Config_Cjba.周_成交金额: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()); }; break;

                        case Base_Config_Cjba.周_建筑面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls()); }; break;

                        case Base_Config_Cjba.周_套内面积: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].ints()); }; break;

                        case Base_Config_Cjba.周_建面均价:
                        {
                            var cjje = temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs());
                            var jzmj = temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls());
                            //var jmjj = temp_cjba_sz.Sum(m => m[Base_Config_Cjba.上周_建筑面积._ConfigCjbaMc()].doubls()) != 0 ? (temp_cjba_bz.Sum(m => m[Base_Config_Cjba.上周_成交金额._ConfigCjbaMc()].longs()) / temp_cjba_bz.Sum(m => m[Base_Config_Cjba.上周_建筑面积._ConfigCjbaMc()].doubls())).je_y() : 0;
                            dr1[dt.Columns[j].ColumnName] = jzmj != 0 ? (cjje / jzmj).je_y() : 0;
                        }; break;

                        case Base_Config_Cjba.周_套内均价: { dr1[dt.Columns[j].ColumnName] = temp_cjba_sz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].doubls()) != 0 ? (temp_cjba_bz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()) / temp_cjba_bz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].doubls())).je_y() : 0; }; break;
                        }
                    }
                }
                else if (Base_Config_Jzgj._竞争格局参数名称.Contains(dt.Columns[j].ColumnName))
                {
                    switch (dt.Columns[j].ColumnName)
                    {
                    case Base_Config_Jzgj.项目名称: { dr1[dt.Columns[j].ColumnName] = item.lpcs[0]; }; break;

                    case Base_Config_Jzgj.业态: { dr1[dt.Columns[j].ColumnName] = yt; }; break;

                    case Base_Config_Jzgj.竞争格局名称: { dr1[dt.Columns[j].ColumnName] = item.jzgjmc; }; break;

                    case Base_Config_Jzgj.竞争格局_主力面积区间: { dr1[dt.Columns[j].ColumnName] = item.zlmjqj; }; break;

                    default: { dr1[dt.Columns[j].ColumnName] = ""; }; break;
                    }
                }
                else
                {
                    switch (dt.Columns[j].ColumnName)
                    {
                    case "sssz_ts": { dr1[dt.Columns[j].ColumnName] = temp_cjba_sssz.Sum(m => m["ts"].ints()); }; break;

                    case "sssz_jmjj": { dr1[dt.Columns[j].ColumnName] = temp_cjba_sssz.Sum(m => m["jzmj"].doubls()) != 0 ? (temp_cjba_sssz.Sum(m => m["cjje"].longs()) / temp_cjba_sssz.Sum(m => m["jzmj"].doubls())).je_y() : 0; }; break;

                    case "ssz_ts": { dr1[dt.Columns[j].ColumnName] = temp_cjba_ssz.Sum(m => m["ts"].doubls()); }; break;

                    case "ssz_jmjj": { dr1[dt.Columns[j].ColumnName] = temp_cjba_ssz.Sum(m => m["jzmj"].doubls()) != 0 ? (temp_cjba_ssz.Sum(m => m["cjje"].longs()) / temp_cjba_ssz.Sum(m => m["jzmj"].doubls())).je_y() : 0; }; break;
                    }
                }
            }

            return(dr1);
        }
Beispiel #6
0
        private string GetBill()
        {
            string _result = string.Empty;

            DateTime _now = DateTime.Now;

            //当前用户所有费用明细
            DataTable _idt = DataAgent.InBill.LoadInBill(_openid);
            DataTable _odt = DataAgent.OutBill.LoadOutBill(_openid);

            //总集合
            EnumerableRowCollection <DataRow> _irs = _idt.AsEnumerable();
            EnumerableRowCollection <DataRow> _ors = _odt.AsEnumerable();

            //总金额
            decimal _isum = _irs.Sum(r => r.ToDecimal("ItemMoney"));   //总收入
            decimal _osum = _ors.Sum(r => r.ToDecimal("ItemMoney"));   //总支出
            decimal _ssum = _isum - _osum;                             //总结余

            _result += "总收入=" + _isum.ToString("0.00");
            _result += ";总支出=" + _osum.ToString("0.00");
            _result += ";总结余=" + _ssum.ToString("0.00");

            //年处理
            DateTime       _sydate = Convert.ToDateTime(_now.ToString("yyyy") + "-01-01 00:00:00");
            DateTime       _eydate = Convert.ToDateTime(_now.ToString("yyyy") + "-12-31 23:59:59");
            List <DataRow> _iyrs   = _irs.Where(r => r.ToDateTime("ItemDate") >= _sydate && r.ToDateTime("ItemDate") <= _eydate).ToList();
            List <DataRow> _oyrs   = _ors.Where(r => r.ToDateTime("ItemDate") >= _sydate && r.ToDateTime("ItemDate") <= _eydate).ToList();
            decimal        _iysum  = _iyrs.Sum(r => r.ToDecimal("ItemMoney")); //年总收入
            decimal        _oysum  = _oyrs.Sum(r => r.ToDecimal("ItemMoney")); //年总支出

            _result += "|" + _sydate.ToString("MM月dd日") + "-" + _eydate.ToString("MM月dd日");
            _result += ";年总收入=" + _iysum.ToString("0.00");
            _result += ";年总支出=" + _oysum.ToString("0.00");

            //月处理
            DateTime       _smdate = Tools.FirstDayOfMonth(_now);
            DateTime       _emdate = Tools.LastDayOfMonth(_now);
            List <DataRow> _imrs   = _irs.Where(r => r.ToDateTime("ItemDate") >= _smdate && r.ToDateTime("ItemDate") <= _emdate).ToList();
            List <DataRow> _omrs   = _ors.Where(r => r.ToDateTime("ItemDate") >= _smdate && r.ToDateTime("ItemDate") <= _emdate).ToList();
            decimal        _imsum  = _imrs.Sum(r => r.ToDecimal("ItemMoney")); //月总收入
            decimal        _omsum  = _omrs.Sum(r => r.ToDecimal("ItemMoney")); //月总支出

            _result += "|" + _smdate.ToString("MM月dd日") + "-" + _emdate.ToString("MM月dd日");
            _result += ";月总收入=" + _imsum.ToString("0.00");
            _result += ";月总支出=" + _omsum.ToString("0.00");

            //周处理
            DateTime       _swdate = Convert.ToDateTime(Tools.FirstDayOfWeek(_now).ToString("yyyy-MM-dd 00:00:00"));
            DateTime       _ewdate = Convert.ToDateTime(Tools.LastDayOfWeek(_now).ToString("yyyy-MM-dd 23:59:59"));
            List <DataRow> _iwrs   = _irs.Where(r => r.ToDateTime("ItemDate") >= _swdate && r.ToDateTime("ItemDate") <= _ewdate).ToList();
            List <DataRow> _owrs   = _ors.Where(r => r.ToDateTime("ItemDate") >= _swdate && r.ToDateTime("ItemDate") <= _ewdate).ToList();
            decimal        _iwsum  = _iwrs.Sum(r => r.ToDecimal("ItemMoney")); //周总收入
            decimal        _owsum  = _owrs.Sum(r => r.ToDecimal("ItemMoney")); //周总支出

            _result += "|" + _swdate.ToString("MM月dd日") + "-" + _ewdate.ToString("MM月dd日");
            _result += ";周总收入=" + _iwsum.ToString("0.00");
            _result += ";周总支出=" + _owsum.ToString("0.00");

            //日处理
            DateTime       _sddate = Convert.ToDateTime(_now.ToString("yyyy-MM-dd 00:00:00"));
            DateTime       _eddate = Convert.ToDateTime(_now.ToString("yyyy-MM-dd 23:59:59"));
            List <DataRow> _idrs   = _irs.Where(r => r.ToDateTime("ItemDate") >= _sddate && r.ToDateTime("ItemDate") <= _eddate).ToList();
            List <DataRow> _odrs   = _ors.Where(r => r.ToDateTime("ItemDate") >= _sddate && r.ToDateTime("ItemDate") <= _eddate).ToList();
            decimal        _idsum  = _idrs.Sum(r => r.ToDecimal("ItemMoney")); //日总收入
            decimal        _odsum  = _odrs.Sum(r => r.ToDecimal("ItemMoney")); //日总支出

            _result += "|" + _sddate.ToString("yyyy年MM月dd日");
            _result += ";日总收入=" + _idsum.ToString("0.00");
            _result += ";日总支出=" + _odsum.ToString("0.00");

            return(_result);
        }
        public DataRow GET_ROW_BA1(string yt, DataRow dr1, System.Data.DataTable dt,
                                   EnumerableRowCollection <DataRow> temp_ba_bz,
                                   EnumerableRowCollection <DataRow> temp_ba_sz,
                                   EnumerableRowCollection <DataRow> temp_ba_ssz,
                                   EnumerableRowCollection <DataRow> temp_ba_sssz,
                                   EnumerableRowCollection <DataRow> temp_ba_bn,
                                   JP_JPXM_INFO item)
        {
            for (int j = 0; j < dt.Columns.Count; j++)
            {
                try
                {
                    #region _备案数据


                    if (Base_Config_Cjba._备案数据.Contains(dt.Columns[j].ColumnName))
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case Base_Config_Cjba.本周_备案套数: { dr1[dt.Columns[j].ColumnName] = temp_ba_bz != null?temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_备案套数._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.本周_成交金额: { dr1[dt.Columns[j].ColumnName] = temp_ba_bz != null?temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()).je_wy() : 0; }; break;

                        case Base_Config_Cjba.本周_建筑面积: { dr1[dt.Columns[j].ColumnName] = temp_ba_bz != null?temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls()).mj() : 0; }; break;

                        case Base_Config_Cjba.本周_套内面积: { dr1[dt.Columns[j].ColumnName] = temp_ba_bz != null?temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].doubls()).mj() : 0; }; break;

                        case Base_Config_Cjba.本周_建面均价:
                        {
                            if ((temp_ba_bz != null && temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()) / temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_建筑面积._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Cjba.本周_套内均价:
                        {
                            if ((temp_ba_bz != null && temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_成交金额._ConfigCjbaMc()].longs()) / temp_ba_bz.Sum(m => m[Base_Config_Cjba.本周_套内面积._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Cjba.周_备案套数: { dr1[dt.Columns[j].ColumnName] = temp_ba_sz != null?temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_备案套数._ConfigCjbaMc()].ints()) : 0; }; break;

                        case Base_Config_Cjba.周_成交金额: { dr1[dt.Columns[j].ColumnName] = temp_ba_sz != null?temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()).je_wy() : 0; }; break;

                        case Base_Config_Cjba.周_建筑面积: { dr1[dt.Columns[j].ColumnName] = temp_ba_sz != null?temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls()).mj() : 0; }; break;

                        case Base_Config_Cjba.周_套内面积: { dr1[dt.Columns[j].ColumnName] = temp_ba_sz != null?temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].doubls()).mj() : 0; }; break;

                        case Base_Config_Cjba.周_建面均价:
                        {
                            if ((temp_ba_sz != null && temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()) / temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_建筑面积._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Cjba.周_套内均价:
                        {
                            if ((temp_ba_sz != null && temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].doubls()) != 0))
                            {
                                dr1[dt.Columns[j].ColumnName] = (temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_成交金额._ConfigCjbaMc()].longs()) / temp_ba_sz.Sum(m => m[Base_Config_Cjba.周_套内面积._ConfigCjbaMc()].doubls())).je_y();
                            }
                            else
                            {
                                dr1[dt.Columns[j].ColumnName] = "0";
                            }
                        }; break;

                        case Base_Config_Cjba.本周_备案套数环比:
                        {
                            dr1[dt.Columns[j].ColumnName] = ((temp_ba_bz.Sum(m => m["ts"].ints()) - temp_ba_sz.Sum(m => m["ts"].ints())) / temp_ba_sz.Sum(m => m["ts"].ints())).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_套内均价环比:
                        {
                            long bz_cjje = temp_ba_bz.Sum(m => m["cjje"].ints());
                            long bz_tnmj = temp_ba_bz.Sum(m => m["tnmj"].ints());
                            long sz_cjje = temp_ba_sz.Sum(m => m["cjje"].ints());
                            long sz_tnmj = temp_ba_sz.Sum(m => m["tnmj"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje / bz_tnmj - sz_cjje / sz_tnmj) / (sz_cjje / sz_tnmj)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_套内面积环比:
                        {
                            long bz_tnmj = temp_ba_bz.Sum(m => m["tnmj"].ints());
                            long sz_tnmj = temp_ba_sz.Sum(m => m["tnmj"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_tnmj - sz_tnmj) / (sz_tnmj)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_套均总价环比:
                        {
                            long bz_cjje = temp_ba_bz.Sum(m => m["cjje"].ints());
                            long bz_ts   = temp_ba_bz.Sum(m => m["ts"].ints());
                            long sz_cjje = temp_ba_sz.Sum(m => m["cjje"].ints());
                            long sz_ts   = temp_ba_sz.Sum(m => m["ts"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje / bz_ts - sz_cjje / sz_ts) / (sz_cjje / sz_ts)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_建筑面积环比:
                        {
                            long bz_cjje = temp_ba_bz.Sum(m => m["cjje"].ints());
                            long bz_jzmj = temp_ba_bz.Sum(m => m["jzmj"].ints());
                            long sz_cjje = temp_ba_sz.Sum(m => m["cjje"].ints());
                            long sz_jzmj = temp_ba_sz.Sum(m => m["jzmj"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje / bz_jzmj - sz_cjje / sz_jzmj) / (sz_cjje / sz_jzmj)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_建面均价环比:
                        {
                            long bz_cjje = temp_ba_bz.Sum(m => m["cjje"].ints());
                            long bz_jzmj = temp_ba_bz.Sum(m => m["jzmj"].ints());
                            long sz_cjje = temp_ba_sz.Sum(m => m["cjje"].ints());
                            long sz_jzmj = temp_ba_sz.Sum(m => m["jzmj"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje / bz_jzmj - sz_cjje / sz_jzmj) / (sz_cjje / sz_jzmj)).doubls().ss_bfb();
                        }; break;

                        case Base_Config_Cjba.本周_成交金额环比:
                        {
                            long bz_cjje = temp_ba_bz.Sum(m => m["cjje"].ints());
                            long sz_cjje = temp_ba_sz.Sum(m => m["cjje"].ints());
                            dr1[dt.Columns[j].ColumnName] = ((bz_cjje - sz_cjje) / sz_cjje).doubls().ss_bfb();
                        }; break;



                        default: { dr1[dt.Columns[j].ColumnName] = "0"; }; break;
                        }
                    }
                    #endregion
                    #region _竞争格局参数名称


                    else if (Base_Config_Jzgj._竞争格局参数名称.Contains(dt.Columns[j].ColumnName))
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case Base_Config_Jzgj.项目名称:
                        {
                            dr1[dt.Columns[j].ColumnName] = item.lpcs[0];
                        }; break;

                        case Base_Config_Jzgj.业态:
                        {
                            dr1[dt.Columns[j].ColumnName] = yt;
                        }; break;

                        case Base_Config_Jzgj.组团:
                        {
                            dr1[dt.Columns[j].ColumnName] = item != null && item.ztcs != null?string.Join(",", item.ztcs) : "";
                        }; break;

                        case Base_Config_Jzgj.竞争格局_主力面积区间:
                        {
                            dr1[dt.Columns[j].ColumnName] = item.zlmjqj;
                        }; break;

                        case Base_Config_Jzgj.竞争格局名称:
                        {
                            dr1[dt.Columns[j].ColumnName] = item.jzgjmc;
                        }; break;
                        }
                    }
                    #endregion

                    else if (Base_Config_Cjba_Qn._全年备案数据.Contains(dt.Columns[j].ColumnName))
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case Base_Config_Cjba_Qn.全年_累计套内均价:
                        {
                            double tnmj = temp_ba_bn.Sum(m => m["tnmj"].doubls());
                            dr1[dt.Columns[j].ColumnName] = tnmj != 0 ? (temp_ba_bn.Sum(m => m["cjje"].longs()) / tnmj).je_y().ToString() : "-";
                        }; break;

                        case Base_Config_Cjba_Qn.全年_累计成交建面:
                        {
                            dr1[dt.Columns[j].ColumnName] = temp_ba_bn.Sum(m => m["jzmj"].doubls()).mj_wf();
                        }; break;

                        case Base_Config_Cjba_Qn.全年_累计成交金额:
                        {
                            dr1[dt.Columns[j].ColumnName] = temp_ba_bn.Sum(m => m["cjje"].longs()).je_wy();
                        }; break;
                        }
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            return(dr1);
        }
Beispiel #8
0
        private void ProcessAttackSpeed(EnumerableRowCollection <EnfeebleGroup> slowSet,
                                        ref StringBuilder sb, ref List <StringMods> strModList)
        {
            strModList.Add(new StringMods
            {
                Start  = sb.Length,
                Length = lsSpeedTitle.Length,
                Bold   = true,
                Color  = Color.Red
            });
            sb.Append(lsSpeedTitle + "\n");

            strModList.Add(new StringMods
            {
                Start  = sb.Length,
                Length = lsSpeedHeader1.Length,
                Bold   = true,
                Color  = Color.Black
            });
            sb.Append(lsSpeedHeader1 + "\n");

            strModList.Add(new StringMods
            {
                Start     = sb.Length,
                Length    = lsSpeedHeader2.Length,
                Bold      = true,
                Underline = true,
                Color     = Color.Black
            });
            sb.Append(lsSpeedHeader2 + "\n");


            int totalFights   = slowSet.Count();
            int totalSlowCast = slowSet.Sum(a => a.Enfeebled.Count());

            int    slowedActions    = 0;
            int    normalActions    = 0;
            int    totalMobsSlowed  = 0;
            double slowedAttackRate = 0;
            double normalAttackRate = 0;

            DateTime slowBufferTime = DateTime.MinValue;
            DateTime slowLimitTime  = DateTime.MinValue;

            TimeSpan totalWindowTime = TimeSpan.Zero;
            TimeSpan unslowedTime    = TimeSpan.Zero;

            foreach (var mob in slowSet)
            {
                if (mob.Enfeebled.Any())
                {
                    totalMobsSlowed++;
                }

                var mobActionList = mob.Actions.ToList();
                unslowedTime += mob.FightEndTime - mob.FightStartTime;

                for (int i = 0; i < mob.Enfeebled.Count(); i++)
                {
                    // Get the limits of the time period we will look at.

                    var enf = mob.Enfeebled.ElementAt(i);

                    // Start point
                    slowBufferTime = enf.Timestamp.AddSeconds(-3);

                    // Preliminary end point
                    slowLimitTime = mob.FightEndTime;

                    if ((i + 1) < mob.Enfeebled.Count())
                    {
                        slowLimitTime = mob.Enfeebled.ElementAt(i + 1).Timestamp.AddSeconds(-2);
                    }

                    if (slowLimitTime > enf.Timestamp.AddMinutes(3))
                    {
                        slowLimitTime = enf.Timestamp.AddMinutes(3);
                    }

                    // Final end point determined

                    totalWindowTime += slowLimitTime - slowBufferTime;

                    // Get all actions within that window
                    var actionsInWindow = mob.Actions.Where(a =>
                                                            a.Timestamp >= slowBufferTime &&
                                                            a.Timestamp <= slowLimitTime);

                    slowedActions += actionsInWindow.Count();

                    foreach (var action in actionsInWindow)
                    {
                        mobActionList.Remove(action);
                    }
                }

                normalActions += mobActionList.Count;
            }

            unslowedTime -= totalWindowTime;

            if (totalWindowTime > TimeSpan.Zero)
            {
                slowedAttackRate = ((double)slowedActions / totalWindowTime.TotalSeconds) * 60;
            }

            if (unslowedTime > TimeSpan.Zero)
            {
                normalAttackRate = ((double)normalActions / unslowedTime.TotalSeconds) * 60;
            }


            sb.AppendFormat(lsSpeedFormat,
                            totalFights, totalSlowCast, totalMobsSlowed, slowedActions, slowedAttackRate,
                            normalActions, normalAttackRate);
            sb.Append("\n\n\n");
        }
Beispiel #9
0
        private void ProcessParalyze(EnumerableRowCollection <EnfeebleGroup> paralyzeSet,
                                     ref StringBuilder sb, ref List <StringMods> strModList)
        {
            strModList.Add(new StringMods
            {
                Start  = sb.Length,
                Length = lsParalyzeTitle.Length,
                Bold   = true,
                Color  = Color.Red
            });
            sb.Append(lsParalyzeTitle + "\n\n");

            strModList.Add(new StringMods
            {
                Start     = sb.Length,
                Length    = lsParalyzeHeader.Length,
                Bold      = true,
                Underline = true,
                Color     = Color.Black
            });
            sb.Append(lsParalyzeHeader + "\n");

            int totalFights   = paralyzeSet.Count();
            int totalParaCast = paralyzeSet.Sum(a => a.Enfeebled.Count());

            int    totalParalyzed     = 0;
            int    totalActions       = 0;
            int    totalMobsParalyzed = 0;
            double paralyzeRate       = 0;

            DateTime paraBufferTime = DateTime.MinValue;
            DateTime paraLimitTime  = DateTime.MinValue;

            foreach (var mob in paralyzeSet)
            {
                if (mob.Enfeebled.Any())
                {
                    totalMobsParalyzed++;
                    totalParalyzed += mob.Paralyzed.Count();
                }

                for (int i = 0; i < mob.Enfeebled.Count(); i++)
                {
                    // Get the limits of the time period we will look at for possible
                    // paralyze effects.

                    var enf = mob.Enfeebled.ElementAt(i);

                    // Start point
                    paraBufferTime = enf.Timestamp.AddSeconds(-3);

                    // Preliminary end point
                    paraLimitTime = mob.FightEndTime;

                    if ((i + 1) < mob.Enfeebled.Count())
                    {
                        paraLimitTime = mob.Enfeebled.ElementAt(i + 1).Timestamp.AddSeconds(-2);
                    }

                    if (paraLimitTime > enf.Timestamp.AddMinutes(3))
                    {
                        paraLimitTime = enf.Timestamp.AddMinutes(3);
                    }

                    // Final end point determined

                    // Get all actions within that window
                    var actionWindow = mob.Actions.Where(a =>
                                                         a.Timestamp >= paraBufferTime &&
                                                         a.Timestamp <= paraLimitTime);

                    totalActions += actionWindow.Count();
                }
            }

            if (totalActions > 0)
            {
                paralyzeRate = (double)totalParalyzed / totalActions;
            }

            sb.AppendFormat(lsParalyzeFormat,
                            totalFights,
                            totalMobsParalyzed,
                            totalParalyzed,
                            totalActions,
                            paralyzeRate);
            sb.Append("\n\n\n");
        }
Beispiel #10
0
        public void createReportTenant()
        {
            if (dtReport == null)
            {
                return;
            }
            monthPlan = listMonth[DateTime.Parse(dtReport.Rows[0]["monthX"].ToString()).Month];
            DateTime dayX = DateTime.Parse(dtReport.Rows[0]["dayX"].ToString());

            datePlan = $"{dayX.Day}.{dayX.Month}";
            rep      = new ExcelUnLoad();
            int crow     = 1;
            int startRow = 1;

            AddHeaderTenant(ref crow);
            var tenants     = dtReport.AsEnumerable().GroupBy(g => g.Field <string>("new_tenant_Name")).Select(s => s.Key);
            int indexTenant = 0;

            foreach (string tenant in tenants)
            {
                rep.AddSingleValue(tenant, crow, 1);
                int startTenant = crow;
                // таблица по арендатору
                EnumerableRowCollection <DataRow> rTenant = dtReport.AsEnumerable().Where(r => r.Field <string>("new_tenant_Name") == tenant);
                // объекты
                var objects = rTenant.GroupBy(g => g.Field <string>("objectName")).Select(s => s.Key);
                foreach (string obj in objects)
                {
                    rep.AddSingleValue(obj, crow, 2);
                    int startObject = crow;

                    // таблица по объекту
                    EnumerableRowCollection <DataRow> rObject = rTenant.Where(r => r.Field <string>("objectName") == obj);
                    // секции
                    var sections = rObject.GroupBy(g => g.Field <string>("nameSection")).Select(s => s.Key);
                    foreach (var section in sections)
                    {
                        rep.AddSingleValue(section, crow, 3);
                        int startSection = crow;
                        //договоры
                        EnumerableRowCollection <DataRow> rAgrements = rObject.Where(r => r.Field <string>("nameSection") == section);
                        foreach (DataRow dr in rAgrements)
                        {
                            rep.AddSingleValue(dr["Agreement"].ToString(), crow, 4);
                            rep.AddSingleValue(DateTime.Parse(dr["Start_Date"].ToString()).ToShortDateString(), crow, 5);
                            rep.AddSingleValue(DateTime.Parse(dr["End_Date"].ToString()).ToShortDateString(), crow, 6);
                            rep.AddSingleValueObject(dr["Total_Sum"], crow, 7);
                            rep.AddSingleValueObject(dr["SummaPlanView"], crow, 8);
                            decimal before25day = (dr["payments"] == DBNull.Value ? 0 : (decimal)dr["payments"]);
                            if (before25day < 0)
                            {
                                rep.AddSingleValueObject((-1 * before25day), crow, 9);
                            }
                            if (before25day > 0)
                            {
                                rep.AddSingleValueObject(before25day, crow, 10);
                            }
                            decimal pay = (dr["paymentsNew"] == DBNull.Value ? 0 : (decimal)dr["paymentsNew"]);
                            if (pay != 0)
                            {
                                rep.AddSingleValueObject(pay, crow, 13);
                            }

                            /* decimal curDebt = before25day + pay;
                             * if (curDebt < 0)
                             *   rep.AddSingleValue((-curDebt).ToString("0.00"), crow, 13);
                             * if (curDebt > 0)
                             *   rep.AddSingleValue(curDebt.ToString("0.00"), crow, 14);
                             *
                             *
                             * decimal currDown = (decimal)dr["percDebt"];
                             * if (currDown != 0 && curDebt < 0)
                             * {
                             *   rep.AddSingleValue($"{((curDebt / -currDown) * 100).ToString("0.00")}%", crow, 15);
                             * }
                             */
                            rep.AddSingleValue(dr["landLord_name"].ToString(), crow, 21);
                            crow++;
                        }
                        rep.Merge(startSection, 3, crow - 1, 3);
                        rep.SetCellAlignmentToJustify(startSection, 3, crow - 1, 3);
                    }
                    //итого долг на 25 число
                    EnumerableRowCollection <DataRow> rCol = rObject
                                                             .Where(r => r.Field <object>("payments") != null);
                    // тут будет у нас или в одну или в другую считаться

                    decimal rowSumm = rCol.Sum(s => s.Field <decimal>("payments"));

                    // decimal rowSumm = rCol
                    //    .Where(r => r.Field<decimal>("payments") < 0)
                    //   .Sum(s => s.Field<decimal>("payments"));
                    if (rowSumm < 0)
                    {
                        rep.AddSingleValueObject((-rowSumm), startObject, 11);
                    }
                    //переплата на 25 число
                    // rowSumm = rCol
                    //    .Where(r => r.Field<decimal>("payments") > 0)
                    //    .Sum(s => s.Field<decimal>("payments"));
                    if (rowSumm > 0)
                    {
                        rep.AddSingleValueObject(rowSumm, startObject, 12);
                    }



                    //сумма оплаты
                    rCol = rObject
                           .Where(r => r.Field <object>("paymentsNew") != null);
                    rowSumm = rCol
                              .Sum(s => s.Field <decimal>("paymentsNew"));
                    if (rowSumm != 0)
                    {
                        rep.AddSingleValueObject(rowSumm, startObject, 14);
                    }
                    //итого долг - считается сумма текущего по секции - если в -, то долг, если в +, то переплата... для - считается переплата

                    //это как в предыдущем, только по другому идет сортировочка

                    /*rowSumm = rTenant.Sum(s => s.Field<decimal>("payments") + s.Field<decimal>("paymentsNew"));
                     * if (rowSumm < 0)
                     *  rep.AddSingleValue((-rowSumm).ToString("0.00"), startObject, 16);
                     * if (rowSumm > 0)
                     *  rep.AddSingleValue(rowSumm.ToString("0.00"), startObject, 18);
                     * // итого % долга  - при минусовом rowSumm, делим вот на то число
                     * decimal total_sum = rCol.Where(r => r.Field<decimal>("percDebt") > 0).Sum(s => s.Field<decimal>("percDebt"));
                     * if (rowSumm < 0 && total_sum != 0)
                     *  rep.AddSingleValue((-rowSumm * 100 / total_sum).ToString("0.00") + "%", startObject, 17);*/
                    // итого переплата

                    decimal currentSum = rObject.Sum(s => (s.Field <decimal>("payments") + s.Field <decimal>("paymentsNew")));


                    if (currentSum < 0)
                    {
                        rep.AddSingleValueObject((-currentSum), startObject, 15);
                    }
                    if (currentSum > 0)
                    {
                        rep.AddSingleValueObject(currentSum, startObject, 16);
                    }


                    decimal currDown = rObject.Sum(s => s.Field <decimal>("percDebt"));
                    if (currDown != 0 && currentSum < 0)
                    {
                        rep.AddSingleValue($"{((currentSum / -currDown) * 100).ToString("0.00")}%", startObject, 17);
                    }



                    rep.Merge(startObject, 2, crow - 1, 2);
                    rep.Merge(startObject, 11, crow - 1, 11);
                    rep.Merge(startObject, 12, crow - 1, 12);
                    rep.Merge(startObject, 14, crow - 1, 14);
                    rep.Merge(startObject, 15, crow - 1, 15);
                    rep.Merge(startObject, 16, crow - 1, 16);
                    rep.Merge(startObject, 17, crow - 1, 17);

                    rep.SetCellAlignmentToJustify(startObject, 2, crow - 1, 2);
                    rep.SetCellAlignmentToJustify(startObject, 11, crow - 1, 11);
                    rep.SetCellAlignmentToJustify(startObject, 12, crow - 1, 12);
                    rep.SetCellAlignmentToJustify(startObject, 14, crow - 1, 14);
                    rep.SetCellAlignmentToJustify(startObject, 15, crow - 1, 15);
                    rep.SetCellAlignmentToJustify(startObject, 16, crow - 1, 16);
                    rep.SetCellAlignmentToJustify(startObject, 17, crow - 1, 17);
                }

                decimal summ = rTenant.Sum(s => s.Field <decimal>("payments") + s.Field <decimal>("paymentsNew"));
                if (summ < 0)
                {
                    rep.AddSingleValueObject((-summ), startTenant, 18);
                }
                if (summ > 0)
                {
                    rep.AddSingleValueObject(summ, startTenant, 20);
                }
                // итого % долга  - при минусовом rowSumm, делим вот на то число
                decimal sum_total = rTenant.Where(r => r.Field <decimal>("percDebt") > 0).Sum(s => s.Field <decimal>("percDebt"));
                if (summ < 0 && sum_total != 0)
                {
                    rep.AddSingleValue((-summ * 100 / sum_total).ToString("0.00") + "%", startTenant, 19);
                }

                rep.Merge(startTenant, 18, crow - 1, 18);
                rep.Merge(startTenant, 19, crow - 1, 19);
                rep.Merge(startTenant, 20, crow - 1, 20);
                rep.SetCellAlignmentToJustify(startTenant, 18, crow - 1, 18);
                rep.SetCellAlignmentToJustify(startTenant, 19, crow - 1, 19);
                rep.SetCellAlignmentToJustify(startTenant, 20, crow - 1, 20);

                rep.Merge(startTenant, 1, crow - 1, 1);
                rep.SetCellAlignmentToJustify(startTenant, 1, crow - 1, 1);

                //подстветка каждого второго арендатора
                //цвет до со 1 по 21 ячейки
                if (indexTenant % 2 == 1)
                {
                    rep.SetCellColor(startTenant, 1, crow - 1, 21, Color.LightGray);
                }
                indexTenant++;
            }

            rep.SetPageOrientationToLandscape();
            rep.SetPageSetup(1, 9999, true);
            rep.SetBorders(1, 1, crow - 1, 21);
            rep.SetPrintRepeatHead(1, 2);

            rep.SetBottomMargin(0);
            rep.SetFooterMargin(0);
            rep.SetHeaderMargin(0);
            rep.SetLeftMargin(0);
            rep.SetRightMargin(0);
            rep.SetTopMargin(0);

            rep.Show();
        }
Beispiel #11
0
        public void createReportSection()
        {
            /*Task<DataTable> task = Config.hCntMain.getDataReport();
             * task.Wait();
             * dtReport = task.Result;*/
            if (dtReport == null)
            {
                return;
            }
            monthPlan = listMonth[DateTime.Parse(dtReport.Rows[0]["monthX"].ToString()).Month];
            DateTime dayX = DateTime.Parse(dtReport.Rows[0]["dayX"].ToString());

            datePlan = $"{dayX.Day}.{dayX.Month}";
            rep      = new ExcelUnLoad();
            int crow     = 1;
            int startRow = 1;

            AddHeaderSection(ref crow);
            var objects = dtReport.AsEnumerable().GroupBy(g => g.Field <string>("objectName")).Select(s => s.Key);
            //индекс секции для подкраски строчки
            int indexSection = 0;

            foreach (string obj in objects)
            {
                rep.AddSingleValue(obj, crow, 1);
                int startObject = crow;
                //дататейбл по объекту
                EnumerableRowCollection <DataRow> rObject = dtReport.AsEnumerable().Where(r => r.Field <string>("objectName") == obj);
                //секциии
                var sections = rObject.GroupBy(g => g.Field <string>("nameSection")).Select(s => s.Key);
                foreach (string sect in sections)
                {
                    rep.AddSingleValue(sect, crow, 2);
                    int startSection = crow;

                    //дататейбл по обхекту и секции
                    EnumerableRowCollection <DataRow> rSection = rObject.Where(r => r.Field <string>("nameSection") == sect);
                    //арендаторы
                    var tenants = rSection.GroupBy(g => new { id_tenant = g.Field <int>("tenant_id"), name = g.Field <string>("tenant_Name") }).Select(r => new{ r.Key.name, r.Key.id_tenant });
                    foreach (var tenant in tenants)
                    {
                        rep.AddSingleValue(tenant.name, crow, 3);
                        int startTenant = crow;
                        //договоры
                        EnumerableRowCollection <DataRow> rAgrements = rSection.Where(r => r.Field <int>("tenant_id") == tenant.id_tenant);
                        foreach (DataRow dr in rAgrements)
                        {
                            rep.AddSingleValueObject(dr["Agreement"], crow, 4);
                            rep.AddSingleValueObject(dr["Total_Sum"], crow, 5);
                            rep.AddSingleValueObject(dr["SummaPlanView"], crow, 6);
                            decimal before25day = (dr["payments"] == DBNull.Value ? 0 : (decimal)dr["payments"]);
                            if (before25day < 0)
                            {
                                rep.AddSingleValueObject((-1 * before25day), crow, 7);
                            }
                            if (before25day > 0)
                            {
                                rep.AddSingleValueObject(before25day, crow, 8);
                            }
                            decimal pay = (dr["paymentsNew"] == DBNull.Value ? 0 : (decimal)dr["paymentsNew"]);
                            if (pay > 0)
                            {
                                rep.AddSingleValueObject(pay, crow, 11);
                            }
                            decimal curDebt = before25day + pay;
                            if (curDebt < 0)
                            {
                                rep.AddSingleValueObject((-curDebt), crow, 13);
                            }
                            if (curDebt > 0)
                            {
                                rep.AddSingleValueObject(curDebt, crow, 15);
                            }


                            decimal currDown = (decimal)dr["percDebt"];
                            if (currDown != 0 && curDebt < 0)
                            {
                                rep.AddSingleValue($"{((curDebt / -currDown) * 100).ToString("0.00")}%", crow, 14);
                            }

                            rep.AddSingleValue(dr["landLord_name"].ToString(), crow, 18);
                            crow++;
                        }
                        rep.Merge(startTenant, 3, crow - 1, 3);
                        rep.SetCellAlignmentToJustify(startTenant, 3, crow - 1, 3);
                    }
                    //итого долг на 25 число
                    EnumerableRowCollection <DataRow> rCol = rSection
                                                             .Where(r => r.Field <object>("payments") != null);
                    // переписано, теперь тупо все суммируется и если >0 то переплата, если <0 то долг
                    decimal rowSumm = rCol.Sum(s => s.Field <decimal>("payments"));
                    if (rowSumm > 0)
                    {
                        rep.AddSingleValueObject(rowSumm, startSection, 10);
                    }
                    if (rowSumm < 0)
                    {
                        rep.AddSingleValueObject(-rowSumm, startSection, 9);
                    }

                    /*decimal rowSumm = rCol
                     *  .Where(r => r.Field<decimal>("payments") < 0)
                     *  .Sum(s => s.Field<decimal>("payments"));
                     * if (rowSumm!=0)
                     *  rep.AddSingleValueObject(-rowSumm, startSection, 9);
                     * //переплата на 25 число
                     * rowSumm = rCol
                     *  .Where(r=> r.Field<decimal>("payments") > 0)
                     *  .Sum(s => s.Field<decimal>("payments"));
                     * if (rowSumm!=0)
                     *  rep.AddSingleValueObject(rowSumm, startSection, 10);
                     */
                    //сумма оплаты
                    rCol = rSection
                           .Where(r => r.Field <object>("paymentsNew") != null);
                    rowSumm = rCol
                              .Sum(s => s.Field <decimal>("paymentsNew"));
                    if (rowSumm != 0)
                    {
                        rep.AddSingleValueObject(rowSumm, startSection, 12);
                    }
                    //итого долг - считается сумма текущего по секции - если в -, то долг, если в +, то переплата... для - считается переплата

                    rowSumm = rSection.Sum(s => s.Field <decimal>("payments") + s.Field <decimal>("paymentsNew"));
                    if (rowSumm < 0)
                    {
                        rep.AddSingleValueObject((-rowSumm), startSection, 16);
                    }
                    if (rowSumm > 0)
                    {
                        rep.AddSingleValueObject(rowSumm, startSection, 17);
                    }
                    // итого % долга  - при минусовом rowSumm, делим вот на то число
                    // закомментить проценты!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    //decimal total_sum = rCol.Where(r=>r.Field<decimal>("percDebt")>0).Sum(s => s.Field<decimal>("percDebt"));
                    //if (rowSumm < 0 && total_sum!=0)
                    //    rep.AddSingleValue((-rowSumm * 100 / total_sum).ToString("0.00") + "%", startSection, 17);
                    ////////////////////////////////////////////////////////////////////////
                    // итого переплата

                    rep.Merge(startSection, 2, crow - 1, 2);
                    rep.Merge(startSection, 9, crow - 1, 9);
                    rep.Merge(startSection, 10, crow - 1, 10);
                    rep.Merge(startSection, 12, crow - 1, 12);
                    rep.Merge(startSection, 16, crow - 1, 16);
                    //rep.Merge(startSection, 17, crow - 1, 17);
                    rep.Merge(startSection, 17, crow - 1, 17);

                    rep.SetCellAlignmentToJustify(startSection, 2, crow - 1, 2);
                    rep.SetCellAlignmentToJustify(startSection, 9, crow - 1, 9);
                    rep.SetCellAlignmentToJustify(startSection, 10, crow - 1, 10);
                    rep.SetCellAlignmentToJustify(startSection, 12, crow - 1, 12);
                    rep.SetCellAlignmentToJustify(startSection, 16, crow - 1, 16);
                    //rep.SetCellAlignmentToJustify(startSection, 17, crow - 1, 17);
                    rep.SetCellAlignmentToJustify(startSection, 17, crow - 1, 17);

                    //цвет до со 2 до 18 ячейки
                    if (indexSection % 2 == 1)
                    {
                        rep.SetCellColor(startSection, 2, crow - 1, 18, Color.LightGray);
                    }
                    indexSection++;
                }
                rep.Merge(startObject, 1, crow - 1, 1);
                rep.SetCellAlignmentToJustify(startObject, 1, crow - 1, 1);
            }

            rep.SetPageOrientationToLandscape();
            rep.SetPageSetup(1, 9999, true);
            rep.SetBorders(1, 1, crow - 1, 18);
            rep.SetPrintRepeatHead(1, 2);
            rep.SetBottomMargin(0);
            rep.SetFooterMargin(0);
            rep.SetHeaderMargin(0);
            rep.SetLeftMargin(0);
            rep.SetRightMargin(0);
            rep.SetTopMargin(0);
            rep.Show();
        }