Some time ago in order to practiced hand, I designed an online diary system of imitation QQ mailbox Calendar
Front Desk with Css+html+javascript implementation
The backend is implemented with Mvc+dbmapper
Developed by vs2010+sqlserver2008
The core sections are as follows:
User Login
Calendar view
Lunar calendar (the lunar calendar with the mouse parked on the bottom of the status bar)
Journal editor (click Date to edit journal)
Note Note (the date of the diary has been marked with a light yellow color)
Part of the code:
1Refill:function() {//fill again with the last filled month2 This. Fill ( This. Last_year_month);3 },4Fill:function(S_d) {//The parameter must be the first day of the month in the 2015-9-1 format. Determine from which cell to start binding numbers to which cell ends5 varTable = document.getElementById ( This. ID);6 varNdate1 = This. Getformatday (s_d);7 varTodayDate = This. Getformatday ();8 varCurday = 1;9 varMaxday = This. Monthdays[ndate1. Month];Ten if(Ndate1. Month = = 1) { One if(Ndate1. Year%!! = 0 && ndate1. Year% 4 = = = 0) | | Ndate1. Year% 400 = = = 0) { AMaxday = 29; - - } the - } - for(vari = 1; i < table.rows.length; i++) - for(varj = 0; J < Table.rows[i].cells.length; J + +) { +Table.rows[i].cells[j].classname = ' '; -Table.rows[i].cells[j].setattribute (' Data ', '); +Table.rows[i].cells[j].onmouseover =NULL; ATable.rows[i].cells[j].onmouseout =NULL; atTable.rows[i].cells[j].onclick =NULL;//cleans up events and properties that were loaded on the last population to avoid affecting the - - if((i = = 1) && (J < parseint (ndate1). Week, 10))) { -table.rows[i].cells[j].innerhtml = ' '; - - } in Else { - if(Curday >maxday) { totable.rows[i].cells[j].innerhtml = ' '; + } - Else { the if(Todaydate.year = = = Ndate1. Year && Todaydate.month = = = Ndate1. Month && Todaydate.date0 = = =curday) { *Table.rows[i].cells[j].classname = ' Today-cell '; $ }Panax NotoginsengTable.rows[i].cells[j].setattribute (' Data ', ndate1. Year + '-' + (ndate1. Month + 1) + '-' +curday); -table.rows[i].cells[j].innerhtml = Curday + ' <br/><span class= ' Nongli-cell ' > ' the+ Nongli. Getlunarday (ndate1. Year, (Ndate1. Month + 1), curday). Cday + ' </span> '; +curday++; A varb = This; the //display Lunar Calendar mouse Move-in remove event +Table.rows[i].cells[j].onmouseover =function () { - varSelectdate = This. getattribute (' Data '); $ varde = Selectdate.split ('-'); $ varNong = Nongli. Getlunarday (parseint (de[0]), parseint (De[1]), parseint (de[2])); -document.getElementById (B.longli). InnerHTML = ' lunar ' + Nong. Cmonth +Nong. Cday; - } theTable.rows[i].cells[j].onmouseout =function () { - Wuyidocument.getElementById (B.longli). InnerHTML = "; the } - WuTable.rows[i].cells[j].onclick =function () { - varSelectdate = This. getattribute (' Data '); About if(B.ondatecellclickinstanceofFunction) $ {B.ondatecellclick (selectdate);} - } - } - } A } + This. Last_year_month = ndate1. Year + '-' + (ndate1. Month + 1) + '-1 '; the This. Selectnoteddates ( This. Last_year_month); - }, $Datechange:function () { the varIndexmonth = document.getElementById ( This. selectmonth). SelectedIndex; the varmonth = document.getElementById ( This. selectmonth). Options[indexmonth].value; the the - varIndexyear = document.getElementById ( This. selectyear). SelectedIndex; in varYear = document.getElementById ( This. selectyear). Options[indexyear].value; the the This. Fill (year + '-' + month + '-1 ')); About},
JavaScript code
1 Public classnoteentity:idbtablenaming2 {3 [PrimaryKey]4 Public int? Id {Get;Set; }5 Public int? Usernameid {Get;Set; }6 Public stringTitle {Get;Set; }7 Public stringNotetime {Get;Set; }8 Public stringContent {Get;Set; }9 stringIdbtablenaming.dbtablename//Display Implementation InterfaceTen { One Get{return "Note"; } A } - } - the -Idbmapper db = Dbmapper.createdbmapper (Dbmapper.provider_sqlserver,NULL); - PublicNoteentity Getnote (intUseridstringdate) - { +list<noteentity> LST = db. Query<noteentity> ("Select Id,usernameid,title,notetime,content from Note where [email protected] and CONVERT (varchar), notetime,23 ) [Email protected]", - Newnoteentity () { +Usernameid=UserId, ANotetime=convert.todatetime (date). ToString ("YYYY-MM-DD")//convert 2015-9-4 to 2015-09-04 at }). ToList (); - if(LST.) Count>0){returnlst[0];} - Else{return NULL;} - } - - Public BOOLDeletenote (stringDateintuserId) { inlist<noteentity> LST = db. Query<noteentity> ("Select Id,usernameid,title,notetime,content from Note where [email protected] and CONVERT (varchar), notetime,23 ) [Email protected]", - Newnoteentity () to { +Usernameid =UserId, -Notetime = Convert.todatetime (date). ToString ("YYYY-MM-DD")//convert 2015-9-4 to 2015-09-04 the }). ToList (); * if(LST.) Count >0) $ {Panax NotoginsengDb. Delete<noteentity> (Newnoteentity () { -id=lst[0]. Id the }); + return(Db. Execute () >0); A } the Else { + return false; - } $}
C # code
Online diary system Design