123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using DevComponents.DotNetBar.Controls;
- namespace WCS_Client.UC
- {
- public class LC_TwoDateTime : TextBoxDropDown
- {
- public LC_TwoDateTime()
- {
- this.BackgroundStyle.Class = "TextBoxBorder";
- this.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
- this.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
- this.BackColor = System.Drawing.SystemColors.Control;
- this.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
- this.ReadOnly = true;
- this.ButtonCustom.Visible = true;
- this.ButtonCustom.Shortcut = DevComponents.DotNetBar.eShortcut.Ins;
- this.ButtonCustomClick += new EventHandler(Item_ButtonCustomClick);
- this.ButtonCustom2.Visible = false;
- this.ButtonDropDown.Visible = false;
- this.ButtonClear.Visible = true;
- this.ButtonClear.Shortcut = DevComponents.DotNetBar.eShortcut.Del;
- this.ButtonClearClick += new System.ComponentModel.CancelEventHandler(Item_ButtonClearClick);
- }
- DateTime _StartDateTime = DateTime.MinValue;
- DateTime _EndDateTime = DateTime.MinValue;
-
- private void Item_ButtonCustomClick(object sender, EventArgs e)
- {
- Frm_TowDateTime frm = new Frm_TowDateTime(_StartDateTime, _EndDateTime);
- frm.SubmitEvent += new Frm_TowDateTime.SubmitHandler(frm_SubmitEvent);
- frm.ShowDialog();
- frm = null;
- }
- public List<DateTime> GetValue()
- {
- if (!IsValueNull())
- {
- return new List<DateTime>() { _StartDateTime, _EndDateTime };
- }
- return null;
- }
- public void SetValue(List<DateTime> LCValue)
- {
- if (LCValue == null || LCValue.Count != 2)
- {
- frm_SubmitEvent(DateTime.MinValue, DateTime.MinValue);
- }
- else
- {
- frm_SubmitEvent(LCValue[0], LCValue[1]);
- }
- }
- /// <summary>
- /// 控件数据改变
- /// </summary>
- private void frm_SubmitEvent(DateTime SDataTime, DateTime EDateTime)
- {
- if (SDataTime == DateTime.MinValue || EDateTime == DateTime.MinValue || SDataTime > EDateTime)
- {
- _StartDateTime = DateTime.MinValue;
- _EndDateTime = DateTime.MinValue;
- this.Text = "";
- }
- else
- {
- _StartDateTime = SDataTime;
- _EndDateTime = EDateTime;
- this.Text = string.Format("[{0}] 至 [{1}]", _StartDateTime.ToString("yyyy-MM-dd HH:mm:ss"), _EndDateTime.ToString("yyyy-MM-dd HH:mm:ss"));
- }
- }
- /// <summary>
- /// 是否控件输入值是否为空
- /// </summary>
- /// <returns>true,空值;false,已经输入值</returns>
- public bool IsValueNull()
- {
- return (_StartDateTime == DateTime.MinValue || _EndDateTime == DateTime.MinValue || _StartDateTime > _EndDateTime);
- }
- private void Item_ButtonClearClick(object sender, System.ComponentModel.CancelEventArgs e)
- {
- this.Text = "";
- _StartDateTime = DateTime.MinValue;
- _EndDateTime = DateTime.MinValue;
- }
- public void ClearValue()
- {
- Item_ButtonClearClick(null, null);
- }
- }
- }
|