Exemple #1
0
        /// <summary>
        /// 获取单个的Quota
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ResultQuotaInfo GetQuotaInfoById(int id)
        {
            ResultQuotaInfo quotaInfo = new ResultQuotaInfo();

            quotaInfo.QuotaData    = new Quota();
            quotaInfo.QuotaLogList = new List <QuotaLog>();
            quotaInfo.Page         = new Padding();
            List <Model.TB_Quota> currentQuota = new List <TB_Quota>();

            currentQuota = quotaOperator.GetQuota(" and QUOTAID=" + id);
            if (currentQuota != null && currentQuota.Count > 0)
            {
                QueryQuotaLogContract queryQuotaLog = new QueryQuotaLogContract {
                    QuotaId = currentQuota.First().QuotaId, PageCurrent = 1, PageSize = 100
                };
                var quotaLogList = GetQuotaLogs(queryQuotaLog);
                quotaInfo.QuotaLogList = quotaLogList.QuotaLogList;
                quotaInfo.Page         = quotaLogList.Page;
                quotaInfo.QuotaData    = currentQuota.Select(p => new Quota
                {
                    ObjectDesc = p.ObjectDesc,
                    ObjectId   = p.ObjectId,
                    ObjectType = p.ObjectType,
                    QuotaId    = p.QuotaId,
                    QuotaTime  = p.QuotaTime,
                    QuotaType  = (QuotaType)p.QuotaType,
                    QuotaValue = (float)p.QuotaValue,
                    ItemCode   = p.ItemCode,
                    Reserved   = p.Reserved
                }).First();
            }
            return(quotaInfo);
        }
Exemple #2
0
        /// <summary>
        /// 定额加载
        /// </summary>
        /// <param name="queryQuota"></param>
        /// <returns></returns>
        public ResultQuotaInfo GetQuotaInfo(QueryQuotaContact queryQuota)
        {
            #region 定义变量
            ResultQuotaInfo       quotaInfo    = new ResultQuotaInfo();
            List <Model.TB_Quota> currentQuota = new List <TB_Quota>();
            string currentWhere = string.Empty;
            #endregion

            #region 组织查询条件

            //月定额
            if (queryQuota.QuotaType == 1)
            {
                currentWhere  = " and OBJECTID=" + queryQuota.ObjectId;
                currentWhere += " and ItemCode='" + queryQuota.ItemCode + "' ";
                currentWhere += " and QuotaType=" + queryQuota.QuotaType;
                if (queryQuota.Date != null && !string.IsNullOrEmpty(queryQuota.Date.ToString()))
                {
                    currentWhere += string.Format(" and ( DATEPART(year,QUOTATIME)={0} and DATEPART(month,QUOTATIME) ={1})", queryQuota.Date.Year, queryQuota.Date.Month);
                }
            }
            else if (queryQuota.QuotaType == 2)
            {
                currentWhere  = " and OBJECTID=" + queryQuota.ObjectId;
                currentWhere += " and ItemCode='" + queryQuota.ItemCode + "' ";
                currentWhere += " and QuotaType=" + queryQuota.QuotaType;
                if (queryQuota.Date != null && !string.IsNullOrEmpty(queryQuota.Date.ToString()))
                {
                    currentWhere += string.Format(" and DATEPART(year,QUOTATIME)={0}", queryQuota.Date.Year);
                }
            }

            #endregion

            #region 组织数据
            currentQuota = quotaOperator.GetQuota(currentWhere);
            if (currentQuota != null && currentQuota.Count > 0)
            {
                QueryQuotaLogContract queryQuotaLog = new QueryQuotaLogContract {
                    QuotaId = currentQuota.First().QuotaId, PageCurrent = 1, PageSize = queryQuota.PageSize
                };
                var quotaLogList = GetQuotaLogs(queryQuotaLog);
                quotaInfo.QuotaLogList = quotaLogList.QuotaLogList;
                quotaInfo.Page         = quotaLogList.Page;
                quotaInfo.QuotaData    = currentQuota.Select(p => new Quota
                {
                    ObjectDesc = p.ObjectDesc,
                    ObjectId   = p.ObjectId,
                    ObjectType = p.ObjectType,
                    QuotaId    = p.QuotaId,
                    QuotaTime  = p.QuotaTime,
                    QuotaType  = (QuotaType)p.QuotaType,
                    QuotaValue = (float)p.QuotaValue,
                    ItemCode   = p.ItemCode,
                    Reserved   = p.Reserved
                }).First();
            }


            #endregion

            return(quotaInfo);
        }