示例#1
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Dates -->
        /// <summary>
        ///      operates off of the .Text property of the control
        /// </summary>
        /// <param name="form">allows no-op if the control is not on the form</param>
        /// <param name="control"></param>
        /// <param name="defaultValue"></param>
        /// <returns>will not return null, if null is passed to it will return Date.Null</returns>
        public static TimeDate_old Dates(Form form, Control control, TimeDate_old defaultDate)
        {
            TimeDate_old date;

            if (defaultDate == null)
            {
                defaultDate = TimeDate_old.Null;
            }
            date = defaultDate.DateOnly;
            if (Active(form, control))
            {
                if (Regex.IsMatch(control.Text, "^[0-3]?[0-9]/[0-3]?[0-9]/....$"))
                {
                    date = (new TimeDate_old(control.Text, DateTimeKind.Utc));
                }
                else
                {
                    date = (new TimeDate_old(control.Text, DateTimeKind.Local)).Utc();
                }
                if (date.IsNull)
                {
                    date = defaultDate;
                }
            }
            return(date);
        }
示例#2
0
 public static void Dates(Form form, TextBox txtDateTime, TimeDate_old date, string format)
 {
     if (Scrape.Active(form, txtDateTime))
     {
         txtDateTime.Text = date.ToString(format);
     }
 }
示例#3
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Dates -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="form">allows no-op if the control is not on the form</param>
        /// <param name="dateField"></param>
        /// <param name="timeField"></param>
        /// <param name="defaultDate"></param>
        /// <returns></returns>
        public static TimeDate_old Dates(Form form, string dateField, string timeField, TimeDate_old defaultDate)
        {
            TimeDate_old date = new TimeDate_old(
                Dates(form, dateField, defaultDate).AddHours(12).DateOnly
                , Time(form, timeField, defaultDate.CLRFormat.TimeOfDay)
                , DateTimeKind.Local);

            return(date);
        }
示例#4
0
        public static TimeDate_old Dates(Form form, DateTimePicker dateField, DateTimePicker timeField, TimeDate_old defaultDate)
        {
            TimeDate_old date = defaultDate;

            if (Active(form, dateField) && Active(form, timeField))
            {
                date = new TimeDate_old(
                    Dates(form, dateField, defaultDate).AddHours(6).DateOnly
                    , Time(form, timeField, defaultDate.CLRFormat.TimeOfDay)
                    , DateTimeKind.Local);
            }
            return(date);
        }
示例#5
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Dates -->
        /// <summary>
        ///      Sets the date field of a control
        /// </summary>
        /// <param name="form">allows no-op if the control is not on the form</param>
        /// <param name="control"></param>
        /// <param name="date"></param>
        public static void Dates(Form form, Control control, TimeDate_old date, TimeDate_old defaultDate, Label nullImage)
        {
            if (Scrape.Active(form, control))
            {
                Type type = control.GetType();
                switch (type.Name.ToString())
                {
                case "DateTimePicker": Dates(form, ((DateTimePicker)control), date, defaultDate, nullImage); break;

                default: control.Text = date.ToString(); break;
                }
            }
        }
示例#6
0
        // ----------------------------------------------------------------------------------------
        /// <!-- ValidPickerDate -->
        /// <summary>
        ///      Converts a date to one accepted by a DateTimePicker
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static DateTime ValidPickerDate(object obj)
        {
            DateTime date = TimeDate_old.ClrDate(obj, DateTimePicker.MinimumDateTime);

            if (date < DateTimePicker.MinimumDateTime)
            {
                return(DateTimePicker.MinimumDateTime);
            }
            if (date > DateTimePicker.MaximumDateTime)
            {
                return(DateTimePicker.MaximumDateTime);
            }
            return(date);
        }
示例#7
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Dates -->
        /// <summary>
        ///      Sets the date field of a control
        /// </summary>
        /// <param name="form">allows no-op if the control is not on the form</param>
        /// <param name="control"></param>
        /// <param name="date"></param>
        public static void Dates(Form form, Control control, TimeDate_old date)
        {
            if (Scrape.Active(form, control))
            {
                DateTime clrDate = TimeDate_old.ClrDate(date);
                Type     type    = control.GetType();
                switch (type.Name.ToString())
                {
                case "DateTimePicker": Dates(form, ((DateTimePicker)control), clrDate, new Label()); break;

                default: control.Text = date.ToString(); break;
                }
            }
        }
示例#8
0
        //public static void DataSource(Form form, string controlName, object dataSource) { DataSource(form, Scrape.Control(form, controlName), dataSource); }


        // ----------------------------------------------------------------------------------------
        /// <!-- Date -->
        /// <summary>
        ///      Sets the date time picker date, defaulting to Now
        /// </summary>
        /// <param name="pick"></param>
        /// <param name="date"></param>
        public static void Dates(Form form, DateTimePicker pick, TimeDate_old date, TimeDate_old defaultDate, Label nullImage)
        {
            if (Scrape.Active(form, pick))
            {
                pick.Visible      = true;
                nullImage.Visible = false;
                if (date.IsNull || date.CLRFormat < pick.MinDate || date.CLRFormat > pick.MaxDate)
                {
                    if (defaultDate.IsNull)
                    {
                        nullImage.Visible = true; // this is broken
                    }
                    else
                    {
                        pick.Value = defaultDate.CLRFormat;
                    }
                }
                else
                {
                    pick.Value = Scrape.ValidPickerDate(date.CLRFormat);
                }
            }
        }
示例#9
0
 // ----------------------------------------------------------------------------------------
 /// <!-- _Date -->
 /// <summary>
 ///      Retrieves an xml datetime given the path
 /// </summary>
 /// <param name="xdoc"></param>
 /// <param name="namespacePrefix"></param>
 /// <returns></returns>
 public DateTime _Date(PathSlicer xpath, string namespacePrefix)
 {
     return(TimeDate_old.ClrDate(_Str(xpath, namespacePrefix, ""), (DateTime)SqlDateTime.MinValue));
 }
示例#10
0
 public static TimeDate_old Dates(Form form, string controlName, TimeDate_old defaultDate)
 {
     return(Dates(form, Control(form, controlName), defaultDate));
 }                                                                                                                                                                 /// <summary>Assumes Date.Null for default</summary>
示例#11
0
 public TimeDate_old Dates(Control control, TimeDate_old defaultDate)
 {
     return(Dates(_form, control, defaultDate));
 }
示例#12
0
 // instantiable version:
 public void Dates(Control control, TimeDate_old date, TimeDate_old defaultDate, Label nullImage)
 {
     Dates(_form, control, date, defaultDate, nullImage);
 }
示例#13
0
 // instantiable version:
 public void Dates(Control control, TimeDate_old date)
 {
     Dates(_form, control, date);
 }
示例#14
0
 public void Dates(DateTimePicker pick, TimeDate_old date, TimeDate_old defaultDate, Label nullImage)
 {
     Dates(_form, pick, date, defaultDate, nullImage);
 }