Esempio n. 1
0
 protected void OnButtonEliminar(object sender, EventArgs e)
 {
     lblMsg.Text = lblError.Text = "";
     if (grdInfo.SelectedIndex == -1)
     {
         lblError.Text = "No ha seleccionado un registro para eliminar.";
     }
     else
     {
         Teatro    daoTheater = new Teatro();
         var       idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
         TeatroDto r          = daoTheater.getTeatro(idToLocate);
         if (r != null)
         {
             try {
                 var rslt = daoTheater.crearTeatro(r, 3);
                 if (rslt == -1)
                 {
                     lblError.Text = "El registro de teatro a eliminar no se puede eliminar ya que tiene referencias en el sistema.";
                 }
                 else
                 {
                     lblMsg.Text = "Registro eliminado con éxito.";
                 }
             } catch (Exception) {
                 lblError.Text = "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;
         }
     }
 }
Esempio n. 2
0
 protected void OnButtonActualizar(object sender, EventArgs e)
 {
     lblMsg.Text = lblError.Text = "";
     if (!ValidarCampos())
     {
         lblError.Text = "No ha ingresado datos para actualizar.";
     }
     else
     {
         Teatro    daoTheater = new Teatro();
         var       idToLocate = Convert.ToInt32(grdInfo.DataKeys[grdInfo.SelectedIndex].Value);
         TeatroDto r          = daoTheater.getTeatro(idToLocate);
         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;
             daoTheater.crearTeatro(r, 2);
             CargarGridInfoData();
             LimpiarControles();
             btnNuevo.Visible    = true;
             btnEliminar.Visible = btnActualizar.Visible = btnCancelar.Visible = false;
             lblMsg.Text         = "Actualización realizada con éxito.";
         }
     }
 }
Esempio n. 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");
            }
        }
