Ejemplo n.º 1
0
        public TimeSpan GetTotalLastMonth()
        {
            DateTime start = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);

            start = start.AddMonths(-1);
            DateTime end = start.AddMonths(1);

            return(GetTotal(start, end));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Only for test pupropse
        /// </summary>
        private void InitializeWithSomeSmsRecords()
        {
            vSMSMessages = new List <Message>(99);
            for (int i = 0; i < 99; ++i)
            {
                vSMSMessages.Add(new Message());
            }

            var date = new System.DateTime(2000, 1, 1);

            for (int i = 0; i < 99; i += 3)
            {
                vSMSMessages[i].PhoneNumber   = 11111111;
                vSMSMessages[i].UserName      = "******";
                vSMSMessages[i].ReceivingTime = date.AddDays(i);

                vSMSMessages[i + 1].PhoneNumber   = 22222222;
                vSMSMessages[i + 1].UserName      = "******";
                vSMSMessages[i + 1].ReceivingTime = date.AddDays(i + 1);

                vSMSMessages[i + 2].PhoneNumber   = 33333333;
                vSMSMessages[i + 2].UserName      = "******";
                vSMSMessages[i + 2].ReceivingTime = date.AddDays(i + 2);
                date = date.AddMonths(6);
            }

            for (int i = 0; i < 99; ++i)
            {
                vSMSMessages[i].Text = $"[{vSMSMessages[i].ReceivingTime}] Generated message #{i}.";
            }
        }
Ejemplo n.º 3
0
        public static DateObject OffsetDateObject(DateObject date, int offset, DatePeriodTimexType timexType)
        {
            DateObject result;

            switch (timexType)
            {
            case DatePeriodTimexType.ByYear:
                result = date.AddYears(offset);
                break;

            case DatePeriodTimexType.ByMonth:
                result = date.AddMonths(offset);
                break;

            case DatePeriodTimexType.ByWeek:
                result = date.AddDays(7 * offset);
                break;

            case DatePeriodTimexType.ByDay:
                result = date.AddDays(offset);
                break;

            default:
                result = date;
                break;
            }

            return(result);
        }
        public decimal GetTotalMoneyByMonth(int year, int month, bool isOut)
        {
            System.DateTime beginDate = new System.DateTime(year, month, 01);
            System.DateTime endDate   = beginDate.AddMonths(1);
            int             beginDay  = System.DateTimeExtensions.ToDayNumber(beginDate);
            int             endDay    = System.DateTimeExtensions.ToDayNumber(endDate);

            return(TypeExtensions.Convert <decimal>(_dataContext.ExecuteScalar("select sum([Money]) as p from [FundsConsumeTypeDay] where [UserId]=@p1 and [Day]>=@p2 and [Day]<@p3 and [IsOut]=@p4", Program.CurrentUser.Id, beginDay, endDay, isOut), 0M));
        }
Ejemplo n.º 5
0
        public InitFormData()
        {
            FactoryWarehouse = new List <FactoryWarehouseDTO>();
            ProductionTeam   = new List <Support.DTO.ProductionTeam>();

            /// Start date: first date current date
            /// End date: last date current date
            System.DateTime currentDate = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, 1);
            StartDate = currentDate.ToString("dd/MM/yyyy");
            EndDate   = currentDate.AddMonths(1).AddDays(-1).ToString("dd/MM/yyyy");
        }
Ejemplo n.º 6
0
 protected override void OnMonthChanged()
 {
     System.DateTime current = this.Month;
     if (current.Month != last.Month || current.Year != last.Year)
     {
         System.Console.WriteLine("Month thinks is changed {0} {1}", last.ToString(), current.ToString());
         last        = current;
         query.Range = new DateRange(current, current.AddMonths(1));
     }
     base.OnMonthChanged();
 }
Ejemplo n.º 7
0
        public CalendarView(Context context, System.DateTime currentDate) : base(context, Resource.Style.cust_dialog)
        {
            currentContext = context;
//            Window.RequestFeature(Android.Views.WindowFeatures.NoTitle);

            if (currentDate > new System.DateTime(1970, 1, 1, 0, 0, 0))
            {
                currentDate = currentDate.AddMonths(-1);

                month.Set(currentDate.Year, currentDate.Month, currentDate.Day);
            }
        }
