Ejemplo n.º 1
0
        void UpdateChart(TimeFrame timeFrame)
        {
            if (_dtExchangeRate == null)
            {
                return;
            }

            mainChart.BeginUpdate();
            rangeChart.BeginUpdate();
            _dtPercentageChange = _dtExchangeRate.ConvertToPercentage();
            foreach (var currency in _viewModel.Currencies)
            {
                currency.ExchangeRateSeries.ItemsSource     = _dtExchangeRate;
                currency.PercentageChangeSeries.ItemsSource = _dtPercentageChange;
                rangeChart.Series.First(s => !((ChartSeries)s).IsPercentage && s.SeriesName.Equals(currency.Symbol)).ItemsSource = _dtExchangeRate;
                rangeChart.Series.First(s => ((ChartSeries)s).IsPercentage && s.SeriesName.Equals(currency.Symbol)).ItemsSource  = _dtPercentageChange;
            }
            rangeChart.EndUpdate();
            mainChart.EndUpdate();
            switch (timeFrame)
            {
            case TimeFrame.FiveDays:
                mainChart.AxisX.Min    = _endPlotDate.AddBusinessDays(-5).ToOADate();
                mainChart.AxisX.Format = "MMM dd yyyy";
                break;

            case TimeFrame.TenDays:
                mainChart.AxisX.Min    = _endPlotDate.AddBusinessDays(-10).ToOADate();
                mainChart.AxisX.Format = "MMM dd yyyy";
                break;

            case TimeFrame.OneMonth:
                mainChart.AxisX.Format = "MMM dd yyyy";
                mainChart.AxisX.Min    = _endPlotDate.AddMonths(-1).ToOADate();
                break;

            case TimeFrame.SixMonths:
                mainChart.AxisX.Format = "MMM dd yyyy";
                mainChart.AxisX.Min    = _endPlotDate.AddMonths(-6).ToOADate();
                break;

            case TimeFrame.OneYear:
                mainChart.AxisX.Format = "MMM yy";
                mainChart.AxisX.Min    = _endPlotDate.AddYears(-1).ToOADate();
                break;

            case TimeFrame.FiveYears:
                mainChart.AxisX.Format = "yyyy";
                mainChart.AxisX.Min    = _endPlotDate.AddYears(-5).ToOADate();
                break;

            case TimeFrame.TenYears:
                mainChart.AxisX.Format = "yyyy";
                mainChart.AxisX.Min    = _startPlotDate.ToOADate();
                break;
            }
            mainChart.AxisX.Max = _endPlotDate.ToOADate();
            rangeSelector.UpdateLayout();
        }
        private void UpdateChart(TimeFrame timeFrame)
        {
            chartMain.BeginUpdate();
            _dtPercentageChange = _dtExchangeRate.ConvertToPercentage();
            foreach (var currency in _currencies)
            {
                currency.ExchangeRateSeries.DataSource     = _dtExchangeRate;
                currency.PercentageChangeSeries.DataSource = _dtPercentageChange;

                foreach (var series in chartRangeSelector.Series.Where(s => s.Name.Equals(currency.Symbol)))
                {
                    series.DataSource = ((ChartSeries)series).IsPercentage ? _dtPercentageChange : _dtExchangeRate;
                }
            }
            chartMain.EndUpdate();
            switch (timeFrame)
            {
            case TimeFrame.FiveDays:
                chartMain.AxisX.Min    = _endPlotDate.AddBusinessDays(-5).ToOADate();
                chartMain.AxisX.Format = "MMM dd yyyy";
                break;

            case TimeFrame.TenDays:
                chartMain.AxisX.Min    = _endPlotDate.AddBusinessDays(-10).ToOADate();
                chartMain.AxisX.Format = "MMM dd yyyy";
                break;

            case TimeFrame.OneMonth:
                chartMain.AxisX.Format = "MMM dd yyyy";
                chartMain.AxisX.Min    = _endPlotDate.AddMonths(-1).ToOADate();

                break;

            case TimeFrame.SixMonths:
                chartMain.AxisX.Format = "MMM dd yyyy";
                chartMain.AxisX.Min    = _endPlotDate.AddMonths(-6).ToOADate();
                break;

            case TimeFrame.OneYear:
                chartMain.AxisX.Format = "MMM yy";
                chartMain.AxisX.Min    = _endPlotDate.AddYears(-1).ToOADate();

                break;

            case TimeFrame.FiveYears:
                chartMain.AxisX.Format = "yyyy";
                chartMain.AxisX.Min    = _endPlotDate.AddYears(-5).ToOADate();

                break;

            case TimeFrame.TenYears:
                chartMain.AxisX.Format = "yyyy";
                chartMain.AxisX.Min    = _startPlotDate.ToOADate();

                break;
            }
            chartMain.AxisX.Max = _endPlotDate.ToOADate();
        }
        /// <summary>
        /// Returns the last business day in the month of the given date
        /// </summary>
        public static DateTime LastBusinessDayOfMonth(this DateTime date, IBusinessCalendar calendar)
        {
            DateTime firstDayOfNextMonth = new DateTime(date.Year, date.Month, 1).AddMonths(1);
            DateTime result = firstDayOfNextMonth.AddBusinessDays(-1, calendar);

            return(result);
        }
