private TBL_PUESTOS cargaEntidad(TBL_PUESTOS item) { item.DIM_CODIGO = Convert.ToInt32(ddlDimensiones.SelectedValue); item.PAR_CODIGO = Convert.ToInt32(ddlParqueadero.SelectedValue); item.PUE_NOMBRE = txtDescripcion.Text.Trim().ToUpper(); return(item); }
protected void btnGuardar_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtDescripcion.Text)) { try { TBL_PUESTOS item = new TBL_PUESTOS(); if (hfCodigo.Value.Equals(CConstantes.Constantes.VALOR_POR_DEFECTO)) { logicaPuestos.Guardar(cargaEntidad(item)); } else { item = logicaPuestos.ItemPorCodigo(Convert.ToInt32(hfCodigo.Value)); item = cargaEntidad(item); logicaPuestos.Modificar(item); } limpiarControles(); cargarGrid(); } catch (Exception ex) { divMensaje.Attributes.Add("Style", "display:block"); lblMensaje.Text = ex.Message; } } }
public void Modificar(TBL_PUESTOS item) { try { dc.SaveChanges(); } catch (Exception ex) { throw new ArgumentException(ex.Message); } }
public void Guardar(TBL_PUESTOS item) { try { LogicaParqueadero logicaParqueadero = new LogicaParqueadero(); int numeroPuestoParqueo = dc.TBL_PUESTOS.Where(aux => aux.PAR_CODIGO.Equals(item.PAR_CODIGO)).Count(); if (numeroPuestoParqueo <= logicaParqueadero.ItemPorCodigo(item.PAR_CODIGO).PAR_PUESTOS) { item.PUE_CODIGO = secuencial(); dc.TBL_PUESTOS.Add(item); dc.SaveChanges(); } else { throw new ArgumentException(CConstantes.ConstantesMensajesValidaciones.MENSAJE_NUMERO_MAXIMO); } } catch (Exception ex) { throw new ArgumentException(ex.Message); } }
protected void gvdatos_RowCommand(object sender, GridViewCommandEventArgs e) { try { divMensaje.Attributes.Add("Style", "display:none"); lblMensaje.Text = string.Empty; if (e.CommandName.Equals(CConstantes.Constantes.MODIFICAR)) { TBL_PUESTOS item = logicaPuestos.ItemPorCodigo(Convert.ToInt32(e.CommandArgument)); hfCodigo.Value = item.PUE_CODIGO.ToString(); txtDescripcion.Text = item.PUE_NOMBRE; } else if (e.CommandName.Equals(CConstantes.Constantes.ELIMINAR)) { logicaPuestos.Eliminar(Convert.ToInt32(e.CommandArgument)); cargarGrid(); } } catch (Exception ex) { divMensaje.Attributes.Add("Style", "display:block"); lblMensaje.Text = ex.Message; } }