Esempio n. 1
0
 //This method returns period for given booking
 public MPeriod getBookingPeriod(MBatteryStorage storage, DateTime time)
 {
     List<MPeriod> periods = dbPeriod.getStoragePeriods(storage.id,true);
     MPeriod lastPeriod = periods[periods.Count - 1];
     if (time.CompareTo(lastPeriod.time) > 0)//if time of booking is later then time of last period
     {
         while (time.CompareTo(lastPeriod.time) > 0) //while time of booking is earlier or in the same time then time of last period
         {
             lastPeriod = createPeriod(storage);//create new period
         }
     }
     else //if time of booking is before time of last period
     {
         for (int x = periods.Count - 1; x >= 1; x--) //for periods from last to first
         {
             MPeriod next = periods[x]; //last created period
             MPeriod curr = periods[x - 1]; //second last period
             if ((time.CompareTo(curr.time) >= 0) & (time.CompareTo(next.time) < 0)) //if time of booking is later then current and earlier then next period
             {
                 return curr;
             }
         }
      }
     return lastPeriod;
 }
 public static IQueryable<BOLichBieuKhongDinhKy> GetAllVisualRun(KaraokeEntities kara,BAN ban)
 {
     int? khuID = ban == null ? null : ban.KhuID;
     DateTime dtNow = DateTime.Now;
     DateTime dt = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day);
     TimeSpan ts = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
     var querya = BOMenuLoaiGia.GetAllVisual(kara);
     var queryb = from b in GetAllVisual(kara)
                  where
                      ts.CompareTo(b.GioBatDau.Value) >= 0 && ts.CompareTo(b.GioKetThuc.Value) <= 0 &&
                      dt.CompareTo(b.NgayBatDau.Value) >= 0 && dt.CompareTo(b.NgayKetThuc.Value) <= 0 &&
                      (
                         b.KhuID == null ||
                         b.KhuID == khuID
                      )
                  select b;
     var query = from a in querya
                 join b in queryb on a.LoaiGiaID equals b.LoaiGiaID
                 select new BOLichBieuKhongDinhKy
                 {
                     MenuLoaiGia = a,
                     LichBieuKhongDinhKy = b
                 };
     return query.Distinct();
 }
Esempio n. 3
0
        public void TableSorter(List<String> lst)
        {
            int result = 0;
            Boolean b = false;
            DateTime d1 = new DateTime();
            DateTime d2 = new DateTime();
            for (int i = 1; i < lst.Count; i++)
            {
                d1 = Convert.ToDateTime(lst.ElementAt(i - 1));
                d2 = Convert.ToDateTime(lst.ElementAt(i));
                Console.WriteLine(d1);
                Console.WriteLine(d2);
                result = d1.CompareTo(d2);
                Console.WriteLine(result);
                if (result < 0)
                {
                    b = true;
                }
                else
                {
                    b = false;
                    break;
                }
            }
            if (b == true)
            {
                Console.WriteLine("Sorted ascending");
            }
            else
            {
                for (int i = 1; i < lst.Count; i++)
                {
                    d1 = Convert.ToDateTime(lst.ElementAt(i - 1));
                    d2 = Convert.ToDateTime(lst.ElementAt(i));
                    Console.WriteLine(d1);
                    Console.WriteLine(d2);
                    result = d1.CompareTo(d2);
                    Console.WriteLine(result);
                    if (result > 0)
                    {
                        b = true;
                    }
                    else
                    {
                        b = false;
                        Console.WriteLine("Not sorted");
                        break;
                    }
                }
                if (b == true)
                {
                    Console.WriteLine("Sorted descending");
                }

            }
        }
 public bool isInPeriod(MPeriod period, DateTime time, MBatteryStorage storage)
 {
     DateTime first = period.time;
     double hours = (double) storage.type.capacity;
     DateTime second = period.time.AddHours(hours);
     if ((time.CompareTo(first) >= 0) & (time.CompareTo(second) < 0))
     {
         return true;
     }
     else return false;
 }
Esempio n. 5
0
        internal static bool ValidRelativeMonthYear(MonthYear input,
                                                    int lowerBound, MonthYearUnit lowerUnit, RangeBoundaryType lowerBoundType,
                                                    int upperBound, MonthYearUnit upperUnit, RangeBoundaryType upperBoundType)
        {
            DateTime now = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            DateTime lowerDate = DateTime.MinValue;
            DateTime upperDate = DateTime.MaxValue;
            DateTime inputDate = new DateTime(input.Year, input.Month, 1);

            switch (lowerUnit)
            {
                case MonthYearUnit.Month:
                    lowerDate = now.AddMonths(lowerBound * -1);
                    break;
                case MonthYearUnit.Year:
                    lowerDate = now.AddYears(lowerBound * -1);
                    break;
            }
            switch (upperUnit)
            {
                case MonthYearUnit.Month:
                    upperDate = now.AddMonths(upperBound);
                    break;
                case MonthYearUnit.Year:
                    upperDate = now.AddYears(upperBound);
                    break;
            }

            //default the bound check to true - if lowerBoundType is Ignore, no test will be performed.
            bool lowerBoundOk = true;
            if (lowerBoundType == RangeBoundaryType.Inclusive)
            {
                lowerBoundOk = inputDate.CompareTo(lowerDate) >= 0;
            }
            else if (lowerBoundType == RangeBoundaryType.Exclusive)
            {
                lowerBoundOk = inputDate.CompareTo(lowerDate) > 0;
            }

            //default the bound check to true - if upperBoundType is Ignore, no test will be performed.
            bool upperBoundOk = true;
            if (upperBoundType == RangeBoundaryType.Inclusive)
            {
                upperBoundOk = inputDate.CompareTo(upperDate) <= 0;
            }
            else if (upperBoundType == RangeBoundaryType.Exclusive)
            {
                upperBoundOk = inputDate.CompareTo(upperDate) < 0;
            }

            return lowerBoundOk && upperBoundOk;
        }
