Inheritance: ICloneable, IFormatProvider
        /// <summary>
        ///     Converts the DateTime value to a universal sortable long date time string.
        /// </summary>
        /// <exception cref="ArgumentNullException">The format info can not be null.</exception>
        /// <param name="dateTime">The DateTime value to convert.</param>
        /// <param name="formatInfo">The date time format info.</param>
        /// <returns>The given value converted to a universal sortable long date time string.</returns>
        public static String ToUniversalSortableLongDateTimeString( this DateTime dateTime,
                                                                    DateTimeFormatInfo formatInfo )
        {
            formatInfo.ThrowIfNull( nameof( formatInfo ) );

            return dateTime.ToString( "U", formatInfo );
        }
Exemple #2
0
        public void NuConvertStrToDateTime()
        {
            var unValidData1 = "16.01.2014".ToDateTimeUniformSafe();
            var unValidData3 = "16.01.14".ToDateTimeUniformSafe();
            var unValidData4 = "16.01.14 22:14:15".ToDateTimeUniformSafe();
            var unValidData5 = "16-01-2014".ToDateTimeUniformSafe();
            var unValidData6 = "16.01.2014 22-14-15".ToDateTimeUniformSafe();
            var unValidData7 = String.Empty.ToDateTimeUniformSafe();
            var unValidData8 = "".ToDateTimeUniformSafe();
            var unValidData9 = " ".ToDateTimeUniformSafe();
            var unValidData10 = "16.16.2014 22-14-15".ToDateTimeUniformSafe();
            var unValidData11 = "16.11.2014 26-14-15".ToDateTimeUniformSafe();

            Assert.IsNull(unValidData1);
            Assert.IsNull(unValidData3);
            Assert.IsNull(unValidData4);
            Assert.IsNull(unValidData5);
            Assert.IsNull(unValidData6);
            Assert.IsNull(unValidData7);
            Assert.IsNull(unValidData8);
            Assert.IsNull(unValidData9);
            Assert.IsNull(unValidData10);
            Assert.IsNull(unValidData11);

            Assert.IsNotNull("16.01.2014 22:14:15".ToDateTimeUniformSafe());
            Assert.IsNotNull("16.01.2014 22:14:15.561".ToDateTimeUniformSafeMils());

            var dateTimeFormat = new DateTimeFormatInfo { DateSeparator = ".", ShortDatePattern = "dd.MM.yyyy" };
            var validData1 = "16.01.2014".ToDateTimeUniformSafe(dateTimeFormat);
            var validData2 = "16.01.2014 22:14:15".ToDateTimeUniformSafe(dateTimeFormat);

            Assert.AreEqual(validData1, new DateTime(2014, 1, 16));
            Assert.AreEqual(validData2, new DateTime(2014, 1, 16, 22, 14, 15));
        }
        public IQueryable<AutoPouring> GetAutoPouring(string begTimes, string endTimes, string resin)
        {
            _apc.Configuration.ProxyCreationEnabled = false;
            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
            dtFormat.ShortDatePattern = "yyyy-MM-dd";
            DateTime begtime, endtime;
            begtime = Convert.ToDateTime(begTimes, dtFormat);//DateTime.Parse(begTimes);
            //begtime = DateTime.Parse(begTimes);
            endtime = Convert.ToDateTime(endTimes, dtFormat);//DateTime.Parse(endTimes);

               // Expression<Func<AutoPouring, bool>> sqlstr = a => (Convert.ToDateTime(a.SampleTimes.ToShortDateString(),dtFormat)>=begtime)
               //                  && (Convert.ToDateTime(a.SampleTimes.ToShortDateString(), dtFormat) <= endtime)
            //                 && (a.ResinNo.Contains(resin) || resin == null);

            ///ef6中使用DbFunctions解決日期比較問題,使用System.Data.Objects.SqlClient.SqlFunctions會報錯
            var query = from a in _apc.AutoPouring
                        where (DbFunctions.TruncateTime(a.SampleTimes)>=begtime || begtime==null)
                           && (DbFunctions.TruncateTime(a.SampleTimes)<=endtime|| endtime==null)
                           //&&   DbFunctions.DiffDays(a.SampleTimes,endtime)<=0  DbFunctions.
                           && (a.ResinNo.Contains(resin) || resin == null)
                        select a;
               return query;

            //Expression<Func<AutoPouring, bool>> theName = (a => a.SampleTimes.ToString("yyyy-MM-dd HH:mm:ss")> begTimes && a.ResinNo.Contains(resin));
            //var query = _apc.AutoPouring.Where(sqlstr.Compile()).AsQueryable();
        }
        public void ReadOnly(DateTimeFormatInfo format, bool expected)
        {
            Assert.Equal(expected, format.IsReadOnly);

            DateTimeFormatInfo readOnlyFormat = DateTimeFormatInfo.ReadOnly(format);
            Assert.True(readOnlyFormat.IsReadOnly);
        }
Exemple #5
0
 static AccountXml()
 {
     DateTimeFormatInfo = new DateTimeFormatInfo
     {
         ShortTimePattern = "yyyy-MM-dd HH:mm:ss"
     };
 }
        public void Clone(DateTimeFormatInfo format)
        {
            DateTimeFormatInfo clone = (DateTimeFormatInfo)format.Clone();
            Assert.NotSame(format, clone);

            Assert.False(clone.IsReadOnly);
            Assert.Equal(format.AbbreviatedDayNames, clone.AbbreviatedDayNames);
            Assert.Equal(format.AbbreviatedMonthGenitiveNames, clone.AbbreviatedMonthGenitiveNames);
            Assert.Equal(format.AbbreviatedMonthNames, clone.AbbreviatedMonthNames);
            Assert.Equal(format.DayNames, clone.DayNames);
            Assert.Equal(format.MonthGenitiveNames, clone.MonthGenitiveNames);
            Assert.Equal(format.MonthNames, clone.MonthNames);
            Assert.Equal(format.ShortestDayNames, clone.ShortestDayNames);

            Assert.Equal(format.AMDesignator, clone.AMDesignator);
            Assert.Equal(format.FullDateTimePattern, clone.FullDateTimePattern);
            Assert.Equal(format.LongDatePattern, clone.LongDatePattern);
            Assert.Equal(format.LongTimePattern, clone.LongTimePattern);
            Assert.Equal(format.MonthDayPattern, clone.MonthDayPattern);
            Assert.Equal(format.PMDesignator, clone.PMDesignator);
            Assert.Equal(format.RFC1123Pattern, clone.RFC1123Pattern);
            Assert.Equal(format.ShortDatePattern, clone.ShortDatePattern);
            Assert.Equal(format.ShortTimePattern, clone.ShortTimePattern);
            Assert.Equal(format.SortableDateTimePattern, clone.SortableDateTimePattern);
            Assert.Equal(format.UniversalSortableDateTimePattern, clone.UniversalSortableDateTimePattern);
            Assert.Equal(format.YearMonthPattern, clone.YearMonthPattern);
            Assert.Equal(format.CalendarWeekRule, clone.CalendarWeekRule);
            Assert.Equal(format.FirstDayOfWeek, clone.FirstDayOfWeek);
        }
        public static void SetPersianDateTimeFormatInfo(DateTimeFormatInfo persianDateTimeFormatInfo)
        {
            persianDateTimeFormatInfo.MonthNames = new[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
            persianDateTimeFormatInfo.MonthGenitiveNames = persianDateTimeFormatInfo.MonthNames;
            persianDateTimeFormatInfo.AbbreviatedMonthNames = persianDateTimeFormatInfo.MonthNames;
            persianDateTimeFormatInfo.AbbreviatedMonthGenitiveNames = persianDateTimeFormatInfo.MonthNames;

            persianDateTimeFormatInfo.DayNames = new[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
            persianDateTimeFormatInfo.AbbreviatedDayNames = new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
            persianDateTimeFormatInfo.ShortestDayNames = persianDateTimeFormatInfo.AbbreviatedDayNames;
            persianDateTimeFormatInfo.FirstDayOfWeek = DayOfWeek.Saturday;

            persianDateTimeFormatInfo.AMDesignator = "ق.ظ";
            persianDateTimeFormatInfo.PMDesignator = "ب.ظ";

            persianDateTimeFormatInfo.DateSeparator = "/";
            persianDateTimeFormatInfo.TimeSeparator = ":";

            persianDateTimeFormatInfo.FullDateTimePattern = "tt hh:mm:ss yyyy mmmm dd dddd";
            persianDateTimeFormatInfo.YearMonthPattern = "yyyy, MMMM";
            persianDateTimeFormatInfo.MonthDayPattern = "dd MMMM";

            persianDateTimeFormatInfo.LongDatePattern = "dddd, dd MMMM,yyyy";
            persianDateTimeFormatInfo.ShortDatePattern = "yyyy/MM/dd";

            persianDateTimeFormatInfo.LongTimePattern = "hh:mm:ss tt";
            persianDateTimeFormatInfo.ShortTimePattern = "hh:mm tt";
        }
Exemple #8
0
 public static DateTime openDateTimeAttributeFromNode(XmlNode node, string attributeName, string xmlNamespace)
 {
     XmlAttribute attr = node.Attributes[attributeName, xmlNamespace];
     DateTimeFormatInfo formatter = new DateTimeFormatInfo();
     formatter.FullDateTimePattern = PetriXmlHelper.DATE_FORMAT;
     return DateTime.ParseExact(attr.Value, PetriXmlHelper.DATE_FORMAT, formatter);
 }
 public void AMDesignator_Set()
 {
     string newAMDesignator = "AA";
     var format = new DateTimeFormatInfo();
     format.AMDesignator = newAMDesignator;
     Assert.Equal(newAMDesignator, format.AMDesignator);
 }
Exemple #10
0
 public static DateTimeFormatInfo IndianDateFormat()
 {
     DateTimeFormatInfo dtinfo = new DateTimeFormatInfo();
     dtinfo.ShortDatePattern = "dd/MM/yyyy";
     dtinfo.DateSeparator = "/";
     return dtinfo;
 }
 public void MonthNames_Set()
 {
     string[] newMonthNames = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "" };
     var format = new DateTimeFormatInfo();
     format.MonthNames = newMonthNames;
     Assert.Equal(newMonthNames, format.MonthNames);
 }
        public void PosTest2()
        {
            DateTimeFormatInfo info = new DateTimeFormatInfo();

            VerificationHelper(info, 0, "AD");
            VerificationHelper(info, 1, "AD");
        }
 private void VerificationHelper(DateTimeFormatInfo expected, Object obj)
 {
     Assert.True(obj is DateTimeFormatInfo);
     DateTimeFormatInfo actual = obj as DateTimeFormatInfo;
     Assert.False(actual.IsReadOnly);
     IsEquals(actual.AbbreviatedDayNames, expected.AbbreviatedDayNames);
     IsEquals(actual.AbbreviatedMonthGenitiveNames, expected.AbbreviatedMonthGenitiveNames);
     IsEquals(actual.AbbreviatedMonthNames, expected.AbbreviatedMonthNames);
     IsEquals(actual.DayNames, expected.DayNames);
     IsEquals(actual.MonthGenitiveNames, expected.MonthGenitiveNames);
     IsEquals(actual.MonthNames, expected.MonthNames);
     IsEquals(actual.ShortestDayNames, expected.ShortestDayNames);
     IsEquals(actual.AMDesignator, expected.AMDesignator);
     //DateTimeFormatInfo.DateSeparator property has been removed
     IsEquals(actual.FullDateTimePattern, expected.FullDateTimePattern);
     IsEquals(actual.LongDatePattern, expected.LongDatePattern);
     IsEquals(actual.LongTimePattern, expected.LongTimePattern);
     IsEquals(actual.MonthDayPattern, expected.MonthDayPattern);
     IsEquals(actual.PMDesignator, expected.PMDesignator);
     IsEquals(actual.RFC1123Pattern, expected.RFC1123Pattern);
     IsEquals(actual.ShortDatePattern, expected.ShortDatePattern);
     IsEquals(actual.ShortTimePattern, expected.ShortTimePattern);
     IsEquals(actual.SortableDateTimePattern, expected.SortableDateTimePattern);
     //DateTimeFormatInfo.TimeSeparator property has been removed
     IsEquals(actual.UniversalSortableDateTimePattern, expected.UniversalSortableDateTimePattern);
     IsEquals(actual.YearMonthPattern, expected.YearMonthPattern);
     IsEquals(actual.CalendarWeekRule, expected.CalendarWeekRule);
     IsEquals(actual.FirstDayOfWeek, expected.FirstDayOfWeek);
 }
Exemple #14
0
 /// <summary>
 /// Represents a method that set persian option to specified instance CultureInfo
 /// </summary>
 /// <param name="dateTimeFormat">Represents an instance of DateTimeFormatInfo that persian option should be set to it.</param>
 public static void InitPersianDateTimeFormat(DateTimeFormatInfo info)
 {
     if (info == null)
         return;
     PersianCalendar calendar = new PersianCalendar();
     bool readOnly = (bool)dateTimeFormatInfoReadOnly.GetValue(info);
     if (readOnly)
     {
         dateTimeFormatInfoReadOnly.SetValue(info, false);
     }
     dateTimeFormatInfoCalendar.SetValue(info, calendar);
     //object obj2 = dateTimeFormatInfoCultureTableRecord.GetValue(info);
     //cultureTableRecordUseCurrentCalendar.Invoke(obj2, new object[] { calendarID.GetValue(calendar, null) });
     info.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
     info.ShortestDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
     info.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
     info.AbbreviatedMonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
     info.MonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
     info.AMDesignator = "ق.ظ";
     info.PMDesignator = "ب.ظ";
     info.FirstDayOfWeek = DayOfWeek.Saturday;
     info.FullDateTimePattern = "yyyy MMMM dddd";
     info.LongDatePattern = "yyyy MMMM dddd, dd";
     info.ShortDatePattern = "yyyy/MM/dd";
     if (readOnly)
     {
         dateTimeFormatInfoReadOnly.SetValue(info, true);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PersianCultureInfo"/> class.
 /// </summary>
 public PersianCultureInfo()
     : base("fa-IR", false) {
     _calendar = new PersianCalendar();
     _format = PersianDateTimeFormatInfo.GetFormatInfo(_calendar);
     base.DateTimeFormat = _format;
     NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
 }
        public void TestWritable()
        {
            DateTimeFormatInfo info = new DateTimeFormatInfo();
            DateTimeFormatInfo actual = DateTimeFormatInfo.ReadOnly(info);

            Assert.True(actual.IsReadOnly);
        }
Exemple #17
0
        public JObject Get(int year)
        {
            //DO DO: egt the month from the query string
            DateTimeFormatInfo dtfi = new DateTimeFormatInfo();

            JObject result = new JObject(
                new JProperty("bikes",
                    new JArray(Bike.getBikes().OrderBy(b => b.name).Select(b => JObject.FromObject(b)))),

                new JProperty("riders",
                    new JArray(Rider.getRiders().OrderBy(r => r.name).Select(r => JObject.FromObject(r)))),

                new JProperty("routes",
                    new JArray(Route.getRoutes().OrderBy(r => r.name).Select(r => JObject.FromObject(r)))),

                new JProperty("rides",
                    new JArray(Ride.getRides().OrderByDescending(r => r.ride_date).Select(r => JObject.FromObject(new RideVM(r))))),

                new JProperty("payments",
                    new JArray(Payment.getPayments().OrderBy(p => p.paid_date).Select(p => p.toJObject()))),

                new JProperty("colorList", getChartColors()),

                new JProperty("months", Enumerable.Range(1, 12).Select(i => new JObject(
                    new JProperty("month", i), new JProperty("caption", dtfi.GetAbbreviatedMonthName(i))))),

                new JProperty("riderSummary", getRiderSummary(year))

            );

            App.BikesDebug.dumpToFile("model.json", result.ToString(Newtonsoft.Json.Formatting.Indented));

            return result;
        }
        /// <summary>
        ///     Converts the DateTime value to a short date string.
        /// </summary>
        /// <exception cref="ArgumentNullException">The format info can not be null.</exception>
        /// <param name="dateTime">The DateTime value to convert.</param>
        /// <param name="formatInfo">The date time format info.</param>
        /// <returns>The given value converted to a short date string.</returns>
        public static String ToShortDateString( this DateTime dateTime, DateTimeFormatInfo formatInfo )
        {
            dateTime.ThrowIfNull( nameof( dateTime ) );
            formatInfo.ThrowIfNull( nameof( formatInfo ) );

            return dateTime.ToString( "d", formatInfo );
        }
        private void Analysbtn_Click(object sender, EventArgs e)
        {
            //we check the input number and if the number length = 14 will move to next step
            if (IDTB.Text.Length == 14)
            {
                //create object from DTFI to get month name
                DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
                //create object from IDAnalyst  which contains all of process
                IDAnalyst id = new IDAnalyst();
                //convert id number from string in textBox to long
                long num = long.Parse(IDTB.Text);
                //set DateTimePicker "Date" to Date input to extract name of the day and month
                DTP.Value = new DateTime(int.Parse(id.GetBirthYear(num)), int.Parse(id.GetBirthMonth(num)), int.Parse(id.GetBirthDay(num)));
                //assign value of Day TextBox to day from IDAnalyst class and get a day from DateTimePicker
                Daytb.Text = id.GetBirthDay(num)+" : "+DTP.Value.DayOfWeek.ToString();
                //Get Month and using DTFI to get month name which we get from DateTimePicker
                Montb.Text = id.GetBirthMonth(num)+" : "+dtfi.GetMonthName(DTP.Value.Month);
                //Get Month Year
                Yeartb.Text = id.GetBirthYear(num);
                //Get Sex
                Sextb.Text = id.Sex(num);
                //Get Get Province Name
                provtb.Text = id.GetProvince(num);
                //Get Child number
                cid.Text = id.NumOfChild(num).ToString();

            }
        }
        public async void getItemFromDB()
        {
            this.allItems.Clear();
            try
            {
                var dp = App.conn;
                using (var statement = dp.Prepare(@"SELECT * FROM TaskItem"))
                {
                    while (SQLiteResult.ROW == statement.Step())
                    {
                        //do with pic
                        BitmapImage bimage = new BitmapImage();
                        StorageFile file = await StorageFile.GetFileFromPathAsync((string)statement[4]);
                        IRandomAccessStream instream = await file.OpenAsync(FileAccessMode.Read);
                        string boot = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(file);
                        await bimage.SetSourceAsync(instream);
                        // 处理时间
                        DateTime dt;
                        DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                        dtFormat.ShortDatePattern = "yyyy-MM-dd";
                        dt = Convert.ToDateTime((string)statement[3], dtFormat);
                        this.allItems.Add(new Models.TaskItem(statement[0].ToString(), statement[1].ToString(), (string)statement[2], bimage, dt, (string)statement[4], (string)statement[5], (string)statement[6]));
                    }
                }
            }
            catch
            {
                return;
            }


        }
 public void AbbreviatedDayNames_Set()
 {
     string[] newAbbreviatedDayNames = new string[] { "1", "2", "3", "4", "5", "6", "7" };
     var format = new DateTimeFormatInfo();
     format.AbbreviatedDayNames = newAbbreviatedDayNames;
     Assert.Equal(newAbbreviatedDayNames, format.AbbreviatedDayNames);
 }
        public DonorService(IMinistryPlatformService ministryPlatformService, IProgramService programService, ICommunicationService communicationService, IAuthenticationService authenticationService, IContactService contactService,  IConfigurationWrapper configuration, ICryptoProvider crypto)
            : base(authenticationService, configuration)
        {
            _ministryPlatformService = ministryPlatformService;
            _programService = programService;
            _communicationService = communicationService;
            _contactService = contactService;
            _crypto = crypto;

            _donorPageId = configuration.GetConfigIntValue("Donors");
            _donationPageId = configuration.GetConfigIntValue("Donations");
            _donationDistributionPageId = configuration.GetConfigIntValue("Distributions");
            _donorAccountsPageId = configuration.GetConfigIntValue("DonorAccounts");
            _findDonorByAccountPageViewId = configuration.GetConfigIntValue("FindDonorByAccountPageView");
            _donationStatusesPageId = configuration.GetConfigIntValue("DonationStatus");
            _donorLookupByEncryptedAccount = configuration.GetConfigIntValue("DonorLookupByEncryptedAccount");
            _myHouseholdDonationDistributions = configuration.GetConfigIntValue("MyHouseholdDonationDistributions");
            _recurringGiftBySubscription = configuration.GetConfigIntValue("RecurringGiftBySubscription");
            _recurringGiftPageId = configuration.GetConfigIntValue("RecurringGifts");
            _myDonorPageId = configuration.GetConfigIntValue("MyDonor");
            _myHouseholdDonationRecurringGifts = configuration.GetConfigIntValue("MyHouseholdDonationRecurringGifts");
            _myHouseholdRecurringGiftsApiPageView = configuration.GetConfigIntValue("MyHouseholdRecurringGiftsApiPageView");
            _myHouseholdPledges = configuration.GetConfigIntValue("MyHouseholdPledges");

            _dateTimeFormat = new DateTimeFormatInfo
            {
                AMDesignator = "am",
                PMDesignator = "pm"
            };

        }
 public void ShortestDayNames_Set()
 {
     string[] newShortestDayNames = new string[] { "1", "2", "3", "4", "5", "6", "7" };
     var format = new DateTimeFormatInfo();
     format.ShortestDayNames = newShortestDayNames;
     Assert.Equal(newShortestDayNames, format.ShortestDayNames);
 }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            serviceDeferral = taskInstance.GetDeferral();

            // Register to receive an event if Cortana dismisses the background task. This will
            // occur if the task takes too long to respond, or if Cortana's UI is dismissed.
            // Any pending operations should be cancelled or waited on to clean up where possible.
            taskInstance.Canceled += OnTaskCanceled;

            var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails;

            // Load localized resources for strings sent to Cortana to be displayed to the user.
            cortanaResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("Resources");

            // Select the system language, which is what Cortana should be running as.
            cortanaContext = ResourceContext.GetForViewIndependentUse();

            // Get the currently used system date format
            dateFormatInfo = CultureInfo.CurrentCulture.DateTimeFormat;

            // This should match the uap:AppService and VoiceCommandService references from the 
            // package manifest and VCD files, respectively. Make sure we've been launched by
            // a Cortana Voice Command.
            if (triggerDetails != null && triggerDetails.Name == "AwfulVoiceCommandService")
            {
                try
                {
                    voiceServiceConnection =
                        VoiceCommandServiceConnection.FromAppServiceTriggerDetails(
                            triggerDetails);

                    voiceServiceConnection.VoiceCommandCompleted += OnVoiceCommandCompleted;

                    VoiceCommand voiceCommand = await voiceServiceConnection.GetVoiceCommandAsync();

                    // Depending on the operation (defined in AdventureWorks:AdventureWorksCommands.xml)
                    // perform the appropriate command.
                    switch (voiceCommand.CommandName)
                    {
                        case "didMyThreadsUpdate":
                            await CheckForBookmarksForUpdates();
                            break;
                        case "didMyPmUpdate":
                            await CheckPmsForUpdates();
                            break;
                        default:
                            // As with app activation VCDs, we need to handle the possibility that
                            // an app update may remove a voice command that is still registered.
                            // This can happen if the user hasn't run an app since an update.
                            LaunchAppInForeground();
                            break;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Handling Voice Command failed " + ex.ToString());
                }
            }
        }
        private static string ExpandPredefinedFormat(string format, ref DateTime dateTime, ref DateTimeFormatInfo dtfi, ref TimeSpan offset)
        {
            switch (format[0])
            {
                case 'o':
                case 'O':
                    dtfi = DateTimeFormatInfo.InvariantInfo;
                    goto Label_0160;

                case 'r':
                case 'R':
                    if (offset != NullOffset)
                    {
                        dateTime -= offset;
                    }
                    else if (dateTime.Kind == DateTimeKind.Local)
                    {
                        InvalidFormatForLocal(format, dateTime);
                    }
                    dtfi = DateTimeFormatInfo.InvariantInfo;
                    goto Label_0160;

                case 's':
                    dtfi = DateTimeFormatInfo.InvariantInfo;
                    goto Label_0160;

                case 'u':
                    if (offset == NullOffset)
                    {
                        if (dateTime.Kind == DateTimeKind.Local)
                        {
                            InvalidFormatForLocal(format, dateTime);
                        }
                        break;
                    }
                    dateTime -= offset;
                    break;

                case 'U':
                    if (offset != NullOffset)
                    {
                        throw new FormatException(Environment.GetResourceString("Format_InvalidString"));
                    }
                    dtfi = (DateTimeFormatInfo) dtfi.Clone();
                    if (dtfi.Calendar.GetType() != typeof(GregorianCalendar))
                    {
                        dtfi.Calendar = GregorianCalendar.GetDefaultInstance();
                    }
                    dateTime = dateTime.ToUniversalTime();
                    goto Label_0160;

                default:
                    goto Label_0160;
            }
            dtfi = DateTimeFormatInfo.InvariantInfo;
        Label_0160:
            format = GetRealFormat(format, dtfi);
            return format;
        }
        public static string ConvertDateToString(object dateObject)
        {
            DateTimeFormatInfo datefomatProvider = new DateTimeFormatInfo();
            datefomatProvider.DateSeparator = "/";
            datefomatProvider.FullDateTimePattern = "dd/MM/yyyy";

            return Convert.ToDateTime(dateObject, datefomatProvider).ToString("dd/MM/yyyy");
        }
 public void SetUp()
 {
     parser = new PvcsHistoryParser();
     dfi = new DateTimeFormatInfo();
     dfi.AMDesignator = "AM";
     dfi.PMDesignator = "PM";
     dfi.MonthDayPattern = @"M/d/yy h:mm:ss tt";
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PersianCultureInfo"/> class.
 /// </summary>
 public PersianCultureInfo()
     : base("fa-IR", false)
 {
     calendar = new PersianCalendar();
     systemCalendar = new System.Globalization.PersianCalendar();
     format = CreateDateTimeFormatInfo();
     SetCalendar();
 }
 public void TestLongTimePatternLocale2(string locale)
 {
     CultureInfo myTestCulture = new CultureInfo(locale);
     DateTimeFormatInfo myDateTimeFormat = new DateTimeFormatInfo();
     myDateTimeFormat.LongTimePattern = "H:mm:ss";
     myTestCulture.DateTimeFormat = myDateTimeFormat;
     Assert.Equal("H:mm:ss", myTestCulture.DateTimeFormat.LongTimePattern);
 }
Exemple #30
0
 public static DateTime convertDatetime(string date)
 {
     System.Globalization.DateTimeFormatInfo dtfi = new System.Globalization.DateTimeFormatInfo();
     dtfi.ShortDatePattern = "dd/MM/yyyy";
     dtfi.DateSeparator = "/";
     DateTime datec = Convert.ToDateTime(date, dtfi);
     return datec;
 }
        /// <summary>
        /// Returns the string that describes the functionality of the
        /// CalendarDayButton that is associated with this
        /// CalendarDayButtonAutomationPeer.  This method is called by
        /// GetHelpText.
        /// </summary>
        /// <returns>
        /// The help text, or String.Empty if there is no help text.
        /// </returns>
        protected override string GetHelpTextCore()
        {
            CalendarDayButton button = OwningCalendarDayButton;

            if (button != null && button.DataContext != null && button.DataContext is DateTime)
            {
                DateTime dataContext = (DateTime)OwningCalendarDayButton.DataContext;
                Globalization.DateTimeFormatInfo info = DateTimeHelper.GetCurrentDateFormat();

                return(!button.IsBlackout ?
                       dataContext.Date.ToString(info.LongDatePattern, info) :
                       string.Format(info, "Blackout Day - {0}", dataContext.Date.ToString(info.LongDatePattern, info)));
            }

            return(base.GetHelpTextCore());
        }
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            System.Globalization.DateTimeFormatInfo dateTimeFormat = GetCurrentDateFormat();
            string[] shortestDayNames = dateTimeFormat.ShortestDayNames;
            string[] dayNames         = dateTimeFormat.DayNames;

            for (int i = 0; i < shortestDayNames.Count(); i++)
            {
                if (shortestDayNames[i] == value.ToString())
                {
                    return(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(dayNames[i]));
                }
            }

            return(null);
        }
        /// <summary>
        /// Returns the string that describes the functionality of the
        /// CalendarDayButton that is associated with this
        /// CalendarDayButtonAutomationPeer.  This method is called by
        /// GetHelpText.
        /// </summary>
        /// <returns>
        /// The help text, or String.Empty if there is no help text.
        /// </returns>
        protected override string GetHelpTextCore()
        {
            CalendarDayButton button = OwningCalendarDayButton;

            if (button != null && button.DataContext != null && button.DataContext is DateTime)
            {
                DateTime dataContext = (DateTime)OwningCalendarDayButton.DataContext;
                Globalization.DateTimeFormatInfo info = DateTimeHelper.GetCurrentDateFormat();

                return(!button.IsBlackout ?
                       dataContext.Date.ToString(info.LongDatePattern, info) :
                       string.Format(info, System.Windows.Controls.Properties.Resources.CalendarAutomationPeer_BlackoutDayHelpText, dataContext.Date.ToString(info.LongDatePattern, info)));
            }

            return(base.GetHelpTextCore());
        }
 private void DataSelect_SelectedDateChanged(object sender, System.EventArgs e)
 {
     if (this.DataSelect.IsDropDownOpen && this.DataSelect.IsInitialized)
     {
         this.InitUI();
         this.Clear();
         System.DateTime dt     = this.DataSelect.SelectedDate.Value;
         string          format = "yyyy-MM-dd";
         string          time   = dt.ToString(format, System.Globalization.DateTimeFormatInfo.InvariantInfo);
         System.Globalization.DateTimeFormatInfo info  = new System.Globalization.DateTimeFormatInfo();
         System.Globalization.DateTimeStyles     style = System.Globalization.DateTimeStyles.None;
         this.DataSelect.SelectedDate = new System.DateTime?(System.DateTime.Parse(time, info, style));
         this.Starttime = time + " 00:00:00";
         this.endtime   = time + " 24:00:00";
         if (this.type == MessageActorType.EntStaff)
         {
             Staff staff = this.dataService.GetStaff(this.id);
             if (staff != null)
             {
                 this.viewModel.SendStaffDataSearchMessage(this.sessionService.Uid, staff.Uid, this.Starttime, 0, 10, this.endtime, MessageRecordType.MESSAGE_CHAT_RECORD);
                 this.sessionService.IsDateSearch = true;
             }
         }
         else
         {
             if (this.type == MessageActorType.CooperationStaff)
             {
                 if (this.coopStaff != null)
                 {
                     this.viewModel.SendCooperationMessageRecordRequestByDate(this.sessionService.Uid, this.coopStaff.Uid, this.coopStaff.ProjectId, this.Starttime, this.page, 10, this.endtime, MessageRecordType.MESSAGE_CHAT_RECORD);
                 }
             }
             else
             {
                 EntGroup group = this.dataService.GetEntGroup(this.id);
                 if (group != null)
                 {
                     this.viewModel.SendGroupSearchRecord(this.sessionService.Uid, this.id, this.Starttime, 0, 10, this.endtime, MessageRecordType.MESSAGE_CHAT_RECORD);
                     this.sessionService.IsDateSearch = true;
                 }
             }
         }
         this.InitPage();
         this.DataSelect.Text           = this.endtime;
         this.DataSelect.IsDropDownOpen = false;
     }
 }
        protected void btnTravelDays_Click(object sender, EventArgs e)
        {
            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

            dtFormat.ShortDatePattern = "yyyy/MM/dd";
            DateTime dtBeginDate  = Convert.ToDateTime(BeginDate.Text, dtFormat);
            DateTime dtEndDate    = Convert.ToDateTime(EndDate.Text, dtFormat);
            int      intBeginFlag = int.Parse(BeginFlag.Value);
            int      intEndFlag   = int.Parse(EndFlag.Value);
            float    fResult      = 0;
            TimeSpan ts;

            //int differenceInDays = ts.Days;
            flotxDays = 0;
            for (DateTime dtT = dtBeginDate; dtT < dtEndDate.AddDays(1); dtT = dtT.AddDays(1))
            {
                int intdtT = (int)dtT.DayOfWeek;
                if (intdtT == 6 || intdtT == 0)
                {
                    flotxDays = flotxDays + 1;
                }
            }
            txDays.Text = flotxDays.ToString();

            if (intBeginFlag == 1 && intEndFlag == 1)
            {
                ts      = dtEndDate - dtBeginDate;
                fResult = ts.Days + float.Parse("1");
            }
            if (intBeginFlag == 0 && intEndFlag == 1)
            {
                ts      = dtEndDate - dtBeginDate.AddDays(1);
                fResult = ts.Days + float.Parse("0.5") + float.Parse("1");
            }
            if (intBeginFlag == 1 && intEndFlag == 0)
            {
                ts      = dtEndDate - dtBeginDate;
                fResult = ts.Days - float.Parse("0.5") + float.Parse("1");
            }
            if (intBeginFlag == 0 && intEndFlag == 0)
            {
                ts      = dtEndDate - dtBeginDate;
                fResult = ts.Days;
            }

            TravelDays.Text = fResult.ToString();
        }
Exemple #36
0
        /// <summary>
        /// format string datetime
        /// </summary>
        /// <param name="date">date</param>
        /// <returns></returns>
        public static DateTime Parse(string date)
        {
            System.Globalization.DateTimeFormatInfo formatInfo = new System.Globalization.DateTimeFormatInfo();
            formatInfo.ShortDatePattern = m_DatePattern;
            DateTime parseTime;

            try
            {
                parseTime = DateTime.Parse(date, formatInfo);
            }
            catch
            {
                parseTime = MeanlessDate;
            }

            return(parseTime);
        }
Exemple #37
0
        public ActionResult getInstallments()
        {
            var context = new RRRoadwaysDBContext();
            //var dataInstallments = context.Installment.ToList().OrderByDescending(x => x.Id);
            List <Installment> installments = context.Installment.ToList();
            List <Vehicle>     vehicles     = context.Vehicle.Where(x => x.IsDeleted == false).ToList();

            System.Globalization.DateTimeFormatInfo mfi = new System.Globalization.DateTimeFormatInfo();

            var dataInstallments = (from i in installments
                                    join v in vehicles on i.VehicleId equals v.Id
                                    select new { i.Id, v.VehicleNumber, InstallmentsMonth = mfi.GetMonthName(Convert.ToInt32(i.InstallmentsMonth)), InstallmentDate = i.InstallmentDate.GetValueOrDefault().ToString("dddd, dd MMMM yyyy"), i.InstallmentDetail, i.Amount }
                                    ).ToList();


            return(Json(new { data = dataInstallments }, new Newtonsoft.Json.JsonSerializerSettings()));
        }
Exemple #38
0
    public void Insert_InvoiceMaster()
    {
        System.Globalization.DateTimeFormatInfo dateInfo = new System.Globalization.DateTimeFormatInfo();
        dateInfo.ShortDatePattern = "dd-MM-yyyy";

        PLobj.INCid       = objBL.Generate_INCCHID();
        PLobj.Vid         = Convert.ToInt32(cmbVendoreName.SelectedItem.Value);
        PLobj.INCDate     = Convert.ToDateTime(txtINCDt.Text, dateInfo);
        PLobj.InvoiceNO   = Convert.ToInt32(txtInvoiceNo.Text);
        PLobj.PoNo        = txtPONO.Text;
        PLobj.Podate      = Convert.ToDateTime(txtPODt.Text, dateInfo);
        PLobj.CreatedDate = Convert.ToDateTime(CurrDt, dateInfo);
        PLobj.Enteredby   = Session["UserName"].ToString();
        PLobj.Status      = "N";

        K = objBL.InvoiceMaster(PLobj);
    }
Exemple #39
0
        private void 实时数据预约写文件_Tick(object sender, EventArgs e)
        {
            string             timenow = DateTime.Now.ToString();
            DateTime           dt0, dt1, dt2;
            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

            dtFormat.ShortDatePattern = "yyyy/MM/dd HH:mm:ss";
            dt0 = Convert.ToDateTime(StartTime实时, dtFormat);
            dt1 = Convert.ToDateTime(timenow, dtFormat);
            dt2 = Convert.ToDateTime(StopTime实时, dtFormat);
            if (DateTime.Compare(dt1, dt0) >= 0 &&
                DateTime.Compare(dt1, dt2) < 0)
            {
                //正在采集?
                if (RealPointRecordFlag == 1)
                {
                }
                else
                {
                    //没在采集,现在打开
                    if (RealPointRecord == null)
                    {
                        RealPointRecord          = new Thread(RealPointRecordFunc);
                        RealPointRecord.Priority = ThreadPriority.AboveNormal;
                    }
                    if (RealPointRecord.ThreadState == System.Threading.ThreadState.Unstarted ||
                        RealPointRecord.ThreadState == System.Threading.ThreadState.Stopped)
                    {
                        RealPointRecord.Start();
                        RealPointRecordFlag = 1;
                        //设置开关
                        toolStripMenuItem9.Checked  = true;
                        toolStripMenuItem10.Checked = false;
                    }
                }
            }
            //关闭采集
            else if (DateTime.Compare(dt1, dt2) >= 0)
            {
                RealPointRecordFlag = 0;
                实时数据预约写文件.Enabled   = false;
                //设置开关
                toolStripMenuItem9.Checked  = false;
                toolStripMenuItem10.Checked = true;
            }
        }
Exemple #40
0
 private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.DateSelect.IsDropDownOpen && this.DateSelect.Text != this.startTime)
     {
         this.DateSearch = true;
         this.trgMessageTable.Rows.Clear();
         System.DateTime dt     = this.DateSelect.SelectedDate.Value;
         string          format = "yyyy-MM-dd";
         string          time   = dt.ToString(format, System.Globalization.DateTimeFormatInfo.InvariantInfo);
         System.Globalization.DateTimeFormatInfo info  = new System.Globalization.DateTimeFormatInfo();
         System.Globalization.DateTimeStyles     style = System.Globalization.DateTimeStyles.None;
         this.DateSelect.SelectedDate = new System.DateTime?(System.DateTime.Parse(time, info, style));
         this.startTime = time + " 00:00:00";
         this.endTime   = time + " 24:00:00";
         this.messageCenter.SendOADataSearch(this.sessionService.Uid, this.startTime, 0, 10, this.type, this.endTime);
     }
 }
Exemple #41
0
 /// <summary>
 /// 檢查日期時間是否合法。
 /// </summary>
 /// <param name="datetime">日期或時間字串。</param>
 /// <param name="format">格式化字串。</param>
 /// <remarks>
 /// format格式:
 /// 年: yyyy
 /// 月: MM
 /// 日: dd
 /// 時: HH
 /// 分: mm
 /// 秒: ss
 /// </remarks>
 public static bool ValidateDateTime(string datetime, string format)
 {
     if (datetime == null || datetime.Length == 0)
     {
         return(false);
     }
     try
     {
         System.Globalization.DateTimeFormatInfo dtfi = new System.Globalization.DateTimeFormatInfo();
         dtfi.FullDateTimePattern = format;
         DateTime dt = DateTime.ParseExact(datetime, "F", dtfi);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #42
0
        /// <summary>
        /// 判断是否在开启日期之前.
        /// </summary>
        /// <returns><c>true</c>, 时, <c>false</c> 不是.</returns>
        /// <param name="iStartDate">开始日期(YYYY/MM/DD HH:MM).</param>
        public static bool isBeforeDate(string iStartDate)
        {
            DateTime _now = DateTime.Now;

            if ((false == string.IsNullOrEmpty(iStartDate)) &&
                (false == "-".Equals(iStartDate)))
            {
                DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
                dtFormat.ShortDatePattern = "yyyy/MM/dd HH:MM";

                DateTime _start = Convert.ToDateTime(iStartDate, dtFormat);
                if (_now.CompareTo(_start) < 0)
                {
                    return(true);
                }
            }
            return(false);
        }
 private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.DateSelect.IsInitialized && this.DateSelect.IsDropDownOpen)
     {
         System.DateTime dt     = this.DateSelect.SelectedDate.Value;
         string          format = "yyyy-MM-dd";
         string          time   = dt.ToString(format, System.Globalization.DateTimeFormatInfo.InvariantInfo);
         System.Globalization.DateTimeFormatInfo info  = new System.Globalization.DateTimeFormatInfo();
         System.Globalization.DateTimeStyles     style = System.Globalization.DateTimeStyles.None;
         this.DateSelect.SelectedDate = new System.DateTime?(System.DateTime.Parse(time, info, style));
         this.Starttime = time + " 00:00:00";
         this.endtime   = time + " 24:00:00";
         this.Showpage  = 0;
         if (this.IsMark)
         {
             if (this.IsStaff)
             {
                 this.messageCenter.SendStaffDateSearchMark(this.sessionService.Uid, this.ID, this.Starttime, 0, 10, this.endtime, MessageRecordType.MESSAGE_CENTER_RECORD);
                 this.IsDataSearch = true;
             }
             else
             {
                 this.messageCenter.SendGroupDateSearchMark(this.ID, this.Starttime, 0, 10, this.sessionService.Uid, this.endtime, MessageRecordType.MESSAGE_CENTER_RECORD);
                 this.IsDataSearch = true;
             }
         }
         else
         {
             if (this.IsStaff)
             {
                 this.viewModel.SendStaffSearchRecord(this.sessionService.Uid, this.ID, this.Starttime, 0, 10, this.endtime, MessageRecordType.MESSAGE_CENTER_RECORD);
                 this.IsDataSearch = true;
             }
             else
             {
                 this.viewModel.SendGroupSearchRecord(this.sessionService.Uid, this.ID, this.Starttime, 0, 10, this.endtime, MessageRecordType.MESSAGE_CENTER_RECORD);
                 this.IsDataSearch = true;
             }
         }
         this.DateSelect.IsDropDownOpen = false;
     }
 }
Exemple #44
0
        //获取工单详细信息
        public static string GetWorkOrderInfo(string data)
        {
            string[]           data1    = data.Split(',');
            string             cid      = data1[0].ToString();
            string             Stime    = data1[1].ToString();
            string             Etime    = data1[2].ToString();
            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

            dtFormat.ShortDatePattern = "yyyy/MM/dd";
            DateTime Stime1 = Convert.ToDateTime(Stime, dtFormat);
            DateTime Etime1 = Convert.ToDateTime(Etime, dtFormat);

            var context = LEDAO.APIGateWay.GetEntityContext();
            var var     = from a in context.P_WorkOrder join c in context.P_SSW_PrintList on a.order_no equals c.order_no into d from e in d.DefaultIfEmpty() join f in context.P_SSW_TemplateList on a.product_code equals f.product_code into j from k in j.DefaultIfEmpty() join m in context.B_Product on a.product_code equals m.product_code into n from p in n.DefaultIfEmpty() where (a.product_code.IndexOf(cid) != -1 && a.input_time >= Stime1 && a.input_time <= Etime1 && a.state == 1)select new { Order_No = a.order_no, product_code = a.product_code, Qty = a.qty, State = e.state == null ? "在制" : "打印完成", InputTime = a.input_time, completed = e.completed == null ? 0 : e.completed, Template_id = k.Template_id, product_name = p.product_name };

            {
                return(JsonConvert.SerializeObject(var.ToList()));
            }
            return(null);
        }
Exemple #45
0
        //

        public static string DateTimeString(DateTime time)
        {
            System.Globalization.DateTimeFormatInfo info = new System.Globalization.DateTimeFormatInfo();

#if NO
            CultureInfo en = new CultureInfo("en-US");

            CultureInfo save = Thread.CurrentThread.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = en;
#endif

            string strTime = time.ToString(info.LongTimePattern,
                                           DateTimeFormatInfo.InvariantInfo);

#if NO
            Thread.CurrentThread.CurrentCulture = save;
#endif
            return(strTime);
        }
Exemple #46
0
        // format a string from a given DateTime reference.
        // possible format:
        //    (1) "dd/MM/yyyy HH:mm:ss" (HH - 24 hours clock)
        static internal string ToString(DateTime dateTime, System.Globalization.DateTimeFormatInfo formatter)
        {
            string dateTimeString;

            try
            {
                dateTimeString = dateTime.ToString(formatter);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                StringBuilder dateTimeTmpString = new StringBuilder();

                //..

                dateTimeString = dateTimeTmpString.ToString();
            }

            return(dateTimeString);
        }
    public void InsertLoanMaster()
    {
        System.Globalization.DateTimeFormatInfo dateInfo = new System.Globalization.DateTimeFormatInfo();
        dateInfo.ShortDatePattern = "dd/MM/yyyy";
        PLobj.BID       = Convert.ToInt32(CmbBankName.SelectedValue);
        PLobj.LoanDt    = Convert.ToDateTime(txtLoanDt.Text, dateInfo);
        PLobj.AccountNo = Convert.ToInt64(txtAccountNo.Text);
        PLobj.DueDt     = Convert.ToDateTime(txtEMTDt.Text, dateInfo);
        PLobj.LoanAmt   = Convert.ToDecimal(txtLoanTotAmt.Text);
        PLobj.EmiAmt    = Convert.ToDecimal(txtEMIAmt.Text);
        PLobj.Status    = "UnPaid";
        K = objBL.InsertLoanMaster(PLobj);

        if (K > 0)
        {
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "err_msg", "alert(' Loan Record Saved Successful !');location.href='LoanEntry.aspx'", true);
        }
        {
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "err_msg", "alert(' Loan Record Inserted Failed !');location.href='LoanEntry.aspx'", true);
        }
    }
