本文整理汇总了C#中System.Windows.Forms.DateTimePicker类的典型用法代码示例。如果您正苦于以下问题:C# DateTimePicker类的具体用法?C# DateTimePicker怎么用?C# DateTimePicker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DateTimePicker类属于System.Windows.Forms命名空间,在下文中一共展示了DateTimePicker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: listarMicros
public static void listarMicros(DataGridView dgMicros, String patente, String patenteEstimada,
String modelo, String modeloEstimado, DateTimePicker dtpFechaAlta, String marca, String tipoServicio,
decimal numero, bool mostrarDeshabilitados, bool mostrarHabilitados)
{
try
{
using (SqlConnection conn = new SqlConnection(main.connString))
using (SqlCommand cmd = new SqlCommand("BONDIOLA.listarMicros", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
SQL_Library.agregarParametro(cmd, "@patente", patente);
SQL_Library.agregarParametro(cmd, "@patenteEstimada", patenteEstimada);
SQL_Library.agregarParametro(cmd, "@modelo", modelo);
SQL_Library.agregarParametro(cmd, "@modeloEstimado", modeloEstimado);
SQL_Library.agregarParametroFecha(cmd, dtpFechaAlta, "@fecha_alta");
SQL_Library.agregarParametro(cmd, "@marca", marca);
SQL_Library.agregarParametro(cmd, "@tipoServicio", tipoServicio);
SQL_Library.agregarParametro(cmd, "@numero", numero);
SQL_Library.agregarParametro(cmd, "@mostrarDeshabilitados", mostrarDeshabilitados);
SQL_Library.agregarParametro(cmd, "@mostrarHabilitados", mostrarHabilitados);
SQL_Library.agregarParametro(cmd, "@fechaActual", Properties.Settings.Default.Fecha);
SQL_Library.llenarDataGrid(dgMicros, conn, cmd);
}
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
}
示例2: ListarEntredatas
public void ListarEntredatas(DataGridView dgv, string codigo, DateTimePicker dtpInicial, DateTimePicker dtpFinal)
{
try
{
InstanciarBanco();
dgv.DataSource = ((from mov in _banco.MovimentacaoProduto
join prod in _banco.Produto on new { Codigo = mov.Codigo } equals new { Codigo = prod.Codigo }
where prod.Codigo == codigo && mov.Data >= dtpInicial.Value.Date && mov.Data <= dtpFinal.Value.Date
group new { mov, prod } by new
{
mov.Codigo,
prod.Nome
} into g
select new
{
Código = g.Key.Codigo,
Nome = g.Key.Nome,
Quantidade = g.Sum(p => p.mov.Quantidade),
Total = g.Sum(p => p.mov.Valor)
}).Distinct()).ToList();
}
catch (CustomException erro)
{
DialogMessage.MessageFullComButtonOkIconeDeInformacao(erro.Message, "Aviso");
}
catch (Exception erro)
{
DialogMessage.MessageComButtonOkIconeErro(erro.Message, "Erro");
}
}
示例3: CreateControl
/// <summary>
/// Create the editor control
/// </summary>
/// <returns></returns>
protected override Control CreateControl()
{
System.Windows.Forms.DateTimePicker dtPicker = new System.Windows.Forms.DateTimePicker();
dtPicker.Format = DateTimePickerFormat.Time;
dtPicker.ShowUpDown = true;
return dtPicker;
}
示例4: DateTimePickerPresentation
/// <summary>
/// Initializes a new instance of the 'DateTimePickerPresentation' class.
/// </summary>
/// <param name="maskedTextBox">.NET MaskedTextBox reference.</param>
/// <param name="dateTimePicker">.NET DateTimePicker reference.</param>
public DateTimePickerPresentation(MaskedTextBox maskedTextBox, DateTimePicker dateTimePicker)
{
mMaskedTextBoxIT = maskedTextBox;
mDateTimePickerIT = dateTimePicker;
if (mMaskedTextBoxIT != null)
{
// Create and configure the ErrorProvider control.
mErrorProvider = new ErrorProvider();
mErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
// Link MaskedTextBox control events.
mMaskedTextBoxIT.GotFocus += new EventHandler(HandleMaskedTextBoxITGotFocus);
mMaskedTextBoxIT.LostFocus += new EventHandler(HandleMaskedTextBoxITLostFocus);
mMaskedTextBoxIT.TextChanged += new EventHandler(HandleMaskedTextBoxITTextChanged);
mMaskedTextBoxIT.EnabledChanged += new EventHandler(HandleMaskedTextBoxITEnabledChanged);
mMaskedTextBoxIT.KeyDown += new KeyEventHandler(HandleMaskedTextBoxITKeyDown);
}
if (dateTimePicker != null)
{
mDateTimePickerIT.Enter += new System.EventHandler(HandleDateTimePickerITEnter);
mDateTimePickerIT.KeyUp += new System.Windows.Forms.KeyEventHandler(HandleDateTimePickerITKeyUp);
mDateTimePickerIT.DropDown += new System.EventHandler(HandleDateTimePickerITDropDown);
mDateTimePickerIT.CloseUp += new System.EventHandler(HandleDateTimePickerCloseUp);
}
}
示例5: IsValidTimeRange
public static bool IsValidTimeRange(DateTimePicker dtpStartTime, DateTimePicker dtpEndTime, NumericUpDown numericUpDown)
{
// Check if the start time is after the end time.
if (dtpStartTime.Value > dtpEndTime.Value)
{
MessageBox.Show("The end time must be greater than the start time.", "Entry Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
dtpEndTime.Focus();
return false;
}
// TODO: Bug - The date time picker does not roll back to the previous day if the default
// end time is set for the next day. For example, if we start the program at 8:00 PM, the
// end time will be set for 12:00 AM the next day. This causes the validation to pass even
// if the form shows that the time range is too small.
// Check if at least two time slots can fit in the time range.
TimeSpan twoTimeSlotsSpan = TimeSpan.FromMinutes((int) numericUpDown.Value * 2);
if (dtpEndTime.Value - dtpStartTime.Value < twoTimeSlotsSpan)
{
MessageBox.Show("The difference between the start and end time must provide for at least two time slots.", "Entry Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
dtpEndTime.Focus();
return false;
}
return true;
}
示例6: EIBDatePickerBase
public EIBDatePickerBase()
{
dateTimePicker = new DateTimePicker();
dateTimePicker.Size = new Size(width, height);
//dateTimePicker.CalendarForeColor = Color.White;
dateTimePicker.Dock = DockStyle.Top;
this.Controls.Add(dateTimePicker);
this.Resize += new System.EventHandler(EIBDatePickerBase_Resize);
this.Size = new Size(width + 5, height + 5);
this._Width = width;
if (string.IsNullOrEmpty(this.Name))
{
this.Name = "datepicker" + counter;
}
if (string.IsNullOrEmpty(this.ControlName))
{
this.ControlName = this.Name;
}
checkUniqueness(this.Name);
datapickerNames.Add(this.Name, this.Name);
this.Margin = new Padding(0, 0, 0, 0);
this.Font = SystemFonts.DefaultFont;
this.Layout += new LayoutEventHandler(Control_Layout);
this.SizeChanged += new System.EventHandler(Control_SizeChanged);
}
示例7: SelectCoDK
/*Lấy ra dòng dữ liệu và gán vào các hộp text*/
public void SelectCoDK(DChuyenBay DCB, TextEdit txtMaCB, ComboBoxEdit cbMaDB, ComboBoxEdit cbMaMB
, TimeEdit dtGioBay, TextEdit txtDiemDi, ComboBoxEdit cbDiemDen
, DateTimePicker dtNgayDi, DateTimePicker dtNgayDen, TextEdit txtVeL1,
TextEdit txtVeL2, TextEdit txtGhiChu)
{
try
{
string path = string.Format("Select * From ChuyenBay Where MaChuyenBay='{0}'", DCB.MCB);
DataTable dtt = DA.TbView(path);
txtMaCB.EditValue = dtt.Rows[0]["MaChuyenBay"].ToString().Trim();
cbMaDB.EditValue = dtt.Rows[0]["MaDuongBay"].ToString().Trim();
cbMaMB.EditValue = dtt.Rows[0]["MaMayBay"].ToString().Trim();
dtGioBay.Text = dtt.Rows[0]["GioBay"].ToString().Trim();
txtDiemDi.EditValue = dtt.Rows[0]["DiemDi"].ToString().Trim();
cbDiemDen.EditValue = dtt.Rows[0]["DiemDen"].ToString().Trim();
dtNgayDi.Text = dtt.Rows[0]["NgayDi"].ToString().Trim();
dtNgayDen.Text = dtt.Rows[0]["NgayDen"].ToString().Trim();
txtVeL1.EditValue = dtt.Rows[0]["SLV_Loai1"].ToString().Trim();
txtVeL2.EditValue = dtt.Rows[0]["SLV_Loai2"].ToString().Trim();
txtGhiChu.EditValue = dtt.Rows[0]["GhiChu"].ToString().Trim();
//return dt.TbView(path);
}
catch
{
XtraMessageBox.Show("Vui lòng kích vào lưới thông tin chọn thông tin cần sửa !", "Chú ý !",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例8: ListarPordata
public void ListarPordata(DataGridView dgv, string codigo, DateTimePicker dtp)
{
try
{
InstanciarBanco();
dgv.DataSource = ((from mov in _banco.MovimentacaoProduto
join prod in _banco.Produto on new { Codigo = mov.Codigo } equals new { Codigo = prod.Codigo }
where prod.Codigo == codigo && mov.Data == dtp.Value.Date
group new { mov, prod } by new
{
mov.Codigo,
prod.Nome
} into g
select new
{
Código = g.Key.Codigo,
Nome = g.Key.Nome,
Quantidade = g.Sum(p => p.mov.Quantidade),
Total = g.Sum(p => p.mov.Valor)
}).Distinct()).ToList();
}
catch (CustomException error)
{
throw new CustomException(error.Message);
}
catch (Exception error)
{
throw new Exception(error.Message);
}
}
示例9: ConfigurationForm
public ConfigurationForm()
{
InitializeComponent();
settings.Load(settings.cXMLSectionUpdate);
settings.Load(settings.cXMLSectionMusic);
settings.Load(settings.cXMLSectionVideo);
settings.Load(settings.cXMLSectionMisc);
releaseVersion.Text = String.Format("Version: {0}", Assembly.GetExecutingAssembly().GetName().Version.ToString());
DateTime buildDate = getLinkerTimeStamp(Assembly.GetExecutingAssembly().Location);
compileTime.Text += " " + buildDate.ToString() + " GMT";
timePicker = new DateTimePicker();
timePicker.Format = DateTimePickerFormat.Time;
timePicker.ShowUpDown = true;
timePicker.Location = new Point(309, 85);
timePicker.Width = 100;
CheckUpdate.Controls.Add(timePicker);
if (MiscConfigGUI.MostRecentFanartTimerInt != 0)
numFanartTimer.Value = (decimal)MiscConfigGUI.MostRecentFanartTimerInt;
else
numFanartTimer.Value = 7;
}
示例10: ListarEntreDatas
public void ListarEntreDatas(DataGridView dgv, DateTimePicker dtpInicial, DateTimePicker dtpFinal)
{
try
{
InstanciarBanco();
dgv.DataSource = ((from movimentacaoCaixa in _banco.MovimentacaoCaixa
where movimentacaoCaixa.Data >= dtpInicial.Value.Date
&& movimentacaoCaixa.Data <= dtpFinal.Value.Date
group movimentacaoCaixa by new
{
movimentacaoCaixa.Data
} into g
select new
{
Valor = g.Sum(p => p.Valor),
Data = g.Key.Data
}).Distinct()).ToList();
}
catch (CustomException erro)
{
throw new CustomException(erro.Message);
}
catch (Exception erro)
{
throw new Exception(erro.Message);
}
}
示例11: InitSpec
protected void InitSpec(DateTimePicker box)
{
_Box = box;
_MenuList = new Dictionary<string, ToolStripMenuItem>(15);
InitMenu("yyyyMMdd", "yyyyMMdd", MuDate);
InitMenu("yyyy-MM-dd", "yyyy-MM-dd", MuDate);
InitMenu("yyyy/MM/dd", "yyyy/MM/dd", MuDate);
InitMenu("yyyy.MM.dd", "yyyy.MM.dd", MuDate);
InitMenu("yyyy年MM月dd日", "yyyy年MM月dd日", MuDate);
InitMenu("HHmmss", "HHmmss", MuTime);
InitMenu("HH:mm:ss", "HH:mm:ss", MuTime);
InitMenu("HH时mm分ss秒", "HH时mm分ss秒", MuTime);
InitMenu("H:m:s", "H:m:s", MuTime);
InitMenu("H时m分s秒", "H时m分s秒", MuTime);
InitMenu("h:m:s", "h:m:s", MuTime);
InitMenu("h时m分s秒", "h时m分s秒", MuTime);
InitMenu("yyyyMMdd HHmmss", "yyyyMMdd HHmmss", MuDateTime);
InitMenu("yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss", MuDateTime);
InitMenu("yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm:ss", MuDateTime);
InitMenu("yyyy年MM月dd日 HH时mm分ss秒", "yyyy年MM月dd日 HH时mm分ss秒", MuDateTime);
_LastMenu = MiDateDef;
_LastMenu.Checked = true;
}
示例12: selectDetails
public void selectDetails(TextBox txt_Total, DateTimePicker startDatePicker, DateTimePicker endDatePicker)
{
var startDate = startDatePicker.Value.ToString("dd-MMM-yyyy");
var endDate = endDatePicker.Value.ToString("dd-MMM-yyyy");
string query_String = "SELECT SUM(Cost) FROM Bookings WHERE Return_Date BETWEEN'" + startDate + "'AND'" + endDate + "'";
try
{
connection.Open();
cmd = connection.CreateCommand();
cmd.CommandText = query_String;
data_reader = cmd.ExecuteReader();//the reader is used to read in the required record
data_reader.Read();
txt_Total.Text = data_reader.GetValue(0).ToString();
connection.Close();
}
catch (Exception)
{
MessageBox.Show("No Records For the Chosen Period", "ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
}
示例13: Pagos
public Pagos(string cuota,int codEmpresa)
{
this.codEmpresa=codEmpresa;
InitializeComponent();
this.lbTotalPago.Text = cuota;
PagoMemDT = pago_MembresiaTableAdapter.GetDataByEmpresa(codEmpresa);
//vistaPagos();
PagoMemDT.Columns["perid_pago"].ColumnName = "Período de Pago";
PagoMemDT.Columns["num_cuota"].ColumnName = "Número de Cuota";
PagoMemDT.Columns["monto"].ColumnName = "Monto";
PagoMemDT.Columns["fech_pago"].ColumnName = "Fecha de Pago";
PagoMemDT.Columns["pagado"].ColumnName = "Estado";
PagoMemDT.Columns["num_recib"].ColumnName = "Número de Recibo";
PagoMemDT.Columns["observaciones"].ColumnName = "Observaciones";
PagoMemDT.Columns["tipo"].ColumnName = "Tipo";
this.dgPagosEmpresa.DataSource = PagoMemDT;
this.domainNumCuotas.SelectedItem=5;
dtpFechaPago = new DateTimePicker();
dtpFechaPago.Format = DateTimePickerFormat.Short;
dtpFechaPago.Visible = false;
dtpFechaPago.Width = this.dgPagosEmpresa.Columns[5].Width-5;
this.dgPagosEmpresa.Controls.Add(dtpFechaPago);
this.dtpFechaPago.ValueChanged += dtpFechaPago_ValueChanged;
this.dgPagosEmpresa.CellBeginEdit += this.dgPagosEmpresa_CellBeginEdit;
this.dgPagosEmpresa.CellEndEdit += this.dgPagosEmpresa_CellEndEdit;
}
示例14: EditValue
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (provider != null)
{
editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
}
if (editorService != null)
{
if (value == null)
{
time = DateTime.Now.ToString("HH:mm");
}
DateTimePicker picker = new DateTimePicker();
picker.Format = DateTimePickerFormat.Custom;
picker.CustomFormat = "HH:mm";
picker.ShowUpDown = true;
if (value != null)
{
picker.Value = DateTime.Parse((string)value);
}
editorService.DropDownControl(picker);
value = picker.Value.ToString("HH:mm");
}
return value;
}
示例15: ListarPorDia
public void ListarPorDia(DataGridView dgv, DateTimePicker dtp)
{
try
{
InstanciarBanco();
dgv.DataSource = (from movimentacaoCaixa in
(from mcaixa in _banco.MovimentacaoCaixa
where mcaixa.Data == dtp.Value.Date
select new
{
mcaixa.Valor,
mcaixa.Data
})
group movimentacaoCaixa by new { movimentacaoCaixa.Data } into g
select new
{
Valor = g.Sum(p => p.Valor),
Data = g.Key.Data
}).ToList();
}
catch (CustomException erro)
{
throw new CustomException(erro.Message);
}
catch (Exception erro)
{
throw new Exception(erro.Message);
}
}