Ejemplo n.º 8
0
        public void OrderDetailsDateFilterFunctioning()
        {
            // The date filter should block any order number search
            // that is before the specified date
            var db           = new Database();
            var orderOne     = db.FetchOrderDetails(1);
            var orderOneDict = orderOne.First() as IDictionary <string, object>;

            System.DateTime orderOneDate = (System.DateTime)orderOneDict["order_date"];

            var goodStartDate = orderOneDate.AddMonths(-1).ToString("yyyy-MM-dd");
            var badStartDate  = orderOneDate.AddMonths(1).ToString("yyyy-MM-dd");

            var goodResult = db.FetchDateFilteredOrderDetails(1, goodStartDate);

            Assert.True(goodResult.Count() > 0);

            var badResult = db.FetchDateFilteredOrderDetails(1, badStartDate);

            Assert.True(badResult.Count() == 0);
        }
Ejemplo n.º 9
0
        private bool BoolMethod()
        {
            System.Type c    = GetType();
            string      name = Name;

            Name = name;
            System.DateTime cal = System.DateTime.Now;
            int             min = cal.Minute;

            cal.AddMonths(7 - cal.Month);
            cal.AddHours(12);
            return(base.ExistSimilarFieldAndMethod());
        }
Ejemplo n.º 10
0
        public override CompileResult Execute(IEnumerable <FunctionArgument> arguments, ParsingContext context)
        {
            ValidateArguments(arguments, 3);
            var year  = ArgToInt(arguments, 0);
            var month = ArgToInt(arguments, 1);
            var day   = ArgToInt(arguments, 2);
            var date  = new System.DateTime(year, 1, 1);

            month -= 1;
            date   = date.AddMonths(month);
            date   = date.AddDays((double)(day - 1));
            return(CreateResult(date.ToOADate(), DataType.Date));
        }
        public void AddMonths_ShouldMimicSystem()
        {
            var anyDateTimeTicks = 200;
            var anyMonths = 5;

            var sut = new Abstractions.DateTime(anyDateTimeTicks);
            var systemDateTime = new System.DateTime(anyDateTimeTicks);

            //  Act.
            var res = sut.AddMonths(anyMonths);

            //  Assert.
            var expectedResult = systemDateTime.AddMonths(anyMonths);
            AssertEquals(expectedResult, res);
        }
Ejemplo n.º 12
0
        public GetApprenticeshipSteps(TestContext context)
        {
            _context    = context;
            _apprentice = _fixture.Build <Apprentice>().Create();

            var startDate = new System.DateTime(2000, 01, 01);

            _fixture.Inject(new CourseDetails("", 1, null,
                                              startDate, startDate.AddMonths(32)));

            _apprenticeship = _fixture.Build <Apprenticeship>()
                              .Do(a => a.ConfirmTrainingProvider(true))
                              .Do(a => a.ConfirmEmployer(true))
                              .Do(a => a.ConfirmApprenticeshipDetails(true))
                              .Do(a => a.ConfirmHowApprenticeshipWillBeDelivered(true))
                              .Create();
        }
Ejemplo n.º 13
0
        public TimeSpan GetMonthlyAverage()
        {
            DateTime start       = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
            DateTime end         = start.AddMonths(1);
            TimeSpan monthTotal  = GetTotal(start, end);
            int      workingDays = 0;
            DateTime today       = DateTime.Today;

            for (DateTime index = start; index <= today; index = index.AddDays(1))
            {
                if (index.DayOfWeek != DayOfWeek.Saturday && index.DayOfWeek != DayOfWeek.Sunday)
                {
                    workingDays++;
                }
            }
            return(new TimeSpan(monthTotal.Ticks / workingDays));
        }