Esempio n. 4
0
 protected void OnButtonNuevo(object sender, EventArgs e)
 {
     lblMsg.Text = lblError.Text = "";
     if (!ValidarCampos())
     {
         lblError.Text = "No ha ingresado datos para crear.";
     }
     else
     {
         Teatro    daoTheter   = new Teatro();
         TeatroDto theaterInfo = new TeatroDto()
         {
             idCine                = Convert.ToInt32(listaCines.SelectedValue),
             nombreTeatro          = txtNombre.Text,
             telefono1Teatro       = txtTelefono1.Text,
             telefono2Teatro       = txtTelefono2.Text,
             telefono3Teatro       = txtTelefono3.Text,
             idMunicipioTeatro     = Convert.ToInt32(listaMunicipios.SelectedValue),
             idDepeartamentoTeatro = Convert.ToInt32(listaDepartamentos.SelectedValue),
             direccionTeatro       = txtDireccion.Text
         };
         daoTheter.crearTeatro(theaterInfo, 1);
         LimpiarControles();
         btnEliminar.Visible = btnActualizar.Visible = false;
         lblMsg.Text         = "Nuevo registro realizado con éxito.";
         CargarGridInfoData();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Retrieves one record from DB.
        /// </summary>
        /// <param name="id">Filter to use</param>
        /// <returns>NULL if no record found.</returns>
        public TeatroDto getTeatro(int id)
        {
            SqlTransaction transaction = null;
            SqlDataReader  rdr         = null;
            HandleDatabase hdb         = null;

            try {
                TeatroDto r = null;
                hdb = new HandleDatabase(Settings.Connection);
                hdb.Open();
                SqlParameter param = new SqlParameter();
                param.ParameterName = "@id";
                param.Value         = id;
                param.SqlDbType     = SqlDbType.Int;
                string sql = "sp_obtenerTeatro @id";
                transaction = hdb.BeginTransaction("getTeatro");
                rdr         = hdb.ExecSelectSQLStmtAsReader(transaction, sql, param);
                if (rdr.HasRows)
                {
                    rdr.Read();
                    r = new TeatroDto()
                    {
                        idTeatro              = Convert.ToInt32(rdr["idteatro"]),
                        idCine                = Convert.ToInt32(rdr["idcine"]),
                        nombreTeatro          = rdr["nombreteatro"].ToString(),
                        telefono1Teatro       = rdr["telefono1teatro"].ToString(),
                        telefono2Teatro       = rdr["telefono2teatro"].ToString(),
                        telefono3Teatro       = rdr["telefono3teatro"].ToString(),
                        idMunicipioTeatro     = Convert.ToInt32(rdr["idMunicipioTeatro"]),
                        idDepeartamentoTeatro = Convert.ToInt32(rdr["idDepartamentoTeatro"]),
                        direccionTeatro       = rdr["direccionteatro"].ToString()
                    };
                }
                return(r);
            } catch (Exception) {
                return(null);
            } finally {
                if (rdr != null)
                {
                    rdr.Close();
                }
                if (transaction != null)
                {
                    transaction.Commit();
                }
                if (hdb != null)
                {
                    hdb.Close();
                }
            }
        }
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())
     {
         if (log.IsDebugEnabled)
         {
             log.Debug("No data info supplied");
         }
         registerToastrMsg(MessageType.Error, "No ha ingresado datos para crear.");
     }
     else
     {
         Teatro    daoTheter   = new Teatro();
         TeatroDto theaterInfo = new TeatroDto()
         {
             idCine                = Convert.ToInt32(listaCines.SelectedValue),
             nombreTeatro          = txtNombre.Text,
             telefono1Teatro       = txtTelefono1.Text,
             telefono2Teatro       = txtTelefono2.Text,
             telefono3Teatro       = txtTelefono3.Text,
             idMunicipioTeatro     = Convert.ToInt32(listaMunicipios.SelectedValue),
             idDepeartamentoTeatro = Convert.ToInt32(listaDepartamentos.SelectedValue),
             direccionTeatro       = txtDireccion.Text
         };
         if (log.IsDebugEnabled)
         {
             log.Debug("Record data [" + theaterInfo.ToString() + "]");
         }
         daoTheter.crearTeatro(theaterInfo, 1);
         LimpiarControles();
         btnEliminar.Visible = btnActualizar.Visible = false;
         registerToastrMsg(MessageType.Success, "Nuevo registro realizado con éxito.");
         CargarGridInfoData();
         if (log.IsDebugEnabled)
         {
             log.Debug("New record created");
         }
     }
     if (log.IsDebugEnabled)
     {
         log.Debug("OnButtonNuevo Ends");
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Puts info into DB.
        /// </summary>
        /// <param name="info">Record information to submit</param>
        /// <param name="op">Which kind to operation to make. 1:Insert, 2:update, 3:delete</param>
        /// <returns>Identity ID for just created record.</returns>
        public int crearTeatro(TeatroDto info, int op)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("crearTeatro Starts");
            }
            HandleDatabase hdb         = null;
            SqlTransaction transaction = null;
            int            rslt        = 0;

            try {
                List <SqlParameter> paramList = new List <SqlParameter>()
                {
                    new SqlParameter()
                    {
                        ParameterName = "@operacion", Value = op, SqlDbType = SqlDbType.Int
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@id", Value = info.idTeatro, SqlDbType = SqlDbType.Int
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@idCine", Value = info.idCine, SqlDbType = SqlDbType.Int
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@nombreTeatro", Value = info.nombreTeatro.ToString(), SqlDbType = SqlDbType.VarChar
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@telefono1Teatro", Value = info.telefono1Teatro.ToString(), SqlDbType = SqlDbType.VarChar
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@telefono2Teatro", Value = info.telefono2Teatro.ToString(), SqlDbType = SqlDbType.VarChar
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@telefono3Teatro", Value = info.telefono3Teatro.ToString(), SqlDbType = SqlDbType.VarChar
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@idMunicipioTeatro", Value = info.idMunicipioTeatro, SqlDbType = SqlDbType.Int
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@idDepartamentoTeatro", Value = info.idDepeartamentoTeatro, SqlDbType = SqlDbType.Int
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@direccionTeatro", Value = info.direccionTeatro, SqlDbType = SqlDbType.VarChar
                    }
                };

                String sql = "sp_crearActualizarTeatro @operacion, @id, @idCine, @nombreTeatro, @telefono1Teatro, @telefono2Teatro, @telefono3Teatro, @idMunicipioTeatro, @idDepartamentoTeatro, @direccionTeatro";
                var    i   = 1;
                if (log.IsDebugEnabled)
                {
                    log.Debug("SQL=[" + sql + "]");
                    paramList.ForEach(p => {
                        var paramValues = "ParameterName=[" + p.ParameterName + "], Value=[" + p.Value + "], SqlDbType=[" + p.SqlDbType + "]";
                        log.Debug("Parameter " + i++ + " val=[" + paramValues + "]");
                    });
                }
                hdb = new HandleDatabase(Settings.Connection);
                hdb.Open();
                transaction = hdb.BeginTransaction("crearCine");
                rslt        = hdb.ExecuteSelectSQLStmtAsScalar(transaction, sql, paramList.ToArray());
            } catch (Exception ex) {
                if (log.IsFatalEnabled)
                {
                    log.Fatal("Exception occurred " + ex.Message);
                    log.Fatal("Exception trace=[" + ex.StackTrace + "]");
                    log.Fatal("Returns -1");
                }
                rslt = -1;
            } finally {
                try {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                    if (hdb != null)
                    {
                        hdb.Close();
                    }
                } catch (Exception e) {
                    if (log.IsFatalEnabled)
                    {
                        log.Fatal("Exception occurred " + e.Message);
                        log.Fatal("Exception trace=[" + e.StackTrace + "]");
                        log.Fatal("Returns -1");
                    }
                    rslt = -1;
                }
            }
            if (log.IsDebugEnabled)
            {
                log.Debug("rslt=[" + rslt + "]");
                log.Debug("crearTeatro Ends");
            }
            return(rslt);
        }
Esempio n. 8
0
        /// <summary>
        /// Retrieves one record from DB.
        /// </summary>
        /// <param name="id">Filter to use</param>
        /// <returns>NULL if no record found.</returns>
        public TeatroDto getTeatro(int id)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("getTeatro Starts");
            }
            SqlTransaction transaction = null;
            SqlDataReader  rdr         = null;
            HandleDatabase hdb         = null;
            TeatroDto      r           = null;

            try {
                hdb = new HandleDatabase(Settings.Connection);
                hdb.Open();
                SqlParameter param = new SqlParameter()
                {
                    ParameterName = "@id", Value = id, SqlDbType = SqlDbType.Int
                };
                string sql = "sp_obtenerTeatro @id";
                if (log.IsDebugEnabled)
                {
                    log.Debug("SQL=[" + sql + "]");
                    var paramValues = "ParameterName=[" + param.ParameterName + "], Value=[" + param.Value + "], SqlDbType=[" + param.SqlDbType + "]";
                    log.Debug("Parameter val=[" + paramValues + "]");
                }
                transaction = hdb.BeginTransaction("getTeatro");
                rdr         = hdb.ExecSelectSQLStmtAsReader(transaction, sql, param);
                if (rdr.HasRows)
                {
                    rdr.Read();
                    r = new TeatroDto()
                    {
                        idTeatro              = Convert.ToInt32(rdr["idteatro"]),
                        idCine                = Convert.ToInt32(rdr["idcine"]),
                        nombreTeatro          = rdr["nombreteatro"].ToString(),
                        telefono1Teatro       = rdr["telefono1teatro"].ToString(),
                        telefono2Teatro       = rdr["telefono2teatro"].ToString(),
                        telefono3Teatro       = rdr["telefono3teatro"].ToString(),
                        idMunicipioTeatro     = Convert.ToInt32(rdr["idMunicipioTeatro"]),
                        idDepeartamentoTeatro = Convert.ToInt32(rdr["idDepartamentoTeatro"]),
                        direccionTeatro       = rdr["direccionteatro"].ToString()
                    };
                }
            } catch (Exception ex) {
                if (log.IsFatalEnabled)
                {
                    log.Fatal("Exception occurred " + ex.Message);
                    log.Fatal("Exception trace=[" + ex.StackTrace + "]");
                    log.Fatal("Result sets to null");
                }
                r = null;
            } finally {
                try {
                    if (rdr != null)
                    {
                        rdr.Close();
                    }
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                    if (hdb != null)
                    {
                        hdb.Close();
                    }
                } catch (Exception e) {
                    if (log.IsFatalEnabled)
                    {
                        log.Fatal("Exception occurred " + e.Message);
                        log.Fatal("Exception trace=[" + e.StackTrace + "]");
                        log.Fatal("Result sets to null");
                    }
                    r = null;
                }
            }
            if (log.IsDebugEnabled)
            {
                if (r == null)
                {
                    log.Debug("Result is NULL");
                }
                else
                {
                    log.Debug("Result sets to [" + r.ToString() + "]");
                }
                log.Debug("getTeatro Ends");
            }
            return(r);
        }
