public void Borrar()
 {
     AulaEstado AulaEstado = new AulaEstado();
     AulaEstado.Id = Convert.ToInt32(this.txtId.Text);
     db.borrarAulaEstado(AulaEstado);
     cargarDataGrid();
     edicion(false);
 }
        public bool Guardar()
        {
            edicion(false);
            if (this.txtId.Text == "")
            {
                /*------------INSERTAR FACULTAD----------------*/
                if (this.txtDescripcion.Text != "")
                {
                    AulaEstado AulaEstado = new AulaEstado();
                    AulaEstado.Descripcion = this.txtDescripcion.Text;
                    insertAulaEstado(AulaEstado);
                    this.dgAulaEstados.Enabled = true;
                    cargarDataGrid();
                    this.txtId.DataBindings.Add("Text", AulaEstadosBindingSource, "Id");
                    this.txtDescripcion.DataBindings.Add("Text", AulaEstadosBindingSource, "Descripcion");
                    this.AulaEstadosBindingSource.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 != "")
                {
                    AulaEstado AulaEstado = new AulaEstado();
                    AulaEstado.Id = Convert.ToInt32(this.txtId.Text);
                    AulaEstado.Descripcion = this.txtDescripcion.Text;
                    actualizarAulaEstado(AulaEstado);
                    this.dgAulaEstados.Enabled = true;
                    cargarDataGrid();
                    return true;
                }
                else
                {
                    MessageBox.Show("Descripción no puede estar vacio","Error",MessageBoxButtons.OK);
                    return false;
                }
                /*---------FIN Actualizar FACULTAD----------------*/

            }
        }
示例#3
0
        public Boolean actualizarAulaEstado(AulaEstado AulaEstado)
        {
            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 aula_estado set descripcion=@descripcion where id_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 = AulaEstado.Descripcion;
                this.command.Parameters["@id"].Value = AulaEstado.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();
            }
        }
示例#4
0
        public Boolean insertAulaEstado(AulaEstado AulaEstado)
        {
            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 aula_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 = AulaEstado.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();
            }
        }
示例#5
0
 /*--------------------FIN CATALOGO AulaTipoUsos------------------------*/
 /*--------------------Catalogo de AulaEstadoUsos-------------------------*/
 public List<AulaEstado> getAulaEstado()
 {
     SqlDataReader dataReader = null;
     List<AulaEstado> AulaEstado = new List<AulaEstado>();
     try
     {
         string query = "Select * from aula_estado";
         command = new SqlCommand(query, connection);
         command.Connection.Open();
         dataReader = command.ExecuteReader();
         while (dataReader.Read())
         {
             AulaEstado edi = new AulaEstado();
             edi.Id = Convert.ToInt32(dataReader["id_estado"].ToString());
             edi.Descripcion = dataReader["descripcion"].ToString();
             AulaEstado.Add(edi);
         }
         return AulaEstado;
     }
     catch (Exception e)
     {
         throw new Exception("Error al obtener datos de AulaEstado. " + e.Message.ToString());
     }
     finally
     {
         command.Connection.Close();
     }
 }
示例#6
0
        public Boolean borrarAulaEstado(AulaEstado AulaEstado)
        {
            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 aula_estado where id_estado=@id;";
                this.command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int));
                this.command.Parameters["@id"].Value = AulaEstado.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();
            }
        }
        private bool insertAulaEstado(AulaEstado AulaEstado)
        {
            try
            {
                db.insertAulaEstado(AulaEstado);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return true;
        }
        private bool actualizarAulaEstado(AulaEstado AulaEstado)
        {
            try
            {
                db.actualizarAulaEstado(AulaEstado);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return true;
        }