using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using HangBiao.AOA.Common;
using TedaBus.RFPrincipal;
public partial class AOA_RenShi_LunZhiBiao : AppPage
{
Database db = DatabaseFactory.CreateDatabase("HangBiao");
System.Security.Principal.IPrincipal p = Context.User;
if (p != null)
{
SitePrincipal user = p as SitePrincipal;
if (user != null)
{
if (user.HasPermission((int)UserPermission.办公室_值班表管理))
{
showManage = true;
}
}
}
btnManage.Visible = showManage;
lblMonth.Text = DateTime.Today.Month.ToString();
ArrayList alBind = new ArrayList();
string year = DateTime.Today.Year.ToString();
string month = DateTime.Today.Month.ToString();
DutyBLL bll = new DutyBLL(db);
ArrayList alDuty = bll.GetByMonth(year, month);
int firstPos = (alDuty[0] as DutyData).GetDayInWeek();
for (int i = 0; i < firstPos; i++)
{
DutyData lastMonthDuty = new DutyData();
lastMonthDuty.DutyDate = (alDuty[0] as DutyData).DutyDate.AddDays(i - firstPos);
alBind.Add(lastMonthDuty);
}
foreach (object obj in alDuty)
{
alBind.Add(obj);
}
dlDays.DataSource = alBind;
dlDays.DataBind();
}
protected void dlDays_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
DutyData data = e.Item.DataItem as DutyData;
Label lblDay = e.Item.FindControl("lblDay") as Label;
MultiView mvDay = e.Item.FindControl("mvDay") as MultiView;
if (data.DutyDate.Month == DateTime.Today.Month)
{
lblDay.Text = data.DutyDate.Day.ToString();
if (data.DutyDate == DateTime.Today)
{
e.Item.BackColor = System.Drawing.Color.LightPink;
}
}
else
{
mvDay.Visible = false;
e.Item.BorderWidth = 0;
}
用.net的Calendar控件啊,下面再放一个label或者别的用来显示数据的控件
然后定义一个str=Calendar1.SelectedDate.ToShortDateString()
在数据表ca中设置id,date,thing 三个字段,
查询数据库 select thing from ca where date = str
OK,把查询结果赋给label.text就可以了