Exemple #48
0
        /// <summary>
        /// 英字元号取得
        /// </summary>
        /// <param name="date">日付</param>
        /// <returns>英字元号(H:平成etc)</returns>
        public static string GetAlphabetEra(DateTime date)
        {
            System.Globalization.DateTimeFormatInfo formatInfo = null;
            System.Globalization.CultureInfo        culture    = new System.Globalization.CultureInfo("ja-JP");

            formatInfo          = culture.DateTimeFormat;
            formatInfo.Calendar = new System.Globalization.JapaneseCalendar();

            int    era     = formatInfo.Calendar.GetEra(DateTime.Now);
            string eraText = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

            for (int i = 0; i < eraText.Length; i++)
            {
                if (formatInfo.GetEra(eraText[i].ToString()) == era)
                {
                    return(eraText[i].ToString());
                }
            }

            return("H");
        }
Exemple #49
0
        private void DataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }
            this.Id_Label.Text = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            this.textBox1.Text = this.dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
            this.textBox2.Text = this.dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
            this.textBox3.Text = this.dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
            this.textBox4.Text = this.dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
            this.textBox5.Text = this.dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

            dtFormat.ShortDatePattern  = "yyyy-MM-dd";
            this.dateTimePicker1.Value = Convert.ToDateTime(this.dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(), dtFormat);
            this.dateTimePicker2.Value = Convert.ToDateTime(this.dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(), dtFormat);
            this.Create_label.Text     = this.dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
            this.Chang_label.Text      = this.dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
            this.textBox8.Text         = this.dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString();
        }
