Ejemplo n.º 1
0
        public static bool Modificar(Cotizacioness cotizacion)
        {
            bool paso = false;

            Contexto contexto = new Contexto();



            foreach (var item in cotizacion.Detalle)
            {
                var estado = item.Id > 0 ? EntityState.Modified : EntityState.Added;
                contexto.Entry(item).State = estado;
            }


            contexto.Entry(cotizacion).State = EntityState.Modified;

            if (contexto.SaveChanges() > 0)
            {
                paso = true;
            }
            contexto.Dispose();

            return(paso);
        }
Ejemplo n.º 2
0
        private void LlenarCampos(Cotizacioness cotizacion)
        {
            CotizacionIDNum.Value = cotizacion.CotizacionId;
            FechaCotPicker.Text   = cotizacion.Fecha;
            ObservacionBox.Text   = cotizacion.Comentario;


            dataGridDetalle.DataSource = cotizacion.Detalle;


            dataGridDetalle.Columns["Id"].Visible           = false;
            dataGridDetalle.Columns["CotizacionId"].Visible = false;
        }
Ejemplo n.º 3
0
        private void BuscarCotBoton_Click(object sender, EventArgs e)
        {
            int           id         = Convert.ToInt32(CotizacionIDNum.Value);
            Cotizacioness Cotizacion = BLL.CotizacionesBLL.Buscar(id);

            if (Cotizacion != null)
            {
                LlenarCampos(Cotizacion);
            }
            else
            {
                MessageBox.Show("No se encontro!", "Fallo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 4
0
        public static bool Guardar(Cotizacioness cotizacion)
        {
            bool paso = false;

            Contexto contexto = new Contexto();

            if (contexto.Cotizaciones.Add(cotizacion) != null)
            {
                contexto.SaveChanges();
                paso = true;
            }

            contexto.Dispose();


            return(paso);
        }
Ejemplo n.º 5
0
        public static bool Eliminar(int id)
        {
            bool paso = false;

            Contexto contexto = new Contexto();


            Cotizacioness cotizacion = contexto.Cotizaciones.Find(id);

            contexto.Cotizaciones.Remove(cotizacion);
            if (contexto.SaveChanges() > 0)
            {
                paso = true;
            }

            contexto.Dispose();



            return(paso);
        }
Ejemplo n.º 6
0
        public static Cotizacioness Buscar(int id)
        {
            Cotizacioness cotizacion = new Cotizacioness();
            Contexto      contexto   = new Contexto();


            cotizacion = contexto.Cotizaciones.Find(id);

            cotizacion.Detalle.Count();


            foreach (var item in cotizacion.Detalle)
            {
                string s = item.Articulos.Descripcion;
                string r = item.Personas.Nombre;
            }
            contexto.Dispose();



            return(cotizacion);
        }
Ejemplo n.º 7
0
        private Cotizacioness LlenaClase()
        {
            Cotizacioness cotizacion = new Cotizacioness();

            cotizacion.CotizacionId = Convert.ToInt32(CotizacionIDNum.Value);
            cotizacion.Fecha        = FechaCotPicker.Text;
            cotizacion.Comentario   = ObservacionBox.Text;


            foreach (DataGridViewRow item in dataGridDetalle.Rows)
            {
                cotizacion.AgregarDetalle(
                    ToInt(item.Cells["id"].Value),
                    ToInt(item.Cells["CotizacionId"].Value),
                    ToInt(item.Cells["PersonaId"].Value),
                    ToInt(item.Cells["ArticuloId"].Value),
                    ToInt(item.Cells["Cantidad"].Value),
                    ToInt(item.Cells["Precio"].Value),
                    ToInt(item.Cells["Importe"].Value)
                    );
            }
            return(cotizacion);
        }