在线日记系统设计

前段时间为了练手,自己设计了一个仿QQ邮箱日历 的在线日记系统

前台采用CSS+HTML+Javascript实现 

后端用的 是 MVC+DBMapper 实现

Vs2010+SQLServer2008开发的

 

核心部分如下:

 

用户登录

日历查看

 

农历查看(状态栏下方显示鼠标停放 的日期的农历)

 

日记编辑(点击日期编辑日记)

 

记事标注(有日记的日期做了淡黄色标注)

 

部分代码:

 1    ReFill: function () {//用最后一次填充的年月再次填充
 2         this.Fill(this.last_Year_Month);
 3     },
 4     Fill: function (s_d) {//参数必须是2015-9-1  格式  某个月的第一天 好确定 从哪个单元格开始绑定数字 到哪个单元格结束
 5         var table = document.getElementById(this.id);
 6         var ndate1 = this.getFormatDay(s_d);
 7         var todayDate = this.getFormatDay();
 8         var curday = 1;
 9         var maxday = this.monthDays[ndate1.Month];
10         if (ndate1.Month === 1) {
11             if ((ndate1.Year % 100 != 0 && ndate1.Year % 4 === 0) || ndate1.Year % 400 === 0) {
12                 maxday = 29;
13 
14             }
15 
16         }
17         for (var i = 1; i < table.rows.length; i++)
18             for (var j = 0; j < table.rows[i].cells.length; j++) {
19                 table.rows[i].cells[j].className = '';
20                 table.rows[i].cells[j].setAttribute('data', '');
21                 table.rows[i].cells[j].onmouseover = null;
22                 table.rows[i].cells[j].onmouseout = null;
23                 table.rows[i].cells[j].onclick = null;//清理上次填充时 加载的事件和属性 以免影响本次
24 
25                 if ((i === 1) && (j < parseInt(ndate1.Week, 10))) {
26                     table.rows[i].cells[j].innerHTML = ' ';
27 
28                 }
29                 else {
30                     if (curday > maxday) {
31                         table.rows[i].cells[j].innerHTML = ' ';
32                     }
33                     else {
34                         if (todayDate.Year === ndate1.Year && todayDate.Month === ndate1.Month && todayDate.Date0 === curday) {
35                             table.rows[i].cells[j].className = 'today-cell';
36                         }
37                         table.rows[i].cells[j].setAttribute('data', ndate1.Year + '-' + (ndate1.Month + 1) + '-' + curday);
38                         table.rows[i].cells[j].innerHTML = curday + '<br/><span class="nongli-cell">'
39                   + nongli.GetLunarDay(ndate1.Year, (ndate1.Month + 1), curday).CDay + '</span>';
40                         curday++;
41                         var b = this;
42                         //显示农历鼠标移入移除事件
43                         table.rows[i].cells[j].onmouseover = function () {
44                             var selectDate = this.getAttribute('data');
45                             var de = selectDate.split('-');
46                             var nong = nongli.GetLunarDay(parseInt(de[0]), parseInt(de[1]), parseInt(de[2]));
47                             document.getElementById(b.longli).innerHTML = '农历' + nong.CMonth + nong.CDay;
48                         }
49                         table.rows[i].cells[j].onmouseout = function () {
50 
51                             document.getElementById(b.longli).innerHTML = '';
52                         }
53 
54                         table.rows[i].cells[j].onclick = function () {
55                             var selectDate = this.getAttribute('data');
56                             if (b.onDateCellClick instanceof Function)
57                             { b.onDateCellClick(selectDate); }
58                         }
59                     }
60                 }
61             }
62         this.last_Year_Month = ndate1.Year + '-' + (ndate1.Month + 1) + '-1';
63         this.selectNotedDates(this.last_Year_Month);
64     },
65     dateChange: function () {
66         var IndexMonth = document.getElementById(this.selectMonth).selectedIndex;
67         var month = document.getElementById(this.selectMonth).options[IndexMonth].value;
68 
69 
70         var IndexYear = document.getElementById(this.selectYear).selectedIndex;
71         var year = document.getElementById(this.selectYear).options[IndexYear].value;
72 
73         this.Fill(year + '-' + month + '-1');
74     },
Javascript代码

 

 

 1     public class NoteEntity:IDbTableNaming
 2     {
 3         [PrimaryKey]
 4         public int? Id { get; set; }
 5         public int? UserNameId { get; set; }
 6         public string Title { get; set; }
 7         public string NoteTime { get; set; }
 8         public string Content { get; set; }
 9         string IDbTableNaming.DBTableName//显示实现接口
10         {
11             get { return "Note"; }
12         }
13     }
14 
15 
16         IDbMapper db = DbMapper.CreateDbMapper(DbMapper.PROVIDER_SQLSERVER, null);
17         public NoteEntity GetNote(int userId, string date)
18         {
19             List<NoteEntity> lst = db.Query<NoteEntity>("select Id,UserNameId,Title,NoteTime,Content from Note where UserNameId=@UserNameId and CONVERT(varchar(100),NoteTime,23)=@NoteTime",
20                 new NoteEntity(){
21                    UserNameId=userId,
22                    NoteTime=Convert.ToDateTime(date).ToString("yyyy-MM-dd")//把 2015-9-4 转换为 2015-09-04
23                 }).ToList();
24             if(lst.Count>0){return lst[0];}
25             else{return null;}
26         }
27 
28         public bool DeleteNote(string date,int userId) { 
29             List<NoteEntity> lst = db.Query<NoteEntity>("select Id,UserNameId,Title,NoteTime,Content from Note where UserNameId=@UserNameId and CONVERT(varchar(100),NoteTime,23)=@NoteTime",
30                 new NoteEntity()
31                 {
32                     UserNameId = userId,
33                     NoteTime = Convert.ToDateTime(date).ToString("yyyy-MM-dd")//把 2015-9-4 转换为 2015-09-04
34                 }).ToList();
35             if (lst.Count > 0)
36             {
37                 db.Delete<NoteEntity>(new NoteEntity() { 
38                   Id=lst[0].Id
39                 });
40                 return (db.Execute() > 0);
41             }
42             else {
43                 return false;
44             }
45         }
C#代码

 

posted @ 2015-09-13 11:38  hufun  阅读(479)  评论(0编辑  收藏  举报