<link rel="stylesheet" type="text/css" href="../../Content/styles/fullcalendar.css">
<style type="text/css">
#calendar {
width: 900px;
margin: 20px auto 10px auto;
margin-left:10px;
}
</style>
<script src="../../Content/scripts/plugins/fullcalendar/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="../../Content/scripts/plugins/fullcalendar/jquery-ui-1.10.2.custom.min.js" type="text/javascript"></script>
<script src="../../Content/scripts/plugins/fullcalendar/fullcalendar.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
firstDay:1,
//editable: true,
timeFormat: 'H:mm',
axisFormat: 'H:mm',
events: [@Html.Raw(System.Web.HttpUtility.HtmlDecode(@ViewBag.message))
]
});
});
[HttpGet]
public ActionResult FullCalendar()
{
string EquipmentID = Request.QueryString["EquipmentID"];
string EqptName = Request.QueryString["EqptName"];
string events = "";
SummaryStepBLL summarystepbll = new SummaryStepBLL();
var data = summarystepbll.GetListEquipment(1, EquipmentID);
foreach(SummaryStepEntity item in data)
{
SummaryOfDay sod = item.SummaryStepJson.ToObject<SummaryOfDay>();
//机械租赁费
var machine = sod.machine.ToObject<IEnumerable<MachineEntity>>();
machine= machine.Where(t => t.EquipmentID == EquipmentID );
decimal totalMachine = 0;
DateTime timeMachine = DateTime.Now;
foreach (var machineItem in machine)
{
totalMachine += Convert.ToDecimal(machineItem.Total);
timeMachine = machineItem.RptDate.Value;
}
if (totalMachine != 0)
{
events += "{title:'租赁费:" + totalMachine + "',start:'" + timeMachine.ToString("yyyy-MM-dd") + "',end:'" + timeMachine.ToString("yyyy-MM-dd") + "',},";
}
//机械耗油
var oil = sod.oil.ToObject<IEnumerable<OilConsumeEntity>>();
oil = oil.Where(t => t.EquipmentID == EquipmentID);
decimal totalOil = 0;
DateTime timeOil = DateTime.Now;
foreach (var itemOil in oil)
{
totalOil += Convert.ToDecimal(itemOil.Total); //总价
timeOil = itemOil.OilTime.Value;
}
if (totalOil != 0)
{
events += "{title:'油费:" + totalOil + "',start:'" + timeOil.ToString("yyyy-MM-dd") + "',end:'" + timeOil.ToString("yyyy-MM-dd") + "',},";
}
//机械运费
var freight = sod.freight.ToObject<IEnumerable<FreightEntity>>();
freight = freight.Where(t => t.EquipmentID == EquipmentID);
decimal totalFreight = 0;
DateTime timeFreight = DateTime.Now;
foreach (var itemFreight in freight)
{
if (itemFreight.JFLB != null)
{
if (itemFreight.JFLB.IndexOf("材料费") > -1)
{
}
else
{
totalFreight += Convert.ToDecimal(itemFreight.Total); //总价
timeFreight = itemFreight.RptDate.Value;
}
}
else
{
totalFreight += Convert.ToDecimal(itemFreight.Total); //总价
timeFreight = itemFreight.RptDate.Value;
}
}
if (totalFreight != 0)
{
events += "{title:'运费:" + totalFreight + "',start:'" + timeFreight.ToString("yyyy-MM-dd") + "',end:'" + timeFreight.ToString("yyyy-MM-dd") + "',},";
}
}
ViewBag.name = EqptName;
ViewBag.message = events;
ViewData["EquipmentID"] = EquipmentID;
return View();
}
</script>
<div id="main" style="width:900px">
<div id='calendar'></div>
</div>
[HttpGet]
public ActionResult FullCalendar()
{
string EquipmentID = Request.QueryString["EquipmentID"];
string EqptName = Request.QueryString["EqptName"];
string events = "";
SummaryStepBLL summarystepbll = new SummaryStepBLL();
var data = summarystepbll.GetListEquipment(1, EquipmentID);
foreach(SummaryStepEntity item in data)
{
SummaryOfDay sod = item.SummaryStepJson.ToObject<SummaryOfDay>();
//机械租赁费
var machine = sod.machine.ToObject<IEnumerable<MachineEntity>>();
machine= machine.Where(t => t.EquipmentID == EquipmentID );
decimal totalMachine = 0;
DateTime timeMachine = DateTime.Now;
foreach (var machineItem in machine)
{
totalMachine += Convert.ToDecimal(machineItem.Total);
timeMachine = machineItem.RptDate.Value;
}
if (totalMachine != 0)
{
events += "{title:'租赁费:" + totalMachine + "',start:'" + timeMachine.ToString("yyyy-MM-dd") + "',end:'" + timeMachine.ToString("yyyy-MM-dd") + "',},";
}
//机械耗油
var oil = sod.oil.ToObject<IEnumerable<OilConsumeEntity>>();
oil = oil.Where(t => t.EquipmentID == EquipmentID);
decimal totalOil = 0;
DateTime timeOil = DateTime.Now;
foreach (var itemOil in oil)
{
totalOil += Convert.ToDecimal(itemOil.Total); //总价
timeOil = itemOil.OilTime.Value;
}
if (totalOil != 0)
{
events += "{title:'油费:" + totalOil + "',start:'" + timeOil.ToString("yyyy-MM-dd") + "',end:'" + timeOil.ToString("yyyy-MM-dd") + "',},";
}
//机械运费
var freight = sod.freight.ToObject<IEnumerable<FreightEntity>>();
freight = freight.Where(t => t.EquipmentID == EquipmentID);
decimal totalFreight = 0;
DateTime timeFreight = DateTime.Now;
foreach (var itemFreight in freight)
{
if (itemFreight.JFLB != null)
{
if (itemFreight.JFLB.IndexOf("材料费") > -1)
{
}
else
{
totalFreight += Convert.ToDecimal(itemFreight.Total); //总价
timeFreight = itemFreight.RptDate.Value;
}
}
else
{
totalFreight += Convert.ToDecimal(itemFreight.Total); //总价
timeFreight = itemFreight.RptDate.Value;
}
}
if (totalFreight != 0)
{
events += "{title:'运费:" + totalFreight + "',start:'" + timeFreight.ToString("yyyy-MM-dd") + "',end:'" + timeFreight.ToString("yyyy-MM-dd") + "',},";
}
}
ViewBag.name = EqptName;
ViewBag.message = events;
ViewData["EquipmentID"] = EquipmentID;
return View();
}