Example #1
0
 protected void Sacar_Sqls(FacturaCliente fc, ref ArrayList sqlStrings)
 {
     for (int i = 0; i < fc.SqlStrings.Count; i++)
     {
         sqlStrings.Add(fc.SqlStrings[i]);
     }
 }
Example #2
0
 protected void Grabar_Factura(Object Sender, EventArgs E)
 {
     //Primero debemos revisar que se haya digitado una cantidad de dias valida
     if (DatasToControls.ValidarInt(diasPlazo.Text))
     {
         if (System.Convert.ToInt32(diasPlazo.Text) > 0)
         {
             FacturaCliente miFacturaCliente = new FacturaCliente("FG", prefFact.Text, nitCSAEX.Text, almacen.SelectedValue, "F", Convert.ToUInt32(numFact.Text), Convert.ToUInt32(diasPlazo.Text), Convert.ToDateTime(fechFactura.Text), Convert.ToDateTime(fechFactura.Text).AddDays(Convert.ToInt32(diasPlazo.Text)), Convert.ToDateTime(null), Convert.ToDouble(totalApro.Text.Substring(1)), Convert.ToDouble(totalIva.Text.Substring(1)), 0, 0, 0, 0, centCostos.SelectedValue, obsrv.Text, DBFunctions.SingleData("SELECT pven_codigo FROM ccartera"), HttpContext.Current.User.Identity.Name.ToLower(), null);
             miFacturaCliente.SqlRels = ArmarDetalles();
             //Ahora creamos nuestro objeto de tipo FacturaGarantias
             if (miFacturaCliente.GrabarFacturaCliente(true))
             {
                 Response.Redirect("" + indexPage + "?process=Automotriz.GarantiasAprobadas&prefF=" + miFacturaCliente.PrefijoFactura + "&numF=" + miFacturaCliente.NumeroFactura + "");
             }
             //lb.Text += miFacturaCliente.ProcessMsg;
             else
             {
                 lb.Text += miFacturaCliente.ProcessMsg;
             }
         }
         else
         {
             Utils.MostrarAlerta(Response, "Valor de dias de plazo no puede ser negativo. Revise por favor");
         }
     }
     else
     {
         Utils.MostrarAlerta(Response, "Valor de dias de plazo no valido. Revise por favor");
     }
 }
Example #3
0
        protected bool Liquidar_Intereses(ref ArrayList sqls)
        {
            int            i, j;
            double         valIva    = 0;
            bool           exito     = true;
            FacturaCliente miFactura = new FacturaCliente();
            uint           numero    = Convert.ToUInt32(DBFunctions.SingleData("SELECT pdoc_ultidocu FROM pdocumento WHERE pdoc_codigo='" + ddlPrefijo.SelectedValue + "'"));

            if (!Validar_PreLiq())
            {
                for (i = 0; i < dtPreLiq.Rows.Count; i++)
                {
                    if (Convert.ToBoolean(dtPreLiq.Rows[i][4]))
                    {
                        numero++;
                        if (DBFunctions.SingleData("SELECT ccar_cobivaintmor FROM ccartera") == "S")
                        {
                            valIva    = Convert.ToDouble(dtPreLiq.Rows[i][3]) * 0.16;
                            miFactura = new FacturaCliente("FC", ddlPrefijo.SelectedValue, dtPreLiq.Rows[i][0].ToString(), ddlAlmacen.SelectedValue, "F", numero,
                                                           5, DateTime.Now, DateTime.Now, Convert.ToDateTime(null), Convert.ToDouble(dtPreLiq.Rows[i][3]), valIva,
                                                           0, 0, 0, 0, DBFunctions.SingleData("SELECT pcen_centcart FROM palmacen WHERE tvig_vigencia='V' and palm_almacen='" + ddlAlmacen.SelectedValue + "'"),
                                                           "Factura de Intereses por Mora", DBFunctions.SingleData("SELECT pven_codigo FROM ccartera"), HttpContext.Current.User.Identity.Name.ToLower(), null);
                            final.Add(miFactura.PrefijoFactura + "-" + miFactura.NumeroFactura);
                            Session["final"] = final;
                        }
                        else
                        {
                            miFactura = new FacturaCliente("FC", ddlPrefijo.SelectedValue, dtPreLiq.Rows[i][0].ToString(), ddlAlmacen.SelectedValue, "F", numero,
                                                           5, DateTime.Now, DateTime.Now, Convert.ToDateTime(null), Convert.ToDouble(dtPreLiq.Rows[i][3]), 0,
                                                           0, 0, 0, 0, DBFunctions.SingleData("SELECT pcen_centcart FROM palmacen WHERE tvig_vigencia='V' and palm_almacen='" + ddlAlmacen.SelectedValue + "'"),
                                                           "Factura de Intereses por Mora", DBFunctions.SingleData("SELECT pven_codigo FROM ccartera"), HttpContext.Current.User.Identity.Name.ToLower(), null);
                            final.Add(miFactura.PrefijoFactura + "-" + miFactura.NumeroFactura);
                            Session["final"] = final;
                        }
                        for (j = 0; j < detalles.Count; j++)
                        {
                            string[] partes = null;
                            partes = detalles[j].ToString().Split('@');
                            if (dtPreLiq.Rows[i][0].ToString() == partes[0].ToString())
                            {
                                miFactura.SqlRels.Add("INSERT INTO dfacturaclientemora VALUES('@1',@2,'" + partes[1].ToString() + "'," + partes[2].ToString() + "," + Convert.ToDouble(partes[4]) + "," + Convert.ToInt32(partes[5]) + ")");
                            }
                        }
                        if (miFactura.GrabarFacturaCliente(false))
                        {
                            Sacar_Sqls(miFactura, ref sqls);
                        }
                        else
                        {
                            sqls.Add(miFactura.ProcessMsg);
                        }
                    }
                }
            }
            else
            {
                exito = false;
            }
            return(exito);
        }
