コード例 #1
0
        private CultureInfo SetCultureInfo(DateEnum dn)
        {
            CultureInfo cu = null;

            switch (dn)
            {
            case DateEnum.AR:
                cu = new CultureInfo("ar-SA");
                cu.DateTimeFormat.Calendar         = new UmAlQuraCalendar();
                cu.DateTimeFormat.DateSeparator    = "/";
                cu.DateTimeFormat.ShortDatePattern = "dd/MM/yyy";
                cu.DateTimeFormat.ShortTimePattern = "HH:mm";

                break;

            case DateEnum.EN:
                cu = new CultureInfo("en-US");
                cu.DateTimeFormat.Calendar         = new GregorianCalendar();
                cu.DateTimeFormat.DateSeparator    = "/";
                cu.DateTimeFormat.ShortDatePattern = "dd/MM/yyy";
                cu.DateTimeFormat.ShortTimePattern = "HH:mm";

                break;

            default:
                Debug.WriteLine("Error CultureInfo pls check SPEC.CULTURE Date.class");
                break;
            }


            return(cu);
        }
コード例 #2
0
ファイル: BusinessDetailBll.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 获取实际收款(当季、当月、本周)
        /// </summary>
        /// <param name="type">查询条件</param>
        /// <param name="date"></param>
        /// <returns></returns>
        public static ResultDTO GetCurrentActualReceipt(string type, DateEnum date)
        {
            string sql, condition = "";

            switch (date)
            {
            case DateEnum.Month:
                condition = "BelongYear = YEAR(getDate()) AND BeLongMonth = MONTH(getDate())";
                break;

            case DateEnum.Quarter:
                condition = "BelongYear = YEAR(getDate()) AND BelongQuarter = datepart(quarter,getdate())";
                break;

            case DateEnum.Week:
                condition = "(ArrivedDate between dateadd(wk, datediff(wk,0,getdate()), 0)  and getdate())";
                break;
            }

            var db = new MarketContext();

            EnumQueryType con = (EnumQueryType)System.Enum.Parse(typeof(EnumQueryType), type);

            switch (con)
            {
            case EnumQueryType.Customer:
                sql = @"select CustomerID as ID,CustomerName AS Name
                            ,Convert(decimal(18,2),isnull(SUM(Amount),0)/10000) AS TotalMoney
                            ,count(distinct ContractInfoID)  as ContractCount
                            ,COUNT(DISTINCT ID) AS RecordNum from S_C_Receipt WHERE {0} 
                            GROUP BY CustomerName,CustomerID
                            ORDER BY TotalMoney DESC";
                break;

            case EnumQueryType.Department:
                sql = @"SELECT ReceiptMasterUnitID as ID,ReceiptMasterUnit as Name
                            ,Convert(decimal(18,2),isnull(SUM(Amount),0)/10000) AS TotalMoney
                            ,count(distinct ContractInfoID) as ContractCount
                            ,COUNT(DISTINCT CustomerID) AS RecordNum  
                            FROM S_C_Receipt WHERE {0} 
                            GROUP BY ReceiptMasterUnit,ReceiptMasterUnitID
                            ORDER BY TotalMoney DESC";
                break;

            case EnumQueryType.NotGroup:
                sql = @"select ContractInfoID as ID,ContractName as Name,
                            COUNT(ContractName) AS RecordNum,
                            Convert(decimal(18,2),isnull(SUM(Amount)/10000,0)) AS ReceiptValue,
                            MAX(ArrivedDate) AS LastTime from S_C_Receipt WHERE {0}
                            GROUP BY ContractName,ContractInfoID
                            ORDER BY ReceiptValue DESC";
                return(WebApi.Success(db.Database.SqlQuery <ContractBll>(string.Format(sql, condition))));

            default:
                return(WebApi.Error(EnumException.请求参数不合法));
            }
            return(WebApi.Success(db.Database.SqlQuery <BusinessDetailBll>(string.Format(sql, condition))));
        }
