Beispiel #1
0
 /// <summary>
 /// Event fired to update a new record
 /// </summary>
 /// <param name="sender">object which fires the event</param>
 /// <param name="e">Event arguments</param>
 protected void OnButtonActualizar(object sender, EventArgs e)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug("OnButtonActualizar Ends");
     }
     if (!ValidarCampos())
     {
         registerToastrMsg(MessageType.Error, "No ha ingresado datos para actualizar.");
     }
     else
     {
         Cine    daoMovie   = new Cine();
         var     idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
         CineDto r          = daoMovie.getCine(idToLocate);
         if (r == null)
         {
             if (log.IsDebugEnabled)
             {
                 log.Debug("Record not found  for id [" + idToLocate + "]");
             }
         }
         if (r != null)
         {
             r.nombreCine = txtNombre.Text;
             r.nit        = txtNit.Text;
             if (log.IsDebugEnabled)
             {
                 log.Debug("Update Record data [" + r.ToString() + "]");
             }
             daoMovie.createCine(r, 2);
             CargarGridInfoData();
             txtNombre.Text      = txtNit.Text = "";
             btnNuevo.Visible    = true;
             btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = false;
             registerToastrMsg(MessageType.Success, "Actualización realizada con éxito.");
             if (log.IsDebugEnabled)
             {
                 log.Debug("Update sucessfull");
             }
         }
     }
     if (log.IsDebugEnabled)
     {
         log.Debug("OnButtonActualizar Ends");
     }
 }
Beispiel #2
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())
     {
         registerToastrMsg(MessageType.Error, "No ha ingresado datos para crear.");
         if (log.IsDebugEnabled)
         {
             log.Debug("No data input");
         }
     }
     else
     {
         Cine    daoMovie  = new Cine();
         CineDto movieInfo = new CineDto()
         {
             nombreCine = txtNombre.Text, nit = txtNit.Text, fechaCreacionCine = DateTime.Now
         };
         if (log.IsDebugEnabled)
         {
             log.Debug("New Record data [" + movieInfo.ToString() + "]");
         }
         daoMovie.createCine(movieInfo, 1);
         txtNombre.Text      = txtNit.Text = "";
         btnEliminar.Visible = btnActualizar.Visible = false;
         registerToastrMsg(MessageType.Success, "Nuevo registro realizado con éxito.");
         CargarGridInfoData();
         if (log.IsDebugEnabled)
         {
             log.Debug("Record created with data=[" + movieInfo.ToString() + "]");
         }
     }
     if (log.IsDebugEnabled)
     {
         log.Debug("OnButtonNuevo End");
     }
 }
Beispiel #3
0
 /// <summary>
 /// Event fired to remove a new record
 /// </summary>
 /// <param name="sender">object which fires the event</param>
 /// <param name="e">Event arguments</param>
 protected void OnButtonEliminar(object sender, EventArgs e)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug("OnButtonEliminar Starts");
     }
     if (grdInfo.SelectedIndex == -1)
     {
         registerToastrMsg(MessageType.Error, "No ha seleccionado un registro para eliminar.");
         if (log.IsDebugEnabled)
         {
             log.Debug("No input data to remove");
         }
     }
     else
     {
         Cine daoMovie   = new Cine();
         var  idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
         if (log.IsDebugEnabled)
         {
             log.Debug("id for record to delete is [" + idToLocate + "]");
         }
         CineDto r = daoMovie.getCine(idToLocate);
         if (r == null)
         {
             if (log.IsDebugEnabled)
             {
                 log.Debug("Record to remove not found");
             }
         }
         if (r != null)
         {
             if (log.IsDebugEnabled)
             {
                 log.Debug("Record data to remove [" + r.ToString() + "]");
             }
             try {
                 var rslt = daoMovie.createCine(r, 3);
                 if (log.IsDebugEnabled)
                 {
                     log.Debug("Record to remove =[" + r.ToString() + "]");
                 }
                 if (rslt == -1)
                 {
                     registerToastrMsg(MessageType.Error, "El registro de cine a eliminar no se puede eliminar ya que tiene referencias en el sistema.");
                     if (log.IsDebugEnabled)
                     {
                         log.Debug("Record has referenced data, cannot be removed");
                     }
                 }
                 else
                 {
                     registerToastrMsg(MessageType.Success, "Registro eliminado con éxito.");
                     if (log.IsDebugEnabled)
                     {
                         log.Debug("Record removed");
                     }
                 }
             } catch (Exception) {
                 registerToastrMsg(MessageType.Error, "El registro de cine a eliminar no se puede eliminar ya que tiene referencias en el sistema.");
                 if (log.IsDebugEnabled)
                 {
                     log.Debug("Record has referenced data, cannot be removed");
                 }
             }
             CargarGridInfoData();
             txtNombre.Text      = txtNit.Text = "";
             btnNuevo.Visible    = true;
             btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = false;
         }
     }
     if (log.IsDebugEnabled)
     {
         log.Debug("OnButtonEliminar Ends");
     }
 }