Example #4
0
        protected void Guardar_Cliente(DataTable dtConceptos, ref ArrayList sqlStrings)
        {
            ArrayList totales = new ArrayList();

            facs    = new ArrayList();
            totales = this.Calcular_Totales();
            FacturaCliente miFactura = new FacturaCliente();
            string         completo;

            string[] partes;
            int      numero = Convert.ToInt32(DBFunctions.SingleData("SELECT pdoc_ultidocu FROM dbxschema.pdocumento WHERE pdoc_codigo='" + this.ddlPrefijo.SelectedValue + "'"));

            // Se actualiza el valor del servicio a los clientes que este mes se cumple un Año de contrato
            miFactura.SqlRels.Add("UPDATE pcausacioncliente SET PCAU_VALOCAUS = ROUND(PCAU_VALOCAUS*(1+(PCAU_PORCINCR*0.01)),0) WHERE MONTH(PCAU_FECHINIC) = (SELECT PMES_MESVIGENTE FROM CCARTERA);");

            for (int i = 0; i < totales.Count; i++)
            {
                completo  = totales[i].ToString();
                partes    = completo.Split('-');
                miFactura = new FacturaCliente(ddlPrefijo.SelectedValue, ddlPrefijo.SelectedValue, partes[0], ddlAlmacen.SelectedValue, "F", Convert.ToUInt32(numero + i + 1), Convert.ToUInt32(DBFunctions.SingleData("SELECT CASE WHEN mcli_diasplaz IS NULL THEN 0 ELSE mcli_diasplaz END CASE FROM dbxschema.mcliente WHERE mnit_nit='" + partes[0] + "'")), DateTime.Now.Date, DateTime.Now.AddDays(Convert.ToInt32(DBFunctions.SingleData("SELECT CASE WHEN mcli_diasplaz IS NULL THEN 0 ELSE mcli_diasplaz END CASE FROM dbxschema.mcliente WHERE mnit_nit='" + partes[0] + "'"))), Convert.ToDateTime(null), Convert.ToDouble(partes[1]), Convert.ToDouble(partes[2]), 0, 0, 0, 0, DBFunctions.SingleData("SELECT pcen_codigo FROM cempresa"), tbDetalle.Text, DBFunctions.SingleData("SELECT pven_codigo FROM ccartera"), HttpContext.Current.User.Identity.Name.ToLower(), null);
                facs.Add(ddlPrefijo.SelectedValue + "-" + (numero + i + 1).ToString());
                Session["facs"] = facs;
                for (int j = 0; j < dtConceptos.Rows.Count; j++)
                {
                    if (dtConceptos.Rows[j][0].ToString() == partes[0])
                    {
                        miFactura.SqlRels.Add("INSERT INTO dfacturacliente VALUES(default,'@1',@2,'" + dtConceptos.Rows[j][3].ToString() + " " + tbDetalle.Text + "', " + dtConceptos.Rows[j][1].ToString() + "," + (Convert.ToDouble(dtConceptos.Rows[j][1]) * (Convert.ToDouble(dtConceptos.Rows[j][2]) / 100)).ToString() + ")");
                    }
                }
                if (miFactura.GrabarFacturaCliente(false))
                {
                    this.Sacar_Sqls(miFactura, ref sqlStrings);
                }
                else
                {
                    sqlStrings.Add(miFactura.ProcessMsg);
                }
            }
        }
