`
hjwromantic
  • 浏览: 27706 次
  • 性别: Icon_minigender_1
文章分类
社区版块
存档分类
最新评论

Java版的xgcalendar实现

 
阅读更多


jsp:

<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib uri="/WEB-INF/tagtld/htmlTagComponet.tld" prefix="JB"%>
<html>
<head>
<JB:ComponentBase id="bomponentBase" isJudgeSession="true"></JB:ComponentBase>
<style>
html,body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
overflow: hidden;
}
.bltable {
width: 100%;
}
.bltable td.bg {
color: #000000;
border-right: 0px solid #C1DAD7;
border-bottom: 0px dashed #8BB4D7;
border-top: 0px solid #C1DAD7;
border-left: 0px solid #C1DAD7;
text-align: right;
height:22px;
font: normal 9pt 宋体;
background-color: #D8E6F6;
background-repeat: repeat;
background-position: top;
vertical-align:middle ;

}
/**无背景*/
.bltable th.nobg {
border-right: 0px solid #C1DAD7;
border-bottom: 0px dashed #8BB4D7;
border-top: 0px solid #C1DAD7;
border-left: 0px solid #C1DAD7;
background: none;
vertical-align:middle;
font: normal 9pt 宋体;
}
.bltable td {
border-right: 0px solid #C1DAD7;
border-bottom: 0px dashed #8BB4D7;
border-top: 0px solid #C1DAD7;
border-left: 0px solid #C1DAD7;
background: #fff;
font: normal 9pt 宋体;
padding:1px;
vertical-align:middle;
color: #000000;
}
/**
td向右对齐
*/
.bltable td.td_align_right {
text-align:right;
vertical-align:middle;
}
/**
td向中对齐
*/
.bltable td.td_align_center {
vertical-align:middle;
}
/**
td向左对齐
*/
.bltable td.td_align_left {
text-align:left;
vertical-align:middle;
}
/**表格结束*/
fieldset {
padding:2px;
width:99%;
margin-top:1px;
border:0px solid navy;
background:#f4f9ff;
}
fieldset legend {
cursor:default;
color:#000;
font-weight:bold;
padding-left:10px;
padding-top:6px;
padding-bottom:6px;
border:0px solid #navy;
background:#f4f9ff;
font-size:14px;
}
fieldset label {
float:left;
width:100%;
text-align:center;
padding:15px;
margin:1px;
}
fieldset div {
clear:left;
margin-bottom:2px;
}
</style>
</head>
<script type="text/javascript">
function okOperate(){//确定
//刷新列表
closeBlDialog();
}
function noOperate(){//取消
closeBlDialog();
}
//异步请求回调函数
function ajaxbtnOkCallBack(data){
var dataObj = eval("(" + data + ")");
if(dataObj.result=='true'){
OpenBlDialog('创建日程明细','创建日程明细成功!','OK','','','okOperate()','noOperate()','','');

} else{
OpenBlDialog('创建日程明细','创建日程明细异常!','ERROR','','','okOperate()','noOperate()','','');
}
}
var formOperate = new FormOperateObject();
function btnOk(){//确定
var isValid = formOperate.formValidate('scheduleEditForm');//验证表单
var formDataStr = formOperate.getFormById('scheduleEditForm');//获取表单数据
formDataStr = formOperate.changeURLParamValue(formDataStr,'stpartdate',$('#stpartdate').datebox('getValue'));
formDataStr = formOperate.changeURLParamValue(formDataStr,'etpartdate',$('#etpartdate').datebox('getValue'));
if (isValid){
//提交数据
var url = "${pageContext.request.contextPath}/BPHandler?_bpForm=org.jplogic.system.web.view.webform.ScheduleMngForm&_operate=adddetails&operateType=add&"+formDataStr;
var data = formOperate.AjaxCall(url,false,'ajaxbtnOkCallBack');//同以下注释代码功能 ,返回的值可作为其他业务判断使用
}
}
function btnCannel(){//取消
//关闭当前form窗口
closeBlDialog();
//获取父窗口对象
closeBlWindowsByObject('ScheduleAddPageForm',parent.ScheduleAddPageForm);
parent.$("#gridcontainer").reload();
}
function okOperate(){//确定
//刷新列表
closeBlDialog();
closeBlWindowsByObject('ScheduleAddPageForm',parent.ScheduleAddPageForm);
parent.$("#gridcontainer").reload();
}
function noOperate(){//取消
closeBlDialog();
}
</script>
<body>
<form method="post" id="scheduleEditForm">
<table class="bltable" id="scheduleEdittable" border="0" cellspacing="0" style="width:100%;" >
<caption></caption>
<tbody>
<tr>
<td class="bg" width="15%" scope="col">*主题:</td>
<td class="td_align_left" colspan="3">
<JB:InputText id="Subject" name="Subject" classname="validatebox" style="width:550px;height:22px;border:1px solid #ccc;" data_Options="required:true" required="true" ></JB:InputText>
<!-- 隐藏域 -->
<JB:InputText id="colorvalue" name="colorvalue" type="hidden" style="width:125px;height:22px;border:1px solid #ccc;"></JB:InputText>
</td>
</tr>

<tr>
<td class="bg" width="15%" scope="col">*时间:</td>
<td class="td_align_left" colspan="3">
<JB:InputText id="stpartdate" name="stpartdate" classname="datebox" style="width:125px;height:22px;border:1px solid #ccc;" data_Options="required:true" required="true"></JB:InputText>
<JB:InputText id="etpartdate" name="etpartdate" classname="datebox" style="width:125px;height:22px;border:1px solid #ccc;" data_Options="required:true" required="true"></JB:InputText>
<input id="IsAllDayEvent" name="IsAllDayEvent" type="checkbox" value="1" "checked" />All Day Event
</td>
</tr>


<tr>
<td class="bg" width="15%" scope="col">位置信息:</td>
<td class="td_align_left" colspan="3">
<JB:InputText id="Location" name="Location" classname="validatebox" style="width:550px;height:22px;border:1px solid #ccc;" data_Options="required:true" required="true"></JB:InputText>
</td>
</tr>


<tr>
<td class="bg" width="15%" scope="col">备注:</td>
<td class="td_align_left" colspan="3">
<JB:TextArea id="description" componentName="description" style="width:550px;height:140px;border:1px solid #ccc;" rows="8" data_Options="required:true" required="true"></JB:TextArea>
</td>
</tr>

<tr align="center">
<td class="td_align_center" colspan="4" align="center">
<!-- 隐藏域 -->
<JB:InputText id="timezone" name="timezone" type="hidden" style="width:520px;height:22px;border:1px solid #ccc;"></JB:InputText>
<JB:InputText id="id" name="id" type="hidden" style="width:520px;height:22px;border:1px solid #ccc;"></JB:InputText>
<JB:Buttun id="ok" btnText="确定" onclick="btnOk()" style="width:90px;height:35px;"></JB:Buttun>
<JB:Buttun id="cannel" btnText="取消" onclick="btnCannel()" style="width:90px;height:35px;"></JB:Buttun>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

截图:


<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/tagtld/htmlTagComponet.tld" prefix="JB"%>
<!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 id="Head1">
<title> 日程管理</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/JBPlatformBase/EasyUI/themes/default/easyui.css"></link>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/JBPlatformBase/EasyUI/themes/icon.css"></link>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/JBPlatformBase/EasyUI/demo.css"></link>
<script type="text/javascript" src="${pageContext.request.contextPath}/JBPlatformBase/EasyUI/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/JBPlatformBase/EasyUI/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/JBPlatformBase/EasyUI/locale/easyui-lang-zh_CN.js"></script>

<link href="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/css/dailog.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/css/calendar.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/css/dp.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/css/alert.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/css/main.css" rel="stylesheet" type="text/css" />
<script src="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/js/jquery.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/js/Plugins/Common.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/js/Plugins/datepicker_lang_US.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/js/Plugins/jquery.datepicker.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/js/Plugins/jquery.alert.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/js/Plugins/jquery.ifrmdailog.js" defer="defer" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/js/Plugins/wdCalendar_lang_US.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/JBPlatformBase/xgCalendar/js/Plugins/jquery.calendar.js" type="text/javascript"></script>

<!-- 窗口支持 -->

<script src='${pageContext.request.contextPath}/JBPlatformBase/commonJs/extForm.js'></script>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<script type="text/javascript">
var ScheduleEditPageForm=null;//自定义编辑窗口
var ScheduleAddPageForm=null;
var basepath = '<%=basePath%>';
$(document).ready(function () {
var view = "week";
var DATA_FEED_URL = "${pageContext.request.contextPath}/BPHandler?_bpForm=org.jplogic.system.web.view.webform.ScheduleMngForm";
var op = {
view: view,
theme: 3,
showday: new Date(),//当前日期
EditCmdhandler: Edit,
DeleteCmdhandler: Delete,
ViewCmdhandler: View,
onWeekOrMonthToDay: wtd,
onBeforeRequestData: cal_beforerequest,//在请求之前
onAfterRequestData: cal_afterrequest,
onRequestDataError: cal_onerror,
autoload: true,
url: DATA_FEED_URL + "&_operate=list",
//快速添加日程响应的 Url 地址
quickAddUrl: DATA_FEED_URL + "&_operate=add",
////拖拽更新时响应的 Url 地址
quickUpdateUrl: DATA_FEED_URL + "&_operate=update",
//快速删除日程时响应的Urk 地址
quickDeleteUrl: DATA_FEED_URL + "&_operate=remove"
};


var $dv = $("#calhead");
var _MH = document.documentElement.clientHeight;
var dvH = $dv.height() + 2;
op.height = _MH - dvH;//视图的高度,如果不设置则默认获取所在页面的高度
op.eventItems = [];//日程数据,可通过此参数设置初始化数据


var p = $("#gridcontainer").bcalendar(op).BcalGetOp();
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}
$("#caltoolbar").noSelect();


$("#hdtxtshow").datepicker({ picker: "#txtdatetimeshow", showtarget: $("#txtdatetimeshow"),
onReturn: function (r) {
var p = $("#gridcontainer").gotoDate(r).BcalGetOp();
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}
}
});
function cal_beforerequest(type) {//在请求之前,type为数字,表示事件的类型(1:加载,2:新增,3:删除,4:更新)
var t = "数据加载中...";
switch (type) {
case 1:
t = "数据加载中...";
break;
case 2:
case 3:
case 4:
t = "该请求处理...";
break;
}
$("#errorpannel").hide();
$("#loadingpannel").html(t).show();
}
function cal_afterrequest(type) {//请求之后执行,type为数字,表示事件的类型(1:加载,2:新增,3:删除,4:更新)
switch (type) {
case 1:
$("#loadingpannel").hide();
break;
case 2:
case 3:
case 4:
$("#loadingpannel").html("Success!");
window.setTimeout(function () { $("#loadingpannel").hide(); }, 2000);
break;
}


}
function cal_onerror(type, data) {
$("#errorpannel").show();
}

function Edit(data) {//编辑
/*
var eurl = "${pageContext.request.contextPath}/jsp/JpSystem/ScheduleEditForm.jsp?id={0}&start={2}&end={3}&isallday={4}&title={1}";
if (data) {
var url = StrFormat(eurl, data);
alert(url);
OpenModelWindow(url, { width: 600, height: 400, caption: "修改日程明细", onclose: function () {
$("#gridcontainer").reload();
}
});
}
*/
if(data){
var formOperate = new FormOperateObject();
//提交数据
var url = "${pageContext.request.contextPath}/BPHandler?_bpForm=org.jplogic.system.web.view.webform.ScheduleMngForm&_operate=editSchedule&id={0}&start={2}&end={3}&isallday={4}&title={1}";
url = StrFormat(url, data);
$.ajax({
type: "post",
url: url,
datatype: "json",
contentType: "application/json;charset=utf-8",
success: function(data) {
var dataObj= eval("(" + data + ")");
if(dataObj.result=='true'){
//打开窗体
ScheduleEditPageForm = OpenBlWindows('修改日程明细','','${pageContext.request.contextPath}/images/blImgs/windows.png','ScheduleEditPageForm',850,350,'${pageContext.request.contextPath}/jsp/JpSystem/ScheduleEditPageForm.jsp',false,'',true,true,true,true);
}else if(dataObj.result=='false'){
OpenBlDialog('修改日程明细','修改日程明细异常!','ERROR','','','okOperate()','noOperate()','','',basepath);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
}
function okOperate(){//确定
//刷新列表
closeBlDialog();
}
function noOperate(){//取消
closeBlDialog();
}

function View(data) {
var str = "";
$.each(data, function (i, item) {
str += "[" + i + "]: " + item + "\n";
});
document.write(str); debugger;
}
function Delete(data, callback) {
$.alerts.okButton = "确定";
$.alerts.cancelButton = "取消";
hiConfirm("是否删除该日程安排记录?", '确认', function (r) {
r && callback(0);
});
}
function wtd(p) {
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}
$("#caltoolbar div.fcurrent").each(function () {
$(this).removeClass("fcurrent");
})
$("#showdaybtn").addClass("fcurrent");
}
//to show day view
$("#showdaybtn").click(function (e) {
//document.location.href="#day";
$("#caltoolbar div.fcurrent").each(function () {
$(this).removeClass("fcurrent");
})
$(this).addClass("fcurrent");
var p = $("#gridcontainer").swtichView("day").BcalGetOp();
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}
});
//to show week view
$("#showweekbtn").click(function (e) {
//document.location.href="#week";
$("#caltoolbar div.fcurrent").each(function () {
$(this).removeClass("fcurrent");
})
$(this).addClass("fcurrent");
var p = $("#gridcontainer").swtichView("week").BcalGetOp();
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}


});
//to show month view
$("#showmonthbtn").click(function (e) {
//document.location.href="#month";
$("#caltoolbar div.fcurrent").each(function () {
$(this).removeClass("fcurrent");
})
$(this).addClass("fcurrent");
var p = $("#gridcontainer").swtichView("month").BcalGetOp();
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}
});


$("#showreflashbtn").click(function (e) {///刷新事件

$("#gridcontainer").reload();

});


//新增日程安排事件
$("#faddbtn").click(function (e) {
/*
var eurl = "${pageContext.request.contextPath}/jsp/JpSystem/ScheduleEditForm.jsp?id={0}&start={2}&end={3}&isallday={4}&title={1}";
var url = eurl;
OpenModelWindow(url, { width: 500, height: 400, caption: "创建日程安排" });//打开窗口
*/
//打开窗体
ScheduleAddPageForm = OpenBlWindows('创建日程安排','','${pageContext.request.contextPath}/images/blImgs/windows.png','ScheduleAddPageForm',850,350,'${pageContext.request.contextPath}/jsp/JpSystem/ScheduleAddPageForm.jsp',false,'',true,true,true,true);
});
//go to today
$("#showtodaybtn").click(function (e) {
var p = $("#gridcontainer").gotoDate().BcalGetOp();
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}
});
//previous date range
$("#sfprevbtn").click(function (e) {
var p = $("#gridcontainer").previousRange().BcalGetOp();
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}


});
//next date range
$("#sfnextbtn").click(function (e) {
var p = $("#gridcontainer").nextRange().BcalGetOp();
if (p && p.datestrshow) {
$("#txtdatetimeshow").text(p.datestrshow);
}
});


});
</script>
</head>
<body>
<div>
<div></div>
<div id="calhead" style="padding-left:1px;padding-right:1px;">
<div class="cHead"><div class="ftitle">日程安排管理</div>
<div id="loadingpannel" class="ptogtitle loadicon" style="display: none;">加载数据中...</div>
<div id="errorpannel" class="ptogtitle loaderror" style="display: none;">很抱歉,无法加载数据,请稍后再试</div>
</div>
<div id="caltoolbar" class="ctoolbar">
<div id="faddbtn" class="fbutton">
<div>
<span title='创建新事件' class="addcal">
新增
</span>
</div>
</div>
<div class="btnseparator"></div>
<div id="showtodaybtn" class="fbutton">
<div>
<span title='返回今天日程记录' class="showtoday">
今天
</span>
</div>
</div>
<div class="btnseparator"></div>
<div id="showdaybtn" class="fbutton">
<div><span title='天' class="showdayview">天</span></div>
</div>
<div id="showweekbtn" class="fbutton fcurrent">
<div><span title='周' class="showweekview">周</span></div>
</div>
<div id="showmonthbtn" class="fbutton">
<div><span title='月' class="showmonthview">月</span></div>
</div>
<div class="btnseparator"></div>
<div id="showreflashbtn" class="fbutton">
<div><span title='刷新视图' class="showdayflash">刷新</span></div>
</div>
<div class="btnseparator"></div>
<div id="sfprevbtn" title="向前" class="fbutton">
<span class="fprev"></span>
</div>
<div id="sfnextbtn" title="下一个" class="fbutton">
<span class="fnext"></span>
</div>
<div class="fshowdatep fbutton">
<div>
<input type="hidden" name="txtshow" id="hdtxtshow" />
<span id="txtdatetimeshow">正加载...</span>
</div>
</div>

<div class="clear"></div>
</div>
</div>
<div style="padding:1px;">


<div class="t1 chromeColor">
&nbsp;</div>
<div class="t2 chromeColor">
&nbsp;</div>
<div id="dvCalMain" class="calmain printborder">
<div id="gridcontainer" style="overflow-y: visible;">
</div>
</div>
<div class="t2 chromeColor">
&nbsp;</div>
<div class="t1 chromeColor">
&nbsp;
</div>
</div>
</div>
</body>
</html>

截图:



代码:

/**

* 编辑日程安排信息记录
*
* @return boolean
* @throws Exception
*/
@PermissionOperate(permissionOperateId="editSchedule",description="编辑日程安排信息记录",isLog=true,isOpenTransaction=false)
public boolean editSchedule() throws Exception {
try {
String id = GeneralHelper.safeString(this.requestParamResolver.getStringParam("id"));
Jqcalendar jqcalendar = JqcalendarDao.findByJpid(id);
if(jqcalendar!=null){
this.requestParamResolver.addParam("id", GeneralHelper.safeString(id));
this.requestParamResolver.addParam("Subject", GeneralHelper.safeString(jqcalendar.getSubject()));
this.requestParamResolver.addParam("colorvalue",GeneralHelper.safeString(jqcalendar.getColor()));
this.requestParamResolver.addParam("stpartdate", GeneralHelper.safeString(jqcalendar.getStartTime()));
this.requestParamResolver.addParam("etpartdate",GeneralHelper.safeString(jqcalendar.getEndTime()));
this.requestParamResolver.addParam("IsAllDayEvent",GeneralHelper.safeString(jqcalendar.getIsAllDayEvent()+""));
this.requestParamResolver.addParam("Location",GeneralHelper.safeString(jqcalendar.getLocation()));
this.requestParamResolver.addParam("description",GeneralHelper.safeString(jqcalendar.getDescription()));
this.requestParamResolver.addParam("timezone",GeneralHelper.safeString(""));
this.UpdateBPForm();//更新业务form信息
}else{
JSONObject jsonobject3 = new JSONObject();
jsonobject3.put("result", "false");
this.write2JSONObject(jsonobject3);
return false;
}
JSONObject jsonobject2 = new JSONObject();
jsonobject2.put("result", "true");
this.write2JSONObject(jsonobject2);
return true;
} catch (Exception err) {
err.printStackTrace();
return false;
}
}


/**
* 新增日程安排详细资料
*
* @return boolean
* @throws Exception
*/
@PermissionOperate(permissionOperateId="adddetails",description="新增日程安排详细资料",isLog=true,isOpenTransaction=false)
public boolean adddetails() throws Exception {
try {
String operateType = GeneralHelper.safeString(this.requestParamResolver.getStringParam("operateType"));//操作类型
String stpartdate = GeneralHelper.safeString(this.requestParamResolver.getStringParam("stpartdate"));
String etpartdate = GeneralHelper.safeString(this.requestParamResolver.getStringParam("etpartdate"));
String id = GeneralHelper.safeString(this.requestParamResolver.getStringParam("id"));
String Subject = GeneralHelper.safeString(this.requestParamResolver.getStringParam("Subject"));
String IsAllDayEvent = GeneralHelper.safeString(this.requestParamResolver.getStringParam("IsAllDayEvent"));
String Description = GeneralHelper.safeString(this.requestParamResolver.getStringParam("Description"));
String Location = GeneralHelper.safeString(this.requestParamResolver.getStringParam("Location"));
String colorvalue = GeneralHelper.safeString(this.requestParamResolver.getStringParam("colorvalue"));
String timezone = GeneralHelper.safeString(this.requestParamResolver.getStringParam("timezone"));
String st1 = stpartdate;
String et1 = etpartdate;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date st= dateFormat.parse(st1);
Date et= dateFormat.parse(et1);
String misok = "";
if("edit".equals(operateType)){
misok = updateDetailedCalendar(Integer.parseInt(id), st, et, Subject, IsAllDayEvent == "1" ? 1 : 0, Description, Location, colorvalue, timezone);
}else{
misok = addDetailedCalendar(st, et, Subject, IsAllDayEvent == "1" ? 1 : 0, Description, Location, colorvalue, timezone);
}
JSONObject jsonobject3 = new JSONObject();
jsonobject3.put("result", misok);
this.write2JSONObject(jsonobject3);
//this.write2JSONString(misok);
return true;
} catch (Exception err) {
err.printStackTrace();
return false;
}
}

/**
* 更新日程信息
* @param id
* @param st
* @param et
* @param sub
* @param ade
* @param dscr
* @param loc
* @param color
* @param tz
* @return
*/
public String updateDetailedCalendar(int id, Date st, Date et, String sub, int ade, String dscr, String loc, String color, String tz)
{
StringBuilder jsonstr = new StringBuilder();
try
{
Jqcalendar jqcalendar = JqcalendarDao.findByJpid(id+"");
jqcalendar.setStartTime(st);
jqcalendar.setEndTime(et);
jqcalendar.setSubject(sub);
jqcalendar.setIsAllDayEvent((short)ade);
jqcalendar.setDescription(dscr);
jqcalendar.setLocation(loc);
jqcalendar.setColor(color);
JqcalendarDao.updateJqcalendar(jqcalendar);
//jsonstr.append("{\"IsSuccess\":true,\"Msg\":\"操作成功\",\"Data\":" + id + "}");
jsonstr.append("true");
}
catch (Exception ex)
{
jsonstr.append("false");
//jsonstr.append("{\"IsSuccess\":false,\"Msg\":\"操作失败\"}");
//jsonstr.append("{\"IsSuccess\":false,\"Msg\":\"" + ex.getMessage() + "\"}");
}
return jsonstr.toString();
}




/**
* 添加方法
* @param st
* @param et
* @param sub
* @param ade
* @param dscr
* @param loc
* @param color
* @param tz
* @return
*/
public String addDetailedCalendar(Date st, Date et, String sub, int ade, String dscr, String loc, String color, String tz)
{
Jqcalendar jqcalendar = new Jqcalendar();
StringBuilder jsonstr = new StringBuilder();

jqcalendar.setStartTime(st);
jqcalendar.setEndTime(et);
jqcalendar.setSubject(sub);
jqcalendar.setIsAllDayEvent((short)ade);
jqcalendar.setDescription(dscr);
jqcalendar.setLocation(loc);
jqcalendar.setColor(color);
try
{
JqcalendarDao.addJqcalendar(jqcalendar);
String strsql = "select max(calendar.id)+1 from Jqcalendar calendar";
Query query= JqcalendarDao.findQueryByOriginalHQL(strsql);
int maxint=(Integer)query.uniqueResult(); //获取唯一的返回值并强转
//jsonstr.append("{\"IsSuccess\":true,\"Msg\":\"操作成功\",\"Data\":" + maxint+ "}");
jsonstr.append("true");
}
catch (Exception ex)
{
//table2.append("{\"IsSuccess\":false,\"Msg\":\"操作失败\"}");
jsonstr.append("false");
//jsonstr.append("{\"IsSuccess\":false,\"Msg\":\"" + ex.getMessage() + "\"}");
}
return jsonstr.toString();
}

/**
* 删除日程安排
*
* @return boolean
* @throws Exception
*/
@PermissionOperate(permissionOperateId="remove",description="删除日程安排",isLog=true,isOpenTransaction=true)
public boolean remove() throws Exception {
try {
String calendarId = this.requestParamResolver.getStringParam("calendarId");
Jqcalendar jqcalendar = JqcalendarDao.findByJpid(calendarId);
if(jqcalendar!=null){
JqcalendarDao.deleteJqcalendar(jqcalendar);
this.write2JSONString("{\"IsSuccess\":true,\"Msg\":\"删除成功\"}");
return true;
}else{
this.write2JSONString("{\"IsSuccess\":false,\"Msg\":\"删除失败!\"}");
return false;
}
} catch (Exception err) {
err.printStackTrace();
return false;
}
}

/**
* 更新日程安排
*
* @return boolean
* @throws Exception
*/
@PermissionOperate(permissionOperateId="update",description="更新日程安排",isLog=true,isOpenTransaction=true)
public boolean update() throws Exception {
try {
String calendarId = this.requestParamResolver.getStringParam("calendarId");
String CalendarStartTime = this.requestParamResolver.getStringParam("CalendarStartTime");
String CalendarEndTime = this.requestParamResolver.getStringParam("CalendarEndTime");
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
Date CalendarStartdate= dateFormat.parse(CalendarStartTime);
SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
CalendarStartdate = dateFormat2.parse(dateFormat2.format(CalendarStartdate));
Date CalendarEnddate= dateFormat.parse(CalendarEndTime);
CalendarEnddate = dateFormat2.parse(dateFormat2.format(CalendarEnddate));
String upstring = updateCalendar(Integer.parseInt(calendarId),CalendarStartdate, CalendarEnddate);
this.write2JSONString(upstring);
return true;
} catch (Exception err) {
err.printStackTrace();
return false;
}
}

/**
* 更新时间
* @param id
* @param st
* @param et
* @return
*/
public String updateCalendar(int id, Date st, Date et)
{
StringBuilder table2 = new StringBuilder();
try
{
Jqcalendar jqcalendar = JqcalendarDao.findByJpid(id+"");
jqcalendar.setStartTime(st);
jqcalendar.setEndTime(et);
if(jqcalendar!=null){
JqcalendarDao.updateJqcalendar(jqcalendar);
table2.append("{\"IsSuccess\":true,\"Msg\":\"操作成功\",\"Data\":" + id + "}");
}else{
table2.append("{\"IsSuccess\":false,\"Msg\":\"操作失败\"}");
}
}catch (Exception ex){
table2.append("{\"IsSuccess\":false,\"Msg\":\"" + ex.getMessage() + "\"}");
}
return table2.toString();
}


/**
* 新增日程安排
*
* @return boolean
* @throws Exception
*/
@PermissionOperate(permissionOperateId="add",description="新增日程安排",isLog=true,isOpenTransaction=true)
public boolean add() throws Exception {
try {
String CalendarStartTime = this.requestParamResolver.getStringParam("CalendarStartTime");
String CalendarEndTime = this.requestParamResolver.getStringParam("CalendarEndTime");
String CalendarTitle = this.requestParamResolver.getStringParam("CalendarTitle");
String IsAllDayEvent = this.requestParamResolver.getStringParam("IsAllDayEvent");
String str = addCalendar(CalendarStartTime, CalendarEndTime, CalendarTitle, Integer.parseInt(IsAllDayEvent));
this.write2JSONString(str);
return true;
} catch (Exception err) {
err.printStackTrace();
return false;
}
}

/**
* 添加日历
* @param st
* @param et
* @param sub
* @param ade
* @return
*/
public String addCalendar(String st, String et, String sub, int ade)
{
Jqcalendar jqcalendar = new Jqcalendar();
StringBuilder table2 = new StringBuilder();
try
{
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
Date startdate= dateFormat.parse(st);

SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
startdate = dateFormat2.parse(dateFormat2.format(startdate));
Date enddate= dateFormat.parse(et);
enddate = dateFormat2.parse(dateFormat2.format(enddate));
jqcalendar.setStartTime(startdate);
jqcalendar.setEndTime(enddate);
jqcalendar.setSubject(sub);
jqcalendar.setIsAllDayEvent((short)ade);
JqcalendarDao.addJqcalendar(jqcalendar);
String strsql = "select max(calendar.id) from Jqcalendar calendar";
Query query= JqcalendarDao.findQueryByOriginalHQL(strsql);
int maxint=(Integer)query.uniqueResult(); //获取唯一的返回值并强转
table2.append("{\"IsSuccess\":true,\"Msg\":\"操作成功\",\"Data\":" + maxint + "}");
}catch (Exception ex){


table2.append("{\"IsSuccess\":false,\"Msg\":\"" + ex.getMessage() + "\"}");
}
return table2.toString();
}


/**
* 列出日程记录列表
*
* @return boolean
* @throws Exception
*/
@PermissionOperate(permissionOperateId="list",description="列出日程记录列表",isLog=true,isOpenTransaction=false)
public boolean list() throws Exception {
try {
String showdate = this.requestParamResolver.getStringParam("showdate");
String viewtype = this.requestParamResolver.getStringParam("viewtype");

SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式
Date date= dateFormat.parse(showdate);
String dateStr = sdf.format(date);
date = sdf.parse(dateStr);
String jqlist = listCalendar(date, viewtype);
this.write2JSONString(jqlist);
return true;
} catch (Exception err) {
err.printStackTrace();
return false;
}
}


/**
* 两个时间段查询
* @param day
* @param type
* @return
*/
public String listCalendar(Date time, String type)
{
Date st = null;//开始时间
Date et = null;//结束时间
if("month".equals(type)){
Calendar cal = Calendar.getInstance();
cal.setTime(time);//开始计算该时间所在周的时间范围
st = time;
//1个月后
cal.add(Calendar.MONTH,1); //将当前日期加一个月
et = cal.getTime();
}else if("week".equals(type)){
Calendar cal = Calendar.getInstance();
cal.setTime(time);//开始计算该时间所在周的时间范围
//判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
int dayWeek = cal.get(Calendar.DAY_OF_WEEK);//获得当前日期是一个星期的第几天
if(1 == dayWeek) {
cal.add(Calendar.DAY_OF_MONTH, -1);
}
cal.setFirstDayOfWeek(Calendar.MONDAY);//设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
int day = cal.get(Calendar.DAY_OF_WEEK);//获得当前日期是一个星期的第几天
cal.add(Calendar.DATE, cal.getFirstDayOfWeek()-day);//根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
st= cal.getTime();//周一时间,开始时间
cal.add(Calendar.DATE, 6); //周一日期再加6就是周日
et = cal.getTime();//结束时间
}else if("day".equals(type)){
Calendar cal = Calendar.getInstance();
cal.setTime(time);//开始计算该时间所在周的时间范围
st = time;
cal.add(Calendar.DAY_OF_MONTH, -1);//日期前 一天
st = cal.getTime();
cal.add(Calendar.DAY_OF_MONTH, 2);//日期后一天
et = cal.getTime();
}
return listCalendarByRange(st, et);
}
/**
* 输出json
* @param st
* @param et
* @return
*/
@SuppressWarnings("unchecked")
public String listCalendarByRange(Date st, Date et)
{

StringBuilder jsonstr = new StringBuilder();
String exstring = null;
try
{
//数据格式说明:
// 2:参数中eventItems的数据结构:
// eventItems本身是个数组,数组的项本身又是个数组,结构如下所示
// [主键,标题,开始时间,结束时间,是否全天日程,是否跨天日程,是否循环日程,颜色主题,是否有权限,地点,参与人]
// 对应的数据类型
// [String,String,Date,Date,1/0,1/0,1/0,0-21,0/1,String,String]
// 3:异步请求中的数据结构["35","你好开发哈萨克合法可是","2014-03-10 00:00","2014-03-10 00:00",1,0,0,null,1,null,""]
// {"events":[],"issort":true,"start":"\/Date(1261353600000)\/","end":"\/Date(1261958399000)\/","error":null}
// events的结构同2中eventItems的结果,issort是否已在服务端排序(建议在服务端做好排序),接着start和end是本次请求的开始时间和结束时间,error是业务异常对象
// 可在服务端生成,结构为:{ErrorCode:””,ErrorMsg:””} 可在onRequestDataError中捕获,并做友好的提示。

//List<Jqcalendar> calendarlist = JqcalendarDao.QueryRecordsByOriginal(" from Jqcalendar calendar where calendar.startTime between ? and ? ", new Object[]{st,et});
List<Jqcalendar> calendarlist = JqcalendarDao.findAll();
List<ArrayList> lists = new ArrayList<ArrayList>();//添加几列
if(calendarlist!=null&&calendarlist.size()>0){
for (int i = 0; i < calendarlist.size(); i++){
Jqcalendar jqcalendar = calendarlist.get(i);
ArrayList list = new ArrayList();
list.add(jqcalendar.getId()+"");//主键
list.add(jqcalendar.getSubject());//标题
// st.ToString("MM/dd/yyyy HH:mm")
SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
list.add(dateFormat2.format(jqcalendar.getStartTime()));//开始时间
list.add(dateFormat2.format(jqcalendar.getEndTime()));//结束时间
list.add(jqcalendar.getIsAllDayEvent());//是否全天日程,1或0
list.add(0);//是否跨天日程,1或0
list.add(0);//是否循环日程,1或0
list.add(jqcalendar.getColor());//颜色主题 0-21
list.add(1);//是否有权限,1或者0
list.add(jqcalendar.getLocation());//地点
list.add("");//参与人
lists.add(list);
}
}
String ResjsonStr ="";
if(lists!=null&&lists.size()>0){
Gson gson = new Gson();
ResjsonStr =gson.toJson(lists) ;

}else{
ResjsonStr = "[]";
}
jsonstr.append("{\"events\":");
jsonstr.append(ResjsonStr + ",\"issort\":true,");
SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
jsonstr.append("\"start\":\"" +dateFormat2.format(st) + "\",");
jsonstr.append("\"end\":\"" + dateFormat2.format(et) + "\",");
}catch (Exception ex) {
exstring = ex.getMessage();
}
//判断是否存在异常
if (exstring == "" || exstring == null) {
jsonstr.append("\"error\":null}");
} else{
jsonstr.append("\"error\":" + exstring + "}");
}
return jsonstr.toString();
}
分享到:
评论

相关推荐

    xgcalendar

    例如,通过监听事件回调,可以实现与后端服务的交互,动态加载或保存事件数据。 5. **社区与支持** 作为一款开源项目,xgcalendar在GitHub上有活跃的社区,开发者可以在这里找到文档、示例、问题解答和贡献代码。...

    xgcalendar时间插件的PHP官网demo加数据库

    5. **示例代码**:提供实际的PHP和JavaScript代码片段,帮助开发者理解如何在项目中实现特定功能。 6. **自定义配置**:解释如何调整插件的外观和行为,例如改变主题颜色、设置多语言支持等。 7. **常见问题与解决...

    xgcalendar_php

    【xgcalendar_php】是一个基于PHP的开源项目,主要用于实现日历及日程管理功能。这个工具能够帮助用户创建、查看和管理他们的日程事件,适用于个人或团队协作的场景。由于它具备运行所需的全部组件,包括数据库支持...

    jsp(java)版日历(日程)xgcalendar(比fullcalendar效果更好)

    最近项目组要做一个日程管理,原先使用fullcalendar,后面使用xgcalendar,感觉效果更好,而且日历容易定位。 因每个java项目使用的框架不一样,所以我只提取出html,没有后台java的action、service的代码。html复制...

    xgcalendar多国语言日历asp.netMVC3C#修正可运行版

    xGCalendar 是一个基于jQuery 的日历控件,操作方式和样式参考Google Calendar。 功能列表 支持三种视图类型 (日,月,周) 支持定义一周的开始日期(周一或者周日) 支持无刷新获取数据和更新数据 支持拖拽选择时间段。...

    xgcalendar类似google日历-asp.net简单三层版

    【标题】"xgcalendar类似google日历-asp.net简单三层版" 提供的是一个基于ASP.NET技术实现的日历控件,它模仿了Google日历的功能,并采用了三层架构设计,旨在提供一个简单易用的解决方案。 【描述】描述中提到,...

    仿Google日历日程安排demo,JQuery+xgcalendar(中文)

    本项目仿照Google日历创建了一个日程安排的演示Demo,主要利用JQuery库和xgcalendar插件实现,提供了多视图切换(日、周、月)以及灵活的事件添加功能。 首先,我们来详细了解JQuery。JQuery是一个轻量级的...

    基于xgcalendar 修改的会议日程管理系统

    基于xgcalendar修改的会议室预定,日程管理,修改一个前台页面(index.php),该页面没有修改权限,只能查看日程,meetingadmin.php为后台管理页面,jqcalendar.sql为数据库创建(表名jqcalendar),进行中文化修改,...

    php版的简陋日历

    虽然这个日历是用PHP实现的,但最终的展示会依赖于HTML结构和CSS样式。HTML用于创建网页的基本布局,CSS用于美化日历的显示,如颜色、字体和对齐方式。 4. **日历布局**: 一个基本的日历应该包含月份和年份的...

    react-Reactjs滚动和顶部显示联合起来的日历控件

    - 文件名`XgCalendar-master`暗示这是一个Git仓库的主分支,可能包含了项目的源代码、样例、测试和文档等。 - 项目结构:典型的React项目结构可能包括`src`目录(存放源码)、`public`目录(静态资源)、`package....

    日历选择器

    开发者可以探索其代码结构,理解日历选择器的实现原理,以及如何利用提供的API和配置选项来满足特定需求。例如,他们可能会找到关于如何启用年视图、如何处理拖拽事件以及如何自定义日历样式和行为的文档或示例代码...

    日程Calendar

    在"日程Calendar"的压缩包文件"XGCalendar"中,很可能包含了实现上述功能的相关代码、资源文件、数据库结构定义和使用说明。开发者可以通过解压并研究这些文件,深入了解日程管理组件的内部工作原理,以便在自己的...

    仿google日历ashx +Jquery

    原为开源:实现一个Google Calendar 样式的日程管理控件XgCalendar (asp.net MVC) 我改成了ashx 处理请求,适用于一般webform

    仿google日历.rar

    网上搜了很多xgcalendar的例子都是Php开发的,而且官方站上的asp.net/MVC版 在vs10 08 都报错。 所以自己重新用三层写了一下希望对大家有帮助 废话不多说了 先看看它都有些什么功能吧!

Global site tag (gtag.js) - Google Analytics