Пример #1
0
        /// <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");
            }
        }