Example #5
0
        //Aqui vamos a crear la funcion que nos crea la factura dentro de la base de datos
        public bool Grabar_Factura_Pedido(string prefijoPedido, string numeroPedido)
        {
            //FacturaPedido FacturaPedidos = new FacturaPedido();
            //FacturaPedidos.Grabar_Factura_Pedido(string prefijopedi,string numped);
            ArrayList sqlStrings                = new ArrayList();
            ArrayList prefijoPedidoRetoma       = new ArrayList();
            ArrayList numeroPedidoRetoma        = new ArrayList();
            ArrayList estadoActualizacionNumero = new ArrayList();
            bool      status = false;
            int       i;
            //Revisamos si existe alguna factura de cliente con este prefijo y este numero

            /*while(DBFunctions.RecordExist("SELECT * FROM mfacturacliente WHERE pdoc_codigo='"+prefijoFactura+"' AND mfac_numedocu="+numeroFactura+""))
             *      numeroFactura = (Convert.ToInt32(numeroFactura)+1).ToString();*/
            //Averiguamos los días de plazo de este cliente.
            uint diasP = Convert.ToUInt32(DBFunctions.SingleData("Select coalesce(mcli_diasplaz,0) from DBXSCHEMA.MCLIENTE where mnit_nit='" + this.nitCliente + "'"));

            if (Convert.ToString(diasP) == String.Empty)
            {
                diasP = 0;
            }
            //Ahora vamos a grabar el registro de mfacturacliente
            // old sqlStrings.Add("INSERT INTO mfacturacliente VALUES('"+this.prefijoFactura+"',"+this.numeroFactura+",'"+this.nitCliente+"','"+this.almacen+"','F','V','"+this.fechaFactura+"','"+this.fechaVencimiento+"','"+this.fechaPago+"',"+this.valorFactura+","+this.valorIva+","+this.valorFletes+","+this.valorIvaFletes+","+this.valorRetenciones+","+this.valorAbonado+","+this.valorCosto+",0,'"+this.centroCosto+"','"+this.observacion+"','"+this.codigoVendedor+"','"+this.usuario+"','"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"')");
            FacturaCliente FacturaClientes  = new FacturaCliente("V", this.prefijoFactura, this.nitCliente, this.almacen, "F", Convert.ToUInt32(this.numeroFactura), diasP, Convert.ToDateTime(this.fechaFactura), Convert.ToDateTime(this.fechaVencimiento), Convert.ToDateTime(this.fechaPago), Convert.ToDouble(this.valorFactura), Convert.ToDouble(this.valorIva), Convert.ToDouble(this.valorFletes), Convert.ToDouble(this.valorIvaFletes), Convert.ToDouble(this.valorRetenciones), Convert.ToDouble(this.valorCosto), this.centroCosto, this.observacion, this.codigoVendedor, this.usuario, null);
            int            numeroInventario = Convert.ToInt32(DBFunctions.SingleData("Select mveh_inventario from DBXSCHEMA.MasignacionVEHICULO where PDOC_CODIGO = '" + prefijoPedido + "' AND MPED_NUMEPEDI = " + numeroPedido + ";"));

            //Ahora vamos a guardar el registro que nos enlaza la factura con el pedido
            // old sqlStrings.Add("INSERT INTO mfacturapedidovehiculo VALUES('"+this.prefijoFactura+"',"+this.numeroFactura+",'"+prefijoPedido+"',"+numeroPedido+",'C','"+this.fechaHoraCreacion+"')");
            sqlStrings.Add("INSERT INTO mfacturapedidovehiculo VALUES('@1',@2,'" + prefijoPedido + "'," + numeroPedido + ",'C'," + numeroInventario + ")");
            //Ahora se crea un solo pedido para el cliente de retoma
            sqlStrings.Add("INSERT INTO mpedidovehiculoproveedor VALUES('" + this.prefijoPedidoRetoma + "'," + DBFunctions.SingleData("SELECT pdoc_ultidocu + 1 FROM pdocumento WHERE pdoc_codigo='" + this.prefijoPedidoRetoma + "'") + ",'" + this.fechaFactura + "','" + this.nitCliente + "','Retoma Vehiculo Usado')");
            //Ahora grabamos los registros de dpedidovehiculoproveedor
            for (i = 0; i < vehiculosRetoma.Rows.Count; i++)
            {
                sqlStrings.Add("INSERT INTO dpedidovehiculoproveedor VALUES('" + this.prefijoPedidoRetoma + "'," + DBFunctions.SingleData("SELECT pdoc_ultidocu + 1 FROM pdocumento WHERE pdoc_codigo='" + this.prefijoPedidoRetoma + "'") + ",'" + vehiculosRetoma.Rows[i][0].ToString() + "','" + vehiculosRetoma.Rows[i][1].ToString() + "','" + vehiculosRetoma.Rows[i][1].ToString() + "',1,0," + vehiculosRetoma.Rows[i][2].ToString() + ")");
                sqlStrings.Add("INSERT INTO mretomavehiculo VALUES('@1',@2,'" + this.prefijoPedidoRetoma + "'," + DBFunctions.SingleData("SELECT pdoc_ultidocu + 1 FROM pdocumento WHERE pdoc_codigo='" + this.prefijoPedidoRetoma + "'") + ",'" + vehiculosRetoma.Rows[i][0].ToString() + "','" + vehiculosRetoma.Rows[i][1].ToString() + "','" + vehiculosRetoma.Rows[i][3].ToString() + "'," + vehiculosRetoma.Rows[i][4].ToString() + ",'" + vehiculosRetoma.Rows[i][5].ToString() + "','" + vehiculosRetoma.Rows[i][6].ToString() + "',default)");
            }
            sqlStrings.Add("UPDATE pdocumento SET pdoc_ultidocu=pdoc_ultidocu+1 WHERE pdoc_codigo='" + this.prefijoPedidoRetoma + "'");
            //Ahora colocamos el vehiculo como facturado
            sqlStrings.Add("UPDATE mvehiculo SET test_tipoesta=40 WHERE mveh_inventario=" + this.numeroInventario + "");
            //Ahora debemos ingresar los elementos de venta de esta factura en la tabla mfacturaelementosventa
            //   if(1==0) // si configura facturar los elementos de la venta
            {
                for (i = 0; i < elementosVenta.Rows.Count; i++)
                {
                    sqlStrings.Add("INSERT INTO mfacturaelementosventa VALUES('@1',@2,'" + DBFunctions.SingleData("SELECT pite_codigo FROM pitemventavehiculo WHERE pite_nombre='" + elementosVenta.Rows[i][0].ToString() + "'") + "'," + elementosVenta.Rows[i][1].ToString() + ")");
                }
            }
            //Ahora revisamos si es necesario que se cree una factura para la financiera
            if (this.prefijoFacturaFinanciera != "")
            {
                string numeroFacturaFinanciera = "";
                if (prefijoFacturaFinanciera == prefijoFactura)
                {
                    numeroFacturaFinanciera = (Convert.ToInt32(numeroFactura) + 1).ToString();
                }
                else
                {
                    DBFunctions.SingleData("SELECT pdoc_ultidocu+1 FROM pdocumento WHERE pdoc_codigo='" + prefijoFacturaFinanciera + "'");
                }
                while (DBFunctions.RecordExist("SELECT * FROM mfacturacliente WHERE pdoc_codigo='" + prefijoFacturaFinanciera + "' AND mfac_numedocu=" + numeroFacturaFinanciera + ""))
                {
                    numeroFacturaFinanciera = (Convert.ToInt32(numeroFacturaFinanciera) + 1).ToString();
                }
                //Ahora vamos a grabar el registro de mfacturacliente
                sqlStrings.Add("INSERT INTO mfacturacliente VALUES('" + this.prefijoFacturaFinanciera + "'," + numeroFacturaFinanciera + ",'" + this.nitFinanciera + "','" + this.almacen + "','F','V','" + this.fechaFactura + "','" + this.fechaVencimiento + "','" + this.fechaPago + "'," + this.valorFinanciado + "," + this.valorIvaFinanciado + "," + this.valorFletes + "," + this.valorIvaFletes + "," + this.valorRetenciones + ",0," + this.valorCosto + ",0,'" + this.centroCosto + "','Factura A Financiera','" + this.codigoVendedor + "','" + this.usuario + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')");
                //Ahora vamos a guardar el registro que nos enlaza la factura con el pedido
                sqlStrings.Add("INSERT INTO mfacturapedidovehiculo VALUES('" + this.prefijoFacturaFinanciera + "'," + numeroFacturaFinanciera + ",'" + prefijoPedido + "'," + numeroPedido + ",'F','" + numeroInventario + "')");
                //Ahora relacionamos la factura del cliente con la factura de la financiera
                sqlStrings.Add("INSERT INTO mfacturaclienteotrospagos VALUES('@1',@2,'" + this.prefijoFacturaFinanciera + "'," + numeroFacturaFinanciera + ")");
                //Ahora actualizamos el numero de consecutivo de la factura de financiera generada
                sqlStrings.Add("UPDATE pdocumento SET pdoc_ultidocu=" + (Convert.ToInt32(numeroFacturaFinanciera)).ToString() + " WHERE pdoc_codigo='" + this.prefijoFacturaFinanciera + "'");
            }
            //Se actualiza el numero del docuemnto de la factura
            sqlStrings.Add("UPDATE pdocumento SET pdoc_ultidocu=" + (Convert.ToInt32(this.numeroFactura)).ToString() + " WHERE pdoc_codigo='" + this.prefijoFactura + "'");
            //Ahora Cambiamos el estado del pedido
            sqlStrings.Add("UPDATE mpedidovehiculo SET test_tipoesta=30 WHERE pdoc_codigo='" + prefijoPedido + "' AND mped_numepedi=" + numeroPedido + "");
            //Ahora debemos relacionar los anticipos con la factura creada, Deebemos traer todos los anticipos y relacionarlos
            DataSet anticiposHechos = new DataSet();

            DBFunctions.Request(anticiposHechos, IncludeSchema.NO, "SELECT pdoc_codigo, mcaj_numero, mant_valorecicaja FROM manticipovehiculo WHERE mped_codigo='" + prefijoPedido + "' AND mped_numepedi=" + numeroPedido + "");
            for (i = 0; i < anticiposHechos.Tables[0].Rows.Count; i++)
            {
                //sqlStrings.Add("INSERT INTO dcajacliente VALUES('"+anticiposHechos.Tables[0].Rows[i][0].ToString()+"',"+anticiposHechos.Tables[0].Rows[i][1].ToString()+",'"+this.prefijoFactura+"',"+this.numeroFactura+","+anticiposHechos.Tables[0].Rows[i][2].ToString()+",'A')");
                sqlStrings.Add("INSERT INTO ddetallefacturacliente VALUES('@1',@2,'" + anticiposHechos.Tables[0].Rows[i][0].ToString() + "'," + anticiposHechos.Tables[0].Rows[i][1].ToString() + "," + anticiposHechos.Tables[0].Rows[i][2].ToString() + ",'Anticipo a Pedido')");
                sqlStrings.Add("UPDATE MANTICIPOVEHICULO SET TEST_ESTADO = 30 WHERE PDOC_CODIGO = '" + anticiposHechos.Tables[0].Rows[i][0].ToString() + "' AND MCAJ_NUMERO = " + anticiposHechos.Tables[0].Rows[i][1].ToString() + " AND mped_codigo='" + prefijoPedido + "' AND mped_numepedi=" + numeroPedido + " ");
                FacturaClientes.AgregarPago(anticiposHechos.Tables[0].Rows[i][0].ToString(), Convert.ToUInt32(anticiposHechos.Tables[0].Rows[i][1]), Convert.ToDouble(anticiposHechos.Tables[0].Rows[i][2]), "Anticipo a Pedido");
            }

            FacturaClientes.SqlRels = sqlStrings;
            //oldif(DBFunctions.Transaction(sqlStrings))
            if (FacturaClientes.GrabarFacturaCliente(true))
            {
                status      = true;
                processMsg += FacturaClientes.ProcessMsg + "<br>";
            }
            else
            {
                processMsg += "Error: " + FacturaClientes.ProcessMsg + "<br><br>";
            }
            return(status);
        }
Example #6
0
        //Facturar
        protected void Facturar(Object Sender, EventArgs e)
        {
            //Almacena sentencias de faturacion
            ArrayList sqlRefs = null;
            //string vinsVehiculos="";
            string    codVendedor = txtCodVendedor.Text.Trim();
            string    codAlmacen  = ddlAlmacen.SelectedValue;
            string    codCentroCosto;
            string    prefijoFac = prefijoFactura.SelectedValue;
            uint      numeroFac  = Convert.ToUInt16(numeroFactura.Text);
            string    cliente    = nitCliente.Text;
            DateTime  fechaFactura;
            double    totalVehiculos = 0, totalDescuentos = 0, totalIVA = 0, valRetenciones = 0, ivaFletes = 0, valIVAFletes = 0, valFletes = 0, totalFactura = 0, saldoCartera, cupo;
            DataTable dtVehiculos = (DataTable)Session["TABLA_MDEVOLUCIONES"];

            DataRow[] drVehiculo = dtVehiculos.Select("USADO=1");
            int       idUsuario  = Convert.ToInt16(DBFunctions.SingleData("select susu_codigo from susuario where susu_login='******'"));

            //Verificar mfactura no se ha devuelto
            if (!DBFunctions.RecordExist("SELECT MFAC_NUMEDOCU FROM DBXSCHEMA.DFACTURAPEDIDOMAYORVEHICULO WHERE PDOC_CODIGO='" + ddlFacturaD.SelectedValue + "' AND MFAC_NUMEDOCU=" + ddlNumFacturaD.SelectedValue + " AND MFAC_NUMEDOCUDEV IS NULL;"))
            {
                Utils.MostrarAlerta(Response, "La factura no esta disponible para devoluciones.");
                return;
            }
            //Verificar vehiculos seleccionados
            if (drVehiculo.Length == 0)
            {
                Utils.MostrarAlerta(Response, "No seleccionó ningún vehículo");
                return;
            }

            //Validar fecha
            try
            {
                fechaFactura = Convert.ToDateTime(txtFechaFac.Text);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "Fecha no válida");
                return;
            }

            //Valor Fletes y retenciones
            try
            {
                if (txtRetenciones.Text.Length > 0)
                {
                    valRetenciones = Convert.ToDouble(txtRetenciones.Text);
                }
                if (txtFletes.Text.Length > 0)
                {
                    valFletes = Convert.ToDouble(txtFletes.Text);
                }
                ivaFletes = Convert.ToDouble(ddlIVAFletes.SelectedValue);
                if (ivaFletes < 0 || valFletes < 0 || valRetenciones < 0)
                {
                    throw(new Exception());
                }
                valIVAFletes = ((valFletes * ivaFletes) / 100);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "Revise el valor de retenciones y fletes");
                return;
            }

            //Saldo, cupo
            try
            {
                saldoCartera = Convert.ToDouble(txtSaldoCartera.Text.Replace(",", ""));
                cupo         = Convert.ToDouble(txtCupo.Text.Replace(",", ""));
            }
            catch
            {
                saldoCartera = 0;
                cupo         = 0;
                Utils.MostrarAlerta(Response, "Revise el saldo y cupo del cliente");
                //	return;
            }

            //Centro de costo
            codCentroCosto = DBFunctions.SingleData("SELECT pcen_centvvn FROM palmacen WHERE tvig_vigencia='V' and palm_almacen='" + codAlmacen + "'");

            //Traer los dias de plazo fecha de vencimiento factura
            string mfac_vence = DBFunctions.SingleData("select mcli_diasplaz from dbxschema.mcliente where mnit_nit='" + cliente + "'");

            if (mfac_vence != String.Empty)
            {
                mfac_vence = fechaFactura.AddDays(Convert.ToDouble(mfac_vence)).ToString("yyyy-MM-dd");
            }
            else
            {
                mfac_vence = fechaFactura.ToString("yyyy-MM-dd");
            }

            //Generar sentencias relacionadas al proceso de devolucion
            Pedidos.DevolucionVehiculosMayorCliente(ref sqlRefs, ddlFacturaD.SelectedValue, ddlNumFacturaD.SelectedValue, prefijoFactura.SelectedValue, numeroFactura.Text, dtVehiculos, nitCliente.Text, ref totalVehiculos, ref totalDescuentos, ref totalIVA, ref totalFactura, fechaFactura, idUsuario);

            totalFactura += valRetenciones + valFletes + valIVAFletes;

            //Si valor a FACTURAR mas el SALDO EN CARTERA es mayor al cupo y el cupo>0 mostrar advertencia
            if (cupo > 0 && cupo - (totalFactura + saldoCartera) < 0 && lblAdvertencia.Text.Length == 0)
            {
                lblAdvertencia.Text = "Advertencia: el cupo del cliente es menor al saldo en cartera mas el valor de la factura. Para continuar de todas formas vuelva a dar click en facturar.";
            }

            //VERIFICAR numero de factura esta disponible, cambiarlo si no es manual
            if (DBFunctions.RecordExist("select * from mfacturacliente where pdoc_codigo='" + prefijoFac + "' and mfac_numedocu=" + numeroFac))
            {
                if (tipoFacturacion.SelectedValue.ToString() == "A")
                {
                    numeroFac = Convert.ToUInt16(DBFunctions.SingleData("SELECT pdoc_ultidocu + 1 FROM pdocumento WHERE pdoc_codigo='" + prefijoFac + "'"));
                }
                else
                {
                    Utils.MostrarAlerta(Response, "Ya se utilizó el número de factura");
                    return;
                }
            }

            //Revisamos si es necesario crear la factura de financiera, se crea como una factura de cliente al nit de la financiera y se agrega esta factura como un pago a la factura de nuestro cliente
            FacturaCliente facturaVentaVehiculo = new FacturaCliente("FVV", prefijoFac, cliente, codAlmacen, "N", numeroFac,
                                                                     0, fechaFactura, Convert.ToDateTime(mfac_vence), DateTime.Now, totalVehiculos - totalDescuentos, totalIVA,
                                                                     valFletes, valIVAFletes, valRetenciones, 0, codCentroCosto, observaciones.Text, codVendedor, HttpContext.Current.User.Identity.Name, null);

            facturaVentaVehiculo.SqlRels = sqlRefs;

            //Como no es necesaria realizar la retoma entonces grabamos la factura directamente
            if (facturaVentaVehiculo.GrabarFacturaCliente(true))
            {
                Session.Remove("TABLA_MDEVOLUCIONES");
                Response.Redirect("" + indexPage + "?process=Vehiculos.DevolucionPedidoMayor&prefFC=" + facturaVentaVehiculo.PrefijoFactura + "&numFC=" + facturaVentaVehiculo.NumeroFactura + "&path=" + Request.QueryString["path"]);
            }
            else
            {
                lb.Text += "Error: " + facturaVentaVehiculo.ProcessMsg;
            }
        }
Example #7
0
        public bool Guardar_Factura()
        {
            bool             estado      = false;
            FacturaCliente   miFactura   = new FacturaCliente();
            FacturaProveedor miFacturaP  = new FacturaProveedor();
            ArrayList        sqlStrings  = new ArrayList();
            ArrayList        sqlOpcional = new ArrayList();
            int i;

            if (tipoFactura == "C")
            {
                miFactura = new FacturaCliente("FC", this.prefijoFactura, this.nit, this.almacen, "A", Convert.ToUInt32(this.numeroFactura), Convert.ToUInt32(diasPlazo), Convert.ToDateTime(this.fecha), Convert.ToDateTime(fechaVencimiento), Convert.ToDateTime(null), this.valorFactura, this.valorIva, this.valorFletes, this.valorIvaFletes, this.valorRete, this.costoFactura, this.centroCosto, this.observacion, this.vendedor, this.usuario, null);
                //							  0				1			2			3		4						5				  6					7							8											9					10				11				12					13				14				15					16				17				18			19
                //Activos Fijos
                if (tipoGasto == "1")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        sqlStrings.Add("INSERT INTO dgastoactivocliente VALUES('@1',@2,1," + this.tablaDetallesFactura.Rows[i][0].ToString() + ",'" + this.tablaDetallesFactura.Rows[i][1].ToString() + "'," + Convert.ToDouble(this.tablaDetallesFactura.Rows[i][3].ToString().Substring(1)) + ")");
                        sqlStrings.Add("UPDATE mactivofijo SET tvig_vigencia='C' WHERE mafj_codiacti='" + tablaDetallesFactura.Rows[i][1].ToString() + "'");
                    }
                }
                //Gastos Diferidos
                else if (tipoGasto == "2")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        sqlStrings.Add("INSERT INTO dgastodiferidocliente VALUES('@1',@2,2," + this.tablaDetallesFactura.Rows[i][0].ToString() + ",'" + this.tablaDetallesFactura.Rows[i][1].ToString() + "'," + Convert.ToDouble(this.tablaDetallesFactura.Rows[i][3].ToString().Substring(1)) + ")");
                    }
                }
                //Gastos Operativos
                else if (tipoGasto == "3")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        if (this.tablaDetallesFactura.Rows[i][2].ToString() == "")
                        {
                            sqlStrings.Add("INSERT INTO dgastooperativocliente VALUES('@1',@2,3," + this.tablaDetallesFactura.Rows[i][0].ToString() + ",'" + this.tablaDetallesFactura.Rows[i][1].ToString() + "',null," + Convert.ToDouble(this.tablaDetallesFactura.Rows[i][3].ToString().Substring(1)) + "," + i + ")");
                        }
                        else
                        {
                            sqlStrings.Add("INSERT INTO dgastooperativocliente VALUES('@1',@2,3," + this.tablaDetallesFactura.Rows[i][0].ToString() + ",'" + this.tablaDetallesFactura.Rows[i][1].ToString() + "','" + this.tablaDetallesFactura.Rows[i][2].ToString() + "'," + Convert.ToDouble(this.tablaDetallesFactura.Rows[i][3].ToString().Substring(1)) + "," + i + ")");
                        }
                    }
                }
                //Gastos Varios
                else if (tipoGasto == "4")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        //Si es debito y tiene valor base
                        if (((Convert.ToDouble(tablaDetallesFactura.Rows[i][7].ToString())) != 0) && ((Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString())) != 0))
                        {
                            sqlStrings.Add("INSERT INTO dgastosvarioscliente VALUES('@1',@2," + i.ToString() + ",'" + tablaDetallesFactura.Rows[i][6].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][4].ToString().Trim() + "'," + System.Convert.ToInt32(tablaDetallesFactura.Rows[i][5].ToString().Trim()).ToString() + ",'" + tablaDetallesFactura.Rows[i][1].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][0].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][2].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][3].ToString().Trim() + "'," + System.Convert.ToDouble(tablaDetallesFactura.Rows[i][7].ToString()).ToString() + ",'D'," + System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString()).ToString() + ")");
                        }
                        //Si es debito y no tiene valor base
                        else if (((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][7].ToString())) != 0) && ((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString())) == 0))
                        {
                            sqlStrings.Add("INSERT INTO dgastosvarioscliente VALUES('@1',@2," + i.ToString() + ",'" + tablaDetallesFactura.Rows[i][6].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][4].ToString().Trim() + "'," + System.Convert.ToInt32(tablaDetallesFactura.Rows[i][5].ToString().Trim()).ToString() + ",'" + tablaDetallesFactura.Rows[i][1].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][0].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][2].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][3].ToString().Trim() + "'," + (System.Convert.ToDouble(tablaDetallesFactura.Rows[i][7].ToString())).ToString() + ",'D',0)");
                        }
                        //Si es credito y tiene valor base
                        else if (((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][8].ToString())) != 0) && ((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString())) != 0))
                        {
                            sqlStrings.Add("INSERT INTO dgastosvarioscliente VALUES('@1',@2," + i.ToString() + ",'" + tablaDetallesFactura.Rows[i][6].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][4].ToString().Trim() + "'," + System.Convert.ToInt32(tablaDetallesFactura.Rows[i][5].ToString().Trim()).ToString() + ",'" + tablaDetallesFactura.Rows[i][1].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][0].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][2].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][3].ToString().Trim() + "'," + (System.Convert.ToDouble(tablaDetallesFactura.Rows[i][8].ToString())).ToString() + ",'C'," + System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString()).ToString() + ")");
                        }
                        //Si es credito y no tiene valor base
                        else if (((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][8].ToString())) != 0) && ((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString())) == 0))
                        {
                            sqlStrings.Add("INSERT INTO dgastosvarioscliente VALUES('@1',@2," + i.ToString() + ",'" + tablaDetallesFactura.Rows[i][6].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][4].ToString().Trim() + "'," + System.Convert.ToInt64(tablaDetallesFactura.Rows[i][5].ToString().Trim()).ToString() + ",'" + tablaDetallesFactura.Rows[i][1].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][0].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][2].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][3].ToString().Trim() + "'," + (System.Convert.ToDouble(tablaDetallesFactura.Rows[i][8].ToString())).ToString() + ",'C',0)");
                        }
                    }
                }
                //Activos Fijos
                else if (tipoGasto == "5")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        sqlStrings.Add("INSERT INTO DACTIVOFIJOMEJORA VALUES('" + tablaDetallesFactura.Rows[i][1].ToString() + "'," + tablaDetallesFactura.Rows[i][3].ToString().Substring(1).Replace(",", "").Trim() + ",'" + observacion + "', '" + this.prefijoFactura + "', " + this.NumeroFactura + ", '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')");
                        sqlStrings.Add("UPDATE MACTIVOFIJO SET MAFJ_VALOMEJORA = " + tablaDetallesFactura.Rows[i][3].ToString().Substring(1).Replace(",", "").Trim() + " WHERE MAFJ_CODIACTI = '" + tablaDetallesFactura.Rows[i][1].ToString() + "'");
                    }
                }
                if (tablaRetenciones != null)
                {
                    if (tablaRetenciones.Rows.Count != 0)
                    {
                        for (i = 0; i < tablaRetenciones.Rows.Count; i++)
                        {
                            sqlStrings.Add("INSERT INTO mfacturaclienteretencion VALUES('@1',@2,'" + tablaRetenciones.Rows[i][0].ToString() + "'," + Convert.ToDouble(tablaRetenciones.Rows[i][3]).ToString() + "," + Convert.ToDouble(tablaRetenciones.Rows[i][2]).ToString() + ")");
                        }
                    }
                }
                if (tablaIva != null)
                {
                    if (tablaIva.Rows.Count != 0)
                    {
                        for (i = 0; i < tablaIva.Rows.Count; i++)
                        {
                            sqlStrings.Add("INSERT INTO dfacturaclienteiva VALUES('@1',@2," + tablaIva.Rows[i][0].ToString() + ",'" + tablaIva.Rows[i][3].ToString() + "','" + tablaIva.Rows[i][2].ToString() + "'," + tablaIva.Rows[i][1].ToString() + ")");
                        }
                    }
                }
                sqlStrings.Add("INSERT INTO mfacturaadministrativacliente VALUES('@1',@2,'" + cuenta + "')");
                miFactura.SqlRels = sqlStrings;
                if (miFactura.GrabarFacturaCliente(true))
                {
                    this.mensajes = miFactura.ProcessMsg;
                    estado        = true;
                }
                else
                {
                    this.mensajes = miFactura.ProcessMsg;
                }
            }
            else if (tipoFactura == "P")
            {
                miFacturaP = new FacturaProveedor("FP", prefijoFactura, prefijoProveedor, nit, almacen, "A", Convert.ToUInt64(numeroFactura), Convert.ToUInt64(numeroProveedor),
                                                  //								 0			1				2		  3		4	  5					6								7
                                                  "V", Convert.ToDateTime(fecha), Convert.ToDateTime(fechaVencimiento), Convert.ToDateTime(null), Convert.ToDateTime(fecha), valorFactura, valorIva,
                                                  //								8				9						10						11						12						13			14
                                                  valorFletes, valorIvaFletes, valorRete, observacion, usuario);
                //									15			16			 17			18		   19
                this.Sacar_Sqls(ref sqlStrings);
                // cuando el saldo de la factura sea 0, se pone la vigencia en C
                if (valorFactura + valorIva + valorFletes + valorIvaFletes - valorRete == 0)
                {
                    sqlStrings.Add("update MFACTURAPROVEEDOR SET TVIG_VIGENCIA = 'C' WHERE PDOC_CODIORDEPAGO = '@1' AND MFAC_NUMEORDEPAGO = @2 ");
                }
                //Activos Fijos
                if (tipoGasto == "1")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        sqlStrings.Add("INSERT INTO dgastoactivoproveedor VALUES('@1',@2,1," + this.tablaDetallesFactura.Rows[i][0].ToString() + ",'" + this.tablaDetallesFactura.Rows[i][1].ToString() + "'," + Convert.ToDouble(tablaDetallesFactura.Rows[i][3].ToString().Substring(1)) + ")");
                    }
                }
                //Gastos Diferidos
                else if (tipoGasto == "2")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        sqlStrings.Add("INSERT INTO dgastodiferidoproveedor VALUES('@1',@2,2," + this.tablaDetallesFactura.Rows[i][0].ToString() + ",'" + this.tablaDetallesFactura.Rows[i][1].ToString() + "'," + Convert.ToDouble(tablaDetallesFactura.Rows[i][3].ToString().Substring(1)) + ")");
                    }
                }
                //Gastos Operativos
                else if (tipoGasto == "3")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        if (this.tablaDetallesFactura.Rows[i][2].ToString() == "")
                        {
                            sqlStrings.Add("INSERT INTO dgastooperativoproveedor VALUES('@1',@2,3," + this.tablaDetallesFactura.Rows[i][0].ToString() + ",'" + this.tablaDetallesFactura.Rows[i][1].ToString() + "',null," + Convert.ToDouble(tablaDetallesFactura.Rows[i][3].ToString().Substring(1)) + "," + i + ")");
                        }
                        else
                        {
                            sqlStrings.Add("INSERT INTO dgastooperativoproveedor VALUES('@1',@2,3," + this.tablaDetallesFactura.Rows[i][0].ToString() + ",'" + this.tablaDetallesFactura.Rows[i][1].ToString() + "','" + this.tablaDetallesFactura.Rows[i][2].ToString() + "'," + Convert.ToDouble(tablaDetallesFactura.Rows[i][3].ToString().Substring(1)) + "," + i + ")");
                        }
                    }
                }
                //Gastos Varios
                else if (tipoGasto == "4")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        //Si es debito y tiene valor base
                        if (((Convert.ToDouble(tablaDetallesFactura.Rows[i][7].ToString())) != 0) && ((Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString())) != 0))
                        {
                            sqlStrings.Add("INSERT INTO dgastosvariosproveedor VALUES('@1',@2," + i.ToString() + ",'" + tablaDetallesFactura.Rows[i][6].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][4].ToString().Trim() + "'," + System.Convert.ToUInt64(tablaDetallesFactura.Rows[i][5].ToString().Trim()).ToString() + ",'" + tablaDetallesFactura.Rows[i][1].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][0].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][2].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][3].ToString().Trim() + "'," + System.Convert.ToDouble(tablaDetallesFactura.Rows[i][7].ToString()).ToString() + ",'D'," + System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString()).ToString() + ")");
                        }
                        //Si es debito y no tiene valor base
                        else if (((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][7].ToString())) != 0) && ((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString())) == 0))
                        {
                            sqlStrings.Add("INSERT INTO dgastosvariosproveedor VALUES('@1',@2," + i.ToString() + ",'" + tablaDetallesFactura.Rows[i][6].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][4].ToString().Trim() + "'," + System.Convert.ToUInt64(tablaDetallesFactura.Rows[i][5].ToString().Trim()).ToString() + ",'" + tablaDetallesFactura.Rows[i][1].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][0].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][2].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][3].ToString().Trim() + "'," + (System.Convert.ToDouble(tablaDetallesFactura.Rows[i][7].ToString())).ToString() + ",'D',0)");
                        }
                        //Si es credito y tiene valor base
                        else if (((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][8].ToString())) != 0) && ((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString())) != 0))
                        {
                            sqlStrings.Add("INSERT INTO dgastosvariosproveedor VALUES('@1',@2," + i.ToString() + ",'" + tablaDetallesFactura.Rows[i][6].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][4].ToString().Trim() + "'," + System.Convert.ToUInt64(tablaDetallesFactura.Rows[i][5].ToString().Trim()).ToString() + ",'" + tablaDetallesFactura.Rows[i][1].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][0].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][2].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][3].ToString().Trim() + "'," + (System.Convert.ToDouble(tablaDetallesFactura.Rows[i][8].ToString())).ToString() + ",'C'," + System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString()).ToString() + ")");
                        }
                        //Si es credito y no tiene valor base
                        else if (((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][8].ToString())) != 0) && ((System.Convert.ToDouble(tablaDetallesFactura.Rows[i][9].ToString())) == 0))
                        {
                            sqlStrings.Add("INSERT INTO dgastosvariosproveedor VALUES('@1',@2," + i.ToString() + ",'" + tablaDetallesFactura.Rows[i][6].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][4].ToString().Trim() + "'," + System.Convert.ToUInt64(tablaDetallesFactura.Rows[i][5].ToString().Trim()).ToString() + ",'" + tablaDetallesFactura.Rows[i][1].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][0].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][2].ToString().Trim() + "','" + tablaDetallesFactura.Rows[i][3].ToString().Trim() + "'," + (System.Convert.ToDouble(tablaDetallesFactura.Rows[i][8].ToString())).ToString() + ",'C',0)");
                        }
                    }
                }
                //Activos Fijos
                else if (tipoGasto == "5")
                {
                    for (i = 0; i < tablaDetallesFactura.Rows.Count; i++)
                    {
                        sqlStrings.Add("INSERT INTO DACTIVOFIJOMEJORA VALUES('" + tablaDetallesFactura.Rows[i][1].ToString() + "'," + tablaDetallesFactura.Rows[i][3].ToString().Substring(1).Replace(",", "").Trim() + ",'" + observacion + "', '" + this.prefijoFactura + "', " + this.NumeroFactura + ", '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')");
                        sqlStrings.Add("UPDATE MACTIVOFIJO SET MAFJ_VALOMEJORA = " + tablaDetallesFactura.Rows[i][3].ToString().Substring(1).Replace(",", "").Trim() + " WHERE MAFJ_CODIACTI = '" + tablaDetallesFactura.Rows[i][1].ToString() + "'");
                    }
                }
                if (tablaRetenciones != null)
                {
                    if (tablaRetenciones.Rows.Count != 0)
                    {
                        for (i = 0; i < tablaRetenciones.Rows.Count; i++)
                        {
                            sqlStrings.Add("INSERT INTO mfacturaproveedorretencion VALUES('@1',@2,'" + tablaRetenciones.Rows[i][0].ToString() + "'," + Convert.ToDouble(tablaRetenciones.Rows[i][3]).ToString() + "," + Convert.ToDouble(tablaRetenciones.Rows[i][2]).ToString() + ")");
                        }
                    }
                }
                if (tablaIva != null)
                {
                    if (tablaIva.Rows.Count != 0)
                    {
                        for (i = 0; i < tablaIva.Rows.Count; i++)
                        {
                            sqlStrings.Add("INSERT INTO dfacturaproveedoriva VALUES('@1',@2," + tablaIva.Rows[i][0].ToString() + ",'" + tablaIva.Rows[i][3].ToString() + "','" + tablaIva.Rows[i][2].ToString() + "'," + tablaIva.Rows[i][1].ToString() + ")");
                        }
                    }
                }
                sqlStrings.Add("INSERT INTO mfacturaadministrativaproveedor VALUES('@1',@2,'" + cuenta + "')");

                miFacturaP.SqlRels = sqlStrings;
                if (miFacturaP.GrabarFacturaProveedor(true))
                {
                    //Este proceso aplica solamente para EUROTECK y cancela la factua en finanzas sin generar comprobantes de egreso cuando usan la cuenta 1330
                    if (DBFunctions.SingleData("SELECT MNIT_NIT FROM CEMPRESA") == "901087944" && cuenta.ToString().Substring(0, 4) == "1330")
                    {
                        sqlOpcional.Add("update MFACTURAPROVEEDOR set MFAC_VALOABON = MFAC_VALOFACT + MFAC_VALOIVA + MFAC_VALOFLET + MFAC_VALOIVAFLET - MFAC_VALORETE, TVIG_VIGENCIA = 'C' where PDOC_CODIORDEPAGO = '" + prefijoFactura + "' and MFAC_NUMEORDEPAGO = " + Convert.ToUInt64(numeroFactura) + "");
                        if (DBFunctions.Transaction(sqlStrings))
                        {
                            string processMsg = DBFunctions.exceptions;
                        }
                    }
                    estado        = true;
                    this.mensajes = miFacturaP.ProcessMsg;
                }
                else
                {
                    this.mensajes = "Error : " + miFacturaP.ProcessMsg;
                }
            }
            return(estado);
        }