PDA

View Full Version : [CLOSED] Format Calendar with 24 hours, every 15 minnutos



mapperez
May 29, 2014, 6:59 PM
I need the calendar begins at 8:00 am and end at 23:45, 15 minutes intervals.
The problem I have with the code is that when I click it shows me a different time you select



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Import Namespace="System.Collections.Generic" %>
<!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" runat="server">
<title>Ext.NET Example</title>
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />

<script type="text/javascript">
Ext.calendar.template.DayBody.override({
applyTemplate: function(o) {
this.today = Ext.calendar.util.Date.today();
this.dayCount = this.dayCount || 1;

var i = 0,
days = [],
dt = Ext.Date.clone(o.viewStart),
times = [];

for (; i < this.dayCount; i++) {
days[i] = Ext.calendar.util.Date.add(dt, { days: i });
}

// use a fixed DST-safe date so times don't get skipped on DST boundaries
dt = Ext.Date.clearTime(new Date('5/26/1972'));


for (i = 0; i < 48; i++) {

times.push(Ext.Date.format(dt, 'H:i'));
dt = Ext.calendar.util.Date.add(dt, { hours: 0.50 });

}

return this.applyOut({
days: days,
dayCount: days.length,
times: times
}, []).join('');
}
});

var CompanyX = {


DiaClick: function(cal, dt, allDay, el) {
Fenix.Net.Day_Click(dt);
},



record: {

NuevoEvento: function(rec) {
Fenix.Net.AddEvent(rec);
},

show2: function(cal, rec, el) {
try {
Fenix.Net.EditEvent(rec.data);
}
catch (xer) {
alert(xer);
}
}


}
};

</script>

<script runat="server">





protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{

}
}

protected void btn_save_Click(object sender, DirectEventArgs e)
{

Window1.Hidden = true;

EventModelCollection Mcol = new EventModelCollection();
EventModel Meven = new EventModel();

String FechaHora;
DateTime FH;

FechaHora = dtp_fecha.Value.ToString().Substring(0, 10) + ' ' + dtp_hora.Value.ToString();
FH = DateTime.Parse(FechaHora);

Meven.EventId = 1001;
Meven.CalendarId = 3;
Meven.Title = "MARIO PEREZ PEREZ";
Meven.StartDate = FH;
Meven.EndDate = FH.AddMinutes(15);
Meven.IsAllDay = false;
Meven.Notes = "CONTROL UROLOGICO";
Meven.Location = "HECTOR MELO";

Mcol.Add(Meven);

CalendarPanel1.EventStore.Add(Mcol);
CalendarPanel1.Update();



}
protected void GetJSON(object xtr)
{

EventModel Evx = new EventModel();
String StrDatos;
StrDatos = xtr.ToString();



try
{

Dictionary<string, string> ff = Ext.Net.JSON.Deserialize<Dictionary<string, string>>(xtr.ToString());

foreach (var item in ff)
{


switch (item.Key.ToString())
{

case "EventId":
Evx.EventId = int.Parse(item.Value);
frm_cita.Title = "Paciente Citado : Codigo Cita [" + Evx.EventId.ToString() + "]";

break;
case "CalendarId":
Evx.CalendarId = int.Parse(item.Value);
break;
case "StartDate":
Evx.StartDate = DateTime.Parse(item.Value);
dtp_fecha.Value = Evx.StartDate;
break;
case "Title":
Evx.Title = item.Value.ToString();
lbl_paciente.Text = Evx.Title;
break;


}



}

Window1.Show();


}
catch (Exception errx)
{
X.Msg.Alert("TEST", errx.Message.ToString()).Show();
}



}


[DirectMethod(Namespace = "CompanyX")]
public void ShowMsg(string msg)
{
X.Msg.Notify("Message", msg).Show();
}

[DirectMethod(Namespace = "Fenix.Net", ShowMask = true, Msg = "Cargando Modulo")]
public void Day_Click(object dtp)
{
try
{
dtp_fecha.Value = (DateTime)dtp;
dtp_hora.Value = (DateTime)dtp;

Window1.Hidden = false;
Window1.Show();

}
catch
{

}

}


