コード例 #1
0
        public IList<EMTenantAccountDetail> Select(List<string> tenantCodeList, DateTime StartTime, DateTime EndTime, EnumConsumeType? consumeType, int rowIndex, int pageSize, ref int rowCount, ref int IncomeRowCount, ref decimal IncomeAccount, ref int OutlayRowCount, ref decimal OutlayAccount)
        {
            IList<EMTenantAccountDetail> list = new List<EMTenantAccountDetail>();
            if (tenantCodeList == null || tenantCodeList.Count == 0)
                return list;
            StringBuilder strTenantCode = new StringBuilder();
            for (int i = 1, i_count = tenantCodeList.Count; i <= i_count; i++)
            {
                if (i == i_count)
                    strTenantCode.Append(string.Format("'{0}'", tenantCodeList[i - 1].ToString()));
                else
                    strTenantCode.Append(string.Format("'{0}',", tenantCodeList[i - 1].ToString()));
            }

            TenantCountDetailDAL dal = new TenantCountDetailDAL();
            #region 查询所有存入金额
//            string sqlIncome = string.Format(@"select ConsumeMoney from movo_tenantaccount_detail where TenantCode in ({0})
// and CreateTime between '{1}' and '{2}' and OperateType=0;", strTenantCode, StartTime, EndTime);
//            DataSet ds = MySqlHelper.ExecuteDataSet(ConnectionString, sqlIncome, null);
//            if (ds == null || ds.Tables[0].Rows.Count == 0)
//            {
//                IncomeRowCount = 0;
//                IncomeAccount = 0;
//            }
//            else
//            {
//                IncomeAccount = 0;
//                IncomeRowCount = ds.Tables[0].Rows.Count;
//                for (int i = 0, i_Count = ds.Tables[0].Rows.Count; i < i_Count; i++)
//                {
//                    IncomeAccount += Convert.ToDecimal(ds.Tables[0].Rows[i]["ConsumeMoney"]);
//                }
//            }
            
            dal.SelectIncomeAccount(strTenantCode.ToString(), StartTime, EndTime, ref IncomeRowCount, ref IncomeAccount);
            #endregion

            #region 查询所有扣款金额
             
//            string sqlOutlay = string.Format(@"select ConsumeMoney from movo_tenantaccount_detail where TenantCode in ({0})
// and CreateTime between '{1}' and '{2}' and OperateType=1;", strTenantCode, StartTime, EndTime);
//            ds = MySqlHelper.ExecuteDataSet(ConnectionString, sqlOutlay, null);
//            if (ds == null || ds.Tables[0].Rows.Count == 0)
//            {
//                OutlayRowCount = 0;
//                OutlayAccount = 0;
//            }
//            else
//            {
//                OutlayAccount = 0;
//                OutlayRowCount = ds.Tables[0].Rows.Count;
//                for (int i = 0, i_Count = ds.Tables[0].Rows.Count; i < i_Count; i++)
//                {
//                    OutlayAccount += Convert.ToDecimal(ds.Tables[0].Rows[i]["ConsumeMoney"]);
//                }
//            }
            dal.SelectOutlayAccount(strTenantCode.ToString(), StartTime, EndTime, ref OutlayRowCount, ref OutlayAccount);
            #endregion

            //string consumeTypeCondition = consumeType.HasValue ? "and ConsumeType=" + Convert.ToInt32(consumeType.Value) : "";
            
            //查询总数据笔数
//            string sqlAll = string.Format(@"select count(*) from movo_tenantaccount_detail where TenantCode in ({0})
// and CreateTime between '{1}' and '{2}' {3};", strTenantCode, StartTime, EndTime, consumeTypeCondition);
//            ds = MySqlHelper.ExecuteDataSet(ConnectionString, sqlAll, null);
//            if (ds == null || ds.Tables[0].Rows.Count == 0)
//            {
//                rowCount = 0;
//            }
//            else
//            {
//                rowCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
//            }

//            string sql = string.Format(@"select * from movo_tenantaccount_detail where TenantCode in ({0})
// and CreateTime between '{1}' and '{2}' {5} order by CreateTime desc limit {3},{4};", strTenantCode, StartTime, EndTime, rowIndex, pageSize, consumeTypeCondition);
//            ds = MySqlHelper.ExecuteDataSet(ConnectionString, sql, null);
//            if (ds == null || ds.Tables[0].Rows.Count == 0)
//                return list;
//            for (int i = 0, i_Count = ds.Tables[0].Rows.Count; i < i_Count; i++)
//            {
//                list.Add(ConvertInfo(ds.Tables[0].Rows[i]));
//            }
            //代码优化
            
            list = dal.SelectTenantCountDetail(strTenantCode.ToString(), StartTime, EndTime, consumeType, rowIndex, pageSize, ref rowCount);
            return list;
        }