//--- DEFINIR AS DATAS LIMITES PELO DataTipo private void DefinirDataLimite(EnumDataTipo dataTipo) { switch (dataTipo) { case EnumDataTipo.PassadoOuFuturo: break; case EnumDataTipo.Passado: case EnumDataTipo.PassadoPresente: numAno.Minimum = 1900; numAno.Maximum = DateTime.Today.Year; break; case EnumDataTipo.Futuro: case EnumDataTipo.FuturoPresente: numAno.Minimum = DateTime.Today.Year; numAno.Maximum = DateTime.Today.Year + 100; break; default: numAno.Minimum = DateTime.Today.Year - 100; numAno.Maximum = DateTime.Today.Year + 100; break; } }
//--- DEFINIR AS DATAS LIMITES PELO DataTipo private void DefinirDataLimite(EnumDataTipo dataTipo) { switch (dataTipo) { case EnumDataTipo.PassadoOuFuturo: break; case EnumDataTipo.Passado: dtpDateInfo.MaxDate = DateTime.Today.AddDays(-1); break; case EnumDataTipo.PassadoPresente: dtpDateInfo.MaxDate = DateTime.Today; break; case EnumDataTipo.Futuro: dtpDateInfo.MinDate = DateTime.Today.AddDays(1); break; case EnumDataTipo.FuturoPresente: dtpDateInfo.MinDate = DateTime.Today; break; default: dtpDateInfo.MaxDate = DateTime.Today.AddYears(10); dtpDateInfo.MinDate = DateTime.Today.AddYears(-10); break; } }
// SUB NEW | CONSTRUCTOR //------------------------------------------------------------------------------------------------------------ public frmDateMesAnoGet(string SubTitulo, EnumDataTipo myDataTipo, DateTime DataPadrao, Form formOrigem) { InitializeComponent(); _formOrigem = formOrigem; propDataInfo = null; lblSubTitulo.Text = SubTitulo; DefinirDataLimite(myDataTipo); CarregaComboMes(); numAno.Value = DataPadrao.Year; cmbMes.SelectedValue = DataPadrao.Month; numAno.KeyDown += control_KeyDown; cmbMes.KeyDown += control_KeyDown; }
// SUB NEW | CONSTRUCTOR //------------------------------------------------------------------------------------------------------------ public frmDateGet(string SubTitulo, EnumDataTipo myDataTipo, DateTime DataPadrao, Form formOrigem) { InitializeComponent(); propDataInfo = null; lblSubTitulo.Text = SubTitulo; DefinirDataLimite(myDataTipo); if (DataPadrao > dtpDateInfo.MaxDate) { dtpDateInfo.Value = dtpDateInfo.MaxDate; } else if (DataPadrao < dtpDateInfo.MinDate) { dtpDateInfo.Value = dtpDateInfo.MinDate; } else { dtpDateInfo.Value = DataPadrao; } _formOrigem = formOrigem; }