Esempio n. 9
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");
     }
 }
Esempio n. 10
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");
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Puts info into DB.
        /// </summary>
        /// <param name="info">Record information to submit</param>
        /// <param name="op">Which kind to operation to make. 1:Insert, 2:update, 3:delete</param>
        /// <returns>Identity ID for just created record.</returns>
        public int crearTeatro(TeatroDto info, int op)
        {
            HandleDatabase hdb         = null;
            SqlTransaction transaction = null;

            try {
                int rslt = 0;
                List <SqlParameter> paramList = new List <SqlParameter>();
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@operacion", Value = op, SqlDbType = SqlDbType.Int
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@id", Value = info.idTeatro, SqlDbType = SqlDbType.Int
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@idCine", Value = info.idCine, SqlDbType = SqlDbType.Int
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@nombreTeatro", Value = info.nombreTeatro.ToString(), SqlDbType = SqlDbType.VarChar
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@telefono1Teatro", Value = info.telefono1Teatro.ToString(), SqlDbType = SqlDbType.VarChar
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@telefono2Teatro", Value = info.telefono2Teatro.ToString(), SqlDbType = SqlDbType.VarChar
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@telefono3Teatro", Value = info.telefono3Teatro.ToString(), SqlDbType = SqlDbType.VarChar
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@idMunicipioTeatro", Value = info.idMunicipioTeatro, SqlDbType = SqlDbType.Int
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@idDepartamentoTeatro", Value = info.idDepeartamentoTeatro, SqlDbType = SqlDbType.Int
                });
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@direccionTeatro", Value = info.direccionTeatro, SqlDbType = SqlDbType.VarChar
                });

                String sql = "sp_crearActualizarTeatro @operacion, @id, @idCine, @nombreTeatro, @telefono1Teatro, @telefono2Teatro, @telefono3Teatro, @idMunicipioTeatro, @idDepartamentoTeatro, @direccionTeatro";
                hdb = new HandleDatabase(Settings.Connection);
                hdb.Open();
                transaction = hdb.BeginTransaction("crearCine");
                rslt        = hdb.ExecuteSelectSQLStmtAsScalar(transaction, sql, paramList.ToArray());
                return(rslt);
            } catch (Exception) {
                return(-1);
            } finally {
                if (transaction != null)
                {
                    transaction.Commit();
                }
                if (hdb != null)
                {
                    hdb.Close();
                }
            }
        }