コード例 #3
0
        private List <string> BuildDatePeriod(DateEnum choosen_date)
        {
            List <string> datePeriod = new List <string>();

            switch (choosen_date)
            {
            case DateEnum.Month:
            {
                for (int i = countColumn - 1; i >= 0; i--)
                {
                    datePeriod.Add((DateTime.Now.AddMonths(-i).ToString("MMM")));
                }
                break;
            }


            case DateEnum.Week:
            {
                for (int i = countColumn - 1; i >= 0; i--)
                {
                    DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
                    Calendar           cal = dfi.Calendar;
                    var currentDate        = DateTime.Now.AddDays(-7 * i);
                    var weekNum            = cal.GetWeekOfYear(currentDate, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
                    datePeriod.Add(weekNum.ToString());
                }
                break;
            }

            case DateEnum.Day:
            {
                for (int i = countColumn - 1; i >= 0; i--)
                {
                    datePeriod.Add((DateTime.Now.AddDays(-i).ToString("dd")));
                }
                break;
            }

            default:
            {
                //DateEnum.Day
                for (int i = countColumn - 1; i >= 0; i--)
                {
                    datePeriod.Add((DateTime.Now.AddDays(-i).ToString("dd")));
                }
                break;
            }
            }

            return(datePeriod);
        }
コード例 #4
0
ファイル: ContractBll.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 获取实际收款详情(当季、当月、本周)
        /// </summary>
        /// <param name="type">查询条件</param>
        /// <param name="date"></param>
        /// <param name="id">客户ID或部门ID</param>
        /// <returns></returns>
        public static ResultDTO GetCurrentActualReceipt(string type, DateEnum date, string id)
        {
            string condition = "", idName = "";

            switch (date)
            {
            case DateEnum.Month:
                condition = "BelongYear = YEAR(getDate()) AND BeLongMonth = MONTH(getDate())";
                break;

            case DateEnum.Quarter:
                condition = "BelongYear = YEAR(getDate()) AND BelongQuarter = datepart(quarter,getdate())";
                break;

            case DateEnum.Week:
                condition = "(ArrivedDate between dateadd(wk, datediff(wk,0,getdate()), 0)  and getdate())";
                break;
            }

            var db = new MarketContext();

            EnumQueryType con = (EnumQueryType)System.Enum.Parse(typeof(EnumQueryType), type);

            switch (con)
            {
            case EnumQueryType.Customer:
                idName = "con.CustomerID";
                break;

            case EnumQueryType.Department:
                idName = "ReceiptMasterUnitID";
                break;

            default:
                return(WebApi.Error(EnumException.请求参数不合法));
            }
            var sql = @"SELECT con.ContractID as ID,con.ContractName as Name,COUNT(ID) AS RecordNum,
                        Convert(decimal(18,2),isnull(SUM(Amount),0)/10000) AS ReceiptValue,
                        MAX(ArrivedDate) AS LastTime FROM S_C_Receipt left join
                        (
	                        SELECT ID as ContractID,Name as ContractName,PartyA as CustomerID 
	                        FROM S_C_ManageContract WHERE  IsSigned='Signed'
                        )con on S_C_Receipt.CustomerID=con.CustomerID and S_C_Receipt.ContractInfoID=con.ContractID
                        WHERE {0} = '{1}'  AND {2}
                        GROUP BY con.ContractName,con.ContractID
                        ORDER BY ReceiptValue DESC";

            return(WebApi.Success(db.Database.SqlQuery <ContractBll>(string.Format(sql, idName, id, condition))));
        }
コード例 #5
0
ファイル: ContractBll.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 获取已签合同详情(当季、当月、本周)和待签合同额(当年)
        /// </summary>
        /// <param name="type"></param>
        /// <param name="date"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static ResultDTO GetCurrentContract(string type, DateEnum date, string id)
        {
            string sql, condition = "", idName = "";

            switch (date)
            {
            case DateEnum.Quarter:
                condition = "IsSigned='Signed' and BelongYear = YEAR(getDate()) AND BelongQuarter=datepart(quarter,getdate())";
                break;

            case DateEnum.Month:
                condition = "IsSigned='Signed' and BelongYear = YEAR(getDate()) AND BelongMonth=datepart(month,getdate())";
                break;

            case DateEnum.Week:
                condition = "IsSigned='Signed' and SignDate between dateadd(wk, datediff(wk,0,getdate()), 0) and getdate()";
                break;

            case DateEnum.Year:
                condition = "IsSigned!='Signed' --and BelongYear=datepart(year,getdate())";
                break;
            }

            var db = new MarketContext();

            EnumQueryType con = (EnumQueryType)System.Enum.Parse(typeof(EnumQueryType), type);

            switch (con)
            {
            case EnumQueryType.Customer:
                idName = "PartyA";
                break;

            //case EnumQueryType.Department:
            //    idName = "HeadOfSalesDeptID";
            //    break;
            case EnumQueryType.ManagerUser:
                idName = "BusinessManager";
                break;

            default:
                return(WebApi.Error(EnumException.请求参数不合法));
            }
            sql = @"select ID,Name,Convert(decimal(18,2),isnull(ContractRMBAmount,0)/10000) as ReceiptValue,
                            SignDate,BusinessManagerName as UserName from S_C_ManageContract
                            where {0} and {1}='{2}'
                            order by ReceiptValue desc";
            return(WebApi.Success(db.Database.SqlQuery <ContractBll>(string.Format(sql, condition, idName, id))));
        }
コード例 #6
0
        private GraficViewModel InitAndGetGraficViewModel(ModeEnum choosen_mode, DateEnum choosen_date)
        {
            List <double> values = BuildValues(choosen_mode, choosen_date);

            List <double> fillPercentage = BuildPercentage(values);

            List <string> datePeriod = BuildDatePeriod(choosen_date);

            return(new GraficViewModel()
            {
                Values = values.ConvertAll <string>(o => o.ToString()),
                FillPercentage = fillPercentage,
                DatePeriod = datePeriod
            });
        }
コード例 #7
0
        private static MvcHtmlString GetDatePickerHtml(HtmlHelper html, string name, DateEnum dateEnum, string value, ValidateOptions validateOptions)
        {
            DatePicketModel model = new DatePicketModel {
                Name     = name,
                DateType = dateEnum
            };

            html.RenderPartial("~/Views/ControlScripts/_DatePicketScripts.cshtml", model);
            List <string> keyList  = new List <string>();
            StringBuilder builder  = new StringBuilder();
            TagBuilder    builder2 = new TagBuilder("input");

            builder2.GenerateId(name);
            builder2.MergeAttribute("type", "text");
            builder2.MergeAttribute("name", name);
            builder2.MergeAttribute("readonly", "readonly");
            if (!string.IsNullOrEmpty(value))
            {
                builder2.MergeAttribute("value", value);
            }
            bool flag = false;

            if (validateOptions != null)
            {
                builder2.MergeAttribute("data-bvalidator", ValidateCommon.GetValidateAttr(validateOptions));
                if (validateOptions.Required)
                {
                    flag = true;
                }
                if (!string.IsNullOrEmpty(validateOptions.ErrorMsg))
                {
                    builder2.MergeAttribute("data-bvalidator-msg", validateOptions.ErrorMsg);
                }
            }
            builder.AppendLine(builder2.ToString());
            builder.AppendLine(CtrlScripts.RenderScript(html, keyList));
            return(MvcHtmlString.Create((flag ? "<span class='star'>*</span>" : "<span class='star'>&nbsp</span>") + builder.ToString()));
        }
コード例 #8
0
ファイル: ContractBll.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 获取计划收款详情(本年、本年后、本季、本季后、本月、本月后)
        /// </summary>
        /// <param name="type">查询条件</param>
        /// <param name="date"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static ResultDTO GetCurrentPlanReceipt(string type, DateEnum date, string id)
        {
            string sql, condition = "", idName = "";

            switch (date)
            {
            case DateEnum.Year:
                condition = "S_C_PlanReceipt.BelongYear <= YEAR(getdate())";
                break;

            case DateEnum.AfterYear:
                condition = "S_C_PlanReceipt.BelongYear > datepart(year,getdate()) OR S_C_PlanReceipt.BelongYear = NULL";
                break;

            case DateEnum.Quarter:
                condition = "S_C_PlanReceipt.BelongYear <= datepart(year,getdate()) AND S_C_PlanReceipt.BelongQuarter <= datepart(quarter,getdate())";
                break;

            case DateEnum.AfterQuarter:
                condition =
                    "(S_C_PlanReceipt.BelongYear = datepart(year,getdate()) AND S_C_PlanReceipt.BelongQuarter > datepart(quarter,getdate())) OR(S_C_PlanReceipt.BelongYear > datepart(year,getdate())) OR (S_C_PlanReceipt.BelongYear = NULL OR S_C_PlanReceipt.BelongQuarter = NULL)";
                break;

            case DateEnum.Month:
                condition = "S_C_PlanReceipt.BelongYear <= datepart(year,getdate()) AND S_C_PlanReceipt.BelongMonth <= datepart(month,getdate())";
                break;

            case DateEnum.AfterMonth:
                condition =
                    "(S_C_PlanReceipt.BelongYear = datepart(year,getdate()) AND S_C_PlanReceipt.BelongMonth >datepart(month,getdate())) OR (S_C_PlanReceipt.BelongYear > datepart(year,getdate())) OR (S_C_PlanReceipt.BelongYear = NULL OR S_C_PlanReceipt.BelongQuarter = NULL OR S_C_PlanReceipt.BelongMonth = NULL)";
                break;
            }

            var db = new MarketContext();

            EnumQueryType con = (EnumQueryType)System.Enum.Parse(typeof(EnumQueryType), type);

            switch (con)
            {
            case EnumQueryType.Customer:
                idName = "S_C_PlanReceipt.CustomerId";
                break;

            case EnumQueryType.Department:
                idName = "S_C_PlanReceipt.ProductionUnitID";
                break;

            case EnumQueryType.ManagerUser:
                idName = "S_C_PlanReceipt.FirstDutyManID";
                break;

            default:
                return(WebApi.Error(EnumException.请求参数不合法));
            }
            sql = @"SELECT Convert(decimal(18,2),isnull(SUM(PlanReceiptValue-ISNULL(FactReceiptValue,0)),0)/10000) AS ReceiptValue,
                    ContractInfoID as ID,mc.Name as Name FROM S_C_PlanReceipt
                    LEFT JOIN S_C_ManageContract mc
                    ON S_C_PlanReceipt.ContractInfoID=mc.ID
                    WHERE {0} = '{1}' and S_C_PlanReceipt.State in ('UnReceipt') AND {2}
                    GROUP BY ContractInfoID,mc.Name
                    ORDER BY ReceiptValue DESC";
            return(WebApi.Success(db.Database.SqlQuery <ContractBll>(string.Format(sql, idName, id, condition))));
        }
コード例 #9
0
ファイル: BusinessDetailBll.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 获取已签合同(当季、当月、本周)和待签合同额(当年)
        /// </summary>
        /// <param name="type"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public static ResultDTO GetCurrentContract(string type, DateEnum date)
        {
            string sql, condition = "";

            switch (date)
            {
            case DateEnum.Quarter:
                condition = "IsSigned='Signed' and BelongYear = YEAR(getDate()) AND BelongQuarter=datepart(quarter,getdate())";
                break;

            case DateEnum.Month:
                condition = "IsSigned='Signed' and BelongYear = YEAR(getDate()) AND BelongMonth=datepart(month,getdate())";
                break;

            case DateEnum.Week:
                condition = "IsSigned='Signed' and SignDate between dateadd(wk, datediff(wk,0,getdate()), 0) and getdate()";
                break;

            case DateEnum.Year:
                condition = "IsSigned!='Signed' --and BelongYear=datepart(year,getdate())";
                break;
            }

            var db = new MarketContext();

            EnumQueryType con = (EnumQueryType)System.Enum.Parse(typeof(EnumQueryType), type);

            switch (con)
            {
            case EnumQueryType.Customer:
                sql = @"select PartyA as ID,PartyAName as Name,
                            Convert(decimal(18,2),isnull(Sum(ContractRMBAmount),0)/10000) as TotalMoney 
                            ,count(distinct ID) ContractCount
                            from S_C_ManageContract
                            where {0}
                            GROUP BY PartyA,PartyAName
                            ORDER BY TotalMoney DESC";
                break;

//                case EnumQueryType.Department:
//                    sql = @"select HeadOfSalesDeptID as ID,HeadOfSalesDeptName as Name,
//                            Convert(decimal(18,2),isnull(Sum(ContractRMBAmount),0)/10000) as TotalMoney
//                            ,count(distinct ID) ContractCount
//                            from S_C_ManageContract
//                            where {0}
//                            group by HeadOfSalesDeptID,HeadOfSalesDeptName
//                            ORDER BY TotalMoney DESC";
//                    break;
            case EnumQueryType.NotGroup:
                sql = @"select ID,Name,Convert(decimal(18,2),isnull(ContractRMBAmount,0)/10000) as ReceiptValue,
                            SignDate from S_C_ManageContract
                            where {0}
                            order by ReceiptValue desc";
                return(WebApi.Success(db.Database.SqlQuery <ContractBll>(string.Format(sql, condition))));

            default:
                sql = @"select BusinessManager as ID,BusinessManagerName as Name,
                        Convert(decimal(18,2),isnull(Sum(ContractRMBAmount),0)/10000) as TotalMoney 
                        ,count(distinct ID) ContractCount
                        from S_C_ManageContract
                        where {0}
                        group by BusinessManager,BusinessManagerName
                        ORDER BY TotalMoney DESC";
                break;
            }
            return(WebApi.Success(db.Database.SqlQuery <BusinessDetailBll>(string.Format(sql, condition))));
        }
コード例 #10
0
ファイル: BusinessDetailBll.cs プロジェクト: tianzhifeng/EPC
        /// <summary>
        /// 获取计划收款(本年、本年后、本季、本季后、本月、本月后)
        /// </summary>
        /// <param name="type">查询条件</param>
        /// <param name="date"></param>
        /// <returns></returns>
        public static ResultDTO GetCurrentPlanReceipt(string type, DateEnum date)
        {
            string sql, condition = "";

            switch (date)
            {
            case DateEnum.Year:
                condition = "S_C_PlanReceipt.BelongYear <= YEAR(getdate()) ";
                break;

            case DateEnum.AfterYear:
                condition = "(S_C_PlanReceipt.BelongYear > datepart(year,getdate()) OR S_C_PlanReceipt.BelongYear = NULL)";
                break;

            case DateEnum.Quarter:
                condition = "(S_C_PlanReceipt.BelongYear <= datepart(year,getdate()) AND S_C_PlanReceipt.BelongQuarter <= datepart(quarter,getdate()))";
                break;

            case DateEnum.AfterQuarter:
                condition =
                    "((S_C_PlanReceipt.BelongYear = datepart(year,getdate()) AND S_C_PlanReceipt.BelongQuarter > datepart(quarter,getdate())) OR(S_C_PlanReceipt.BelongYear > datepart(year,getdate())) OR (S_C_PlanReceipt.BelongYear = NULL OR S_C_PlanReceipt.BelongQuarter = NULL))";
                break;

            case DateEnum.Month:
                condition = "(S_C_PlanReceipt.BelongYear <= datepart(year,getdate()) AND S_C_PlanReceipt.BelongMonth <= datepart(month,getdate()))";
                break;

            case DateEnum.AfterMonth:
                condition =
                    "((S_C_PlanReceipt.BelongYear = datepart(year,getdate()) AND S_C_PlanReceipt.BelongMonth >datepart(month,getdate())) OR (S_C_PlanReceipt.BelongYear > datepart(year,getdate())) OR (S_C_PlanReceipt.BelongYear = NULL OR S_C_PlanReceipt.BelongQuarter = NULL OR S_C_PlanReceipt.BelongMonth = NULL))";
                break;
            }

            var db = new MarketContext();

            EnumQueryType con = (EnumQueryType)System.Enum.Parse(typeof(EnumQueryType), type);

            switch (con)
            {
            case EnumQueryType.Customer:
                sql = @"SELECT Convert(decimal(18,2),isnull(SUM(PlanReceiptValue-ISNULL(FactReceiptValue,0))/10000,0)) as TotalMoney, 
                            CustomerId as ID,CustomerName as Name,count(distinct ContractInfoID) as ContractCount 
                            FROM S_C_PlanReceipt
                            WHERE S_C_PlanReceipt.State ='UnReceipt' and {0}
                            GROUP BY CustomerId,CustomerName
                            ORDER BY TotalMoney DESC";
                break;

            case EnumQueryType.Department:
                sql = @"SELECT Convert(decimal(18,2),isnull(SUM(PlanReceiptValue-ISNULL(FactReceiptValue,0))/10000,0)) AS TotalMoney,
                            ProductionUnitID as ID,ProductionUnitName as Name,count(distinct ContractInfoID) as ContractCount  
                            FROM S_C_PlanReceipt WHERE S_C_PlanReceipt.State ='UnReceipt' and {0}
                            GROUP BY ProductionUnitID,ProductionUnitName
                            ORDER BY TotalMoney DESC";
                break;

            case EnumQueryType.NotGroup:
                sql = @"SELECT Convert(decimal(18,2),isnull(SUM(PlanReceiptValue-ISNULL(FactReceiptValue,0))/10000,0)) AS ReceiptValue
                            ,S_C_PlanReceipt.ContractInfoID as ID,mc.Name as Name,
                            case when ISNULL(FirstDutyManName,'')='' then '未安排' else ISNULL(FirstDutyManName,'') end as UserName
                            FROM S_C_PlanReceipt LEFT JOIN S_C_ManageContract mc
							ON S_C_PlanReceipt.ContractInfoID=mc.ID
                            WHERE S_C_PlanReceipt.State ='UnReceipt' and {0}
                            GROUP BY S_C_PlanReceipt.ContractInfoID,mc.Name,FirstDutyManName
                            ORDER BY ReceiptValue DESC";
                return(WebApi.Success(db.Database.SqlQuery <ContractBll>(string.Format(sql, condition))));

            default:
                sql = @"SELECT Convert(decimal(18,2),isnull(SUM(PlanReceiptValue-ISNULL(FactReceiptValue,0))/10000,0)) AS TotalMoney,
                        ISNULL(FirstDutyManID,'') as ID,
                        case when ISNULL(FirstDutyManName,'')='' then '未安排' else ISNULL(FirstDutyManName,'') end as Name
                        ,count(distinct ContractInfoID) as ContractCount FROM S_C_PlanReceipt
                        WHERE S_C_PlanReceipt.State ='UnReceipt' and {0}
                        GROUP BY ISNULL(FirstDutyManID,''),ISNULL(FirstDutyManName,'')
                        ORDER BY TotalMoney DESC";
                break;
            }
            return(WebApi.Success(db.Database.SqlQuery <BusinessDetailBll>(string.Format(sql, condition))));
        }
コード例 #11
0
ファイル: DbMethod.cs プロジェクト: 514933266/OneForAll.Core
 /// <summary>
 /// 计算时间差(仅用于数据库表达式解析)
 /// </summary>
 /// <param name="type">计算类型</param>
 /// <param name="startdate">时间(被减数)</param>
 /// <param name="enddate">时间(减数)</param>
 /// <returns>0</returns>
 public int DateDiff(DateEnum type, object startdate, object enddate)
 {
     return(0);
 }
コード例 #12
0
        public static MvcHtmlString KingDatePickerFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TProperty> > expression, DateEnum dateEnum, string value = null, ValidateOptions validateOptions = null)
        {
            ModelMetadata metadata       = ModelMetadata.FromLambdaExpression <TModel, TProperty>(expression, helper.ViewData);
            string        expressionText = ExpressionHelper.GetExpressionText(expression);

            if (metadata.Model != null)
            {
                DateTime time = Convert.ToDateTime(metadata.Model);
                value = (dateEnum == DateEnum.DateTime) ? time.ToString("yyyy-MM-dd HH:mm:ss") : time.ToString("yyyy-MM-dd");
            }
            return(GetDatePickerHtml(helper, expressionText, dateEnum, value, validateOptions));
        }
