关于日历的实现问题

dall3do 2007-11-27 03:56:06
我有个页面想实现行程安排的功能.就是从数据库读指定的某月的数据,根据这个月的天数一一绑定到这个页面的日历所对应的天上:比如说现在是12月.这个页面就生成12月这个月份的日历.然后在12月1号这个格子里面绑定上数据库里面这天要干的事 .请教各位这样要怎么实现
...全文
132 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
chieftech 2007-11-27
  • 打赏
  • 举报
回复
12楼,千万别~俺结婚了,孩都快两岁了
代码我也给你,你自己研究下先
有问题再找我
mingyeh1979@hotmail.com
dall3do 2007-11-27
  • 打赏
  • 举报
回复
==我去在我的程序里面试一下 可以的话马上结帖
dall3do 2007-11-27
  • 打赏
  • 举报
回复
11楼的 我爱你 我就是想实现这样的功能
chieftech 2007-11-27
  • 打赏
  • 举报
回复
效果图:
chieftech 2007-11-27
  • 打赏
  • 举报
回复
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");

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}

protected void Page_Load(object sender, EventArgs e)
{
bool showManage = false;

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;
}

if (data.DayEmployee == string.Empty)
{
mvDay.ActiveViewIndex = 0;
Label lblEmployee = mvDay.FindControl("lblEmployee") as Label;
lblEmployee.Text = data.NightEmployee;
Label lblMobile = mvDay.FindControl("lblMobile") as Label;
lblMobile.Text = data.NightMobile;
}
else
{
mvDay.ActiveViewIndex = 1;
Label lblDayEmployee = mvDay.FindControl("lblDayEmployee") as Label;
lblDayEmployee.Text = data.DayEmployee;
Label lblDayMobile = mvDay.FindControl("lblDayMobile") as Label;
lblDayMobile.Text = data.DayMobile;
Label lblNightEmployee = mvDay.FindControl("lblNightEmployee") as Label;
lblNightEmployee.Text = data.NightEmployee;
Label lblNightMobile = mvDay.FindControl("lblNightMobile") as Label;
lblNightMobile.Text = data.NightMobile;
}
}
}
}
chieftech 2007-11-27
  • 打赏
  • 举报
回复
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LunZhiBiao.aspx.cs" Inherits="AOA_RenShi_LunZhiBiao" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<link href="../../App_Themes/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<table border="0" cellpadding="0" cellspacing="0" style="width: 840px">
<tr>
<td colspan="7" style="font-weight: bold; font-size: 18px; font-family: 新宋体; text-align: center;">
天津航标处<asp:Label ID="lblMonth" runat="server"></asp:Label>月干部轮值表 
<asp:Button ID="btnManage" runat="server" PostBackUrl="~/AOA/RenShi/LunZhiBiao_Manage.aspx"
Text="管理" Visible="False" /></td>
</tr>
<tr>
<td style="width: 120px; height: 23px" class="tr2">
周一</td>
<td style="width: 120px; height: 23px" class="tr2">
周二</td>
<td style="width: 120px; height: 23px" class="tr2">
周三</td>
<td style="width: 120px; height: 23px" class="tr2">
周四</td>
<td style="width: 120px; height: 23px" class="tr2">
周五</td>
<td style="width: 120px; height: 23px; color: green;" class="tr2">
周六</td>
<td style="width: 120px; height: 23px; color: red;" class="tr2">
周日</td>
</tr>
<tr>
<td style="height: 15px;" colspan="7" align="left" valign="top">
<asp:DataList ID="dlDays" runat="server" RepeatColumns="7" RepeatDirection="Horizontal" OnItemDataBound="dlDays_ItemDataBound">
<ItemTemplate>
<center>
<asp:Label ID="lblDay" runat="server" Font-Size="18px" Font-Bold="true"></asp:Label>
</center>
<br />
<asp:MultiView ID="mvDay" runat="server">
<asp:View ID="vWeekDay" runat="server">
<asp:Label ID="lblEmployee" runat="server"></asp:Label>
  <br /> 手机:<asp:Label ID="lblMobile" runat="server"></asp:Label></asp:View>
<asp:View ID="vWeekEnd" runat="server">
<font color="navy">白天:</font><br />
<asp:Label ID="lblDayEmployee" runat="server"></asp:Label>
   <br />手机:<asp:Label ID="lblDayMobile" runat="server"></asp:Label><br />
<font color="navy">夜间:</font><br />
<asp:Label ID="lblNightEmployee" runat="server"></asp:Label>
   <br />手机:<asp:Label ID="lblNightMobile" runat="server"></asp:Label></asp:View>
</asp:MultiView>
</ItemTemplate>
<AlternatingItemStyle Width="120px" Height="120px" BorderColor="Black" BorderWidth="1px" VerticalAlign="Top" />
<ItemStyle Width="120px" Height="120px" BorderColor="Black" BorderWidth="1px" VerticalAlign="Top" />
</asp:DataList></td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
simenpeng 2007-11-27
  • 打赏
  • 举报
回复
你去CSDN的下载里面去下载 有类似的范例
不过
我实现了这个功能
哈哈
我做了彩票日历
和你说的一样
我的日历
不是用日历控件做的
是用反射
自己构成的
我做的效果页面是这个
http://hemai.hnticai.com/LotteryCalendar/Calendar.aspx?date=2007-11-8
你去看吧
嘎嘎
一样能实现我的这个效果滴
simenpeng 2007-11-27
  • 打赏
  • 举报
回复
例题`
dall3do 2007-11-27
  • 打赏
  • 举报
回复
DEMO是什么 本人菜鸟不清楚
lhqmcy 2007-11-27
  • 打赏
  • 举报
回复
联系我,我这有DEMO
dall3do 2007-11-27
  • 打赏
  • 举报
回复
我要实现的功能是等于这个页面就是一个日历.在这个日历的每天上面就直接写做的事了.
Calendar控件不可能实现
dall3do 2007-11-27
  • 打赏
  • 举报
回复
blueiv 2007-11-27
  • 打赏
  • 举报
回复
用.net的Calendar控件啊,下面再放一个label或者别的用来显示数据的控件
然后定义一个str=Calendar1.SelectedDate.ToShortDateString()
在数据表ca中设置id,date,thing 三个字段,
查询数据库 select thing from ca where date = str
OK,把查询结果赋给label.text就可以了
SaintKaKa 2007-11-27
  • 打赏
  • 举报
回复
数据库表 table1
id(主键),userid(用户ID),date(日期),event(事件,行程)

页面添加日历控件,后台根据点击的时间用datediff()函数查询数据表中的date字段
然后用sqldatareader读出
如果dr里没数据,则该天没有事件或行程
有数据则显示

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