private void LlenaDias() { try { rptDias.DataSource = DiasFeriadosDetalle.OrderBy(o => o.Fecha).ToList(); rptDias.DataBind(); } catch (Exception e) { throw new Exception(e.Message); } }
protected void btnAddDiaDescanso_OnClick(object sender, EventArgs e) { try { if (txtDate.Text.Trim() == string.Empty || txtDate.Text.Trim() == "__/__/____") { throw new Exception("Ingrese una fecha"); } if (txtDescripcionDia.Text.Trim() == string.Empty) { throw new Exception("Ingrese una descripción"); } if (DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", null) < DateTime.Parse(DateTime.Now.ToShortDateString())) { throw new Exception("La fecha no puede ser anterior al dia actual"); } DiaFeriado newDay = new DiaFeriado { Id = IdDiaFeriadoEdicion == 0 ? 0 : IdDiaFeriadoEdicion, Descripcion = txtDescripcionDia.Text, Fecha = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", null), IdUsuarioAlta = ((Usuario)Session["UserData"]).Id }; _servicioDias.AgregarDiaFeriado(newDay); if (newDay.Id != 0) { DiasFeriadosDetalle.Single(s => s.Id == newDay.Id).Descripcion = newDay.Descripcion; DiasFeriadosDetalle.Single(s => s.Id == newDay.Id).Fecha = newDay.Fecha; LlenaDias(); } LimpiaCapturaDias(); LlenaCombos(); UsuariosMaster master = (UsuariosMaster)Page.Master; if (master != null) { master.AlertaSucces(); } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }