コード例 #1
0
ファイル: entidad.aspx.cs プロジェクト: poojashingala/try_git
 /// <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");
     }
 }
コード例 #2
0
ファイル: entidad.aspx.cs プロジェクト: poojashingala/try_git
 /// <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");
     }
 }
コード例 #3
0
ファイル: entidad.aspx.cs プロジェクト: poojashingala/try_git
        /// <summary>
        /// Event fired to create a new record
        /// </summary>
        /// <param name="sender">object which fires the event</param>
        /// <param name="e">Event arguments</param>
        protected void OnButtonNuevo(object sender, EventArgs e)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("OnButtonNuevo Starts");
            }
            if (!ValidarCampos())
            {
                if (listaEntidades.SelectedValue == "-1")
                {
                    registerToastrMsg(MessageType.Warning, "Debe seleccionar un valor de entidad para crear un nuevo registro.");
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("Must an entity value to work on");
                    }
                }
                else
                {
                    registerToastrMsg(MessageType.Error, "No ha ingresado datos para crear.");
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("No data input");
                    }
                }
            }
            else
            {
                ParametroSistema    daoPs = new ParametroSistema();
                ParametroSistemaDto ps    = daoPs.getValorParametroSistema(listaEntidades.SelectedValue.ToString());

                if (log.IsDebugEnabled)
                {
                    log.Debug("Record data to work on [" + listaEntidades.SelectedValue.ToString() + "]");
                }
                if (ps == null)
                {
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("Record data not found");
                    }
                }
                if (ps != null)
                {
                    Entidad    daoEnt  = new Entidad();
                    EntidadDto entInfo = new EntidadDto()
                    {
                        idEntidad = 0, codEntidad = Convert.ToInt32(ps.valorParametro), nombreEntidad = ps.descValorParametro, valorEntidad = txtEntidad.Text, descripcionEntidad = txtDescEntidad.Text
                    };
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("Record data [" + entInfo.ToString() + "]");
                    }
                    daoEnt.createEntidad(entInfo, 1);
                    CargarGridInfoData();
                    txtDescEntidad.Text = txtEntidad.Text = "";
                    btnNuevo.Visible    = true;
                    btnEliminar.Visible = btnActualizar.Visible = false;
                    registerToastrMsg(MessageType.Success, "Nuevo registro realizado con éxito.");
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("New record created");
                    }
                }
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("OnButtonNuevo Ends");
            }
        }