Exemple #50
0
        public static DateTime ToDateTime(string strTime)
        {
            System.Globalization.DateTimeFormatInfo info = new System.Globalization.DateTimeFormatInfo();

#if NO
            CultureInfo en = new CultureInfo("en-US");

            CultureInfo save = Thread.CurrentThread.CurrentCulture;
#endif
            DateTime parsedBack = DateTime.ParseExact(strTime,
                                                      info.LongTimePattern,
                                                      DateTimeFormatInfo.InvariantInfo
                                                      // en.DateTimeFormat
                                                      );
#if NO
            Thread.CurrentThread.CurrentCulture = save;
#endif
            // DateTime localTime = TimeZone.CurrentTimeZone.ToLocalTime(parsedBack);
            //return localTime.ToString();
            return(parsedBack);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="defaultvalue">yyyy/MM/dd形式的</param>
        public void SetDefaultValue(string defaultvalue)
        {
            if ("".Equals(defaultvalue) || defaultvalue == null)
            {
                this.dateTimePicker1.Format       = DateTimePickerFormat.Custom;
                this.dateTimePicker1.CustomFormat = "       ";
                //this.dateTimePicker1.Text = "";
                //this.dateTimePicker1.Value = this.dateTimePicker1.MinDate;
            }
            else
            {
                DateTime           dt;
                DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
                dtFormat.ShortDatePattern = "yyyy/MM/dd";
                dt = Convert.ToDateTime(defaultvalue, dtFormat);

                this.dateTimePicker1.Format       = DateTimePickerFormat.Long;
                this.dateTimePicker1.CustomFormat = null;
                this.dateTimePicker1.Value        = dt;
            }
        }
Exemple #52
0
        // 把字符串转换为DateTime对象
        // 注意返回的是GMT时间
        // 注意可能抛出异常
        public static DateTime FromRfc1123DateTimeString(string strTime)
        {
            if (string.IsNullOrEmpty(strTime) == true)
            {
                throw new Exception("时间字符串为空");
            }

            string   strError    = "";
            string   strMain     = "";
            string   strTimeZone = "";
            TimeSpan offset;
            // 将RFC1123字符串中的timezone部分分离出来
            // parameters:
            //      strMain [out]去掉timezone以后的左边部分
            //      strTimeZone [out]timezone部分
            int nRet = SplitRfc1123TimeZoneString(strTime,
                                                  out strMain,
                                                  out strTimeZone,
                                                  out offset,
                                                  out strError);

            if (nRet == -1)
            {
                throw new Exception(strError);
            }

            System.Globalization.DateTimeFormatInfo info = new System.Globalization.DateTimeFormatInfo();
            CultureInfo en = new CultureInfo("en-US");

            CultureInfo save       = Thread.CurrentThread.CurrentCulture;
            DateTime    parsedBack = DateTime.ParseExact(strMain + " GMT",
                                                         info.RFC1123Pattern,
                                                         en.DateTimeFormat/*,
                                                                           * DateTimeStyles.AdjustToUniversal*/
                                                         );

            Thread.CurrentThread.CurrentCulture = save;

            return(parsedBack - offset);
        }
Exemple #53
0
        public IndexViewModel GetModelByUserAndDate(string user, DateTime from, DateTime to)
        {
            MembershipUser currentUser;
            var            model         = GetModel(user, out currentUser);
            var            dateInfo      = new System.Globalization.DateTimeFormatInfo();
            var            selectedMonth = dateInfo.GetMonthName(from.Month);

            model.HiChartTitle = "Expenses Chart As Of " + selectedMonth;

            if (currentUser != null)
            {
                model.Expenses         = GetExpenseModelByUserEmailAndDate(currentUser.Email, from, to);
                model.ExpenseChartData = GetExpensesChart(model.Expenses);
                model.ExpenseTagData   = GetExpensesTag(model.Expenses);
            }
            model.TagList                = GetTagModel();
            model.MonthsList             = GetMonthsList();
            model.ExpenseFilter.FromDate = from;
            model.ExpenseFilter.ToDate   = to;

            return(model);
        }
Exemple #54
0
        private void ShowAllCampgrounds()
        {
            int park_id = CLIHelper.GetInteger("Please Select Park ID ");

            Console.WriteLine();
            Console.WriteLine("Showing All Campgrounds in Selected Park:");
            Console.WriteLine();
            CampgroundDAL     dal         = new CampgroundDAL(connectionString);
            List <Campground> listOfCamps = dal.GetCampGroundsList(park_id);

            foreach (Campground c in listOfCamps)
            {
                System.Globalization.DateTimeFormatInfo gmn = new
                                                              System.Globalization.DateTimeFormatInfo();
                string strMonthName = gmn.GetMonthName(c.OpenFromMM).ToString();
                string endMonthName = gmn.GetMonthName(c.OpenToMM).ToString();

                Console.WriteLine();
                Tools.ColorfulWriteLine("Campground ID".PadRight(20) + "Name".PadRight(35) + "Opens".PadRight(10) + "Closes".PadRight(15) + "Daily Fee", ConsoleColor.Green);
                Console.WriteLine($"{c.CampgroundId})".PadRight(20) + $"{c.Name}".PadRight(35) + $"{strMonthName}".PadRight(10) + $"{endMonthName}".PadRight(15) + $"${c.DailyFee}");
                Console.WriteLine();
            }
        }
        public async Task <List <TimeSpanDto> > GetTimeSpanCollection()
        {
            var result = await Task.Run(() =>
            {
                List <TimeSpanDto> data     = new List <TimeSpanDto>();
                TimeSpanDto dto             = null;
                var startDate               = DateTime.Now.Date.ToString("yyyy/MM/dd");
                var nextDate                = DateTime.Now.AddDays(1).Date.ToString("yyyy/MM/dd");
                DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

                dtFormat.ShortDatePattern = "yyyy/MM/dd HH:mm";

                for (int i = 0; i < 24; i++)
                {
                    var startTime = string.Format("{0}:00", i.ToString().PadLeft(2, '0'));
                    var endTime   = string.Format("{0}:00", (i + 1).ToString().PadLeft(2, '0'));
                    dto           = new TimeSpanDto();
                    dto.Id        = i + 1;
                    dto.Text      = string.Format("{0} {1} - {2}", startDate, startTime, endTime);
                    dto.StartTime = Convert.ToDateTime(string.Format("{0} {1}", startDate, startTime), dtFormat);
                    if (i == 23)
                    {
                        dto.EndTime = Convert.ToDateTime(string.Format("{0} {1}", nextDate, "00:00"), dtFormat);
                    }
                    else
                    {
                        dto.EndTime = Convert.ToDateTime(string.Format("{0} {1}", startDate, endTime), dtFormat);
                    }

                    data.Add(dto);
                }

                return(data);
            });

            return(result);
        }
Exemple #56
0
        // 将u时间字符串转换为本地表现形态字符串
        public static string uDateTimeStringToLocal(string strTime)
        {
            if (String.IsNullOrEmpty(strTime) == true)
            {
                return("");
            }
#if NO
            System.Globalization.DateTimeFormatInfo info = new System.Globalization.DateTimeFormatInfo();
            CultureInfo en = new CultureInfo("en-US");

            CultureInfo save = Thread.CurrentThread.CurrentCulture;
#endif
            DateTime parsedBack = DateTime.ParseExact(strTime,
                                                      "yyyy-MM-dd HH:mm:ssZ",
                                                      DateTimeFormatInfo.InvariantInfo
                                                      // en.DateTimeFormat
                                                      );
#if NO
            Thread.CurrentThread.CurrentCulture = save;
#endif

            DateTime localTime = TimeZone.CurrentTimeZone.ToLocalTime(parsedBack);
            return(localTime.ToString("yyyy-MM-dd HH:mm:ss"));
        }
        protected void Save_Click(object sender, EventArgs e)
        {
            btnTravelDays_Click(null, null);

            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

            dtFormat.ShortDatePattern = "yyyy/MM/dd";
            if ((Convert.ToDateTime(BeginDate.Text, dtFormat) > Convert.ToDateTime(EndDate.Text, dtFormat)) || (Convert.ToDateTime(BeginDate.Text, dtFormat) == Convert.ToDateTime(EndDate.Text, dtFormat) && BeginFlag.Value == "0" && EndFlag.Value == "0"))
            {
                ShowMsgHelper.Alert_Error("Date Error");
            }
            else
            {
                Hashtable ht = new Hashtable();
                ht = ControlBindHelper.GetWebControls(this.Page);
                //ht["EmpID"] = txt_EmpID;
                //ht["CreateDate"] = CreateDate.Text;
                //ht["ApprovalFlag"] = 0;
                if (int_AppFlag == 3)
                {
                    ht["ApprovalFlag"] = 1;
                }
                //ht["NextApprover"] = txt_NextApprover;
                ht["FilesAdd"]   = txt_FilesAdd;
                ht["TravelDays"] = TravelDays.Text;
                int IsOk = DataFactory.SqlDataBase().UpdateByHashtable("Base_PerTravelApply", "id", _key, ht);
                if (IsOk > 0)
                {
                    ShowMsgHelper.AlertMsg("Success!");
                }
                else
                {
                    ShowMsgHelper.Alert_Error("Error!");
                }
            }
        }
Exemple #58
0
        private int CallCJDays(DateTime dtBeginDate, DateTime dtEndDate)
        {
            int intResult = 0;
            int intJR     = 0;
            int intZM     = 0;

            string        sql    = "select * from Base_ATS_HolidaySetting where (BeginDate>='" + dtBeginDate + "' and BeginDate<='" + dtEndDate + "') or (EndDate>='" + dtBeginDate + "' and EndDate<='" + dtEndDate + "')";
            StringBuilder sb_sql = new StringBuilder(sql);
            DataTable     dt     = DataFactory.SqlDataBase().GetDataTableBySQL(sb_sql);

            if (dt.Rows.Count > 0)
            {
                float    fResult = 0;
                TimeSpan ts;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();
                    dtFormat.ShortDatePattern = "yyyy/MM/dd";
                    DateTime dtBDate = Convert.ToDateTime(dt.Rows[0]["BeginDate"].ToString(), dtFormat);
                    DateTime dtEDate = Convert.ToDateTime(dt.Rows[0]["EndDate"].ToString(), dtFormat);
                    ts      = dtEDate - dtBDate;
                    fResult = ts.Days;
                    intJR   = intJR + (int)fResult;
                }
            }

            for (DateTime dtCurr = dtBeginDate; dtCurr <= dtEndDate; dtCurr = dtCurr.AddDays(1))
            {
                if ((int)dtCurr.DayOfWeek == 0 || (int)dtCurr.DayOfWeek == 6)
                {
                    intZM = intZM + 1;
                }
            }
            intResult = intZM + intJR;
            return(intResult);
        }