Ejemplo n.º 4
0
        public void AddBusinessDaysReturnsOriginalDateIfDaysIsZero()
        {
            DateTime original = new DateTime(2018, 01, 01);
            DateTime dt       = original.AddBusinessDays(0);

            Assert.AreEqual(original, dt);
        }
Ejemplo n.º 5
0
        public void AddBusinessDaysWhenStartDateIsWeekDay()
        {
            var start = new DateTime(2000, 1, 3);
            var end   = start.AddBusinessDays(Number);

            Assert.AreNotEqual(start, end);
        }
Ejemplo n.º 6
0
        private void btnEndDateCalculate_Click(object sender, EventArgs e)
        {
            int    idMachine = Convert.ToInt32(comboBoxMachine.SelectedValue);
            int    idDetail  = Convert.ToInt32(this.viewOrderDetail.CurrentRow.Cells[0].Value);
            int    idPlan    = Convert.ToInt32(tBoxPlanNr.Text.Trim());
            double timeInterval;
            List <PlannedProductionEmployeeDetail> productionEmployess = (from PlannedProductionEmployeeDetail in db.PlannedProductionEmployeeDetails
                                                                          where PlannedProductionEmployeeDetail.IdProces == idPlan
                                                                          select PlannedProductionEmployeeDetail).ToList();
            OrderDetail orderDetail = db.OrderDetails.First(f => f.IdDetail == idDetail);
            Product     product     = db.Products.First(f => f.IdProduct == orderDetail.IdProduct);
            Technology  technology  = db.Technologies.First(f => f.IdTechnology == product.IdTechnology);
            Maintenance maintenance = db.Maintenances.First(f => f.IdMaintenance == idMachine);
            Machine     machine     = db.Machines.First(f => f.IdMachine == maintenance.IdMachine);

            employeesQuantity = productionEmployess.Count();
            if (employeesQuantity == 0)
            {
                MessageBox.Show("Nie przydzielono żadnego pracownika!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnSave.Enabled = false;
            }
            else
            {
                timeInterval = orderDetail.Quantity * machine.MetersPerHour * 0.3 * technology.TimePermeter * 0.2
                               / employeesQuantity + orderDetail.Quantity * 0.7;
                DateTime dateEnd   = dateTimeStart.Value.AddMinutes(timeInterval);
                DateTime dateStart = dateTimeStart.Value;
                double   totalDays = (dateEnd - dateStart).TotalDays;
                string   messageAboutProductionDuration = "Produkcja zajmie: " + Convert.ToString(Math.Round(totalDays, 2)) + " dni roboczych.";
                MessageBox.Show(messageAboutProductionDuration, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dateTimeEnd.Value = dateStart.AddBusinessDays(totalDays);
                btnSave.Enabled   = true;
            }
        }
Ejemplo n.º 7
0
        public void AddBusinessDaysAdjsutsIfExtraDaysPushToSaturday()
        {
            DateTime expected = new DateTime(2017, 01, 23);
            DateTime original = new DateTime(2017, 01, 10);

            DateTime dt = original.AddBusinessDays(9);

            Assert.AreEqual(expected, dt);
        }
Ejemplo n.º 8
0
        public void AddBusinessDaysAddsFullWeeks()
        {
            DateTime expected = new DateTime(2017, 01, 19);
            DateTime original = new DateTime(2017, 01, 08);

            DateTime dt = original.AddBusinessDays(9);

            Assert.AreEqual(expected, dt);
        }
Ejemplo n.º 9
0
        public void AddBusinessDaysAdjustsExtraDaysIfOriginalDayIsSunday()
        {
            DateTime expected = new DateTime(2017, 01, 12);
            DateTime original = new DateTime(2017, 01, 08);

            DateTime dt = original.AddBusinessDays(4);

            Assert.AreEqual(expected, dt);
        }
Ejemplo n.º 10
0
        public void AddBusinessDaysAddsBusinessDays()
        {
            DateTime expected = new DateTime(2017, 01, 06);
            DateTime original = new DateTime(2017, 01, 02);

            DateTime dt = original.AddBusinessDays(4);

            Assert.AreEqual(expected, dt);
        }
Ejemplo n.º 11
0
        public virtual Boolean?validate(String value, String matcher = null)
        {
            Boolean?result = null;


            if (matcher.StartsWith("^"))
            {
                result = (String.IsNullOrWhiteSpace(matcher)?regex: new Regex(matcher)).IsMatch(value ?? "");
            }
            else
            {
                var marr = matcher.Split(",");
                switch (marr[0])
                {
                case "date":
                    DateTime date, mdate = DateTime.Now.Date;

                    if (DateTime.TryParse(value, out date))
                    {
                        if (marr.Length == 1)
                        {
                            result = true;
                        }
                        else
                        {
                            if ("now".Equals(marr[2]?.ToLower()) || DateTime.TryParse(marr[2], out mdate))
                            {
                                if (marr.Length > 3 && new Regex(@"^[\+|\-]\d+$").IsMatch(marr[3]))
                                {
                                    mdate = mdate.AddBusinessDays(Int32.Parse(marr[3]));
                                }
                                if (result != true && marr[1].Contains(">"))
                                {
                                    result = date.CompareTo(mdate) > 0;
                                }
                                if (result != true && marr[1].Contains("="))
                                {
                                    result = date.CompareTo(mdate) == 0;
                                }
                                if (result != true && marr[1].Contains("<"))
                                {
                                    result = date.CompareTo(mdate) < 0;
                                }
                            }
                        }
                    }

                    else
                    {
                        result = false;
                    }
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 12
0
        public DateTime GetEndDate(DateTime StartDate, double estimatedEfforts, string acrStatus, int numberOfAssignees)
        {
            if (acrStatus == "ACR Scheduled")
            {
                int      totalDays = Convert.ToInt32(Math.Ceiling(estimatedEfforts / numberOfAssignees));
                DateTime endDate   = StartDate.AddBusinessDays(totalDays);
                return(endDate);
            }

            else
            {
                throw new InvalidOperationException("ACR Not Scheduled");
            }
        }
Ejemplo n.º 13
0
 internal string AddDate(string adddays)
 {
     try
     {
         string formats = "MM/dd/yyyy";
         adddays = adddays.Replace(Constants.TestData_Date, "");
         int      numberofdays = Int32.Parse(adddays);
         DateTime now          = DateTime.Now;
         return(now.AddBusinessDays(numberofdays).ToString(formats));
     }
     catch
     {
         return(DateTime.Now.ToString("MM/dd/yyyy"));
     }
 }
        public void Test()
        {
            var year = DateTime.Today.Year;

            for (var i = year; i < year + 10; i++)
            {
                for (var date = new DateTime(i, 1, 1); date < new DateTime(i + 1, 1, 1); date = date.AddDays(1))
                {
                    for (var j = 0; j < 10; j++)
                    {
                        date.AddBusinessDays(j);
                    }
                }
            }

            Assert.True(true);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Verifica se o dia da data atual é um dia útil
        /// </summary>
        /// <param name="date">Data Atual</param>
        /// <param name="dias">Número de dias úteis a serem adicionados</param>
        /// <returns>True / False</returns>
        public static bool IsBusinessDay(this DateTime date, int dias)
        {
            // Adicionando somente dias úteis a data atual
            DateTime?date2 = date.AddBusinessDays(dias);

            // Verificando se o dia é um dia da semana
            if (date.DayOfWeek == DayOfWeek.Saturday)
            {
                return(false);
            }

            if (date.DayOfWeek == DayOfWeek.Sunday)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 16
0
        //String test;


        public DateTime weekendCheck(DateTime sDate)
        {
            DateTime eDate = new DateTime();

            eDate = sDate;
            sDate = sDate.AddDays(-1);
            // make sure it is not a saturday or Sunday
            // if it is add another day

            do
            {
                System.Diagnostics.Debug.WriteLine("Yo");
                System.Diagnostics.Debug.WriteLine(sDate);
                sDate = sDate.AddBusinessDays(1);
                // return eDate;
            } while ((sDate.DayOfWeek == DayOfWeek.Saturday || sDate.DayOfWeek == DayOfWeek.Sunday || isHoliday(sDate) == true));

            // More than one day so add days day by day and check each time for
            // weekend. do recursively

            return(sDate);
        }
Ejemplo n.º 17
0
 private string GetDate(string adddays)
 {
     try
     {
         string formats = "MM/dd/yyyy";
         adddays = adddays.Replace(Constants.TestData_Date, "");
         DateTime now = DateTime.Now;
         if (adddays == "" || adddays == null)
         {
             return(now.ToString(formats));
         }
         if (adddays == Constants.TestData_HasDate)
         {
             return(String.Concat(Constants.TestData_HasDate, now.ToString(formats)));
         }
         int numberofdays = Int32.Parse(adddays);
         return(now.AddBusinessDays(numberofdays).ToString(formats));
     }
     catch
     {
         return(DateTime.Now.ToString("MM/dd/yyyy"));
     }
 }
Ejemplo n.º 18
0
        private static string CheckLivraisons(Cas cas, bool delais_embauche_actif)
        {
            DateTime dateDebutDev = DateTime.Parse(cas.date_depart);
            DateTime dateDebutMgt = DateTime.Parse(cas.date_depart);

            List <Projet> projetsCas      = new List <Projet>();
            float         coeffEfficience = getCoeffEfficience(cas);

            // On commence par récupérer les informations des projets du cas traité
            using (StreamReader r = new StreamReader("config\\projets.json"))
            {
                string      json  = r.ReadToEnd();
                ProjetsList items = JsonConvert.DeserializeObject <ProjetsList>(json);

                var nomProjetsCas = new List <string>(cas.projects.Split(','));

                foreach (var projet in items.Projets)
                {
                    if (nomProjetsCas.Contains(projet.nom))
                    {
                        projetsCas.Add(projet);
                    }
                }

                // Ensuite pour chaque projet on calcule les dates prévues de fin (dev & mgt) et on vérifie si il y a retard de livraison
                bool retard    = false;
                bool retardDev = false;
                bool retardMgt = false;
                foreach (Projet proj in projetsCas)
                {
                    // Application du coefficient d'efficience
                    decimal nb_dev_days = (decimal)(proj.nb_dev_days * coeffEfficience);
                    decimal nb_mgt_days = (decimal)(proj.nb_mgt_days * coeffEfficience);

                    if ((nb_dev_days - Math.Truncate(nb_dev_days) > 0))
                    {
                        nb_dev_days = (int)nb_dev_days + 1;
                    }

                    if ((nb_mgt_days - Math.Truncate(nb_mgt_days) > 0))
                    {
                        nb_mgt_days = (int)nb_mgt_days + 1;
                    }

                    proj.nb_dev_days = int.Parse(nb_dev_days.ToString());
                    proj.nb_mgt_days = int.Parse(nb_mgt_days.ToString());

                    // Deadline du projet
                    DateTime deadline = DateTime.Parse(proj.deadline);

                    // Calcul des dates prévues de fin de projet (dev & mgt)
                    DateTime finPrevueDev = dateDebutDev.AddBusinessDays(proj.nb_dev_days / cas.nb_dev).AddDays(-1);
                    DateTime finPrevueMgt = dateDebutMgt.AddBusinessDays(proj.nb_mgt_days / cas.nb_chef_proj).AddDays(-1);

                    Console.Write("Date de fin prévue - projet " + proj.nom + ": ");
                    if (finPrevueDev > finPrevueMgt)
                    {
                        Console.WriteLine(finPrevueDev);
                    }
                    else
                    {
                        Console.WriteLine(finPrevueMgt);
                    }

                    // Pour le prochain projet, les dates de débuts de dev & mgt
                    dateDebutDev = finPrevueDev;
                    dateDebutMgt = finPrevueMgt;

                    // Check si retard de livraison
                    if (deadline < finPrevueDev || deadline < finPrevueMgt)
                    {
                        Console.BackgroundColor = ConsoleColor.Red;
                        Console.WriteLine("/!\\ Projet " + proj.nom + " : RETARD DE LIVRAISON /!\\ (deadline le " + proj.deadline + ")");
                        Console.BackgroundColor = ConsoleColor.Black;

                        retard = true;

                        if (deadline < finPrevueDev)
                        {
                            retardDev = true;
                        }

                        if (deadline < finPrevueMgt)
                        {
                            retardMgt = true;
                        }
                    }

                    dateDebutDev = dateDebutDev.AddBusinessDays(1);
                    dateDebutMgt = dateDebutMgt.AddBusinessDays(1);
                }

                // On recalcule les dates de fin en ajoutant progressivement des ressources (selon le type de retard)
                // Et on affiche les ressources nécessaires pour une livvraison dans les temps
                if (retard)
                {
                    int nb_jours_avant_activite = (cas.duree_avt_efficacite + cas.duree_embauche) * 4 * 5;  //80
                    int nbDevSupp = 0;
                    int nbMgtSupp = 0;

                    if (delais_embauche_actif)
                    {
                        Console.WriteLine("Révision des RH avec prise en compte des délais d'embauche");
                    }
                    // Tant que retard, on recalcule
                    while (retard)
                    {
                        if (retardDev && retardMgt)
                        {
                            nbDevSupp++;
                            nbMgtSupp++;
                        }
                        else if (retardDev)
                        {
                            nbDevSupp++;
                        }
                        else if (retardMgt)
                        {
                            nbMgtSupp++;
                        }

                        // on remet les compteurs à zéro
                        dateDebutDev = DateTime.Parse(cas.date_depart);
                        dateDebutMgt = DateTime.Parse(cas.date_depart);
                        retard       = false;
                        retardDev    = false;
                        retardMgt    = false;

                        int nb_jours_tot_dev = 0;
                        int nb_jours_prevu_dev;
                        int nb_jours_tot_mgt = 0;
                        int nb_jours_prevu_mgt;
                        int nb_jours_avec_aide = 0;
                        int nb_jours_sans_aide = 0;

                        decimal jours_avec_nouveaux_emps;
                        decimal jours_sans_nouveaux_emps;

                        DateTime finPrevueDev;
                        DateTime finPrevueMgt;

                        foreach (Projet proj in projetsCas)
                        {
                            // Deadline du projet
                            DateTime deadline = DateTime.Parse(proj.deadline);

                            // cas avec respect des délais d'embauche + efficience (Question E)
                            if (delais_embauche_actif)
                            {
                                // Prévisions sur le nombre de jours atteints une fois le projet pris en compte
                                nb_jours_prevu_dev = nb_jours_tot_dev + proj.nb_dev_days;
                                nb_jours_prevu_mgt = nb_jours_tot_mgt + proj.nb_mgt_days;

                                // si les nouveaux développeurs ne seront pas prêts pour travailler durant le pojet, on ne les comptes pas dans le calcul.
                                if (nb_jours_prevu_dev <= nb_jours_avant_activite)
                                {
                                    finPrevueDev = dateDebutDev.AddBusinessDays(proj.nb_dev_days / cas.nb_dev).AddDays(-1); // incrémentation de la fin prévue pour les développeurs
                                }
                                // sinon...
                                else
                                {
                                    // Cas où les nouveaux développeurs commencent à travailler durant le projet
                                    if (nb_jours_tot_dev <= nb_jours_avant_activite)
                                    {
                                        nb_jours_avec_aide = nb_jours_prevu_dev - nb_jours_avant_activite;               // Calcul du nombre de jours où les nouveaux développeurs seront ajoutés au travail
                                        nb_jours_sans_aide = nb_jours_prevu_dev - nb_jours_tot_dev - nb_jours_avec_aide; // Calcul du nombre de jours sans les nouveaux développeurs

                                        jours_sans_nouveaux_emps = Math.Ceiling((decimal)nb_jours_sans_aide / (cas.nb_dev));
                                        jours_avec_nouveaux_emps = (nb_jours_avec_aide / (cas.nb_dev + nbDevSupp));

                                        finPrevueDev = dateDebutDev.AddBusinessDays((int)jours_sans_nouveaux_emps + (int)jours_avec_nouveaux_emps);  // incrémentation de la fin prévue pour les développeurs
                                    }
                                    // Cas où les nouveaux développeurs tavaillent depuis le début du projet
                                    else
                                    {
                                        finPrevueDev = dateDebutDev.AddBusinessDays(proj.nb_dev_days / (cas.nb_dev + nbDevSupp)).AddDays(-1); // incrémentation de la fin prévue pour les développeurs
                                    }
                                }

                                // si les nouveaux chefs de projets ne seront pas prêts pour travailler durant le pojet, on ne les comptes pas dans le calcul.
                                if (nb_jours_tot_mgt <= nb_jours_avant_activite)
                                {
                                    finPrevueMgt = dateDebutMgt.AddBusinessDays(proj.nb_mgt_days / cas.nb_chef_proj).AddDays(-1); // incrémentation de la fin prévue pour les chefs de projets
                                }
                                else
                                {
                                    // Cas où les nouveaux chefs de projets commencent à travailler durant le projet
                                    if (nb_jours_tot_mgt <= nb_jours_avant_activite)
                                    {
                                        nb_jours_avec_aide = nb_jours_prevu_mgt - nb_jours_avant_activite;               // Calcul du nombre de jours où les nouveaux développeurs seront ajoutés au travail
                                        nb_jours_sans_aide = nb_jours_prevu_mgt - nb_jours_tot_mgt - nb_jours_avec_aide; // Calcul du nombre de jours sans les nouveaux développeurs

                                        jours_sans_nouveaux_emps = Math.Ceiling((decimal)nb_jours_sans_aide / (cas.nb_chef_proj));
                                        jours_avec_nouveaux_emps = (nb_jours_avec_aide / (cas.nb_chef_proj + nbMgtSupp));

                                        finPrevueMgt = dateDebutMgt.AddBusinessDays((int)jours_sans_nouveaux_emps + (int)jours_avec_nouveaux_emps);  // incrémentation de la fin prévue pour les développeurs
                                    }
                                    else
                                    {
                                        finPrevueMgt = dateDebutMgt.AddBusinessDays(proj.nb_mgt_days / (cas.nb_chef_proj + nbMgtSupp)).AddDays(-1); // incrémentation de la fin prévue pour les chefs de projets
                                    }
                                }

                                // Actualisation des dates
                                nb_jours_tot_dev = nb_jours_prevu_dev;
                                nb_jours_tot_mgt = nb_jours_prevu_mgt;
                            }
                            // cas sans respect du temps d'embauche + efficience
                            else
                            {
                                // Calcul des dates prévues de fin de projet
                                finPrevueDev = dateDebutDev.AddBusinessDays(proj.nb_dev_days / (cas.nb_dev + nbDevSupp)).AddDays(-1);
                                finPrevueMgt = dateDebutMgt.AddBusinessDays(proj.nb_mgt_days / (cas.nb_chef_proj + nbMgtSupp)).AddDays(-1);
                            }

                            dateDebutDev = finPrevueDev;
                            dateDebutMgt = finPrevueMgt;

                            // Check si retard de livraison
                            if (deadline < finPrevueDev || deadline < finPrevueMgt)
                            {
                                retard = true;

                                if (deadline < finPrevueDev)
                                {
                                    retardDev = true;
                                }

                                if (deadline < finPrevueMgt)
                                {
                                    retardMgt = true;
                                }
                            }

                            dateDebutDev.AddDays(1);
                            dateDebutMgt.AddDays(1);
                        }
                    }

                    Console.WriteLine("Cas réalisable avec ressources supplémentaires suivantes: " + nbDevSupp + " développeur(s); " + nbMgtSupp + " chefs de projet(s).");
                }
            }
            return("");
        }
Ejemplo n.º 19
0
        private async Task <bool> CheckIfAllNeededDaysExist(DateTime LastExistingDateInTheDB)
        {
            var isThereAnyMissingDate = await _parkingManager.GetAllParkingSpacesWithMissingDate(LastExistingDateInTheDB.AddBusinessDays(daysToAddInAdvance).Date, false);

            var numberOfPArkingSpaces = await _parkingManager.GetAllParkingSpaces();

            return(isThereAnyMissingDate.Count() == numberOfPArkingSpaces.Count());
        }
Ejemplo n.º 20
0
        protected void startdate_TextChanged(object sender, EventArgs e)
        {
            calendar.SelectedDate = Convert.ToDateTime(startdate.Text);

            if (startdate.Text == String.Empty || txtDays.Text == String.Empty)
            {
                enddatetxt.Text = "";
            }

            string   date = "";
            DateTime Date = new DateTime();

            date = startdate.Text;

            Date = Convert.ToDateTime(date);


            calendar.Visible = false;
            int dayamount = Convert.ToInt32(txtDays.Text);
            //calendar.SelectedDate.AddDays(dayamount);
            //check for weekends
            DateTime newDate = new DateTime();

            newDate = Date.AddBusinessDays(dayamount);

            //System.Diagnostics.Debug.WriteLine(newDate);
            //System.Diagnostics.Debug.WriteLine(dayamount);

            /* you orginally had
             *      weekendCheck(newDate);
             * when it was suppose to be
             *      newDate = weekendCheck(newDate);
             */
            newDate = weekendCheck(newDate);

            if (txtDays.Text == String.Empty)
            {
                enddatetxt.Text = " ";
            }
            else if (startdate.Text != String.Empty)
            {
                enddatetxt.Text = newDate.ToShortDateString();
            }

            if (startdate.Text == String.Empty || txtDays.Text == String.Empty)
            {
                enddatetxt.Text = "";
            }

            newDate = weekendCheck(newDate);
            string Department = "";

            cmd             = new SqlCommand("spFindDepIdfromId", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Id", SqlDbType.VarChar).Value = txtID.Text;
            SqlDataReader read = cmd.ExecuteReader();

            while (read.Read())
            {
                Department = read.GetValue(0).ToString();
                break;
                //System.Diagnostics.Debug.WriteLine(daysRemain);
            }
            read.Close();

            string   beginningofall    = calendar.SelectedDate.ToShortDateString();
            DateTime beginningDateTime = Convert.ToDateTime(beginningofall);

            cmd = new SqlCommand("spDateChek", connection);
            SqlDataAdapter adapter = new SqlDataAdapter();

            connection = new SqlConnection(ConfigurationManager.ConnectionStrings["LeaveApplicationSystemConnectionString"].ConnectionString);

            connection.Open();
            cmd.Connection = connection;

            cmd.Parameters.AddWithValue("@SD", SqlDbType.Date).Value = beginningDateTime.ToString("MMM dd,yyyy");
            System.Diagnostics.Debug.WriteLine(beginningDateTime);
            cmd.Parameters.AddWithValue("@DId", SqlDbType.Int).Value = Department;
            var returnParameter = cmd.Parameters.Add("@returnVal", SqlDbType.Int);

            returnParameter.Direction = ParameterDirection.ReturnValue;
            cmd.CommandType           = CommandType.StoredProcedure;

            cmd.ExecuteNonQuery();
            var result  = returnParameter.Value;
            int counter = int.Parse(result.ToString());

            System.Diagnostics.Debug.WriteLine(counter);
            connection.Close();

            if (counter > 0)
            {
                errorlbl2.Text = "You cannot apply for leave in this time period";
            }
            else
            {
                errorlbl2.Text = "";
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Add business days on a DateTime
 /// </summary>
 /// <param name="date">Date to add days</param>
 /// <param name="days">Days to add</param>
 /// <returns>date</returns>
 public static DateTime AddBusinessDays(this DateTime date, int days)
 {
     return(date.AddBusinessDays(days, null));
 }
Ejemplo n.º 22
0
 private static DateTime AddBusinessDays(DateTime current, int days)
 {
     return(current.AddBusinessDays(days));
 }
 public void AddBusinessDaysTest(DateTime startDate, int businessDaysToAdd, bool ignoreHolidays, DateTime expectedDate)
 {
     Assert.Equal(expectedDate, startDate.AddBusinessDays(businessDaysToAdd, ignoreHolidays));
 }
 private static DateTime DetermineBatchStart(DateTime start)
 {
     return(start.DayOfWeek == DayOfWeek.Saturday || start.DayOfWeek == DayOfWeek.Sunday
         ? start.AddBusinessDays(1)
         : start);
 }
Ejemplo n.º 25
0
        public void AddBusinessDaysThrowsIfDaysIsNegative()
        {
            DateTime dt = new DateTime(2018, 01, 01);

            Assert.Throws <ArgumentException>(() => dt.AddBusinessDays(-1));
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Returns a new <see cref="DateTime" /> that subtracts the specified number of business days from this <see cref="DateTime" /> value. Business days exclude Saturday and Sunday. The calculation is iterative. If <paramref name="days" /> is positive, days are subtracted, otherwise days are added.
 /// <para>Example 1: Friday + 2 business days = Tuesday</para>
 /// <para>Example 2: Monday - 2 business days = Thursday</para>
 /// </summary>
 /// <param name="dateTime">The original <see cref="DateTime" /> value.</param>
 /// <param name="days">A <see cref="int" /> value specifying the business days to be subtracted from this <see cref="DateTime" /> object.</param>
 /// <returns>
 /// A new <see cref="DateTime" /> object whose value is the difference of this <see cref="DateTime" /> value and the specified business days.
 /// </returns>
 public static DateTime SubtractBusinessDays(this DateTime dateTime, int days)
 {
     return(dateTime.AddBusinessDays(-days));
 }
Ejemplo n.º 27
0
 public static DateTime AddBusinessDays(this DateTime date, int day)
 {
     return(date.AddBusinessDays(day, new BussinessDayConfig()));
 }
        /// <summary>
        /// Returns the business day that is greater than or equal to the given date
        /// </summary>
        public static DateTime BusinessDayOnOrAfter(this DateTime date, IBusinessCalendar calendar)
        {
            DateTime result = date.IsBusinessDay(calendar) ? date : date.AddBusinessDays(1, calendar);

            return(result);
        }
 public void SetDueByDateFrom(DateTime startDate)
 {
     this.DueByDate = startDate.AddBusinessDays(this.CompletionTime());
 }
Ejemplo n.º 30
0
 public static DateTime AddBusinessDays(this DateTime value, int numberOfDays)
 {
     return(value.AddBusinessDays(numberOfDays, State.National));
 }