private void btnGuardar_Click(object sender, EventArgs e) { Transfers transferencia = new Transfers(); using (transferencia) { transferencia.Folio = Convert.ToInt16(txtFolios.Text); transferencia.Tipo_trapaso = "E"; transferencia.Sucursal = cbOficinas.SelectedValue.ToString(); transferencia.Subtotal = Convert.ToDouble(txtSubtotal.Text); transferencia.Iva = 0; transferencia.Total = 0; transferencia.Facturado = Convert.ToInt16(false); transferencia.CreateTransfer(); List <Transfers> ultimo = transferencia.getTransferbyfolio(Convert.ToInt16(txtFolios.Text), "E"); Det_transfers detalles = new Det_transfers(); using (detalles) { detalles.Folio = Convert.ToInt16(txtFolios.Text); detalles.Tipo = "E"; Product poductos = new Product(); foreach (DataGridViewRow row in dtProductos.Rows) { detalles.Cantidad = Convert.ToDouble(row.Cells["cantidad"].Value.ToString()); detalles.Id_producto = Convert.ToInt16(row.Cells["id"].Value.ToString()); detalles.Precio = Convert.ToDouble(row.Cells["p_u"].Value.ToString()); detalles.CreateDet(); using (poductos) { List <Product> producto = poductos.getProductById(Convert.ToInt16(row.Cells["id"].Value.ToString())); Kardex kardex = new Kardex(); using (kardex) { kardex.Id_producto = Convert.ToInt16(row.Cells["id"].Value.ToString()); kardex.Tipo = "T"; kardex.Id_documento = ultimo[0].Id; kardex.Cantidad = Convert.ToDouble(row.Cells["cantidad"].Value.ToString()); kardex.Antes = producto[0].Existencia; kardex.CreateKardex(); List <Kardex> ultimo_kardez = kardex.getidKardex(Convert.ToInt16(row.Cells["id"].Value.ToString()), ultimo[0].Id, "T"); Afecta_inv afecta = new Afecta_inv(); using (afecta) { afecta.Disminuye(ultimo_kardez[0].Id); } } } } } } //crea_xml(); Folios folio = new Folios(); using (folio) { folio.Transferencia = (Convert.ToInt16(txtFolios.Text) + 1); folio.savenewTransfer(); } PrinterSettings ps = new PrinterSettings(); printDocument1.PrintController = new StandardPrintController(); printDocument1.PrinterSettings = ps; Configuration configuracion = new Configuration(); using (configuracion) { List <Configuration> config = configuracion.getConfiguration(); printDocument1.PrinterSettings.PrinterName = config[0].Impresora; printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); printDocument1.Print(); } this.Close(); }
private void button2_Click(object sender, EventArgs e) { Inv_out salida = new Inv_out( Convert.ToInt16(folio), dtFecha.Text + " 00:00:00", "", Convert.ToDouble(txtTotal.Text), "A" ); Det_salidas det = new Det_salidas(); Kardex kardex = new Kardex(); Product producto = new Product(); Afecta_inv afecta = new Afecta_inv(); int nuevo = 0; det.Id = 0; if (folio == "0") { using (salida) { salida.createInv_out(); List <Inv_out> result = salida.getListabyAll(dtFecha.Text + " 00:00:00", Convert.ToDouble(txtTotal.Text)); folio = result[0].Id.ToString(); det.Id_salida = Convert.ToInt16(folio); foreach (DataGridViewRow row in dtProductos.Rows) { det.Cantidad = Convert.ToInt16(row.Cells["cantidad"].Value.ToString()); det.Id_producto = Convert.ToInt16(row.Cells["id_producto"].Value.ToString()); det.P_u = Convert.ToDouble(row.Cells["p_u"].Value.ToString()); det.Total = Convert.ToDouble(row.Cells["total"].Value.ToString()); using (det) { det.craeteDet_salida(); using (producto) { List <Product> prod = producto.getProductById(Convert.ToInt16(row.Cells["id_producto"].Value.ToString())); nuevo = Convert.ToInt16(row.Cells["cantidad"].Value.ToString()); while (prod[0].Parent != "0") { nuevo = nuevo * Convert.ToInt16(prod[0].C_unidad); prod = producto.getProductById(Convert.ToInt16(prod[0].Parent)); } kardex.Fecha = Convert.ToDateTime(dtFecha.Text).ToString(); kardex.Id_producto = prod[0].Id; kardex.Tipo = "S"; kardex.Cantidad = nuevo; kardex.Antes = prod[0].Existencia; kardex.Id = 0; kardex.Id_documento = Convert.ToInt16(folio); using (kardex) { kardex.CreateKardex(); List <Kardex> numeracion = kardex.getidKardex(prod[0].Id, Convert.ToInt16(folio), "S"); using (afecta) { afecta.Disminuye(numeracion[0].Id); } } } } } } } if (Entrada == "") { Entradas formInterface = this.Owner as Entradas; formInterface.carga(); } this.Close(); }