Ejemplo n.º 14
0
        public IEnumerable <ReportItem <TValue> > GenerateByMonth <TValue>(System.DateTime?from = null, System.DateTime?to = null)
        {
            System.DateTime f = from ?? _MIN, t = to ?? _MAX;

            while (f < t)
            {
                yield return(new ReportItem <TValue>
                {
                    Key = f.Year * 100 + f.Month,
                    Month = f.Month,
                    MonthName = DateUtility.GetMonthName(f.Month),
                    Year = f.Year,
                });

                f = f.AddMonths(1);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Converts a string value to a System.DateTime
        /// </summary>
        /// <param name="value">
        /// The date string.
        /// </param>
        /// <param name="format">
        /// The format where 103 = dd/MM/yyyy
        /// </param>
        /// <returns>
        /// A System.DateTime
        /// </returns>
        /// <exception cref="System.Exception">
        /// Exception is thrown if the given string value does not meet the expected format.
        /// </exception>
        public static System.DateTime ToDateTime(this string value, int format)
        {
            var result = new System.DateTime();

            switch (format)
            {
            case 103:
                // Validate
                if ((!string.IsNullOrEmpty(value)) && System.Text.RegularExpressions.Regex.IsMatch(value.Trim(), "^(((0[1-9]|[12]\\d|3[01])\\/(0[13578]|1[02])\\/((1[6-9]|[2-9]\\d)\\d{2}))|((0[1-9]|[12]\\d|30)\\/(0[13456789]|1[012])\\/((1[6-9]|[2-9]\\d)\\d{2}))|((0[1-9]|1\\d|2[0-8])\\/02\\/((1[6-9]|[2-9]\\d)\\d{2}))|(29\\/02\\/((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$"))
                {
                    // Build
                    var dateParts = value.Trim().Split(System.Convert.ToChar("/"));
                    result = result.AddYears(System.Convert.ToInt32(dateParts[2]) - 1);
                    result = result.AddMonths(System.Convert.ToInt32(dateParts[1]) - 1);
                    result = result.AddDays(System.Convert.ToInt32(dateParts[0]) - 1);
                }
                else
                {
                    throw new System.Exception($"String \"{value}\" is not of expected format \"{format}\".");
                }

                break;

            case -1:
                // Validate
                if ((!string.IsNullOrEmpty(value)) && value.Contains(" "))
                {
                    var strDate = value.Trim().Split(System.Convert.ToChar(" "));
                    if (strDate.Length == 2)
                    {
                        if (System.Text.RegularExpressions.Regex.IsMatch(strDate[0].Trim(), "^(((0[1-9]|[12]\\d|3[01])\\/(0[13578]|1[02])\\/((1[6-9]|[2-9]\\d)\\d{2}))|((0[1-9]|[12]\\d|30)\\/(0[13456789]|1[012])\\/((1[6-9]|[2-9]\\d)\\d{2}))|((0[1-9]|1\\d|2[0-8])\\/02\\/((1[6-9]|[2-9]\\d)\\d{2}))|(29\\/02\\/((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$"))
                        {
                            // Build
                            var dateParts = strDate[0].Trim().Split(System.Convert.ToChar("/"));
                            result = result.AddYears(System.Convert.ToInt32(dateParts[2]) - 1);
                            result = result.AddMonths(System.Convert.ToInt32(dateParts[1]) - 1);
                            result = result.AddDays(System.Convert.ToInt32(dateParts[0]) - 1);
                        }
                        else
                        {
                            throw new System.Exception($"String \"{value}\" is not of expected format \"{System.Convert.ToString(format)}\".");
                        }

                        if (System.Text.RegularExpressions.Regex.IsMatch(strDate[1].Trim(), "^([0-1][0-9]|[2][0-3]):([0-5][0-9])$"))
                        {
                            // Build
                            var timeParts = strDate[1].Trim().Split(System.Convert.ToChar(":"));
                            result = result.AddHours(System.Convert.ToInt32(timeParts[0]));
                            result = result.AddMinutes(System.Convert.ToInt32(timeParts[1]));
                        }
                        else
                        {
                            throw new System.Exception($"String \"{value}\" is not of expected format \"{System.Convert.ToString(format)}\".");
                        }
                    }
                    else
                    {
                        throw new System.Exception($"String \"{value}\" is not of expected format \"{System.Convert.ToString(format)}\".");
                    }
                }
                else
                {
                    throw new System.Exception($"String \"{value}\" is not of expected format \"{System.Convert.ToString(format)}\".");
                }

                break;
            }

            return(result);
        }
Ejemplo n.º 16
0
 public IDateTime AddMonths(int months)
 {
     return(new DateTime(backingDateTime.AddMonths(months).Ticks));
 }
Ejemplo n.º 17
0
        public static LoanAmortizationHeader GenerateLoanAmortization(
            string codeMember,
            string codeAccount,
            decimal amountLoan,
            int termLoan,
            decimal rateAnnualInterest,
            System.DateTime grantedDate,
            decimal monthlyCapitalBuildUp)
        {
            var schedule = new LoanAmortizationHeader();

            // Member Information
            var member = Nfmb.FindByCode(codeMember);

            schedule.MemberCode    = member.MemberCode;
            schedule.MemberName    = member.MemberName;
            schedule.MemberAddress = member.CompleteAddress();

            // Account Information
            var account = Account.FindByCode(codeAccount);

            schedule.AccountCode  = account.AccountCode;
            schedule.AccountTitle = account.AccountTitle;

            schedule.LoanAmount            = amountLoan;
            schedule.MonthlyCapitalBuildUp = monthlyCapitalBuildUp;
            schedule.AnnualInterestRate    = rateAnnualInterest;
            schedule.LoanTerm         = termLoan;
            schedule.ModeOfPayment    = "Monthly";
            schedule.DateGranted      = grantedDate;
            schedule.DateMaturity     = grantedDate.AddMonths(termLoan);
            schedule.FirstPaymentDate = grantedDate.AddMonths(1);

            var monthlyInterest = System.Math.Round((amountLoan * (schedule.AnnualInterestRate / 12)), 2);
            var monthlyPayment  = System.Math.Round((amountLoan / termLoan), 2);

            schedule.MonthlyAmortization = monthlyPayment + monthlyInterest + monthlyCapitalBuildUp;
            var runningBalance = amountLoan;

            for (int i = 1; i < termLoan; i++)
            {
                var item = new LoanAmortizationDetail();
                item.PaymentDate      = grantedDate.AddMonths(i);
                item.PaymentNo        = i;
                item.BeginningBalance = runningBalance;
                item.Payment          = monthlyPayment;
                item.Interest         = monthlyInterest;
                item.CapitalBuildUp   = schedule.MonthlyCapitalBuildUp;
                item.Amortization     = item.Payment + monthlyInterest + item.CapitalBuildUp;
                item.EndingBalance    = item.BeginningBalance - item.Payment;
                schedule.PaymentSchedules.Add(item);

                runningBalance = item.EndingBalance;
            }

            // Add final payment that, balancing discrepancies in monthly payment and amortization
            var lastpayment = new LoanAmortizationDetail();

            lastpayment.PaymentDate      = grantedDate.AddMonths(termLoan);
            lastpayment.PaymentNo        = termLoan;
            lastpayment.BeginningBalance = runningBalance;
            lastpayment.Payment          = amountLoan - schedule.PaymentSchedules.Sum(payment => payment.Payment);
            lastpayment.Interest         = monthlyInterest;
            lastpayment.CapitalBuildUp   = monthlyCapitalBuildUp;
            lastpayment.Amortization     = lastpayment.Payment + monthlyInterest + lastpayment.CapitalBuildUp;
            lastpayment.EndingBalance    = lastpayment.BeginningBalance - lastpayment.Payment;
            schedule.PaymentSchedules.Add(lastpayment);

            return(schedule);
        }
Ejemplo n.º 18
0
        public MainForm()
        {
            InitializeComponent();

            #region dataGridsInit
            var rep = new Model.Repository();

            var dateStart = new System.DateTime(2015, 10, 1);
            var dateEnd   = new System.DateTime(2016, 04, 01);

            var spentTimeList = (
                from total in rep.SpentTimeEvaluation(dateStart, dateEnd)
                join oct in rep.SpentTimeEvaluation(dateStart, dateStart.AddMonths(1)) on total.MemberId equals oct.MemberId
                into temp1
                from oct in temp1.DefaultIfEmpty()
                join nov in rep.SpentTimeEvaluation(dateStart.AddMonths(1), dateStart.AddMonths(2)) on total.MemberId equals nov.MemberId
                into temp2
                from nov in temp2.DefaultIfEmpty()
                join dec in rep.SpentTimeEvaluation(dateStart.AddMonths(2), dateStart.AddMonths(3)) on total.MemberId equals dec.MemberId
                into temp3
                from dec in temp3.DefaultIfEmpty()
                join jan in rep.SpentTimeEvaluation(dateStart.AddMonths(3), dateStart.AddMonths(4)) on total.MemberId equals jan.MemberId
                into temp4
                from jan in temp4.DefaultIfEmpty()
                join feb in rep.SpentTimeEvaluation(dateStart.AddMonths(4), dateStart.AddMonths(5)) on total.MemberId equals feb.MemberId
                into temp5
                from feb in temp5.DefaultIfEmpty()
                join mar in rep.SpentTimeEvaluation(dateStart.AddMonths(5), dateStart.AddMonths(6)) on total.MemberId equals mar.MemberId
                into temp6
                from mar in temp6.DefaultIfEmpty()
                join apr in rep.SpentTimeEvaluation(dateStart.AddMonths(6), dateStart.AddMonths(7)) on total.MemberId equals apr.MemberId
                into temp7
                from apr in temp7.DefaultIfEmpty()
                select new
            {
                MemberName = total.MemberName
                ,
                OctValue = oct?.Value
                ,
                NovValue = nov?.Value
                ,
                DecValue = dec?.Value
                ,
                JanValue = jan?.Value
                ,
                FebValue = feb?.Value
                ,
                MarValue = mar?.Value
                ,
                AprValue = apr?.Value
                ,
                TotalValue = total.Value
            }
                ).ToList();
            spentTimeGridView.DataSource = spentTimeList;

            var spentToEstimateList = (
                from total in rep.SpentToEstimateEvaluation(dateStart, dateEnd)
                join oct in rep.SpentToEstimateEvaluation(dateStart, dateStart.AddMonths(1)) on total.MemberId equals oct.MemberId
                into temp1
                from oct in temp1.DefaultIfEmpty()
                join nov in rep.SpentToEstimateEvaluation(dateStart.AddMonths(1), dateStart.AddMonths(2)) on total.MemberId equals nov.MemberId
                into temp2
                from nov in temp2.DefaultIfEmpty()
                join dec in rep.SpentToEstimateEvaluation(dateStart.AddMonths(2), dateStart.AddMonths(3)) on total.MemberId equals dec.MemberId
                into temp3
                from dec in temp3.DefaultIfEmpty()
                join jan in rep.SpentToEstimateEvaluation(dateStart.AddMonths(3), dateStart.AddMonths(4)) on total.MemberId equals jan.MemberId
                into temp4
                from jan in temp4.DefaultIfEmpty()
                join feb in rep.SpentToEstimateEvaluation(dateStart.AddMonths(4), dateStart.AddMonths(5)) on total.MemberId equals feb.MemberId
                into temp5
                from feb in temp5.DefaultIfEmpty()
                join mar in rep.SpentToEstimateEvaluation(dateStart.AddMonths(5), dateStart.AddMonths(6)) on total.MemberId equals mar.MemberId
                into temp6
                from mar in temp6.DefaultIfEmpty()
                join apr in rep.SpentToEstimateEvaluation(dateStart.AddMonths(6), dateStart.AddMonths(7)) on total.MemberId equals apr.MemberId
                into temp7
                from apr in temp7.DefaultIfEmpty()
                select new
            {
                MemberName = total.MemberName
                ,
                OctValue = oct?.Value
                ,
                NovValue = nov?.Value
                ,
                DecValue = dec?.Value
                ,
                JanValue = jan?.Value
                ,
                FebValue = feb?.Value
                ,
                MarValue = mar?.Value
                ,
                AprValue = apr?.Value
                ,
                TotalValue = total.Value
            }
                ).ToList();
            spentToEstimateGridView.DataSource = spentToEstimateList;

            var onFixList = (
                from total in rep.OnFixEvaluation(dateStart, dateEnd)
                join oct in rep.OnFixEvaluation(dateStart, dateStart.AddMonths(1)) on total.MemberId equals oct.MemberId
                into temp1
                from oct in temp1.DefaultIfEmpty()
                join nov in rep.OnFixEvaluation(dateStart.AddMonths(1), dateStart.AddMonths(2)) on total.MemberId equals nov.MemberId
                into temp2
                from nov in temp2.DefaultIfEmpty()
                join dec in rep.OnFixEvaluation(dateStart.AddMonths(2), dateStart.AddMonths(3)) on total.MemberId equals dec.MemberId
                into temp3
                from dec in temp3.DefaultIfEmpty()
                join jan in rep.OnFixEvaluation(dateStart.AddMonths(3), dateStart.AddMonths(4)) on total.MemberId equals jan.MemberId
                into temp4
                from jan in temp4.DefaultIfEmpty()
                join feb in rep.OnFixEvaluation(dateStart.AddMonths(4), dateStart.AddMonths(5)) on total.MemberId equals feb.MemberId
                into temp5
                from feb in temp5.DefaultIfEmpty()
                join mar in rep.OnFixEvaluation(dateStart.AddMonths(5), dateStart.AddMonths(6)) on total.MemberId equals mar.MemberId
                into temp6
                from mar in temp6.DefaultIfEmpty()
                join apr in rep.OnFixEvaluation(dateStart.AddMonths(6), dateStart.AddMonths(7)) on total.MemberId equals apr.MemberId
                into temp7
                from apr in temp7.DefaultIfEmpty()
                select new
            {
                MemberName = total.MemberName
                ,
                OctValue = oct?.Value
                ,
                NovValue = nov?.Value
                ,
                DecValue = dec?.Value
                ,
                JanValue = jan?.Value
                ,
                FebValue = feb?.Value
                ,
                MarValue = mar?.Value
                ,
                AprValue = apr?.Value
                ,
                TotalValue = total.Value
            }
                ).ToList();
            onFixGridView.DataSource = onFixList;

            var outOfHoursList = (
                from total in rep.OutOfHoursEvaluation(dateStart, dateEnd)
                join oct in rep.OutOfHoursEvaluation(dateStart, dateStart.AddMonths(1)) on total.MemberId equals oct.MemberId
                into temp1
                from oct in temp1.DefaultIfEmpty()
                join nov in rep.OutOfHoursEvaluation(dateStart.AddMonths(1), dateStart.AddMonths(2)) on total.MemberId equals nov.MemberId
                into temp2
                from nov in temp2.DefaultIfEmpty()
                join dec in rep.OutOfHoursEvaluation(dateStart.AddMonths(2), dateStart.AddMonths(3)) on total.MemberId equals dec.MemberId
                into temp3
                from dec in temp3.DefaultIfEmpty()
                join jan in rep.OutOfHoursEvaluation(dateStart.AddMonths(3), dateStart.AddMonths(4)) on total.MemberId equals jan.MemberId
                into temp4
                from jan in temp4.DefaultIfEmpty()
                join feb in rep.OutOfHoursEvaluation(dateStart.AddMonths(4), dateStart.AddMonths(5)) on total.MemberId equals feb.MemberId
                into temp5
                from feb in temp5.DefaultIfEmpty()
                join mar in rep.OutOfHoursEvaluation(dateStart.AddMonths(5), dateStart.AddMonths(6)) on total.MemberId equals mar.MemberId
                into temp6
                from mar in temp6.DefaultIfEmpty()
                join apr in rep.OutOfHoursEvaluation(dateStart.AddMonths(6), dateStart.AddMonths(7)) on total.MemberId equals apr.MemberId
                into temp7
                from apr in temp7.DefaultIfEmpty()
                select new
            {
                MemberName = total.MemberName
                ,
                OctValue = oct?.Value
                ,
                NovValue = nov?.Value
                ,
                DecValue = dec?.Value
                ,
                JanValue = jan?.Value
                ,
                FebValue = feb?.Value
                ,
                MarValue = mar?.Value
                ,
                AprValue = apr?.Value
                ,
                TotalValue = total.Value
            }
                ).ToList();
            outOfHoursGridView.DataSource = outOfHoursList;

            var estimateTimeByRevisionList = (
                from total in rep.EstimateTimeByRevisionEvaluation(dateStart, dateEnd)
                join oct in rep.EstimateTimeByRevisionEvaluation(dateStart, dateStart.AddMonths(1)) on total.MemberId equals oct.MemberId
                into temp1
                from oct in temp1.DefaultIfEmpty()
                join nov in rep.EstimateTimeByRevisionEvaluation(dateStart.AddMonths(1), dateStart.AddMonths(2)) on total.MemberId equals nov.MemberId
                into temp2
                from nov in temp2.DefaultIfEmpty()
                join dec in rep.EstimateTimeByRevisionEvaluation(dateStart.AddMonths(2), dateStart.AddMonths(3)) on total.MemberId equals dec.MemberId
                into temp3
                from dec in temp3.DefaultIfEmpty()
                join jan in rep.EstimateTimeByRevisionEvaluation(dateStart.AddMonths(3), dateStart.AddMonths(4)) on total.MemberId equals jan.MemberId
                into temp4
                from jan in temp4.DefaultIfEmpty()
                join feb in rep.EstimateTimeByRevisionEvaluation(dateStart.AddMonths(4), dateStart.AddMonths(5)) on total.MemberId equals feb.MemberId
                into temp5
                from feb in temp5.DefaultIfEmpty()
                join mar in rep.EstimateTimeByRevisionEvaluation(dateStart.AddMonths(5), dateStart.AddMonths(6)) on total.MemberId equals mar.MemberId
                into temp6
                from mar in temp6.DefaultIfEmpty()
                join apr in rep.EstimateTimeByRevisionEvaluation(dateStart.AddMonths(6), dateStart.AddMonths(7)) on total.MemberId equals apr.MemberId
                into temp7
                from apr in temp7.DefaultIfEmpty()
                select new
            {
                MemberName = total.MemberName
                ,
                OctValue = oct?.Value
                ,
                NovValue = nov?.Value
                ,
                DecValue = dec?.Value
                ,
                JanValue = jan?.Value
                ,
                FebValue = feb?.Value
                ,
                MarValue = mar?.Value
                ,
                AprValue = apr?.Value
                ,
                TotalValue = total.Value
            }
                ).ToList();
            estimateTimeByRevisionGridView.DataSource = estimateTimeByRevisionList;
            #endregion
        }
Ejemplo n.º 19
0
        private void resumeToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            List <RAttribute> attributes = new List <RAttribute>()
            {
                new RAttribute()
                {
                    Short = "R1", IsDirect = true, JunMidValue = 2.00m, MidSenValue = 6.00m, Name = "Оценка выполнения задач"
                },
                new RAttribute()
                {
                    Short = "R2", IsDirect = false, JunMidValue = 1.50m, MidSenValue = 1.00m, Name = "Отношения часов затраченных к оцененным"
                },
                new RAttribute()
                {
                    Short = "R3", IsDirect = false, JunMidValue = 0.20m, MidSenValue = 0.10m, Name = "Возвращаемость к доработке"
                },
                new RAttribute()
                {
                    Short = "R4", IsDirect = true, JunMidValue = 0.05m, MidSenValue = 0.15m, Name = "Работа в нерабочее время"
                },
                new RAttribute()
                {
                    Short = "R5", IsDirect = true, JunMidValue = 2.00m, MidSenValue = 4.00m, Name = "Число оценочных часов на одну ревизию"
                }
            };

            List <RObject> objects = new List <RObject>()
            {
                new RObject()
                {
                    Name = "Альмяшев Равиль", RoomNumber = 7
                },
                new RObject()
                {
                    Name = "Артамонов Николай", RoomNumber = 7
                },
                new RObject()
                {
                    Name = "Бусунин Александр", RoomNumber = 2
                },
                new RObject()
                {
                    Name = "Желепов Алексей", RoomNumber = 2
                },
                new RObject()
                {
                    Name = "Моисеев Владислав", RoomNumber = 2
                },
                new RObject()
                {
                    Name = "Перевозников Сергей", RoomNumber = 7
                },
                new RObject()
                {
                    Name = "Поковба Михаил", RoomNumber = 10
                },
                new RObject()
                {
                    Name = "Прохоров Евгений", RoomNumber = 2
                },
                new RObject()
                {
                    Name = "Фирсова Ольга", RoomNumber = 7
                },
                new RObject()
                {
                    Name = "Храмков Евгений", RoomNumber = 10
                }
            };

            var totalResult = FillResult(objects, attributes, "TotalValue");

            string resumerResult = "";

            try
            {
                var attrResumer = new AttributeResumer();
                attrResumer.AddResult(totalResult);
                resumerResult += attrResumer.GetResult();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show($"Произошла ошибка работы резюматора по признакам: {ex.Message}");
            }

            try
            {
                var octResult = FillResult(objects, attributes, "OctValue");
                var novResult = FillResult(objects, attributes, "NovValue");
                var decResult = FillResult(objects, attributes, "DecValue");
                var janResult = FillResult(objects, attributes, "JanValue");
                var febResult = FillResult(objects, attributes, "FebValue");
                var marResult = FillResult(objects, attributes, "MarValue");
                var aprResult = FillResult(objects, attributes, "AprValue");

                var timeResumer = new TimeResumer();
                var startDate   = new System.DateTime(2015, 10, 1);
                timeResumer.AddResult(startDate, octResult);
                timeResumer.AddResult(startDate.AddMonths(1), novResult);
                timeResumer.AddResult(startDate.AddMonths(2), decResult);
                timeResumer.AddResult(startDate.AddMonths(3), janResult);
                timeResumer.AddResult(startDate.AddMonths(4), febResult);
                timeResumer.AddResult(startDate.AddMonths(5), marResult);
                timeResumer.AddResult(startDate.AddMonths(6), aprResult);
                resumerResult += timeResumer.GetResult();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show($"Произошла ошибка работы темпорального резюматора: {ex.Message}");
            }

            try
            {
                var locResumer = new LocationResumer();
                locResumer.AddResult(totalResult);
                resumerResult += locResumer.GetResult();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show($"Произошла ошибка работы пространственного резюматора: {ex.Message}");
            }

            var resumeForm = new ResumeForm();

            resumeForm.SetResumeText(resumerResult);
            resumeForm.ShowDialog();
        }
Ejemplo n.º 20
0
        /// -------------------------------------------------------------
        ///
        public override void renderContent()
        {
            int lineWidth = 30;

            List <string> forecastData = new List <string>();

            forecastData.Add("Forecast for " + periods + (isMonthBased ? " months" : " years"));
            forecastData.Add("");

            double estimatedSavings = currentBudget.currentSavings;
            double monthlyBudgetSum = currentBudget.getMonthlyBudgetItemsSum();

            List <Loan> loans = new List <Loan>();

            foreach (Loan existingLoan in currentBudget.loans)
            {
                loans.Add(existingLoan.clone());
            }

            System.DateTime now           = System.DateTime.Now;
            List <string>   goalsAchieved = new List <string>();

            for (int p = 0; p < periods * (isMonthBased ? 1 : 12); p++)
            {
                bool shouldPrint = this.isMonthBased | (p % 12 == 0);
                now = now.AddMonths(1);

                if (shouldPrint)
                {
                    forecastData.Add("");
                    string monthName = now.ToString("MMM", CultureInfo.InvariantCulture);
                    forecastData.Add((p / (isMonthBased ? 1 : 12) + 1) + ": " + monthName + ", " + now.Year);
                }

                double monthlyLeftovers = monthlyBudgetSum;
                double debtSum          = 0;

                foreach (Loan loan in loans)
                {
                    if (loan.amount != 0)
                    {
                        double interest = (-loan.amount * loan.interestPercentage / 100) / 12;
                        loan.amount += (loan.monthlyPayment - interest);

                        monthlyLeftovers -= loan.monthlyPayment;

                        if (loan.amount > 0)
                        {
                            estimatedSavings += loan.amount;
                            loan.amount       = 0;
                        }

                        debtSum += loan.amount;

                        if (shouldPrint)
                        {
                            forecastData.Add(Formatter.formatAmountLine(loan.title, loan.amount, lineWidth));
                        }
                    }
                }

                estimatedSavings  = estimatedSavings + (estimatedSavings * (currentBudget.savingsGrowthRate / 100) / 12);
                estimatedSavings += monthlyLeftovers;
                if (shouldPrint)
                {
                    forecastData.Add(Formatter.formatAmountLine("Savings", estimatedSavings, lineWidth));
                }

                if (shouldPrint)
                {
                    foreach (FinanceItem goal in currentBudget.debtGoals)
                    {
                        if (debtSum >= goal.amount && !goalsAchieved.Contains(goal.title))
                        {
                            goalsAchieved.Add(goal.title);
                            forecastData.Add('^' + Formatter.formatAmountLine(goal.title, goal.amount, lineWidth));
                        }
                    }

                    foreach (FinanceItem goal in currentBudget.savingsGoals)
                    {
                        if (estimatedSavings >= goal.amount && !goalsAchieved.Contains(goal.title))
                        {
                            goalsAchieved.Add(goal.title);
                            forecastData.Add('^' + Formatter.formatAmountLine(goal.title, goal.amount, lineWidth));
                        }
                    }
                }
            }

            Render.renderColumnContent(forecastData);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Adds the specified number of months to the value of this instance
 /// </summary>
 /// <param name="years">A number of months. value can be negative or positive</param>
 /// <returns>A Date whose value is the sum of the date represented
 /// by this instance and the number of months represented by value</returns>
 public Date AddMonths(int months)
 {
     return(new Date(m_base.AddMonths(months)));
 }