Exemple #59
0
 public void SetDateFormat(System.Globalization.DateTimeFormatInfo format)
 {
     DateFormat    = format;
     dateText.Hint = format.ShortDatePattern;
 }
Exemple #60
0
        //[AllowAnonymous]
        public async Task <ActionResult <LeaveResponse> > RequestRest([FromBody] LeaveRequest request)
        {
            var stu_id = Int32.Parse(User.Identity.Name);

            if (await UserAccessor.CheckRole(stu_id) == Constants.Role.Provider)
            {
                return(BadRequest(new { message = "Providers cannot create leave application." }));
            }
            int check_leave = await LeaveAccessor.CheckLeave(stu_id, request.work_id, request.leave_day);

            if (check_leave == 1)
            {
                // 已成功申请
                return(Ok(-21));
            }
            else if (check_leave == 2)
            {
                // 正在申请中
                return(Ok(-22));
            }
            var temp = _mapper.Map <LeaveEntity>(request);

            /* 检查请假时间是否在工作时间内 */
            WorkTimeEntity work_time = await WorkAccessor.GetWorkTime(temp.work_id);

            DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

            dtFormat.ShortDatePattern = "yyyy-MM-dd";
            DateTime stDay = Convert.ToDateTime(work_time.start_day, dtFormat);
            DateTime edDay = Convert.ToDateTime(work_time.end_day, dtFormat);
            DateTime lvDay = Convert.ToDateTime(temp.leave_day);

            if (lvDay < stDay || lvDay > edDay || Convert.ToInt32(lvDay.DayOfWeek) != work_time.week_day)
            {
                return(Ok(-10)); //"The date of leave is not included in the work date."
            }

            dtFormat.ShortDatePattern = "HH:mm";
            DateTime stTime   = Convert.ToDateTime(work_time.start_time, dtFormat);
            DateTime edTime   = Convert.ToDateTime(work_time.end_time, dtFormat);
            DateTime lvStTime = Convert.ToDateTime(temp.leave_start, dtFormat);
            DateTime lvEdTime = Convert.ToDateTime(temp.leave_end, dtFormat);

            if (lvStTime < stTime || lvEdTime > edTime)
            {
                return(Ok(-11)); //"The time of leave is not included in the work time."
            }

            temp.leave_duration = CalDurationTime(temp.leave_start, temp.leave_end);
            temp.student_id     = stu_id;

            var ans = await LeaveAccessor.Create(temp);

            if (ans > 0)
            {
                var leavere = await LeaveAccessor.Find(ans);

                if (leavere != null)
                {
                    return(Ok(_mapper.Map <LeaveResponse>(leavere)));
                }
                return(Ok(-1));
            }
            return(Ok(-1));
        }