62,047
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="No.aspx.cs" Inherits="Guest_No"
Title="" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:DropDownList ID="Year" runat="server">
<asp:ListItem Value="0">请选择年</asp:ListItem>
<asp:ListItem>2012</asp:ListItem>
<asp:ListItem>2013</asp:ListItem>
<asp:ListItem>2014</asp:ListItem>
<asp:ListItem>2015</asp:ListItem>
<asp:ListItem>2016</asp:ListItem>
<asp:ListItem>2017</asp:ListItem>
<asp:ListItem>2018</asp:ListItem>
<asp:ListItem>2019</asp:ListItem>
<asp:ListItem>2020</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="Month" runat="server">
<asp:ListItem Value="0">请选择月</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label>
<div runat="server" id="div1" visible="false">
<asp:Table ID="Table1" runat="server" BorderColor="Black" BorderWidth="1px" GridLines="Both">
</asp:Table>
<asp:Button ID="Button2" runat="server" Text="提交" OnClick="Button2_Click" /><asp:Button
ID="Button3" runat="server" Text="重置" />
</div>
</asp:Content>
protected void Button1_Click(object sender, EventArgs e)
{
int i, j, k;
int year = Convert.ToInt32(Year.SelectedValue.ToString());
int month = Convert.ToInt32(Month.SelectedValue.ToString());
if (year.ToString() == "0" || month.ToString() == "0")
{
Label1.Text = "请选择年月";
}
else if (year.ToString() == "0")
{
Label1.Text = "请选择年";
}
else if (month.ToString() == "0")
{
Label1.Text = "请选择月";
}
else
{
int day = Convert.ToInt32(DateTime.DaysInMonth(year, month).ToString());
DateTime firstDay = new DateTime(year, month, 1);
DateTime lostDay = new DateTime(year, month, DateTime.DaysInMonth(year, month));
TableRow tRow1 = new TableRow();
Table1.Rows.Add(tRow1);
TableCell Cell1 = new TableCell();
Cell1.Text = "号";
tRow1.Cells.Add(Cell1);
for (i = 1; i <= day; i++)
{
TableCell tCell1 = new TableCell();
tCell1.Text = i.ToString();
tRow1.Cells.Add(tCell1);
}
TableRow tRow2 = new TableRow();
Table1.Rows.Add(tRow2);
TableCell Cell2 = new TableCell();
Cell2.Text = "1,2";
tRow2.Cells.Add(Cell2);
for (i = 1; i <= day; i++)
{
TableCell tCell2 = new TableCell();
tRow2.Cells.Add(tCell2);
CheckBox CB = new CheckBox();
CB.ID = "cb1" + i.ToString();
tCell2.Controls.Add(CB);
}
}