public static cotizaciones Crear(int region_id, int tipo_vidrio_id, int descuento) { cotizaciones cot = new cotizaciones() { region_id = region_id, tipo_vidrio_id = tipo_vidrio_id, descuento = descuento }; db.cotizaciones.Add(cot); db.SaveChanges(); return(cot); }
/* * private void BtnAgregarCosto_Click(object sender, RoutedEventArgs e) * { * switch ((cbCostos.SelectedItem as tipo_costo).nombre.ToLower()) * { * case "metro lineal sistema": * int valorInicial = Convert.ToInt32(txtValorInicialCosto.Text); * var id = new ItemDetalle() { ValorInicial = Convert.ToInt32(txtValorInicialCosto.Text), CostoFinal = (int)(valorInicial * VanosTotalAncho), Desgloce = (cbCostos.SelectedItem as tipo_costo).nombre }; * id.btnQuitarDetalle.Click += (se, a) => spDetalle.Children.Remove(id); * spDetalle.Children.Add(id); * break; * case "area vano": * int valorInicial = Convert.ToInt32(txtValorInicialCosto.Text); * var id = new ItemDetalle() { ValorInicial = Convert.ToInt32(txtValorInicialCosto.Text), CostoFinal = (int)(valorInicial * VanosTotalAncho), Desgloce = (cbCostos.SelectedItem as tipo_costo).nombre }; * id.btnQuitarDetalle.Click += (se, a) => spDetalle.Children.Remove(id); * spDetalle.Children.Add(id); * break; * case "tasa imprevisto": * break; * default: * txtCostoFinalCosto.IsEnabled = true; * break; * } * * } */ private void BtnNuevaCotizacion_Click(object sender, RoutedEventArgs e) { int region_id = (cbRegiones.SelectedItem as regiones).id; int tipo_vidrio_id = (cbTipoVidrio.SelectedItem as tipo_vidrio).id; int descuento = 0; // TODO - implementar cotizaciones cot = CotizacionBLL.Crear(region_id, tipo_vidrio_id, descuento); spVanos.Children.OfType <ItemVano>().ToList().ForEach(iv => { VanosBLL.Crear(Convert.ToInt32(iv.txtCantAperturas.Text), Convert.ToDecimal(iv.txtAncho.Text), Convert.ToDecimal(iv.txtAlto.Text), cot.id); }); }