local nRowsCount = Grid.GetRowCount("Grid1");
if nRowsCount > 0 then
nTotal =1
for count=1,nRowsCount do
nTotal = Grid.GetCellText("Grid1", count, 50)
sFactura = Input.GetText("Inp_Factura");
sIgv = ComboBox.GetText("Cbx_Impuesto")
sCliente = Input.GetText("Inp_Cliente");
sDireccion = Input.GetText("Inp_Direccion");
sVendedor = ComboBox.GetText("Cbx_Vendedor");
sFecha = Label.GetText("LblFecha");
sHora = Label.GetText("LblHora");
sCodigo1 = Grid.GetCellText("Grid1", count, 1);
sUnidad1 = Grid.GetCellText("Grid1", count, 2);
sNombre1 = Grid.GetCellText("Grid1", count, 3);
sVenta1 = Grid.GetCellText("Grid1", count, 4);
sTotal1 = Grid.GetCellText("Grid1", count, 5);
sCodigo2 = Grid.GetCellText("Grid1", count, 6);
sUnidad2 = Grid.GetCellText("Grid1", count, 7);
sNombre2 = Grid.GetCellText("Grid1", count, 8);
sVenta2 = Grid.GetCellText("Grid1", count, 9);
sTotal2 = Grid.GetCellText("Grid1", count, 10);
sCodigo3 = Grid.GetCellText("Grid1", count, 11);
sUnidad3 = Grid.GetCellText("Grid1", count, 12);
sNombre3 = Grid.GetCellText("Grid1", count, 13);
sVenta3 = Grid.GetCellText("Grid1", count, 14);
sTotal3 = Grid.GetCellText("Grid1", count, 15);
sCodigo4 = Grid.GetCellText("Grid1", count, 16);
sUnidad4 = Grid.GetCellText("Grid1", count, 17);
sNombre4 = Grid.GetCellText("Grid1", count, 18);
sVenta4 = Grid.GetCellText("Grid1", count, 19);
sTotal4 = Grid.GetCellText("Grid1", count, 20);
sCodigo5 = Grid.GetCellText("Grid1", count, 21);
sUnidad5 = Grid.GetCellText("Grid1", count, 22);
sNombre5 = Grid.GetCellText("Grid1", count, 23);
sVenta5 = Grid.GetCellText("Grid1", count, 24);
sTotal5 = Grid.GetCellText("Grid1", count, 25);
sCodigo6 = Grid.GetCellText("Grid1", count, 26);
sUnidad6 = Grid.GetCellText("Grid1", count, 27);
sNombre6 = Grid.GetCellText("Grid1", count, 28);
sVenta6 = Grid.GetCellText("Grid1", count, 29);
sTotal6 = Grid.GetCellText("Grid1", count, 30);
sCodigo7 = Grid.GetCellText("Grid1", count, 31);
sUnidad7 = Grid.GetCellText("Grid1", count, 32);
sNombre7 = Grid.GetCellText("Grid1", count, 33);
sVenta7 = Grid.GetCellText("Grid1", count, 34);
sTotal7 = Grid.GetCellText("Grid1", count, 35);
sCodigo8 = Grid.GetCellText("Grid1", count, 36);
sUnidad8 = Grid.GetCellText("Grid1", count, 37);
sNombre8 = Grid.GetCellText("Grid1", count, 38);
sVenta8 = Grid.GetCellText("Grid1", count, 39);
sTotal8 = Grid.GetCellText("Grid1", count, 40);
sCodigo9 = Grid.GetCellText("Grid1", count, 41);
sUnidad9 = Grid.GetCellText("Grid1", count, 42);
sNombre9 = Grid.GetCellText("Grid1", count, 43);
sVenta9 = Grid.GetCellText("Grid1", count, 44);
sTotal9 = Grid.GetCellText("Grid1", count, 45);
sCodigo10 = Grid.GetCellText("Grid1", count, 46);
sUnidad10 = Grid.GetCellText("Grid1", count, 47);
sNombre10 = Grid.GetCellText("Grid1", count, 48);
sVenta10 = Grid.GetCellText("Grid1", count, 49);
sTotal10 = Grid.GetCellText("Grid1", count, 50);
sSubTotal = Paragraph.GetText("to_Descuento");
sImpuesto = Paragraph.GetText("to_Impuesto")
sTotalFinal = Paragraph.GetText("TotalPago");
SQLite.Query(db, "insert into Facturas values(NULL, '"..sFactura .."', '"..sIgv .."', '"..sCliente .."', '"..sDireccion .."', '"..sVendedor .."', '"..sFecha .."', '"..sHora .."', '"..sCodigo1 .."', '"..sUnidad1 .."', '"..sNombre1 .."', '"..sVenta1 .."', '"..sTotal1 .."', '"..sCodigo2 .."', '"..sUnidad2 .."', '"..sNombre2 .."', '"..sVenta2 .."', '"..sTotal2 .."', '"..sCodigo3 .."', '"..sUnidad3 .."', '"..sNombre3 .."', '"..sVenta3 .."', '"..sTotal3 .."', '"..sCodigo4 .."', '"..sUnidad4 .."', '"..sNombre4 .."', '"..sVenta4 .."', '"..sTotal4 .."', '"..sCodigo5 .."', '"..sUnidad5 .."', '"..sNombre5 .."', '"..sVenta5 .."', '"..sTotal5 .."', '"..sCodigo6 .."', '"..sUnidad6 .."', '"..sNombre6 .."', '"..sVenta6 .."', '"..sTotal6 .."', '"..sCodigo7 .."', '"..sUnidad7 .."', '"..sNombre7 .."', '"..sVenta7 .."', '"..sTotal7 .."', '"..sCodigo8 .."', '"..sUnidad8 .."', '"..sNombre8 .."', '"..sVenta8 .."', '"..sTotal8 .."', '"..sCodigo9 .."', '"..sUnidad9 .."', '"..sNombre9 .."', '"..sVenta9 .."', '"..sTotal9 .."', '"..sCodigo10 .."', '"..sUnidad10 .."', '"..sNombre10 .."', '"..sVenta10 .."', '"..sTotal10 .."', '"..sSubTotal .."', '"..sImpuesto .."', '"..sTotalFinal.."')");
Dialog.TimedMessage("Informe", "Felicidades "..sCliente.." La Factura se a creado con exito", 2000, MB_ICONINFORMATION)
nLastError = Application.GetLastError();
if nLastError ~= SQLite.OK then
Dialog.Message("Error: "..nLastError, SQLite.GetLastErrorString());
end
end
end
DialogEx.Show("AgFac");