コード例 #13
0
 public static MvcHtmlString KingDatePicker(this HtmlHelper helper, string name, DateEnum dateEnum, string value = null, ValidateOptions validateOptions = null)
 {
     return(GetDatePickerHtml(helper, name, dateEnum, value, validateOptions));
 }
コード例 #14
0
        private List <double> BuildValues(ModeEnum choosen_mode, DateEnum choosen_date)
        {
            List <double> values = new List <double>();

            List <IQueryable <Order> > queries = new List <IQueryable <Order> >();

            switch (choosen_date)
            {
            case DateEnum.Month:
            {
                for (int i = countColumn - 1; i >= 0; i--)
                {
                    DateTime date = DateTime.Now.Date.AddMonths(-i);
                    queries.Add(db.Orders.Where(o =>
                                                o.ClosedDate.Year.Equals(date.Year) &&
                                                o.ClosedDate.Month.Equals(date.Month)
                                                ));
                }
                break;
            }

            case DateEnum.Week:
            {
                DateTimeFormatInfo dateTimeInfo = DateTimeFormatInfo.CurrentInfo;
                Calendar           cal          = dateTimeInfo.Calendar;

                for (int i = countColumn - 1; i >= 0; i--)
                {
                    DateTime date = DateTime.Now.Date.AddDays(7 * -i);
                    int      week = cal.GetWeekOfYear(date, dateTimeInfo.CalendarWeekRule, dateTimeInfo.FirstDayOfWeek);
                    queries.Add(db.Orders.Where(o =>
                                                o.ClosedDate.Year.Equals(date.Year) &&
                                                ((o.ClosedDate.DayOfYear - 1) / 7 + 1).Equals(week)));
                }
                break;
            }

            case DateEnum.Day:
            {
                for (int i = countColumn - 1; i >= 0; i--)
                {
                    DateTime date = DateTime.Now.Date.AddDays(-i);
                    queries.Add(db.Orders.Where(o => o.ClosedDate.Date.Equals(date)));
                }
                break;
            }

            default:
            {
                //DateEnum.Day
                for (int i = countColumn - 1; i >= 0; i--)
                {
                    DateTime date = DateTime.Now.Date.AddDays(-i);
                    queries.Add(db.Orders.Where(o => o.ClosedDate.Date.Equals(date)));
                }
                break;
            }
            }

            switch (choosen_mode)
            {
            case ModeEnum.NumberOrders:
            {
                for (int i = 0; i < countColumn; i++)
                {
                    values.Add(queries[i].Count());
                }
                break;
            }

            case ModeEnum.Money:
            {
                for (int i = 0; i < countColumn; i++)
                {
                    values.Add(queries[i].Sum(o => o.TotalPrice));
                }
                break;
            }
            }

            return(values);
        }
コード例 #15
0
        public IActionResult ShowGrafic(ModeEnum choosen_mode, DateEnum choosen_date)
        {
            GraficViewModel graficViewModel = InitAndGetGraficViewModel(choosen_mode, choosen_date);

            return(PartialView(graficViewModel));
        }