예제 #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (WeekEndsPanel.Items.Count != 0)
         {
             ends = new List <WeekEnd>();
             for (int i = 0; i < WeekEndsPanel.Items.Count; i++)
             {
                 string[] dateTimes = WeekEndsPanel.Items[i].ToString().Split(new char[] { '-' });
                 ends.Add(
                     new WeekEnd(DateTime.ParseExact(dateTimes[0], "dd.MM.yyyy", null), DateTime.ParseExact(dateTimes[1], "dd.MM.yyyy", null))
                     );
             }
             FinalDateLabel.Content = WorkDayCalculator.Calculate(DateTime.ParseExact(FirstDay.Text, "dd.MM.yyyy", null), int.Parse(Count.Text), ends.ToArray()).ToString();
         }
         else
         {
             FinalDateLabel.Content = WorkDayCalculator.Calculate(DateTime.ParseExact(FirstDay.Text, "dd.MM.yyyy", null), int.Parse(Count.Text), null).ToString("dd.MM.yyyy");
         }
     }
     catch
     {
         MessageBox.Show("Please enter corrext data");
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            int               count     = 10;
            DateTime          startDate = new DateTime(2021, 12, 1);
            WorkDayCalculator wdc       = new WorkDayCalculator();
            var               res       = wdc.Calculate(startDate, count, null);

            Console.WriteLine(res);
            int count1 = 10;

            WeekEnd[] weekends = new WeekEnd[1]
            {
                new WeekEnd(new DateTime(2021, 4, 23), new DateTime(2021, 4, 25))
            };
            DateTime          startDate1 = new DateTime(2021, 4, 21);
            WorkDayCalculator wdc1       = new WorkDayCalculator();
            var res1 = wdc.Calculate(startDate1, count1, weekends);

            //Console.WriteLine(res1);
            //List<int> ints = new List<int> { 1, 2, 3, 4, 5, 6, 7};
            //List<int> list = new List<int> {12, 13, 14};
            ////ints[0] = 5;
            //foreach (var item in ints)
            //{
            //    Console.Write(item + " ");
            //}


            //var count = 0;
            //for (int i = 0; i < ints.Count; i++)
            //{
            //    if (ints[i] == 3)
            //    {
            //        var l = Enumerable.Range(list[0], list.Count).ToList();
            //        l.Sort();
            //        foreach (var item in l)
            //        {
            //            ints.Insert(count,item);
            //        }
            //        break;
            //    }
            //    count++;
            //}

            //Console.WriteLine();
            //Console.ForegroundColor = ConsoleColor.Red;
            //foreach (var item in ints)
            //{
            //    Console.Write(item + " ");
            //}


            Console.Read();
        }
예제 #3
0
        static void Main(string[] args)
        {
            //
            var Weekend = new WeekEnd(new DateTime(2017, 4, 23), new DateTime(2017, 4, 25));
            var EndDate = WorkDayCalculator.Calculate(new DateTime(2017, 4, 21), 5, Weekend);

            Console.WriteLine(EndDate);
            Console.ReadKey();
        }