Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion WebLab/Agendas/AgendaEdit.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
<div class="panel-body">

<table >

<tr>
<td colspan="2">
<asp:CustomValidator ID="customValidadorGeneral" runat="server" OnServerValidate="customValidadorGeneral_ServerValidate" ValidationGroup="0" ></asp:CustomValidator>
</td>
</tr>
<tr>
<td >Tipo de Servicio:<span style="font-weight:bold"><asp:RangeValidator
ID="rvTipoServicio" runat="server"
Expand Down
30 changes: 30 additions & 0 deletions WebLab/Agendas/AgendaEdit.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,35 @@ private void CargarItems()
}

}

protected void customValidadorGeneral_ServerValidate(object source, ServerValidateEventArgs args)
{
if (oUser != null)
{
TipoServicio tp = new TipoServicio();
tp = (TipoServicio)tp.Get(typeof(TipoServicio), "IdTipoServicio", cboTipoServicio.SelectedValue);
DateTime fDesde = Convert.ToDateTime(txtFechaDesde.Value);
DateTime fHasta = Convert.ToDateTime(txtFechaHasta.Value);

ISession m_session = NHibernateHttpModule.CurrentSession;
ICriteria crit = m_session.CreateCriteria(typeof(Agenda));
crit.Add(Expression.Eq("IdEfector", oCon.IdEfector));
crit.Add(Expression.Eq("IdTipoServicio", tp));
crit.Add(Expression.Eq("IdItem", ddlItem.SelectedValue));
crit.Add(Expression.Le("FechaDesde", fHasta));
crit.Add(Expression.Ge("FechaHasta", fDesde));
crit.Add(Expression.Eq("Baja", false));
if (Request["id"] != null) //Sacar el id de la agenda si es modificacion
crit.Add(Expression.Not(Expression.Eq("IdAgenda", int.Parse(Request["id"]))));

IList items = crit.List();

if (items.Count > 0)
{
args.IsValid = false;
this.customValidadorGeneral.ErrorMessage = "Existe superposición de fechas con otra agenda";
}
}
}
}
}
69 changes: 40 additions & 29 deletions WebLab/Agendas/AgendaEdit.aspx.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.