1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using Library;
- using System.Linq;
- using MySystem.MainModels;
- namespace MySystem
- {
- public class UserAmountSummary
- {
- public readonly static UserAmountSummary Instance = new UserAmountSummary();
- public UserAmountSummary()
- { }
- public decimal GetTrade(int UserId, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.SeoTitle == kind).Sum(m => m.TotalAmount);
- }
- else if (kind == "team")
- {
- amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.SeoTitle == kind).Sum(m => m.TotalAmount);
- }
- }
- db.Dispose();
- return amt;
- }
- public decimal GetTradeByMonth(int UserId, string TradeMonth, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == TradeMonth &&m.SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth &&m.SeoTitle == kind).Sum(m => m.TotalAmount);
- }
- else if (kind == "team")
- {
- amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth &&m.SeoTitle == kind).Sum(m => m.TotalAmount);
- }
- }
- db.Dispose();
- return amt;
- }
- public decimal GetTradeByDate(int UserId, string TradeDate, string kind = "self")
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeDate == TradeDate &&m.SeoTitle == kind);
- if (check)
- {
- if (kind == "self")
- {
- amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeDate == TradeDate &&m.SeoTitle == kind).Sum(m => m.TotalAmount);
- }
- else if (kind == "team")
- {
- amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeDate == TradeDate &&m.SeoTitle == kind).Sum(m => m.TotalAmount);
- }
- }
- db.Dispose();
- return amt;
- }
- }
- }
|