// ---------------------------------------------------------------------------------------- /// <!-- 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); }
public static void Dates(Form form, TextBox txtDateTime, TimeDate_old date, string format) { if (Scrape.Active(form, txtDateTime)) { txtDateTime.Text = date.ToString(format); } }
// ---------------------------------------------------------------------------------------- /// <!-- 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); }
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); }
// ---------------------------------------------------------------------------------------- /// <!-- 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; } } }
// ---------------------------------------------------------------------------------------- /// <!-- 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); }
// ---------------------------------------------------------------------------------------- /// <!-- 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; } } }
//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); } } }
// ---------------------------------------------------------------------------------------- /// <!-- _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)); }
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>
public TimeDate_old Dates(Control control, TimeDate_old defaultDate) { return(Dates(_form, control, defaultDate)); }
// instantiable version: public void Dates(Control control, TimeDate_old date, TimeDate_old defaultDate, Label nullImage) { Dates(_form, control, date, defaultDate, nullImage); }
// instantiable version: public void Dates(Control control, TimeDate_old date) { Dates(_form, control, date); }
public void Dates(DateTimePicker pick, TimeDate_old date, TimeDate_old defaultDate, Label nullImage) { Dates(_form, pick, date, defaultDate, nullImage); }