Exemplo n.º 1
0
 /// <summary>
 /// Record to remove.
 /// </summary>
 /// <param name="sender">Objet which sends event</param>
 /// <param name="e">event parameteres</param>
 protected void OnButtonEliminar(object sender, EventArgs e) {
     if (log.IsDebugEnabled) {
         log.Debug("OnButtonEliminar Starts");
     }
     if (grdInfo.SelectedIndex == -1) {
         if (log.IsDebugEnabled) {
             log.Debug("No input data supplied");
         }
         registerToastrMsg(MessageType.Error, "No ha seleccionado un registro para eliminar.");
     }
     else {
         Entidad daoEnt = new Entidad();
         var idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
         if (log.IsDebugEnabled) {
             log.Debug("Record data id to remove [" + idToLocate + "]");
         }
         EntidadDto r = daoEnt.getValorEntidad(idToLocate);
         if (r == null) {
             if (log.IsDebugEnabled) {
                 log.Debug("Record data to remove not found");
             }
         }                
         if (r != null) {
             if (log.IsDebugEnabled) {
                 log.Debug("Record to remove [" + r.ToString() + "]");
             }
             try {
                 var rslt = daoEnt.createEntidad(r, 3);
                 if (rslt == -1) {
                     if (log.IsDebugEnabled) {
                         log.Debug("Record cannot be removed as relationships would break");
                     }
                     registerToastrMsg(MessageType.Error, "El registro de entidad a eliminar no se puede eliminar ya que tiene referencias en el sistema.");
                 }
                 else {
                     if (log.IsDebugEnabled) {
                         log.Debug("Record removed");
                     }
                     registerToastrMsg(MessageType.Success, "Registro eliminado con éxito.");
                 }
             } catch (Exception) {
                 if (log.IsDebugEnabled) {
                     log.Debug("Record cannot be removed as relationships would break");
                 }
                 registerToastrMsg(MessageType.Error, "El registro de entidad a eliminar no se puede eliminar ya que tiene referencias en el sistema.");
             }
             CargarGridInfoData();
             txtDescEntidad.Text = txtEntidad.Text = "";
             btnNuevo.Visible = true;
             btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = false;
         }
     }
     if (log.IsDebugEnabled) {
         log.Debug("OnButtonEliminar Ends");
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Update a record
 /// </summary>
 /// <param name="sender">Objet which sends event</param>
 /// <param name="e">event parameteres</param>
 protected void OnButtonActualizar(object sender, EventArgs e) {
     if (log.IsDebugEnabled) {
         log.Debug("OnButtonActualizar Starts");
     }
     if (!ValidarCampos()) {
         if (log.IsDebugEnabled) {
             log.Debug("No input data supplied");
         }
         registerToastrMsg(MessageType.Error, "No ha ingresado datos para actualizar.");
     }
     else {
         Entidad daoEnt = new Entidad();
         var idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
         if (log.IsDebugEnabled) {
             log.Debug("Record data id to update [" + idToLocate + "]");
         }
         EntidadDto r = daoEnt.getValorEntidad(idToLocate);
         if (r == null) {
             if (log.IsDebugEnabled) {
                 log.Debug("Record data to update not found");
             }
         }
         if (r != null) {                   
             r.valorEntidad = txtEntidad.Text;
             r.descripcionEntidad = txtDescEntidad.Text;
             if (log.IsDebugEnabled) {
                 log.Debug("Record data id to update [" + r.ToString() + "]");
             }
             daoEnt.createEntidad(r, 2);
             CargarGridInfoData();
             txtDescEntidad.Text = txtEntidad.Text = "";
             btnNuevo.Visible = true;
             btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = false;
             registerToastrMsg(MessageType.Success, "Actualización realizada con éxito.");
             if (log.IsDebugEnabled) {
                 log.Debug("Record updated");
             }
         }
     }
     if (log.IsDebugEnabled) {
         log.Debug("OnButtonActualizar Ends");
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// When a select index changes.
 /// </summary>
 /// <param name="sender">Objet which sends event</param>
 /// <param name="e">event parameteres</param>
 protected void OnGridInfoSelectedIndexChanged(object sender, EventArgs e) {
     if (log.IsDebugEnabled) {
         log.Debug("OnGridInfoSelectedIndexChanged Starts");
     }
     Entidad entDao = new Entidad();
     var idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
     EntidadDto r = entDao.getValorEntidad(idToLocate);
     if (r != null) {
         txtEntidad.Text = r.valorEntidad;
         txtDescEntidad.Text = r.descripcionEntidad;
         btnNuevo.Visible = false;
         btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = true;
     }
     if (log.IsDebugEnabled) {
         log.Debug("OnGridInfoSelectedIndexChanged Ends");
     }
 }