考勤或工作计划之日历图

考勤或工作计划之日历图_第1张图片

1、c#后台代码

  public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        var selDate = context.Request["selDate"] ?? DateTime.Now.Year + "-" + DateTime.Now.Month;
        string resData = ShowCalendar(selDate);

        context.Response.Write(resData);
    }
    
    #region Calen
    private string ShowCalendar(string Month)
    {
        
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append("");

        //table header
        sb.Append("");
        sb.Append("");
        sb.Append("");
        sb.Append("");

        // 0->星期一   6->星期天
        DateTime monthFirstDay = DateTime.Parse(Month + "-1");//月第一天 
        DateTime monthLastDay = monthFirstDay.AddMonths(1).AddDays(-1);//月最后一天 int firstDayOfWeek = (int)monthFirstDay.DayOfWeek;//获取月第一天  是星期几int endDayOfWeek = (int)monthLastDay.DayOfWeek;//获取月最后一天 是星期几
        sb.Append("");
        for (int i = 0; i < firstDayOfWeek; i++)
        {
            sb.AppendFormat("",
                monthFirstDay.AddDays(-(firstDayOfWeek - i)).Day);
        }

        do
        {
            //2013-03-08
            sb.AppendFormat("", monthFirstDay.ToShortDateString(), monthFirstDay.Day);
            if (monthFirstDay.DayOfWeek == DayOfWeek.Saturday)//周六就tr
                sb.Append("");
            if (monthFirstDay == monthLastDay)
                break;
            monthFirstDay = monthFirstDay.AddDays(1);
        } while (true);

        for (int i = 0; i < 6 - endDayOfWeek; i++)
        {
            sb.AppendFormat("",
                monthLastDay.AddDays(i + 1).Day);
        }
        sb.Append("");
        sb.Append("
周日周一周二周三周四周五周六
  {0}{1}" + "
    " + "
  • 任务已超时
  • " + "
  • 正在进行中
  • " + "
  {0}
"); return sb.ToString(); }

2、前台代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

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>兔子工作计划V1.0title>
    <link href="css/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="css/themes/icon.css" rel="stylesheet" type="text/css" />

    <script src="js/easyUI/jquery-1.7.2.min.js" type="text/javascript">script>

    <script src="js/easyUI/jquery.easyui.min.js" type="text/javascript">script>

    <script src="js/easyUI/locale/easyui-lang-zh_CN.js" type="text/javascript">script>

    <script type="text/javascript">
    function Add(){
        $("#divAdd").show();
        $("#divAdd").dialog({
                title: "添加任务",
                modal: true,
                closed:false,
                collapsible: true,
                minimizable: true,
                maximizable: true,
                resizable: true,
                buttons: [{
                    text: '添加',
                    iconCls: 'easyui-linkbutton',
                    handler: function () {
                        //alert('ok');触发表单提交
                        //$("#frmAddRole").submit();
                    }
                }, {
                    text: '取消',
                    handler: function () {
                        $("#divAdd").dialog('close'); //关闭对话框
                    }
                }]
            });
    };
     var currYear=new Date().getFullYear();
     var currMonth=new Date().getMonth()+1;
    $(function(){
        InitYearMonth();
        
       SelData(currYear,currMonth);
        
    })
    
    function  changeYear(){
        var  selYear=$("#selYear").val();
        var  selMonth=$("#selMonth").val();
       SelData(selYear,selMonth);
    }
    
    function  changeMonth(){
         var  selYear=$("#selYear").val();
        var  selMonth=$("#selMonth").val();
        SelData(selYear,selMonth);
    } 
    
    function LastMonth(){
      
       if(currMonth==1){
         currYear=currYear-1;
         currMonth=12;
       }
       else{
         currMonth=currMonth-1;
       }
       $("#selYear").val(currYear);
       $("#selMonth").val(currMonth); 
       SelData(currYear,currMonth);
    }
    
    function NextMonth(){
      
       if(currMonth==12)
       { 
         currYear=currYear+1;
         currMonth=1; 
       }
       else{
         currMonth=currMonth+1;
       }
       $("#selYear").val(currYear);
       $("#selMonth").val(currMonth); 
       SelData(currYear,currMonth);
    }
    
    
    function  SelData(year,month){
       
      var params={selDate:year+"-"+month};
      $.post("GetCalendar.ashx",params,function(data){
          $("#divCalendar").html(data);
      });
    }
    function InitYearMonth()
   {
      var currYear=new Date().getFullYear();
      
      for(var i=2000;i<=currYear;i++)  {
          if(i==currYear)
             $("#selYear").append(""+i+"");
           else
             $("#selYear").append(""+i+"");
              
      }
      
      var currMonth=new Date().getMonth()+1;
      for(var i=1;i<13;i++)
      {
         if(i==currMonth)
             $("#selMonth").append(""+i+"");
         else
             $("#selMonth").append(""+i+"");
      }
      
    }
      
    
    script>

    <style type="text/css">
        .ulshit
        {
            list-style-type: none;
            margin: 0;
        }
    style>
head>
<body>
    <form id="form1" runat="server">
    <center>
        <h3>
            任务计划V1.0
        h3>
    center>
    <div>
        <a id="btn_add" href="javascript:;" class="easyui-linkbutton" iconcls="icon-add"
            onclick="Add();">添加任务a>div>
    <div style="text-align: center; margin-bottom: 40px;">
        <a href="javascript:void(0)" onclick="LastMonth()">
            <img src="images/left.png" />a>
        <select onchange="changeYear()" name="selYear" id="selYear">
        select><select onchange="changeMonth()" name="selMonth" id="selMonth">
        select><a href="javascript:void(0)" onclick="NextMonth()">
            <img src="images/right.png" />a>div>
    <div id="divCalendar">
    div>
    <div id="divAdd" closed="true" style="width: 500px;">
        <p>
            任务名称:<input type="text" id="txtJobName" />p>
        <p>
            任务描述:
            <textarea id="txtMemo" name="ipt_activitymemo" rows="5" cols="45" class="easyui-validatebox"
                style="background-color: #fff;" required="true">textarea>p>
        <%-- <p><a id="A1" href="javascript:;" class="easyui-linkbutton" onclick="Add();">保存a>p>--%>
        <p>
            任务时间:<input type="text" id="txtStartTime" name="ipt_startime" class="easyui-validatebox"
                required="true" />  ~  <input type="text" id="txtEndTime" name="ipt_endtime"
                    class="easyui-validatebox" required="true" />
        p>
    div>
    form>
body>
html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

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>兔子工作计划V1.0title>
    <link href="css/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="css/themes/icon.css" rel="stylesheet" type="text/css" />

    <script src="js/easyUI/jquery-1.7.2.min.js" type="text/javascript">script>

    <script src="js/easyUI/jquery.easyui.min.js" type="text/javascript">script>

    <script src="js/easyUI/locale/easyui-lang-zh_CN.js" type="text/javascript">script>

    <script type="text/javascript">
    function Add(){
        $("#divAdd").show();
        $("#divAdd").dialog({
                title: "添加任务",
                modal: true,
                closed:false,
                collapsible: true,
                minimizable: true,
                maximizable: true,
                resizable: true,
                buttons: [{
                    text: '添加',
                    iconCls: 'easyui-linkbutton',
                    handler: function () {
                        //alert('ok');触发表单提交
                        //$("#frmAddRole").submit();
                    }
                }, {
                    text: '取消',
                    handler: function () {
                        $("#divAdd").dialog('close'); //关闭对话框
                    }
                }]
            });
    };
     var currYear=new Date().getFullYear();
     var currMonth=new Date().getMonth()+1;
    $(function(){
        InitYearMonth();
        
       SelData(currYear,currMonth);
        
    })
    
    function  changeYear(){
        var  selYear=$("#selYear").val();
        var  selMonth=$("#selMonth").val();
       SelData(selYear,selMonth);
    }
    
    function  changeMonth(){
         var  selYear=$("#selYear").val();
        var  selMonth=$("#selMonth").val();
        SelData(selYear,selMonth);
    } 
    
    function LastMonth(){
      
       if(currMonth==1){
         currYear=currYear-1;
         currMonth=12;
       }
       else{
         currMonth=currMonth-1;
       }
       $("#selYear").val(currYear);
       $("#selMonth").val(currMonth); 
       SelData(currYear,currMonth);
    }
    
    function NextMonth(){
      
       if(currMonth==12)
       { 
         currYear=currYear+1;
         currMonth=1; 
       }
       else{
         currMonth=currMonth+1;
       }
       $("#selYear").val(currYear);
       $("#selMonth").val(currMonth); 
       SelData(currYear,currMonth);
    }
    
    
    function  SelData(year,month){
       
      var params={selDate:year+"-"+month};
      $.post("GetCalendar.ashx",params,function(data){
          $("#divCalendar").html(data);
      });
    }
    function InitYearMonth()
   {
      var currYear=new Date().getFullYear();
      
      for(var i=2000;i<=currYear;i++)  {
          if(i==currYear)
             $("#selYear").append(""+i+"");
           else
             $("#selYear").append(""+i+"");
              
      }
      
      var currMonth=new Date().getMonth()+1;
      for(var i=1;i<13;i++)
      {
         if(i==currMonth)
             $("#selMonth").append(""+i+"");
         else
             $("#selMonth").append(""+i+"");
      }
      
    }
      
    
    script>

    <style type="text/css">
        .ulshit
        {
            list-style-type: none;
            margin: 0;
        }
    style>
head>
<body>
    <form id="form1" runat="server">
    <center>
        <h3>
            任务计划V1.0
        h3>
    center>
    <div>
        <a id="btn_add" href="javascript:;" class="easyui-linkbutton" iconcls="icon-add"
            onclick="Add();">添加任务a>div>
    <div style="text-align: center; margin-bottom: 40px;">
        <a href="javascript:void(0)" onclick="LastMonth()">
            <img src="images/left.png" />a>
        <select onchange="changeYear()" name="selYear" id="selYear">
        select><select onchange="changeMonth()" name="selMonth" id="selMonth">
        select><a href="javascript:void(0)" onclick="NextMonth()">
            <img src="images/right.png" />a>div>
    <div id="divCalendar">
    div>
    <div id="divAdd" closed="true" style="width: 500px;">
        <p>
            任务名称:<input type="text" id="txtJobName" />p>
        <p>
            任务描述:
            <textarea id="txtMemo" name="ipt_activitymemo" rows="5" cols="45" class="easyui-validatebox"
                style="background-color: #fff;" required="true">textarea>p>
        <%-- <p><a id="A1" href="javascript:;" class="easyui-linkbutton" onclick="Add();">保存a>p>--%>
        <p>
            任务时间:<input type="text" id="txtStartTime" name="ipt_startime" class="easyui-validatebox"
                required="true" />  ~  <input type="text" id="txtEndTime" name="ipt_endtime"
                    class="easyui-validatebox" required="true" />
        p>
    div>
    form>
body>
html>

这只是初步的功能【希望大家多提需求,具体功能会慢慢跟进】

                                                                                                                            考勤或工作计划之日历图_第2张图片

转载于:https://www.cnblogs.com/zjflove/archive/2013/03/25/2981573.html

你可能感兴趣的:(考勤或工作计划之日历图)