Esempio n. 1
0
 /// <summary>
 /// Loads the CINE table data into a grid.
 /// </summary>
 private void CargarGridInfoData() {
     if (log.IsDebugEnabled) {
         log.Debug("CargarGridInfoData Starts");
     }
     var movieList = new Cine().getCines();
     if (movieList.Count > 0) {
         btnActualizar.Visible = btnEliminar.Visible = false;
     }
     grdInfo.DataSource = movieList;
     grdInfo.SelectedIndex = -1;
     grdInfo.DataBind();
     if (log.IsDebugEnabled) {
         log.Debug("CargarGridInfoData Ends");
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Loads combo box with CINES data.
 /// </summary>
 private void PoblarCines() {
     if (log.IsDebugEnabled) {
         log.Debug("PoblarCines Starts");
     }
     Cine daoMovie = new Cine();
     List<CineDto> movieList = daoMovie.getCines();
     List<KeyValue> l = new List<KeyValue>();
     l.Add(new KeyValue() { key = "-1", value = "-- SELECCIONE --" });
     movieList.ForEach(t => l.Add(new KeyValue() { key = t.idCine.ToString(), value = t.nombreCine }));
     listaCines.DataSource = l;
     listaCines.DataTextField = "value";
     listaCines.DataValueField = "key";
     listaCines.DataBind();
     if (log.IsDebugEnabled) {
         log.Debug("PoblarCines Ends");
     }
 }
Esempio n. 3
0
 /// <summary>
 /// When grid selected index is changed, the event is fired
 /// </summary>
 /// <param name="sender">object which fires the event</param>
 /// <param name="e">Event arguments</param>
 protected void OnGridInfoSelectedIndexChanged(object sender, EventArgs e) {
     if (log.IsDebugEnabled) {
         log.Debug("OnGridInfoSelectedIndexChanged Starts");
     }
     Cine daoMovie = new Cine();
     var idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
     CineDto r = daoMovie.getCine(idToLocate);
     if (r != null) {
         txtNombre.Text = r.nombreCine;
         txtNit.Text = r.nit;
         btnNuevo.Visible = false;
         btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = true;
     }
     if (log.IsDebugEnabled) {
         log.Debug("OnGridInfoSelectedIndexChanged Ends");
     }
 }
Esempio n. 4
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");
            }
        }
Esempio n. 5
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");
     }
 }
Esempio n. 6
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");
     }
 }