📄 mycalendar.java
字号:
sWeek ="星期四";
break;
case 6:
sWeek ="星期五";
break;
case 7:
sWeek ="星期六";
}
return sWeek;
}
public String getDatePlan(String userName){
String resultDatePlan = new String();
String planTitle = new String();
int planBeginHours =0 ;
int planBeginMinutes =0;
int planEndHours =0;
int planEndMinutes=0;
String planStyle = new String ();
String planWholeDay = new String ();
Calendar calendar = Calendar.getInstance ();
String queryString =new String ();
queryString =" SELECT * FROM ps_dateplan WHERE ((username ='"+userName+
"' ) AND((datebeginyear<="+m_glYear+" and dateendyear >"+m_glYear+")or(datebeginmonth<=" +
(m_glMonth+1)+" and dateendmonth >"+(m_glMonth+1)+" and dateendyear="+m_glYear+" and datebeginyear="+m_glYear+
")or(datebeginyear="+m_glYear+" and dateendyear="+m_glYear+" and datebeginmonth = "+(m_glMonth+1)+"and dateendmonth ="+(m_glMonth+1)+
" and datebeginday<="+m_glDay+" and dateendday>="+m_glDay+")) ) ";
int planId,i=0;
DBOperater DB = new DBOperater ("ps_DatePlan");
ResultSet rs = DB.executeQuery (queryString);
if(rs!=null){
try{
while(rs.next())
{
planId = rs.getInt (1);
planBeginHours = rs.getInt (6) ;
planBeginMinutes = rs.getInt (7);
planTitle =rs.getString (9);
if ((planTitle==null)||(planTitle.trim ()==""))
planTitle="无标题";
planStyle =rs.getString (10);
planEndHours = rs.getInt (17);
planEndMinutes = rs.getInt (18);
planWholeDay = rs.getString (21);
if (planWholeDay==null)
planWholeDay = "";
resultDatePlan +="<TR>";
resultDatePlan +="<TD width=354 bgcolor=\"#E6E6E6\">";
// resultDatePlan +=planBeginHours+":"+planBeginMinutes+"-";
// resultDatePlan +=planEndHours+":"+planEndMinutes;
// resultDatePlan +="</TD>";
// resultDatePlan +="<TD>";
resultDatePlan +="<a href=\"DateUpdateThing?y=";
resultDatePlan += m_glYear;
resultDatePlan +="&m=";
resultDatePlan += m_glMonth+1;
resultDatePlan += "&d=";
resultDatePlan += m_glDay;
//resultDatePlan +="&action=edit";
resultDatePlan +="&id=";
resultDatePlan +=planId;
resultDatePlan +="\">";
if (planWholeDay.trim ().compareTo ("period")==0)
{
if (planBeginHours<10)
resultDatePlan +="0"+planBeginHours+":";
else
resultDatePlan +=planBeginHours+":";
if (planBeginMinutes<10)
resultDatePlan +="0"+planBeginMinutes+"-";
else
resultDatePlan += planBeginMinutes+"-";
if (planEndHours<10)
resultDatePlan +="0"+planEndHours+":";
else
resultDatePlan +=planEndHours+":";
if (planEndMinutes<10)
resultDatePlan +="0"+planEndMinutes;
else
resultDatePlan += planEndMinutes;
}
else
resultDatePlan+="时间不确定";
resultDatePlan+=CommonMethods.makeHtmlString(" ["+planStyle+"]");
resultDatePlan += CommonMethods.makeHtmlString(planTitle);
resultDatePlan +="</a>";
resultDatePlan +="</TD>";
resultDatePlan +="<TD width=6 bgcolor=\"#E6E6E6\"> </td><td width=52 bgcolor=\"E6E6E6\">";
resultDatePlan +="<a href=\"DateDelThing?id=";
resultDatePlan += planId;
resultDatePlan +="\">";
resultDatePlan +="删除";
resultDatePlan +="</a>";
resultDatePlan +="</TD>";
resultDatePlan +="</TR>";
i++;
}
}catch(Exception e){
}
}
else
resultDatePlan = "";
DB.close ();
// return queryString;
return resultDatePlan;
}
public String getDateDaily(String userName)
{
String sResult = new String ();
String sTitle = "";
DBOperater DB = new DBOperater ("ps_daily");
ResultSet rs = DB.executeQuery ("select DailyTitle from ps_daily where username='"+userName+"'and DailyYear= "
+m_glYear+" and DailyMonth="+(m_glMonth+1)+" and DailyDay="+m_glDay);
if(rs!=null){
try{
if( rs.next () )
{ sTitle = rs.getString (1);
if (sTitle==null)
sTitle="无标题";
if (sTitle.trim ()=="")
sTitle="无标题";
}
}catch(Exception e){
sResult="";
}
}
DB.close ();
sResult+="<a href=\"DateEditDaily?y=&";
sResult+=m_glYear;
sResult+="m=&";
sResult+=(m_glMonth+1)+"";
sResult+="d=";
sResult+=m_glDay;
sResult+="\">";
sResult+=sTitle;
sResult+="</a>";
sResult+="</td>";
sResult+="<TD width=\"6\"> </td><td width=\"52\"><a href=\"DateDelDaily?y=&";
sResult+=m_glYear;
sResult+="m=&";
sResult+=(m_glMonth+1);
sResult+="d=";
sResult+=m_glDay;
sResult+="\">";
if (sTitle.trim().length ()>0)
sResult+="删除";
sResult+="</a>";
sResult+="</td>";
return sResult;
}
public String getDateAwoke (String userName){
String resultDateAwoke = new String();
int nAwokeDay[] = new int[10];
int nAwokeMinute[] = new int[10];
int nAwokeHour[]= new int[10];
int nBeginYear[]= new int[10];
int nBeginMonth[]= new int[10];
int nBeginDay[]= new int[10];
int nBeginHour[]= new int[10];
int nBeginMinute[]= new int[10];
int nEndYear[]= new int[10];
int nEndMonth[]= new int[10];
int nEndDay[]= new int[10];
int nEndHour[]= new int[10];
int nEndMinute[]= new int[10];
int nAwokeId[]= new int[10];
int nDateBeginHours[]= new int[10];
int i=0;
String[] sTitle= new String[10];
Calendar calendar = Calendar.getInstance ();
int nHour;
int nMinute;
nHour= calendar.get(calendar.HOUR_OF_DAY );
nMinute = calendar.get(calendar.MINUTE );
java.util.Date beginDate,endDate,nowDate;
String planStyle = new String ();
DBOperater DB = new DBOperater ("ps_DatePlan");
ResultSet rs = DB.executeQuery ("select * from ps_DatePlan where dateawoke='yes' and username='"+userName+"'ORDER BY id DESC");
if(rs!=null){
try{
while ( rs.next () ){
nAwokeId[i]=rs.getInt (1);
nBeginYear[i] = rs.getInt (3);
nBeginMonth[i] = rs.getInt (4);
nBeginDay[i] = rs.getInt (5);
nBeginHour[i] = rs.getInt (6);
nBeginMinute[i] = rs.getInt (7);
sTitle[i]=rs.getString (9);
nAwokeDay[i]=rs.getInt (12);
nAwokeHour[i]=rs.getInt (13);
nEndYear[i]=rs.getInt (14);
nEndMonth[i]=rs.getInt (15);
nEndDay[i]=rs.getInt (16);
nEndHour[i]=rs.getInt(17);
nEndMinute[i]=rs.getInt (18);
nAwokeMinute[i]=rs.getInt (23);
calendar.set (nBeginYear[i],nBeginMonth[i]-1,nBeginDay[i]-nAwokeDay[i],nBeginHour[i]-nAwokeHour[i],nBeginMinute[i]-nAwokeMinute[i]);
beginDate=calendar.getTime ();
calendar.set (nEndYear[i],nEndMonth[i]-1,nEndDay[i],nEndHour[i],nEndMinute[i]);
endDate=calendar.getTime ();
calendar.set (m_glYear,m_glMonth,m_glDay,nHour,nMinute);
nowDate=calendar.getTime ();
if (sTitle[i]==null)
sTitle[i]="无标题";
if (sTitle[i].trim ()=="")
sTitle[i]="无标题";
if ((nowDate.after( beginDate)) && (nowDate.before (endDate)))
// if ((nowDate.after (beginDate) && (nowDate.before (endDate)))
{
resultDateAwoke +="<p><a href=DateUpdateThing?y=";
resultDateAwoke +=m_glYear;
resultDateAwoke +="&m=";
resultDateAwoke +=m_glMonth+1;
resultDateAwoke +="&d=";
resultDateAwoke +=m_glDay;
resultDateAwoke +="&id=";
resultDateAwoke +=nAwokeId[i];
resultDateAwoke +=">";
resultDateAwoke +=sTitle[i];
resultDateAwoke +="</a></p>";
}
i++;
if (i>9)
break;
}
}catch(Exception e){
resultDateAwoke="";
}
}
else{
resultDateAwoke="";
}
DB.close ();
return resultDateAwoke;
}
/*public String getImportAwoke (String userName){
String sResultDay = new String ();
Calendar begin= Calendar.getInstance ();
Calendar now =Calendar.getInstance ();
String sTitle=new String ();
now.set(m_glYear,m_glMonth-1,m_glDay);
Calendar end = Calendar.getInstance ();
int nYear,nMonth,nDay,nEndYear,nEndMonth,nEndDay,nId;
DBOperater DB= new DBOperater ("Dataholiday");
String sDateStyle=new String ();
ResultSet rs = DB.executeQuery ("select * from ps_importday where username='"+userName+"' and DateAwoke!='不提醒'");
//查询今天是否是节日或需要提醒的特别的日子
int i=0;
if (rs!=null){
try{
while(rs.next())
{
nYear=rs.getInt ("DateYear");
nMonth=rs.getInt ("DateMonth");
nDay=rs.getInt ("DateDay");
sTitle=rs.getString ("DateTitle");
if ((sTitle==null)||(sTitle.trim ()==""))
sTitle="无标题";
sDateStyle=rs.getString ("DateStyle");
nId=rs.getInt ("id");
nEndYear=rs.getInt ("DateEndYear");
nEndMonth=rs.getInt ("DateEndMonth");
nEndDay=rs.getInt ("DateEndDay");
now.set(m_glYear,m_glMonth,m_glDay);
begin.set(nEndYear,nEndMonth-1,nEndDay);
end.set (nYear,nMonth-1,nDay);
// if(()&&((m_glMonth>nEndMonth-1)&&(m_glMonth<=nMonth-1))
//||((m_glMonth==nEndMonth-1)&&(m_glMonth==nMonth-1)&&(m_glDay>=nEndDay)&&(m_glDay<=nEndDay)))
if (((now.after(begin)) &&(now.before (end))||(now.equals (begin))||(now.equals (end))) && (sDateStyle.trim ().compareTo ("当年")==0))
{ sResultDay+="<tr>";
sResultDay+=nYear+"/";
if (nMonth<10)
sResultDay+="0"+nMonth+"/";
else
sResultDay+=nMonth+"/";
if (nDay<10)
sResultDay+="0"+nDay+"是";
else
sResultDay+=nDay+"是";
sResultDay+="<a href=\"DateEditImport?id=";
sResultDay+=nId+"\">";
sResultDay+=sTitle;
sResultDay+="</a>";
sResultDay+="</tr>";
}
else
{
if (nYear==nEndYear){
begin.set (m_glYear,nEndMonth-1,nEndDay);
end.set (m_glYear,nMonth-1,nEndDay);
}else{
if (m_glMonth==11)
now.set(m_glYear,m_glMonth,m_glDay);
else
now.set(m_glYear,m_glMonth+12,m_glDay);
begin.set (m_glYear,nEndMonth-1,nEndDay);
end.set (m_glYear,nMonth+11,nDay);
}
if((sDateStyle.trim ().compareTo ("每年")==0)&&((now.after(begin)) &&(now.before (end))||(now.equals (begin))||(now.equals (end)))){
sResultDay+="<ul>";
sResultDay+=nMonth+"月";
sResultDay+=nDay+"日是";
sResultDay+="<a href=\"DateEditImport?id=";
sResultDay+=nId+"\"><b>";
sResultDay+=sTitle;
sResultDay+="</b></a>";
sResultDay+="</ul>";
}
}
}
}
catch(Exception e){
}
}
DB.close ();
//sResultDay="select * from ps_importday where username='"+userName+"' and DateAwoke!='不提醒'";
return sResultDay;
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -