public string obtenerNuevoId() { string id = ""; id = bd.ejecutarConsultaValor("select max(cast(IdEmpleado as int))+1 from Empleado"); return(id); }
public string obtenerNuevoId() { string id = ""; try { id = bd.ejecutarConsultaValor("select max(cast(IdCliente as int))+1 from Cliente"); } catch (SqlException ex) { } return(id); }
private void button3_Click(object sender, EventArgs e) //Linea Factura { string servicio = comboBox_servicio.Text; int cantidad = (int)numericUpDown1.Value; serviciosIncluidos.Add(servicio); cantidadServicios.Add(cantidad); int monto = Int32.Parse(db.ejecutarConsultaValor("select Precio from Servicio where Nombre = '" + servicio + "'")); int resultado = monto * cantidad; if (Int32.TryParse(textBox1.Text, out int montoOg)) { resultado += montoOg; } textBox1.Text = resultado.ToString(); comboBox_servicio.ResetText(); numericUpDown1.ResetText(); }
private string obtenerIdEvento(string nomEvento) { string evento = db.ejecutarConsultaValor("select idEvento from Evento where Nombre = '" + nomEvento + "'"); return(evento); }
//recibe como parametro la descripcion y devuelve el codigo public string obtenerCodPais(string d) { string codPais = bd.ejecutarConsultaValor("select codPais from Pais where Descripcion= '" + d + "'"); return(codPais); }
private void toPDF() { Document doc = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = @"C:"; saveFileDialog1.Title = "Guardar Factura"; saveFileDialog1.DefaultExt = "pdf"; saveFileDialog1.Filter = "pdf Files (*.pdf)|*.pdf| All Files (*.*)|*.*"; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; string filename = ""; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { filename = saveFileDialog1.FileName; } if (filename.Trim() != "") { FileStream file = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); PdfWriter.GetInstance(doc, file); doc.Open(); string comboBox = comboBoxIdFactura.Text; string idFactura = db.ejecutarConsultaValor("select IdFactura from Factura where IdFactura = '" + comboBox + "'"); string idEvento = db.ejecutarConsultaValor("select IdEvento from Factura where IdFactura = '" + comboBox + "'"); string idCliente = db.ejecutarConsultaValor("select IdCliente from Factura where IdFactura = '" + comboBox + "'"); string fecha = db.ejecutarConsultaValor("select Fecha from Factura where IdFactura = '" + comboBox + "'"); string monto = db.ejecutarConsultaValor("select Monto from Factura where IdFactura = '" + comboBox + "'"); string idPersona = db.ejecutarConsultaValor("select Id from Cliente where IdCliente = '" + idCliente + "'"); string nom1 = db.ejecutarConsultaValor("select Nombre from PersonaFisica where Id = '" + idPersona + "'"); string ap1 = db.ejecutarConsultaValor("select Apellido1 from PersonaFisica where Id = '" + idPersona + "'"); string ap2 = db.ejecutarConsultaValor("select Apellido2 from PersonaFisica where Id = '" + idPersona + "'"); string nomCliente = nom1 + " " + ap1 + " " + ap2; string nomEvento = db.ejecutarConsultaValor("select Nombre from Evento where IdEvento = '" + idEvento + "'"); DataTable lineaFactura = db.ejecutarConsultaTabla("select IdServicio, Cantidad from LineaFactura where IdFactura = '" + comboBox + "'"); Chunk chunk = new Chunk("Factura EventosDB", FontFactory.GetFont("ARIAL", 20, iTextSharp.text.Font.BOLD)); doc.Add(new Paragraph(chunk)); doc.Add(new Paragraph(" ")); doc.Add(new Paragraph("------------------------------------------------------------------------------------------")); doc.Add(new Paragraph("Id Factura = " + idFactura)); doc.Add(new Paragraph("Cliente = " + nomCliente + " (Id: " + idCliente + ")")); doc.Add(new Paragraph("Evento a realizar = " + nomEvento + " (Id: " + idEvento + ")")); doc.Add(new Paragraph("Fecha de la factura = " + fecha)); doc.Add(new Paragraph("------------------------------------------------------------------------------------------")); doc.Add(new Paragraph("Servicios por cobrar: ")); for (int i = 0; i < lineaFactura.Rows.Count; i++) { DataRow row = lineaFactura.Rows[i]; int f = 0; foreach (object item in row.ItemArray) { if (f == 0) { string nomServicio = db.ejecutarConsultaValor("select Nombre from Servicio where IdServicio = '" + item + "'"); doc.Add(new Paragraph(" -> " + nomServicio + " (Id: " + item + ")")); } else if (f > 0) { doc.Add(new Paragraph(" ----> Cantidad: " + item)); } f++; } } doc.Add(new Paragraph("------------------------------------------------------------------------------------------")); doc.Add(new Paragraph("Monto a cobrar: " + monto)); doc.Add(new Paragraph("------------------------------------------------------------------------------------------")); doc.Add(new Paragraph("------------------------------------------------------------------------------------------")); doc.Add(new Paragraph("------------------------------------------------------------------------------------------")); doc.AddCreationDate(); doc.Close(); } }