System.Windows.Forms.ComboBox comboName = new System.Windows.Forms.ComboBox();
this.comboName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboName.FormattingEnabled = true;
this.comboName.Items.AddRange(new object[] {
"今日进货",
"本月进货",
"本季度进货",
"本年度进货"});
DateTime beginDate = DateTime.Today, endDate = DateTime.Today;
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
switch (comboName.SelectedIndex)
{
case 0:
break;
case 1:
beginDate = new DateTime(year, month, 1);
endDate = new DateTime(year, month, Application.CurrentCulture.Calendar.GetDaysInMonth(year, month));
break;
case 2:
switch ((month + 2) / 3)
{
case 1:
beginDate = new DateTime(year, 1, 1);
endDate = new DateTime(year, 3, 31);
break;
case 2:
beginDate = new DateTime(year, 4, 1);
endDate = new DateTime(year, 6, 30);
break;
case 3:
beginDate = new DateTime(year, 7, 1);
endDate = new DateTime(year, 9, 30);
break;
case 4:
beginDate = new DateTime(year, 10, 1);
endDate = new DateTime(year, 12, 31);
break;
}
break;
case 3:
beginDate = new DateTime(year, 1, 1);
endDate = new DateTime(year, 12, 31);
break;
}
dataView.RowFilter = string.Format("'#{0}#'<=OverDate and OverDate<='#{1}#'", beginDate, endDate);