예제 #1
0
 /// <summary>
 /// Removes a record from database.
 /// </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 record selected to remove");
         }
         registerToastrMsg(MessageType.Error, "No ha seleccionado un registro para eliminar.");
     }
     else {
         Teatro daoTheater = new Teatro();
         var idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
         if (log.IsDebugEnabled) {
             log.Debug("idToLocate [" + idToLocate+ "]");
         }
         TeatroDto r = daoTheater.getTeatro(idToLocate);
         if (r == null) {
             if (log.IsDebugEnabled) {
                 log.Debug("Record data to remove not found");
             }
         }
         if (r != null) {
             if (log.IsDebugEnabled) {
                 log.Debug("Record data to remove [" + r.ToString() + "]");
             }
             try {
                 var rslt = daoTheater.crearTeatro(r, 3);
                 if (rslt == -1) {
                     if (log.IsDebugEnabled) {
                         log.Debug("Record cannot be removed as relationships would be broken");
                     }
                     registerToastrMsg(MessageType.Error, "El registro de teatro 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 be broken");
                 }
                 registerToastrMsg(MessageType.Error, "El registro de teatro a eliminar no se puede eliminar ya que tiene referencias en el sistema.");
             }
             CargarGridInfoData();
             LimpiarControles();
             btnNuevo.Visible = true;
             btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = false;
         }
     }
     if (log.IsDebugEnabled) {
         log.Debug("OnButtonEliminar Ends");
     }
 }
예제 #2
0
 /// <summary>
 /// Updates a record to database
 /// </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("OnButtonEliminar Starts");
     }
     if (!ValidarCampos()) {
         if (log.IsDebugEnabled) {
             log.Debug("No record info to update");
         }
         registerToastrMsg(MessageType.Error, "No ha ingresado datos para actualizar.");
     }
     else {
         Teatro daoTheater = new Teatro();
         var idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
         if (log.IsDebugEnabled) {
             log.Debug("Record id to locate [" +  idToLocate + "]");
         }
         TeatroDto r = daoTheater.getTeatro(idToLocate);
         if (r == null) {
             if (log.IsDebugEnabled) {
                 log.Debug("Record data not found to update");
             }
         }
         if (r != null) {
             r.idCine = Convert.ToInt32(listaCines.SelectedValue);
             r.idMunicipioTeatro = Convert.ToInt32(listaMunicipios.SelectedValue);
             r.idDepeartamentoTeatro = Convert.ToInt32(listaDepartamentos.SelectedValue);
             r.nombreTeatro = txtNombre.Text;
             r.telefono1Teatro = txtTelefono1.Text;
             r.telefono2Teatro = txtTelefono2.Text;
             r.telefono3Teatro = txtTelefono3.Text;
             r.direccionTeatro = txtDireccion.Text;
             if (log.IsDebugEnabled) {
                 log.Debug("Record data [" + r.ToString() + "]");
             }
             daoTheater.crearTeatro(r, 2);
             CargarGridInfoData();
             LimpiarControles();
             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("OnButtonEliminar Ends");
     }
 }
예제 #3
0
 /// <summary>
 /// Loads a record for one selected grid row.
 /// </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");
     }
     Teatro daoTheater = new Teatro();
     var idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
     TeatroDto r = daoTheater.getTeatro(idToLocate);
     if (r != null) {
         listaCines.SelectedValue = r.idCine.ToString();
         listaMunicipios.SelectedValue = r.idMunicipioTeatro.ToString();
         listaDepartamentos.SelectedValue = r.idDepeartamentoTeatro.ToString();
         txtNombre.Text = r.nombreTeatro;
         txtTelefono1.Text = r.telefono1Teatro;
         txtTelefono2.Text = r.telefono2Teatro;
         txtTelefono3.Text = r.telefono3Teatro;
         txtDireccion.Text = r.direccionTeatro;
         btnNuevo.Visible = false;
         btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = true;
     }
     if (log.IsDebugEnabled) {
         log.Debug("OnGridInfoSelectedIndexChanged Ends");
     }
 }