コード例 #1
0
        public void Borrar()
        {
            AlertaEstado AlertaEstado = new AlertaEstado();
            AlertaEstado.Id = Convert.ToInt32(this.txtId.Text);
            try
            {
                db.borrarAlertaEstado(AlertaEstado);
            }
            catch (Exception e)
            {

                MessageBox.Show(e.Message + ". Referencia esta siendo usada en otros formularios");
            }
            cargarDataGrid();
            edicion(false);
        }
コード例 #2
0
        public bool Guardar()
        {
            edicion(false);
            if (this.txtId.Text == "")
            {
                /*------------INSERTAR FACULTAD----------------*/
                if (this.txtDescripcion.Text != "")
                {
                    AlertaEstado AlertaEstado = new AlertaEstado();
                    AlertaEstado.Descripcion = this.txtDescripcion.Text;
                    insertAlertaEstado(AlertaEstado);
                    this.dgAlertaEstados.Enabled = true;
                    cargarDataGrid();
                    this.txtId.DataBindings.Add("Text", AlertaEstados, "Id");
                    this.txtDescripcion.DataBindings.Add("Text", AlertaEstados, "Descripcion");
                    this.AlertaEstados.MoveLast();
                    return true;
                }
                else
                {
                    MessageBox.Show("Descripción no puede estar vacio.", "Error", MessageBoxButtons.OK);
                    return false;
                }

                /*---------FIN INSERTAR FACULTAD----------------*/

            }
            else
            {

                /*------------Actualizar FACULTAD----------------*/
                if (this.txtDescripcion.Text != "")
                {
                    AlertaEstado AlertaEstado = new AlertaEstado();
                    AlertaEstado.Id = Convert.ToInt32(this.txtId.Text);
                    AlertaEstado.Descripcion = this.txtDescripcion.Text;
                    actualizarAlertaEstado(AlertaEstado);
                    this.dgAlertaEstados.Enabled = true;
                    cargarDataGrid();
                    return true;
                }
                else
                {
                    MessageBox.Show("Descripción no puede estar vacio","Error",MessageBoxButtons.OK);
                    return false;
                }
                /*---------FIN Actualizar FACULTAD----------------*/

            }
        }
コード例 #3
0
        private bool insertAlertaEstado(AlertaEstado AlertaEstado)
        {
            try
            {
                db.insertAlertaEstado(AlertaEstado);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return true;
        }
コード例 #4
0
        private bool actualizarAlertaEstado(AlertaEstado AlertaEstado)
        {
            try
            {
                db.actualizarAlertaEstado(AlertaEstado);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return true;
        }
コード例 #5
0
ファイル: Conexion.cs プロジェクト: eduardo-salazar/siga-UAM
        public Boolean borrarAlertaEstado(AlertaEstado AlertaEstado)
        {
            this.connection.Open();
            this.command = this.connection.CreateCommand();
            this.transaction = this.connection.BeginTransaction();

            this.command.Connection = this.connection;
            this.command.Transaction = this.transaction;

            try
            {
                this.command.CommandText = "delete from alerta_estado where id_alerta_estado=@id;";
                this.command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int));
                this.command.Parameters["@id"].Value = AlertaEstado.Id;
                this.command.ExecuteNonQuery();
                this.transaction.Commit();
                return true;
            }
            catch (Exception e)
            {
                try
                {
                    this.transaction.Rollback();
                    throw new Exception("Error al borrar registro. " + e.Message);
                    return false;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error al rollback acción. " + ex.Message);
                    return false;
                }
            }
            finally
            {
                this.connection.Close();
            }
        }
コード例 #6
0
ファイル: Conexion.cs プロジェクト: eduardo-salazar/siga-UAM
        public Boolean insertAlertaEstado(AlertaEstado AlertaEstado)
        {
            this.connection.Open();
            this.command = this.connection.CreateCommand();
            this.transaction = this.connection.BeginTransaction();
            this.command.Connection = this.connection;
            this.command.Transaction = this.transaction;

            try
            {
                this.command.CommandText = "insert into alerta_estado(Descripcion) values(@descripcion);" + "SELECT CAST(scope_identity() AS int)";
                this.command.Parameters.Add(new SqlParameter("@descripcion", SqlDbType.NVarChar, 50));
                this.command.Parameters["@descripcion"].Value = AlertaEstado.Descripcion;
                this.lastUpdated = this.command.ExecuteScalar().ToString();
                this.transaction.Commit();
                return true;
            }
            catch (Exception e)
            {
                try
                {
                    transaction.Rollback();
                    throw new Exception("Error al insertar registro. " + e.Message);
                    return false;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error al roolback accion. " + ex.Message);
                }
            }
            finally
            {
                this.connection.Close();
            }
        }
コード例 #7
0
ファイル: Conexion.cs プロジェクト: eduardo-salazar/siga-UAM
 /*--------------------FIN CATALOGO Alertas------------------------*/
 /*--------------------Catalogo de AlertaEstadoUsos-------------------------*/
 public List<AlertaEstado> getAlertaEstado()
 {
     SqlDataReader dataReader = null;
     List<AlertaEstado> AlertaEstadoUsos = new List<AlertaEstado>();
     try
     {
         string query = "Select * from alerta_estado";
         command = new SqlCommand(query, connection);
         command.Connection.Open();
         dataReader = command.ExecuteReader();
         while (dataReader.Read())
         {
             AlertaEstado edi = new AlertaEstado();
             edi.Id = Convert.ToInt32(dataReader["id_alerta_estado"].ToString());
             edi.Descripcion = dataReader["descripcion"].ToString();
             AlertaEstadoUsos.Add(edi);
         }
         return AlertaEstadoUsos;
     }
     catch (Exception e)
     {
         throw new Exception("Error al obtener datos de AlertaEstado. " + e.Message.ToString());
     }
     finally
     {
         command.Connection.Close();
     }
 }
コード例 #8
0
ファイル: Conexion.cs プロジェクト: eduardo-salazar/siga-UAM
        public Boolean actualizarAlertaEstado(AlertaEstado AlertaEstado)
        {
            this.connection.Open();
            this.command = this.connection.CreateCommand();
            this.transaction = this.connection.BeginTransaction();
            this.command.Connection = this.connection;
            this.command.Transaction = this.transaction;

            try
            {
                this.command.CommandText = "Update alerta_estado set descripcion=@descripcion where id_alerta_estado=@id;";
                this.command.Parameters.Add(new SqlParameter("@descripcion", SqlDbType.NVarChar, 50));
                this.command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int));
                this.command.Parameters["@descripcion"].Value = AlertaEstado.Descripcion;
                this.command.Parameters["@id"].Value = AlertaEstado.Id;
                this.command.ExecuteNonQuery();
                this.transaction.Commit();
                return true;
            }
            catch (Exception e)
            {
                try
                {
                    this.transaction.Rollback();
                    throw new Exception("Error al Actualizar." + e.Message);
                    return false;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error al rollback accion." + ex.Message);
                    return false;
                }
            }
            finally
            {
                this.connection.Close();
            }
        }