Exemplo n.º 1
0
        private void Modificarbutton_Click(object sender, EventArgs e)
        {
            DAL.Contexto contexto = new DAL.Contexto();

            Cotizaciones cotizacion = new Cotizaciones();

            cotizacion = contexto.Cotizaciones.Find(1);
            contexto.Dispose();//me desconecto aqui

            contexto = new DAL.Contexto();

            cotizacion.AgregarDetalle(1, "Croissant", 2);
            cotizacion.AgregarDetalle(1, "Croissant", 2);
            cotizacion.AgregarDetalle(1, "Croissant", 2);
            cotizacion.AgregarDetalle(1, "Croissant", 2);
            cotizacion.AgregarDetalle(1, "Croissant", 2);

            //recorrer el detalle
            foreach (var item in cotizacion.Detalle)
            {
                item.CotizacionId          = cotizacion.CotizacionId;
                contexto.Entry(item).State = EntityState.Added;
            }

            contexto.SaveChanges();
        }
Exemplo n.º 2
0
        private Cotizaciones LlenaClase()
        {
            Cotizaciones cotizacionArticulos = new Cotizaciones();

            cotizacionArticulos.CotizacionId  = Convert.ToInt32(CotizacioIDnumericUpDown.Value);
            cotizacionArticulos.Fecha         = Fecha2dateTimePicker.Value;
            cotizacionArticulos.Observaciones = observacionesTextbox.Text;



            foreach (DataGridViewRow item in DetalleCotizacionesdataGridView.Rows)
            {
                cotizacionArticulos.AgregarDetalle
                    (ToInt(item.Cells["ID"].Value),
                    cotizacionArticulos.CotizacionId,
                    ToInt(item.Cells["PersonaId"].Value),
                    ToInt(item.Cells["ArticuloId"].Value),
                    ToInt(item.Cells["Cantidad"].Value),
                    Convert.ToString(item.Cells["Descripcion"].Value),
                    ToInt(item.Cells["Precio"].Value),
                    ToInt(item.Cells["Importe"].Value)



                    );
            }
            return(cotizacionArticulos);
        }
Exemplo n.º 3
0
        private void Nuevobutton_Click(object sender, EventArgs e)
        {
            DAL.Contexto contexto = new DAL.Contexto();

            Cotizaciones cotizacion = new Cotizaciones()
            {
                CotizacionId = 0,
                Fecha        = new DateTime(2018, 1, 1),
                Monto        = 100
            };

            cotizacion.AgregarDetalle(1, "Pan", 2);
            cotizacion.AgregarDetalle(1, "Mantequilla", 1);

            contexto.Cotizaciones.Add(cotizacion);

            contexto.SaveChanges();
        }
Exemplo n.º 4
0
        private Cotizaciones LlenaClase()
        {
            Cotizaciones cotizacion = new Cotizaciones();

            cotizacion.CotizacionId = Convert.ToInt32(CotizacionIdnumericUpDown.Value);
            cotizacion.Fecha        = fechaDateTimePicker.Value;
            cotizacion.Comentario   = ObservaciontextBox.Text;

            //Agregar cada linea del Grid al detalle
            foreach (DataGridViewRow item in CotizaciondataGridView.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);
        }
        private Cotizaciones LlenaClase()
        {
            Cotizaciones cotizaciones = new Cotizaciones();

            cotizaciones.CotizacionId  = Convert.ToInt32(CotizacionIdNumericUpDown.Value);
            cotizaciones.Fecha         = FechaDateTimePicker.Value;
            cotizaciones.Observaciones = ObservacionesTextBox.Text;

            foreach (DataGridViewRow item in DetalleCotizacionDataGridView.Rows)//Agregar cada linea del Grid al detalle
            {
                cotizaciones.AgregarDetalle(
                    ToInt(item.Cells["Id"].Value),
                    ToInt(item.Cells["CotizacionId"].Value),
                    ToInt(item.Cells["PersonaId"].Value),
                    ToInt(item.Cells["ArticulosId"].Value),
                    ToSingle(item.Cells["CantidadCotizada"].Value),
                    ToSingle(item.Cells["Precio"].Value),
                    ToSingle(item.Cells["Importe"].Value)
                    );
            }

            return(cotizaciones);
        }
        private Cotizaciones LlenaClase()
        {
            Cotizaciones Cotizacion = new Cotizaciones();

            Cotizacion.CotizacionId = Convert.ToInt32(IdnumericUpDown.Value);
            Cotizacion.Fecha        = FechadateTimePicker.Value;
            Cotizacion.Comentario   = ObservacionesrichTextBox.Text;


            foreach (DataGridViewRow item in DetalledataGridView.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);
        }