Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > C#/.NET入门教程

ASP.NET My97DatePicker日期控件实现OA日期记事功能

来源:中文源码网    浏览:140 次    日期:2024-05-12 23:21:20
【下载文档:  ASP.NET My97DatePicker日期控件实现OA日期记事功能.txt 】


ASP.NET My97DatePicker日期控件实现OA日期记事功能
My97DatePicker日期控件是一个非常好用的日期控件,功能非常优秀的日期控件.
对实现页面刷新完善的很好,用日期控件时可以有比较好的享受,这次的OA日期记事功能也得益于此控件,具体效果图如下:
部分代码:
Default页布局一个Calendar日期控件

ShowGridLines="True" ondayrender="Calendar1_DayRender" >


Default页cs代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
private DataTable table ;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
//获取现在绑定的日期
CalendarDay day = e.Day;
//获取当前日期的单元格
TableCell cell = e.Cell;
int currentMonth = DateTime.Now.Month ;
cell.Controls.Clear();
table = PlanOperator.SelectPlanByMonth(day.Date);
if (day.Date.Month >= currentMonth)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat("
{0}
添加日程
", day.Date.ToShortDateString());
DataRow[] planRows = table.Select(string.Format("StartDate<='{0}' AND EndDate>='{1}' ", day.Date, day.Date.AddDays(1)));
cell.Style["background-color"] = planRows.Length <= 0 ? "#E9E9E9" : "#FFFFFF";
int index = 1;
foreach (DataRow row in planRows)
{
string title = row["Title"].ToString().Length > 10 ? row["Title"].ToString().Substring(0, 10) + "..." : row["Title"].ToString();
builder.AppendFormat("{0}.{2}
", index, row["PlanID"], title);
index++;
continue;
}
cell.Controls.Add(new LiteralControl(builder.ToString()));
}
else
{
cell.Style["background-color"] = "#E9E9E9";
}
}
}
控件编辑前台代码:







日程信息



日程主题:BorderColor="#0066FF" BorderStyle="Solid" BorderWidth="1px" >

日程内容:

起始日期:


结束日期:

onclick="btnInsertPlan_Click" />



onclick="btnUpdate_Click1" />
/>


HeaderText="提交对日程的修改中出现了以下问题:" />




控件编辑后台cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class EditPlan : System.Web.UI.Page
{
public DateTime StartDate
{
get { return (DateTime)this.ViewState["StartDate"]; }
set { this.ViewState["StartDate"] = value; }
}
public DateTime EndDate
{
get { return (DateTime)this.ViewState["EndDate"]; }
set { this.ViewState["EndDate"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (this.Request.QueryString.Count != 2)
{
this.Response.End();
return;
}
if (!this.IsPostBack)
{
string action = this.Request.QueryString["Action"];
switch (action)
{
case "New":
this.StartDate = Convert.ToDateTime(this.Request.QueryString["StartDate"]);
this.EndDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, (DateTime.Now.AddMonths(1) - DateTime.Now).Days);
this.pnlNew.Visible = true;
this.pnlEdit.Visible = false;
break;
case "Edit":
int planID = Convert.ToInt32(this.Request.QueryString["PlanID"]);
DataTable table = PlanOperator.SelectPlanById(planID);
this.txtTitle.Text = table.Rows[0]["Title"].ToString();
this.txtContent.Text = table.Rows[0]["PlanContent"].ToString();
this.txtStartDate.Text = table.Rows[0]["StartDate"].ToString();
this.txtEndDate.Text = table.Rows[0]["EndDate"].ToString();
this.hidPlanID.Value = table.Rows[0]["PlanID"].ToString();
this.pnlNew.Visible = false;
this.pnlEdit.Visible = true;
break;
default:
break;
}
}
}
protected void btnInsertPlan_Click(object sender, EventArgs e)
{
int i=PlanOperator.InsertPlan(this.txtTitle.Text, this.txtContent.Text,this.txtStartDate.Text, this.txtEndDate.Text);
if (i == 1)
{
this.Response.Write("");
return;
}
this.Response.Write("");
return;
}
protected void btnUpdate_Click1(object sender, EventArgs e)
{
int i = PlanOperator.UpdatePlan(Convert.ToInt32(this.hidPlanID.Value),this.txtTitle.Text, this.txtContent.Text, this.txtStartDate.Text, this.txtEndDate.Text);
if (i == 1)
{
this.Response.Write("");
return;
}
this.Response.Write("");
return;
}
protected void btnDelete_Click(object sender, EventArgs e)
{
int i = PlanOperator.DeletePlan(Convert.ToInt32(this.hidPlanID.Value));
if (i == 1)
{
this.Response.Write("");
return;
}
this.Response.Write("");
return;
}
}
以上就是关于My97DatePicker日期控件实现OA日期记事功能的全部内容,希望大家会喜欢。

相关内容