[DirectMethod(Namespace = "Fenix.Net", ShowMask = true, Msg = "Cargando Modulo")]
public void EditEvent(object evx)
{
try
{
GetJSON(evx);


}
catch (Exception errx)
{
X.Msg.Alert("MPSOFT", errx.ToString()).Show();
}

}





</script>

</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport ID="Viewport1" runat="server" Layout="Border">
<Items>
<ext:Panel ID="Panel2" runat="server" Title="..." Layout="Border" Region="Center"
Cls="app-center">
<Items>
<ext:Panel ID="Panel3" runat="server" Width="176" Region="West" Border="false" Cls="app-west">
<Items>
<ext:DatePicker ID="DatePicker1" runat="server" Cls="ext-cal-nav-picker">
<Listeners>
<Select Fn="CompanyX.setStartDate" Scope="CompanyX" />
</Listeners>
</ext:DatePicker>
</Items>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="Button1" runat="server" Text="Save All Events" Icon="Disk" Handler="CompanyX.record.saveAll" />
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
<ext:CalendarPanel ID="CalendarPanel1" runat="server" Region="Center" ActiveIndex="0"
Border="false">
<EventStore ID="EventStore1" runat="server" />
<Listeners>
<DayClick Fn="CompanyX.DiaClick" Scope="CompanyX" />
</Listeners>
</ext:CalendarPanel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
<ext:Window ID="Window1" runat="server" Title="Agenda" Icon="Group" Width="430" Height="300"
Modal="true" Layout="Fit" Hidden="true">
<Items>
<ext:FormPanel ID="frm_cita" runat="server" Icon="User" Frame="true" Title="Citar Paciente"
DefaultAnchor="100%" Width="400">
<FieldDefaults LabelAlign="Right" AllowBlank="false" />
<Items>
<ext:FieldSet ID="FieldSet3" runat="server" Title="Paciente Actual" Collapsible="false"
DefaultAnchor="100%">
<Defaults>
<ext:Parameter Name="labelWidth" Value="100" Mode="Raw" />
</Defaults>
<Items>
<ext:FieldContainer ID="FieldContainer3" runat="server" AnchorHorizontal="100%" Layout="HBoxLayout">
<Items>
<ext:Label ID="lbl_paciente" runat="server" Flex="1" Text="MARIO PEREZ PEREZ" UI="Success" />
</Items>
</ext:FieldContainer>
</Items>
</ext:FieldSet>
<ext:FieldSet ID="FieldSet1" runat="server" Title="Datos Cita" Collapsible="true"
DefaultAnchor="100%">
<Defaults>
<ext:Parameter Name="labelWidth" Value="100" Mode="Raw" />
</Defaults>
<Items>
<ext:FieldContainer ID="FieldContainer1" runat="server" FieldLabel="Fecha/Hora" AnchorHorizontal="100%"
Layout="HBoxLayout">
<Items>
<ext:DateField runat="server" ID="dtp_fecha" Format="dd/MM/yyyy" />
<ext:TimeField runat="server" ID="dtp_hora" MinTime="7:00" MaxTime="23:45" Increment="15"
SelectedTime="07:00" Format="H:mm" />
</Items>
</ext:FieldContainer>
</Items>
</ext:FieldSet>
<ext:FieldSet ID="FieldSet2" runat="server" Title="Seleccione Prestador" Collapsible="false"
DefaultAnchor="100%">
<Defaults>
<ext:Parameter Name="labelWidth" Value="100" Mode="Raw" />
</Defaults>
<Items>
<ext:FieldContainer ID="FieldContainer2" runat="server" FieldLabel="Prestador" AnchorHorizontal="100%"
Layout="HBoxLayout">
<Items>
<ext:ComboBox ID="cbx_prestador" runat="server" Flex="1" />
</Items>
</ext:FieldContainer>
</Items>
</ext:FieldSet>
</Items>
<Buttons>
<ext:Button ID="btn_save" runat="server" Text="Guardar" Icon="Disk">
<DirectEvents>
<Click OnEvent="btn_save_Click">
</Click>
</DirectEvents>
</ext:Button>
</Buttons>
</ext:FormPanel>
</Items>
</ext:Window>
</body>
</html>

Daniil
May 30, 2014, 6:04 AM
Hi @mapperez,

I guess along with a DayBody's applyTemplate function you should override something more in the Calendar's sources. I would recommend to search for "dayclick" in the Calendar's sources.