Esempio n. 6
0
        /// <summary>
        /// Search in each row for the smallest "created" field
        /// and the biggest "modified" field.
        /// Update these values: CreatedBy, DateCreated, DateModified, ModifiedBy.
        /// </summary>
        /// <param name="ADataTable">The data table to retrieve the modified and created values.</param>
        private void UpdateFields_SearchDate(DataTable ADataTable)
        {
            System.DateTime TempCreatedDate  = new System.DateTime(System.DateTime.MinValue.Ticks);
            System.DateTime TempModifiedDate = new System.DateTime(System.DateTime.MaxValue.Ticks);
            System.DateTime TempDate         = new System.DateTime(2000, 1, 1);
            String          TempCreatedBy    = StrUnknown;
            String          TempModifiedBy   = StrUnknown;

            // search for the smallest / biggest field
            for (int Counter = 0; Counter < ADataTable.Rows.Count; ++Counter)
            {
                System.Data.DataRow CurrentRow = ADataTable.Rows[Counter];

                if (Counter == 0)
                {
                    TempCreatedDate  = TSaveConvert.ObjectToDate(CurrentRow[UNIT_DATE_CREATED_COL]);
                    TempModifiedDate = TSaveConvert.ObjectToDate(CurrentRow[UNIT_DATE_MODIFIED_COL]);
                    TempCreatedBy    = System.Convert.ToString(CurrentRow[UNIT_CREATED_BY_COL]);
                    TempModifiedBy   = System.Convert.ToString(CurrentRow[UNIT_MODIFIED_BY_COL]);
                }
                else
                {
                    TempDate = TSaveConvert.ObjectToDate(CurrentRow[UNIT_DATE_CREATED_COL]);

                    if (TempDate.CompareTo(TempCreatedDate) < 0)
                    {
                        TempCreatedDate = TempDate;
                        TempCreatedBy   = System.Convert.ToString(CurrentRow[UNIT_CREATED_BY_COL]);
                    }

                    TempDate = TSaveConvert.ObjectToDate(CurrentRow[UNIT_DATE_MODIFIED_COL]);

                    if (TempDate.CompareTo(TempModifiedDate) > 0)
                    {
                        TempModifiedDate = TempDate;
                        TempModifiedBy   = System.Convert.ToString(CurrentRow[UNIT_MODIFIED_BY_COL]);
                    }
                }
            }

            // update the control
            DateCreated  = TempCreatedDate;
            DateModified = TempModifiedDate;
            CreatedBy    = TempCreatedBy;
            ModifiedBy   = TempModifiedBy;

            this.tipFields.SetToolTip(this, this.FToolTipString);
        }
        private static bool Validate_Date(DateTime date)
        {

            int compValue = date.CompareTo(DateTime.Now);
            // Print_To_Console(compValue.ToString());
            return (compValue < 0) ? true : false;
        }
 private bool isFormValid()
 {
     ArrayList errors = new ArrayList();
     DateTime userDate = new DateTime(expenseDate.Value.Year, expenseDate.Value.Month, expenseDate.Value.Day);
     DateTime today = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
     if (userDate.CompareTo(today) > 0)
     {
         errors.Add("Date cannot be greater than today's date.");
     }
     if (itemName.Text.Equals(""))
     {
         errors.Add("Item Name cannot be left empty");
     }
     if (cost.Text.Equals(""))
     {
         errors.Add("Amount cannot be left empty");
     }
     if (category.SelectedItem == null)
     {
         errors.Add("Category should be selected from the list");
     }
     if (errors.Count > 0)
     {
         String consolidatedError = "";
         foreach (String error in errors)
         {
             consolidatedError += (error+"\n");
         }
         MessageBox.Show(consolidatedError, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     else
         return true;
 }
    static int CalculateWorkDays(DateTime dt)
    {
        string[] holidays = { "1/1", "3/3", "1/5", "6/5", "24/5", "6/9", "22/9", "24/12", "25/12" };
        DateTime tempdate = today;
        int sum = 0;

        if (dt.CompareTo(today) < 0)
        {
            return -1;
        }

        int addDay = 0;

        while (today.AddDays(addDay).CompareTo(dt) < 0)
        {
            if (today.AddDays(addDay).DayOfWeek.ToString() != "Sunday" && today.AddDays(addDay).DayOfWeek.ToString() != "Saturday")
            {
                if (!Contains(holidays, (today.AddDays(addDay).Day.ToString() + "/" + today.AddDays(addDay).Month.ToString())))
                {
                    sum++;
                }
            }

            addDay++;
        }

        return sum;
    }
Esempio n. 10
0
 public static DateTime nextAnniversary(this DateTime dateTime)
 {
     DateTime nextTime = new DateTime(DateTime.Now.Year, dateTime.Month, dateTime.Day);
     if (nextTime.CompareTo(DateTime.Now.cropToDays()) < 0)
         return nextTime.AddYears(1);
     return nextTime;
 }
Esempio n. 11
0
        public static List<KeyValuePair<DateTime, DateTime>> SplitToWeek(DateTime dateFrom, DateTime dateTo)
        {
            if (dateFrom.CompareTo(dateTo) > 0)
            {
                throw new System.ArgumentException("dateFrom cannot be later then dateTo");
            }

            List<KeyValuePair<DateTime, DateTime>> _List = new List<KeyValuePair<DateTime, DateTime>>();
            
            try
            {
                DateTime start=dateFrom;
                DateTime end;
                for (DateTime d = dateFrom; d <= dateTo; d = d.AddDays(1))
                {
                    if (d.DayOfWeek==DayOfWeek.Sunday||d==dateTo)
                    {
                        end = d;
                        //d = d.AddDays(6);
                        _List.Add(new KeyValuePair<DateTime, DateTime>(start, end));
                        start = d.AddDays(1);
                    }
                }
            }
            catch (Exception e)
            {
                throw new System.ArgumentException("WeekdayName is Invalid");
            }


            return _List;
        }
Esempio n. 12
0
        public static EMMADataSet.AssetsLostDataTable GetAssetsLost(long ownerID, DateTime startDate, DateTime endDate)
        {
            EMMADataSet.AssetsLostDataTable retVal = new EMMADataSet.AssetsLostDataTable();

            if (startDate.CompareTo(SqlDateTime.MinValue.Value) < 0) startDate = SqlDateTime.MinValue.Value;
            if (endDate.CompareTo(SqlDateTime.MinValue.Value) < 0) endDate = SqlDateTime.MinValue.Value;
            if (startDate.CompareTo(SqlDateTime.MaxValue.Value) > 0) startDate = SqlDateTime.MaxValue.Value;
            if (endDate.CompareTo(SqlDateTime.MaxValue.Value) > 0) endDate = SqlDateTime.MaxValue.Value;

            lock (_tableAdapter)
            {
                _tableAdapter.FillByDate(retVal, ownerID, startDate, endDate);
            }

            return retVal;
        }
Esempio n. 13
0
        public void GetDate(DateTime sender)
        {
            if (this.DataSource == null) return;
            if (this.DataSource.Rows.Count == 0) return;

            try
            {
                DateTime time = sender;
                TimeSpan span = new TimeSpan(30, 0, 0, 0);
                TimeSpan span2 = span;
                DateTime time2 = sender.Subtract(span);
                DateTime time3 = sender.Add(span);
                for (int i = this.DataSource.Rows.Count - 1; i >= 0; i--)
                {
                    if (sender.CompareTo(Convert.ToDateTime(this.DataSource.Rows[i]["sun"])) >= 0)
                    {
                        this.Index = i;
                        DateTime time4 = new DateTime(sender.Year, sender.Month, sender.Day);
                        span2 = (TimeSpan)(time4 - Convert.ToDateTime(this.DataSource.Rows[this.Index]["sun"]));
                        time = Convert.ToDateTime(this.DataSource.Rows[this.Index]["date"]);
                        break;
                    }
                }
                this.year = time.Year;
                if (span2.Days <= 30)
                {
                    this.month = time.Month;
                    this.day = span2.Days + 1;
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }
Esempio n. 14
0
 private static void WorkingDays(int days)
 {
     String yearsFur = furtherDate.ToString().Substring(6, 4);
     String yearNow = now.ToString().Substring(6, 4);
     PopulateFestivals(int.Parse(yearsFur) - int.Parse(yearNow) + 1, yearNow);
     DateTime curr = new DateTime();
     for (int i = 0; i < days; i++)
     {
         curr.AddDays(1);
         if (curr.DayOfWeek == DayOfWeek.Saturday || curr.DayOfWeek == DayOfWeek.Sunday) days--;
         else
         {
             for (int j = 0; j < int.Parse(yearsFur) - int.Parse(yearNow) + 1; j++)
             {
                 for (int t = 0; t < 4; t++)
                 {
                     if (curr.CompareTo(festivals[j, t]) == 0)
                     {
                         days--;
                         break;
                     }
                 }
             }
         }
     }
     Console.WriteLine("Working days : {0}",days);
 }
Esempio n. 15
0
        public static void Main()
        {
            System.DateTime theDay = new System.DateTime(System.DateTime.Today.Year, 7, 28);
            int             compareValue;

            try
            {
                compareValue = theDay.CompareTo(DateTime.Today);
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Value is not a DateTime");
                return;
            }

            if (compareValue < 0)
            {
                System.Console.WriteLine("{0:d} is in the past.", theDay);
            }
            else if (compareValue == 0)
            {
                System.Console.WriteLine("{0:d} is today!", theDay);
            }
            else // compareValue > 0
            {
                System.Console.WriteLine("{0:d} has not come yet.", theDay);
            }
        }
Esempio n. 16
0
        /* ----------------------------------------------------------------- */
        ///
        /// FindFromRecent
        ///
        /// <summary>
        /// 「最近使ったファイル一覧」から、引数に指定された拡張子のファイル
        /// の内、直近に使用したファイル名を返します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private static string FindFromRecent(string ext)
        {
            var    dir  = System.Environment.GetFolderPath(Environment.SpecialFolder.Recent);
            var    info = new IoEx.DirectoryInfo(dir);
            string dest = null;

            foreach (var file in info.GetFiles())
            {
                System.String filename = IoEx.Path.GetFileNameWithoutExtension(file.FullName);
                System.String s        = IoEx.Path.GetExtension(filename).ToLower();
                if (s == ext.ToLower())
                {
                    if (dest == null)
                    {
                        dest = file.FullName;
                    }
                    else
                    {
                        System.DateTime prev = IoEx.File.GetLastWriteTime(dest);
                        System.DateTime cur  = IoEx.File.GetLastWriteTime(file.FullName);
                        if (cur.CompareTo(prev) >= 0)
                        {
                            dest = file.FullName;
                        }
                    }
                }
            }
            return((dest == null) ? null : IoEx.Path.GetFileNameWithoutExtension(dest));
        }
Esempio n. 17
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            if (!(obj is DateTime))
            {
                throw new ArgumentException("Argument is not of type DateTime");
            }
            DateTime dt = (DateTime)obj;

            if (timezone == NoTimezone && dt.timezone != NoTimezone)
            {
                return(0);                      // cannot compare
            }
            if (timezone != NoTimezone && dt.timezone == NoTimezone)
            {
                return(0);                      // cannot compare
            }
            if (timezone == NoTimezone)
            {
                return(myValue.CompareTo(dt.myValue));
            }

            System.DateTime n1 = myValue;
            System.DateTime n2 = dt.myValue;
            n1.AddMinutes(-timezone);
            n2.AddMinutes(-dt.timezone);
            return(n1.CompareTo(n2));
        }
Esempio n. 18
0
 public IQueryable<BAOCAOTHUCHI> GetBOBaoCaoThuChi(DateTime dtFrom, DateTime dtTo)
 {
     return from x in mKaraokeEntities.BAOCAOTHUCHIs
            where dtFrom.CompareTo(x.ThoiGian.Value) <= 0 && dtTo.CompareTo(x.ThoiGian.Value) >= 0
            orderby x.ThoiGianFull
            select x;
 }
Esempio n. 19
0
 //this method checks if the date entered by the user is correct
 //and if it is in the future
 static DateTime EnterValidFutureDate(DateTime todayDate)
 {
     while (true)
     {
         Console.Write("Enter a future date (day.month.year) : ");
         string futureDay = Console.ReadLine();
         DateTime futureDate;
         bool successParse = DateTime.TryParse(futureDay, out futureDate);
         if (successParse)
         {
             int compare = todayDate.CompareTo(futureDate);
             if (compare < 0)
             {
                 return futureDate;
             }
             else
             {
                 Console.WriteLine("The date must be in future!");
             }
         }
         else
         {
             Console.WriteLine("Wrong input!");
         }
     }
 }
        public List<ChartPoint> GetVisitStatistics(DateTime from, DateTime to)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var points = new List<ChartPoint>();
            if (from.CompareTo(to) >= 0) return points;
            for (var d = new DateTime(from.Ticks); d.Date.CompareTo(to.Date) <= 0; d = d.AddDays(1))
            {
                points.Add(new ChartPoint() { Hosts = 0, Hits = 0, Date = TenantUtil.DateTimeFromUtc(d.Date), DisplayDate = TenantUtil.DateTimeFromUtc(d.Date).ToShortDateString() });
            }
            var hits = StatisticManager.GetHitsByPeriod(TenantProvider.CurrentTenantID, from, to);
            var hosts = StatisticManager.GetHostsByPeriod(TenantProvider.CurrentTenantID, from, to);
            if (hits.Count == 0 || hosts.Count == 0) return points;

            hits.Sort((x, y) => x.VisitDate.CompareTo(y.VisitDate));
            hosts.Sort((x, y) => x.VisitDate.CompareTo(y.VisitDate));

            var point = new ChartPoint() { Hosts = 0, Hits = 0, Date = from.Date };
            for (int i = 0, n = points.Count, hitsNum = 0, hostsNum = 0; i < n; i++)
            {
                while (hitsNum < hits.Count && points[i].Date.Date.CompareTo(hits[hitsNum].VisitDate.Date) == 0)
                {
                    points[i].Hits += hits[hitsNum].VisitCount;
                    hitsNum++;
                }
                while (hostsNum < hosts.Count && points[i].Date.Date.CompareTo(hosts[hostsNum].VisitDate.Date) == 0)
                {
                    points[i].Hosts++;
                    hostsNum++;
                }
            }

            return points;
        }
Esempio n. 21
0
    static int WorkingDays(DateTime dateNow, DateTime endDate)
    {
        // Calculating the difference in days between the two dates and thi will give us
        // how many times to run the for cycle
        int daysLenght = Math.Abs((dateNow-endDate).Days);

        // Assigning this value to the counter
        int counter = daysLenght;

        for (int i = 0; i < daysLenght; i++)
        {
            // every time we add 1 day
            dateNow = dateNow.AddDays(1);

            // checking if this date is Saturday or Sunday and substract it
            if (dateNow.DayOfWeek == DayOfWeek.Saturday || dateNow.DayOfWeek == DayOfWeek.Sunday)
            {
            counter--;
            }

            // going thru all Holidays and if there is a match -> substracting one day
            for (int days = 0; days < Holidays.Length; days++)
            {
                if (dateNow.CompareTo(Holidays[days]) == 0)
                {
                    counter--;
                }
            }
        }

        return counter; // final result
    }
Esempio n. 22
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Compare a datetime instance with itself");

        try
        {
            DateTime t = new DateTime(2006, 9, 21, 10, 54, 56, 888);

            if (t.CompareTo(t) != 0)
            {
                TestLibrary.TestFramework.LogError("001.1", "Compare a datetime instance with itself does not return 0");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
 /// <summary>
 /// 対象日が期間内かどうかのチェック
 /// </summary>
 /// <param name="date">対象日</param>
 /// <param name="longFrom">期間開始日</param>
 /// <param name="longTo">期間終了日</param>
 /// <returns>bool</returns>
 public static bool Between(this DateTime date, DateTime longFrom, DateTime longTo)
 {
     if (longTo.CompareTo(longFrom) < 0)
     {
         return false;
     }
     if (date.CompareTo(longFrom) < 0)
     {
         return false;
     }
     if (longTo.CompareTo(date) < 0)
     {
         return false;
     }
     return true;
 }
Esempio n. 24
0
        public static bool DateInBetween(DateTime targetDate, DateTime start, DateTime end)
        {
            try
            {
                if (targetDate != null && targetDate != default(DateTime))
                {
                    if (start.Equals(default(DateTime)))
                    {
                        return true;
                    }
                    if (start.CompareTo(targetDate) < 0)
                    {
                        if (end.Equals(default(DateTime)))
                            return true;
                        else if (end != default(DateTime) && end.CompareTo(targetDate) > 0)
                            return true;
                        else
                            return false;

                    }

                }
            }
            catch (Exception  ex)
            {

                Utility.WriteLogError("Exception Occurred in verification of Dates" + ex.ToString());
            }
            return false;
        }
Esempio n. 25
0
    static int CalculateWorkDays(DateTime today, DateTime date)
    {
        bool isHoliday = false;
        int numberOfWorkDays = 0;

        while (today.CompareTo(date) != 1)
        {
            isHoliday = false;

            foreach (DateTime holiday in holidays)
            {
                if (today.Equals(holiday))
                {
                    isHoliday = true;
                    break;
                }
            }


            if (!isHoliday && today.DayOfWeek != DayOfWeek.Saturday && today.DayOfWeek != DayOfWeek.Sunday)
            {
                numberOfWorkDays++;
            }

            today = today.AddDays(1);
        }

        return numberOfWorkDays;
    }
Esempio n. 26
0
 private void GuardThatArrivalDateIsAfterDeparturetDate(DateTime departureDate, DateTime arrivalDate)
 {
     if (departureDate.CompareTo(arrivalDate) == 1)
     {
         throw new ArrivalDateBeforeDepartureDateException(EventSourceId, departureDate, arrivalDate);
     }
 }
Esempio n. 27
0
        public static List<DateTime> GetDatesByWeekDay(string weekdayName,
            DateTime dateFrom, DateTime dateTo)
        {
            if (dateFrom.CompareTo(dateTo) > 0)
            {
                throw new System.ArgumentException("dateFrom cannot be later then dateTo");
            }
            List<DateTime> DateList = new List<DateTime>();
            try
            {
                DayOfWeek dayOfWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), weekdayName);

                for (DateTime d = dateFrom; d <= dateTo; d = d.AddDays(1))
                {
                    if (dayOfWeek == d.DayOfWeek)
                    {
                        DateList.Add(d);
                        d = d.AddDays(6);
                    }
                }
            }
            catch (Exception e)
            {
                throw new System.ArgumentException("WeekdayName is Invalid");
            }


            return DateList;
        }
        private static void CheckWorkingDates(DateTime now, DateTime final, List<DateTime> holidays)
        {
            //got the length between without weekends or holidays
            int lengthDays = (final - now).Days;
            int length = lengthDays;
            DateTime currentDate = new DateTime();
            //check which dates of the period are weekends or holidays
            //and decrease the length
            //we pass through the whole period
            for (int i = 0; i <= length; i++)
            {
                //increase date
                currentDate = now.AddDays(i);
                //we compare the currentDate with every single holiday
                for (int days = 0; days < holidays.Count; days++)
                {
                    int comparison = currentDate.CompareTo(holidays[days]); //if match return 0
                    if (comparison == 0)
                    {
                        //decrease the length of period
                        lengthDays--;
                    }
                }
                //check is the current day in weekend
                if (currentDate.DayOfWeek == DayOfWeek.Saturday || currentDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    //decrease the length ot period
                    lengthDays--;
                }
            }

            PrintResult(now, final, lengthDays);
        }
Esempio n. 29
0
 static int count(DateTime date)
 {
     DateTime today = DateTime.Now;
     int count = -1;
     DateTime[] holidays = new DateTime[]
     {
         new DateTime(2015, 03, 03),
         new DateTime(2015, 04, 29),
         new DateTime(2015, 12, 25),
         // etc
     };
     Console.WriteLine("You are not working on the following holidays:");
     for (int i = 0; i < holidays.Length; i++)
     {
         Console.WriteLine(holidays[i].ToShortDateString());
     }
     while (date.CompareTo(today) > 0)
     {
         today = today.AddDays(1);
         if (today.DayOfWeek != DayOfWeek.Saturday && today.DayOfWeek != DayOfWeek.Sunday)
         {
             bool flag = true;
             for (int i = 0; i < holidays.Length; i++)
             {
                 if (today.Date == holidays[0].Date && today.Month == holidays[0].Month) flag = false;
             }
             if(flag != false)count++;
         }
     }
     return count;
 }
Esempio n. 30
0
        protected void FieldFiller()
        {

            NumCyclesTextBox.Text = aas.num_runs.ToString("D1");
            AASATextBox.Text = aas.cf.a.ToString("E3");
            AASBTextBox.Text = aas.cf.b.ToString("E3");
            AASCTextBox.Text = aas.cf.c.ToString("E3");
            AASDTextBox.Text = aas.cf.d.ToString("E3");
            CCATextBox.Text = aas.cev.a.ToString("E3");
            CCBTextBox.Text = aas.cev.b.ToString("E3");
            CCCTextBox.Text = aas.cev.c.ToString("E3");
            CCDTextBox.Text = aas.cev.d.ToString("E3");

            DateTime dt = new DateTime();
            DateTime.TryParse(aas.dzero_ref_date.ToString(), out dt);
            if (dt.CompareTo (DateTime.MinValue) <=0)
                dt = D0RefDateTimePicker.MinDate;
            D0RefDateTimePicker.Value = dt;

            D0AverageTextBox.Text = aas.dzero_avg.ToString("F3");
            D0Pos1TextBox.Text = aas.position_dzero[0].ToString("F3");
            D0Pos2TextBox.Text = aas.position_dzero[1].ToString("F3");
            D0Pos3TextBox.Text = aas.position_dzero[2].ToString("F3");
            D0Pos4TextBox.Text = aas.position_dzero[3].ToString("F3");
            D0Pos5TextBox.Text = aas.position_dzero[4].ToString("F3");
            UseTruncMultCheckBox.Checked = aas.use_truncated_mult;
            TMWeightingFactorTextBox.Text = aas.tm_weighting_factor.ToString("F2");
            TMDblsRateLimitTextBox.Text = aas.tm_dbls_rate_upper_limit.ToString("F2");
        }
Esempio n. 31
0
 private static bool isExpired(DateTime expirationDate)
 {
     if (expirationDate.CompareTo(DateTime.Now) < 0)
         return true;
     else
         return false;
 }
Esempio n. 32
0
        public DateRange(DateTime start, DateTime end)
        {
            if (start.CompareTo(end) >= 0) throw new Exception("End date must occur after start date");

            _start = start;
            _end = end;
        }
 public IQueryable<BAOCAOLICHSUBANHANG> GetBaoCaoLichSuBanHang(DateTime dtFrom, DateTime dtTo)
 {
     return from x in mKaraokeEntities.BAOCAOLICHSUBANHANGs
            where dtFrom.CompareTo(x.NgayBan.Value) <= 0 && dtTo.CompareTo(x.NgayBan.Value) >= 0
            orderby x.NgayBan
            select x;
 }
Esempio n. 34
0
 public ToDo(string message, DateTime deadline)
 {
     if (deadline.CompareTo(DateTime.Now) <= 0 && Environment.GetEnvironmentVariable("NDoByEnabled").Equals("1"))
     {
         throw new Exception("The following ToDo's deadline has passed: " + message);
     }
 }
Esempio n. 35
0
 int IComparable <System.DateTime?> .CompareTo(System.DateTime?other)
 {
     if (!_dateTime.HasValue)
     {
         return(other.HasValue ? -1 : 0);
     }
     return(-other?.CompareTo(_dateTime.Value) ?? 0);
 }
Esempio n. 36
0
 private bool ValidateCreditCardExpirationDate(System.DateTime expirationDate, List <string> validationErrors)
 {
     if (expirationDate.CompareTo(DateTime.Now) < 0)
     {
         validationErrors.Add("Card expiration date is in the past");
         return(false);
     }
     return(true);
 }
Esempio n. 37
0
 protected string IsCouponEnd(object endtime)
 {
     System.DateTime dateTime = System.Convert.ToDateTime(endtime);
     if (dateTime.CompareTo(System.DateTime.Now) > 0)
     {
         return(dateTime.ToString());
     }
     return("已过期");
 }
Esempio n. 38
0
        public int CompareTo(object obj)
        {
            MediaTimer objTimer2 = obj as MediaTimer;

            if (obj == null)
            {
                return(0);
            }
            return(DueTime.CompareTo(objTimer2.DueTime));
        }
Esempio n. 39
0
 public int CompareTo(PlayerScoreData other)
 {
     if (playerScore == other.playerScore)
     {
         //Newer Score first
         return(-dateTimeScoreAchieved.CompareTo(other.dateTimeScoreAchieved));
     }
     //Better score first
     return(-playerScore.CompareTo(other.playerScore));
 }
Esempio n. 40
0
 public override bool MoveNext()
 {
     if (_endTime.CompareTo(DateTime.Now) == 1)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 41
0
    // Start is called before the first frame update
    void Start()
    {
        firstAdvent  = new System.DateTime(2020, 11, 29);
        secondAdvent = new System.DateTime(2020, 12, 06);
        thirdAdvent  = new System.DateTime(2020, 12, 13);
        fourthAdvent = new System.DateTime(2020, 12, 20);
        christmasDay = new System.DateTime(2020, 12, 24);

        currentDay = System.DateTime.Today;

        currentDay = christmasDay;

        flame1.SetActive(false);
        flame2.SetActive(false);
        flame3.SetActive(false);
        flame4.SetActive(false);

        if (currentDay.CompareTo(firstAdvent) >= 0)
        {
            Debug.Log("K1 brennt");
            flame1.SetActive(true);
        }

        if (currentDay.CompareTo(secondAdvent) >= 0)
        {
            Debug.Log("K2 brennt");
            flame2.SetActive(true);
        }

        if (currentDay.CompareTo(thirdAdvent) >= 0)
        {
            Debug.Log("K3 brennt");
            flame3.SetActive(true);
        }

        if (currentDay.CompareTo(fourthAdvent) >= 0)
        {
            Debug.Log("K4 brennt");
            flame4.SetActive(true);
        }
    }
Esempio n. 42
0
 public override bool evaluate(System.Object object1, System.Object object2)
 {
     System.DateTime left = (System.DateTime)object1;
     if (left.CompareTo(org.drools.dotnet.evaluator.DateFactory.getRightDate(object2)) >= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 43
0
 public virtual bool evaluate(System.Object object1, System.Object object2)
 {
     //UPGRADE_NOTE: Final was removed from the declaration of 'left '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
     System.DateTime left = (System.DateTime)object1;
     if (left.CompareTo(org.drools.base_Renamed.evaluators.DateFactory.getRightDate(object2)) >= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 44
0
        //  Update the information of the timer
        //  !!!!!!!!!!!!!!!!!!!!!!!! The timer duration is decided by the end time and current time !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        protected virtual void update()
        {
            System.Threading.Thread.Sleep(20);
            currentTime = System.DateTime.Now;

            if (expire == false)                         //  Not expired
            {
                if (currentTime.CompareTo(endTime) <= 0) //  not expire
                {
                    diffTimeSpan = endTime.Subtract(currentTime);
                    if (diffTimeSpan.TotalMilliseconds < 100)    // Turn to expired
                    {
                        expire = true;
                        alarm  = true;
                        onAlarm();
                    }
                    else
                    {
                        ;
                    }
                }
                else   // expire
                {
                    expire       = true;
                    diffTimeSpan = currentTime.Subtract(endTime);
                }
            }

            else // expired
            {
                diffTimeSpan = currentTime.Subtract(endTime);
                if (diffTimeSpan.TotalMilliseconds > 3000)    // Stop alarming
                {
                    if (this.alarm)
                    {
                        this.alarm = false;
                        onAfterAlarm();
                    }
                }
            }

            // Send the update event.
            if (this.pause == false)    //  There is a bug in the onUpdate thread...
            {
                this.onUpdated();
            }

            Console.WriteLine("{0} - {1} = {2}, Alarm: {3}",
                              endTime, currentTime, diffTimeSpan.ToString(),
                              (alarm ? "Yes" : "No"));
        }
Esempio n. 45
0
    public static void Init()
    {
        string   fileName = Application.dataPath + "/Resources/animation.json";
        FileInfo fileInfo = new FileInfo(fileName);

        if (lastWriteTime.CompareTo(fileInfo.LastWriteTime) != 0)
        {
            if (!LoadConfigFile())
            {
                Debug.LogError("解析/Resources/animation.json文本出错");
            }
            lastWriteTime = fileInfo.LastWriteTime;
        }
    }
Esempio n. 46
0
        protected string IsCouponEnd(object endtime)
        {
            System.DateTime time = System.Convert.ToDateTime(endtime);
            string          result;

            if (time.CompareTo(System.DateTime.Now) > 0)
            {
                result = time.ToString();
            }
            else
            {
                result = "已过期";
            }
            return(result);
        }
Esempio n. 47
0
 void Update()
 {
     if (clampPlacementInProgress)
     {
         if (ClampPoints.Count <= 0 || ClampPoints == null)
         {
             System.DateTime currentTime = System.DateTime.Now;
             if (currentTime.CompareTo(dryingTimeEnd) >= 0)
             {
                 UI_Manager.DisplayResultsPanel("Your project is completely dry now. On to the next step.", displayNextSceneButton: true);
                 clampPlacementInProgress = false;
                 saveDryTime = false;
             }
         }
     }
 }
Esempio n. 48
0
    void reset()
    {
        state0    = 1;
        substate0 = 2;
        timer0    = 0.0f;
        rootMenu.SetActive(false);
        signInMenu.SetActive(false);
        sessionMenu.SetActive(false);
        sessionMenu2.SetActive(false);
        sessionMenu2Alt.SetActive(false);
        registroMenu.SetActive(false);
        recoveryMenu.SetActive(false);
        checkMailNotice.SetActive(false);
        instructionsButton.SetActive(false);
        versionText.setOpacity(0.0f);
        giftButton.unpress();
        diceButton.unpress();
        continueGamePanel.Start();
        continueGamePanel.scaleOutImmediately();

        continueGame = gameController.checkQuickSaveInfo();
        System.DateTime dt   = System.DateTime.Now;
        System.DateTime pcdt = new System.DateTime(playcodeYear, playcodeMonth, playcodeDay, 0, 0, 0);
        if (dt.CompareTo(pcdt) <= 0)
        {
            playcodeInput.text = CorrectPlayCode;
            playcodeInput.gameObject.SetActive(false);
            freePlay = true;
        }
        else
        {
            playcodeInput.text = gameController.quickSaveInfo.playcode;
            //playcodeInput.gameObject.SetActive (true);

            //freePlay = false;
            playcodeInput.gameObject.SetActive(false);
            freePlay = true;
        }


        fader.fadeIn();
        instructionsPanel.Start();
        instructionsPanel.scaleOutImmediately();
        instructionsPanel.gameObject.SetActive(false);
        creditsHUD.text = "Créditos: ";
        buyButton.GetComponent <Button> ().interactable = false;
    }
Esempio n. 49
0
    bool TileExistsInCache(int _x, int _y)
    {
        bool ret = File.Exists(Application.persistentDataPath + "/" + Config.MapCacheFolderName + "/" + GC.CurrentZoom + "/" + (GC.CurrentGpsPosition.OsmTilePosition.x + _x) + "_" + (GC.CurrentGpsPosition.OsmTilePosition.y + _y) + ".png");

        if (ret)
        {
            //check if file is too old
            FileInfo        fi        = new FileInfo(Application.persistentDataPath + "/" + Config.MapCacheFolderName + "/" + GC.CurrentZoom + "/" + (GC.CurrentGpsPosition.OsmTilePosition.x + _x) + "_" + (GC.CurrentGpsPosition.OsmTilePosition.y + _y) + ".png");
            System.DateTime renewDate = fi.LastWriteTime.AddDays(1);
            // Debug.Log("Comparison: " + renewDate.CompareTo(System.DateTime.Now));
            if (renewDate.CompareTo(System.DateTime.Now) < 0)
            {
                ret = false;
            }
        }
        return(ret);
    }
Esempio n. 50
0
 // Update is called once per frame
 void Update()
 {
     //gets current time and compare with remaning time
     //count down time if there is time left.
     currentTime = System.DateTime.Now;
     if (RemaningTime.CompareTo(currentTime) == -1)
     {
         gameObject.GetComponent <Button>().interactable = true;
         obj.active = false;
     }
     else
     {
         tmpSpan   = RemaningTime - currentTime;
         text.text = "Time Remaning: " + tmpSpan.Minutes.ToString() + ":" + tmpSpan.Seconds.ToString();
     }
     //add RemaningTime saving to the file.
 }
Esempio n. 51
0
        //To Liuyang: To know whether valid license available, can use the IsValidLicenseAvailable(or License.Status.Licensed) at the chunk listed below.
        //Check if a valid license file is available

        /*** Check if a valid license file is available. ***/
        public static Ultility.LicenseType IsValidLicenseAvailable()
        {
            //Common.Ultility.Ultility.IsValidLicenseAvailable = License.Status.Licensed;
            if (License.Status.Hardware_Lock_Enabled)
            {
                if (License.Status.HardwareID != License.Status.License_HardwareID)
                {
                    Common.Ultility.Ultility.IsValidLicenseAvailable = Ultility.LicenseType.Invalid;
                    return(Ultility.LicenseType.Invalid);
                }
            }

            if (License.Status.Evaluation_Lock_Enabled)
            {
                if (License.Status.Evaluation_Type == License.EvaluationType.Trial_Days)
                {
                    int time         = License.Status.Evaluation_Time;
                    int time_current = License.Status.Evaluation_Time_Current;

                    if (time - time_current > 0 && License.Status.Licensed)
                    {
                        Common.Ultility.Ultility.IsValidLicenseAvailable = Ultility.LicenseType.Evaluation;
                        return(Ultility.LicenseType.Evaluation);
                    }
                }
            }
            else if (License.Status.Expiration_Date_Lock_Enable)
            {
                System.DateTime expiration_date = License.Status.Expiration_Date;

                if (expiration_date.CompareTo(DateTime.Now) > 0 && License.Status.Licensed)
                {
                    Common.Ultility.Ultility.IsValidLicenseAvailable = Ultility.LicenseType.Valid;
                    return(Ultility.LicenseType.Valid);
                }
            }
            else if (License.Status.Licensed)
            {
                Common.Ultility.Ultility.IsValidLicenseAvailable = Ultility.LicenseType.Valid;
                return(Ultility.LicenseType.Valid);
            }

            Common.Ultility.Ultility.IsValidLicenseAvailable = Ultility.LicenseType.Invalid;
            return(Ultility.LicenseType.Invalid);
        }
Esempio n. 52
0
 void Update()
 {
     if (dealBody.refresh)
     {
         UILabel label1 = transform.FindChild("title1").GetComponent <UILabel>();
         label1.text = "[ff0000]" + dealBody.stampName + "[-] " + dealBody.price + "元" + "/" + dealBody.monad;
         string[] ss     = dealBody.bourse.Split(","[0]);
         UILabel  label2 = transform.FindChild("title2").GetComponent <UILabel>();
         label2.text = "剩余数量:" + dealBody.curNum + dealBody.monad;
         UILabel label3 = transform.FindChild("title3").GetComponent <UILabel>();
         label3.text = (dealBody.typeStr.Equals("入库") ? "文交所" : "交易地") + ": " + ss[1];
         UILabel label = transform.FindChild("validTime").GetComponent <UILabel>();
         label.text = dealBody.validTime;
         System.DateTime time = System.DateTime.Parse(dealBody.validTime);
         label.color      = time.CompareTo(System.DateTime.Now) < 0 ? Color.gray : Color.red;
         dealBody.refresh = false;
     }
 }
Esempio n. 53
0
    private System.DateTime GetStartTimeInSensorReadingsList(List <BaseSensorReading> sensorReadings)
    {
        // Impossible maximum, so any date would be set as earliest
        System.DateTime startDateTime = System.DateTime.MaxValue;

        if (sensorReadings != null)
        {
            // Search for earliest time amongst the sensor readings
            foreach (BaseSensorReading aSensorReading in sensorReadings)
            {
                if (startDateTime.CompareTo(aSensorReading.dateTime) > 0)
                {
                    startDateTime = aSensorReading.dateTime;
                }
            }
        }

        return(startDateTime);
    }
Esempio n. 54
0
        void CompareBaselineTimestamps(string suiteName, string dateTime)
        {
            System.DateTime cloudTimestamp = System.DateTime.Parse(dateTime);

            if (_suiteBaselineData.Count == 0)                                                                           //TODO - shouldnt add this to pull baselines as has issue with iOS trying to pull baselines for OSX
            {
                Console.Instance.Write(DebugLevel.File, MessageLevel.Log, "Putting " + suiteName + " in the pull list"); // Write to console
                suiteBaselinesPullList.Add(suiteName);
            }
            else
            {
                int matches = 0;
                foreach (SuiteBaselineData SBD in _suiteBaselineData)
                {
                    if (SBD.suiteName == suiteName && SBD.platform == sysData.Platform && SBD.api == sysData.API)
                    {
                        matches++;
                        System.DateTime localTimestamp = System.DateTime.ParseExact(SBD.suiteTimestamp, Common.dateTimeFormat, null);
                        Console.Instance.Write(DebugLevel.File, MessageLevel.Log, string.Format("Comparing cloud time {0} vs local time {1}", cloudTimestamp, localTimestamp));

                        int timeDiff = cloudTimestamp.CompareTo(localTimestamp);
                        if (timeDiff < 0f)
                        {
                            Console.Instance.Write(DebugLevel.File, MessageLevel.Log, "Cloud Timestamp is old");                              // Write to console
                        }
                        else if (timeDiff > 0f)
                        {
                            Console.Instance.Write(DebugLevel.File, MessageLevel.Log, "Cloud Timestamp is newer, adding " + suiteName + " to pull list");                              // Write to console
                            suiteBaselinesPullList.Add(suiteName);
                        }
                        else if (timeDiff == 0f)
                        {
                            Console.Instance.Write(DebugLevel.File, MessageLevel.Log, "Cloud Timestamp is the same");                              // Write to console
                        }
                    }
                }

                if (matches == 0)
                {
                    suiteBaselinesPullList.Add(suiteName);
                }
            }
        }
Esempio n. 55
0
    private System.DateTime GetEndTimeInSensorReadingsList(List <BaseSensorReading> sensorReadings)
    {
        // Set impossible minimum, so any date would be set as latest
        System.DateTime endDateTime = System.DateTime.MinValue;

        if (sensorReadings != null)
        {
            // Search for latest time amongst the sensor readings
            foreach (BaseSensorReading aSensorReading in sensorReadings)
            {
                if (endDateTime.CompareTo(aSensorReading.dateTime) < 0)
                {
                    endDateTime = aSensorReading.dateTime;
                }
            }
        }

        return(endDateTime);
    }
        public void AddReturn(Checkouts cvalue, int userid, int userstatus, int ivalue)
        {
            ConnectionString myConnection = new ConnectionString();
            string           cs           = myConnection.cs;
            var con = new MySqlConnection(cs);

            con.Open();

            System.DateTime tempreturntime = DateTime.Now;
            string          stm            = @"INSERT INTO itemreturns(checkoutid, returndate) 
            VALUES(@checkoutid, @returndate)";
            var             cmd            = new MySqlCommand(stm, con);

            cmd.Parameters.AddWithValue("@checkoutid", cvalue.checkoutid);
            cmd.Parameters.AddWithValue("@returndate", tempreturntime);
            cmd.Prepare();
            cmd.ExecuteNonQuery();

            cmd.CommandText = @"UPDATE checkouts SET isreturned = 1 WHERE checkoutid = @checkout_id";
            cmd.Parameters.AddWithValue("@checkout_id", cvalue);
            cmd.Prepare();
            cmd.ExecuteNonQuery();

            cmd.CommandText = @"UPDATE items SET ischeckedout = 0 where itemid = @itemid";
            cmd.Parameters.AddWithValue("@itemid", ivalue);
            cmd.Prepare();
            cmd.ExecuteNonQuery();

            cmd.CommandText = @"UPDATE users SET userstatus = @userstatus WHERE userid = @userid";
            cmd.Parameters.AddWithValue("@userid", userid);
            if (tempreturntime.CompareTo(cvalue.duedate) > 0)
            {
                cmd.Parameters.AddWithValue("@userstatus", userstatus + 1);
            }
            else
            {
                cmd.Parameters.AddWithValue("@userstatus", userstatus);
            }

            cmd.Prepare();
            cmd.ExecuteNonQuery();
        }
Esempio n. 57
0
 //  construct from an end time
 public Timer(System.DateTime EndTime)
 {
     endTime     = EndTime;
     startTime   = System.DateTime.Now;
     currentTime = startTime;
     if (currentTime.CompareTo(endTime) < 0)
     {
         originTimeSpan = endTime.Subtract(currentTime);
     }
     else
     {
         throw (new ApplicationException(
                    "The end time is earlier than current time."));
     }
     diffTimeSpan = originTimeSpan;
     expire       = false;
     alarm        = false;
     endSig       = false;
     pause        = false;
 }
        static void Main(string[] args)
        {
            Program1 p = new Program1();

            p.Test1();
            p.Test2();
            p.Test3();
            var    i      = 20;
            long   result = i.Factorial();
            String str    = "Nitesh kumar.kushwaha";
            int    compareValue;

            System.DateTime theDay = new System.DateTime(System.DateTime.Today.Year, 5, 21);

            compareValue = theDay.CompareTo(DateTime.Today);

            str = str.ToProper();
            Console.WriteLine(str);
            Console.WriteLine("Factorial of {0} is : {1}", i, result);
            Console.ReadKey();
        }
Esempio n. 59
0
        //提交离宿
        private void btnDate_Click(object sender, EventArgs e)
        {
            System.DateTime dt  = dateTimePicker1.Value.Date;
            System.DateTime dt2 = dateTimePicker2.Value.Date;
            if (dt.CompareTo(dt2) > 0)
            {
                MessageBoxEx.Show("日期有误!");
                return;
            }
            XmlDocument doc = new XmlDocument();

            doc.Load("事物表.xml");
            XmlElement Users = doc.DocumentElement;

            if (Users.SelectSingleNode("/Users/student[sno='" + Sno + "']") != null)
            {
                MessageBoxEx.Show("您还有假期未消除!");
                return;
            }

            XmlElement student    = doc.CreateElement("student");
            XmlElement sno        = doc.CreateElement("sno");
            XmlElement leavetime  = doc.CreateElement("leavetime");
            XmlElement arrivetime = doc.CreateElement("arrivetime");
            XmlElement state      = doc.CreateElement("state");

            Users.AppendChild(student);
            student.AppendChild(sno);
            student.AppendChild(leavetime);
            student.AppendChild(arrivetime);
            student.AppendChild(state);

            sno.InnerText        = Sno.ToString();
            leavetime.InnerText  = dt.Date.ToString();
            arrivetime.InnerText = dt2.Date.ToString();
            state.InnerText      = "未消假";

            doc.Save("事物表.xml");
            MessageBoxEx.Show("申请成功!");
        }
Esempio n. 60
0
    private void hide(int daysback)
    {
        System.DateTime dt    = new DateTime();
        System.DateTime dtnow = new System.DateTime();

        int count = 0;

        while (count < DataGridEmpCode.Items.Count)
        {
            dtnow = DateTime.Now;
            DataGridEmpCode.Items[count].FindControl("Book_Checkbox");
            int x = DataGridEmpCode.CurrentPageIndex;

            Label starttime = (Label)DataGridEmpCode.Items[count].FindControl("Start_Time");

            if (starttime.Text == "" || starttime.Text == null)
            {
                DataGridEmpCode.Items[count].Visible = false;
            }
            else
            {
                dt = Convert.ToDateTime(starttime.Text);
                int hour = -dtnow.Hour;
                int sec  = -dtnow.Second;
                int min  = -dtnow.Minute;
                dtnow = dtnow.AddHours(hour);
                dtnow = dtnow.AddSeconds(sec);
                dtnow = dtnow.AddMinutes(min);
                dtnow = dtnow.AddDays(daysback);

                if (dtnow.CompareTo(dt) < 0)
                {
                    DataGridEmpCode.Items[count].Visible = false;
                }
            }

            count++;
        }
    }