public void editar(rampa editaRampa)
 {
     using (DBTallerEntities db = new DBTallerEntities())
     {
         db.Entry(editaRampa).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void nuevo(rampa nuevaRampa)
 {
     using (DBTallerEntities db = new DBTallerEntities())
     {
         db.rampa.Add(nuevaRampa);
         db.SaveChanges();
     }
 }
        public rampa buscarId(int?id)
        {
            rampa oRampa = new rampa();

            using (DBTallerEntities db = new DBTallerEntities())
            {
                oRampa = db.rampa.Find(id);
            }
            return(oRampa);
        }
 private void CargaDatos()
 {
     //using (DBTallerEntities db = new DBTallerEntities())
     //{
     //    oRampa = db.rampa.Find(id);
     //    txtNombre.Text = oRampa.nombre;
     //    txtTipo.Text = oRampa.tipo;
     //}
     oRampa         = controladorRampa.buscarId(id);
     txtNombre.Text = oRampa.nombre;
     txtTipo.Text   = oRampa.tipo;
 }
Example #5
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            int?id = GetId();

            if (id != null)
            {
                using (DBTallerEntities db = new DBTallerEntities())
                {
                    rampa oRampa = db.rampa.Find(id);
                    db.rampa.Remove(oRampa);
                    db.SaveChanges();
                }
                dataGridView1.DataSource = controladorRampa.refrescar();
            }
        }
Example #6
0
        private void actualizar(DateTime fecha)
        {
            dgReservacion.Rows.Clear();

            List <reservacion> listaReservacion = controladorReservacion.listarPorFecha(fecha);

            foreach (reservacion r in listaReservacion)
            {
                cliente oCliente = controladorCliente.buscarId(r.id_cliente);
                string  cliente  = oCliente.nombre + " " + oCliente.ap_paterno + " " + oCliente.ap_materno;

                rampa oRampa = controladorRampa.buscarId(r.id_rampa);


                dgReservacion.Rows.Add(r.id, cliente, oRampa.nombre, r.horario, r.fecha, r.observacion);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //using (DBTallerEntities db = new DBTallerEntities())
            //{
            //    if (id==null)
            //        oRampa = new rampa();

            //    oRampa.nombre = txtNombre.Text;
            //    oRampa.tipo = txtTipo.Text;

            //    if (id==null)
            //    db.rampa.Add(oRampa);
            //    else
            //    {
            //        db.Entry(oRampa).State = System.Data.Entity.EntityState.Modified;
            //    }

            //    db.SaveChanges();

            //    this.Close();
            //}

            BorrarMensajeError();
            if (ValidarCampos())
            {
                if (id == null)
                {
                    try
                    {
                        oRampa        = new rampa();
                        oRampa.nombre = txtNombre.Text;
                        oRampa.tipo   = txtTipo.Text;
                        controladorRampa.nuevo(oRampa);
                        MessageBox.Show(this, "Rampa Agregada Exitosamente", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        this.Close();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(this, "Error en el llenado del formulario", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    try
                    {
                        oRampa.nombre = txtNombre.Text;
                        oRampa.tipo   = txtTipo.Text;
                        controladorRampa.editar(oRampa);
                        MessageBox.Show(this, "Rampa Modificada Exitosamente", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        this.Close();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(this, "Error en el llenado del formulario", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                // this.Close();
            }
            else
            {
                MessageBox.Show(this, "Error en el llenado del Formulario", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }