<%
Option Explicit
%>
<%
Session.LCID = 2058
%>
<!--#include file="User.asp"-->
<!--#include file="general.asp"-->
<html>
<head>
<title>Grupo MIM</title>
<link rel=stylesheet href="vista.css">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>
</head>
<BODY>
<!--#INCLUDE FILE="BARRA.asp"-->
<div class="normalw" style="position:absolute; top:1px">
<center>
<!--#include file="empresa.asp"--><br>
<hr>
</center>
</div>
<div class="normalw" style="position:absolute; top:1px;">
Bienvenido: <%= nombre %>. <br>
Hora Actual: <%= time %>
</div>
<div class="normalw" style="position:absolute; top:34px; left:1">
<!--#include file="mpro.asp"-->
</div>
<div class="normal" style="position:absolute; top:80px; left:10">
<center>
<%
'------------ VARIABLE DE SEGUNDA CONEXION
Dim Cn3
'------------ VARIABLES DE LOS RECORDSET
Dim Rs11, Sql11, Rs12, Sql12, Rs13, sql13, Rs14, Sql14, Rs15, Sql15
Dim Rs16, Sql16, Rs17, Sql17, Rs18, Sql18, Rs19, Sql19, Rs20, Sql20
'------------ DECLARO VARIABLES DE CONSULTA
Dim Rol
'--------------- VARIABLES DEL FORM
Dim Empresa, FINICIAL, FFINAL, VendeI, VendeF
'----------- VACIO VARIABLES
Empresa = Request("Empresa")
FINICIAL = Request("FINICIAL")
FFINAL = Request("FFINAL")
VendeI = Request("VendeI")
VendeF = Request("VendeF")
Response.write(Nombre & "<br>")
' ------------ ME CONECTO A LA BASE DE DATOS ----------
Set Cn3 = Server.CreateObject("ADODB.Connection")
Cn3.Open "DRIVER={SQL Server};SERVER=172.17.0.5;UID=ADMINDMEX;PWD=IW2BF01;Database=" & Empresa &""
'--------------- ELIMINO LA TABLA TEMPORAL
Set Rs12 = server.CreateObject("ADODB.Recordset")
Sql12="if exists (select * from dbo.sysobjects where id = object_id(N'" & Nombre & "') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table " & Nombre & ";"
Rs12.open Sql12,Cn3,1,2
Response.Write("<p>Se ha eliminado la Tabla")
'------------ CREO LA NUEVA TABLA TEMPORAL
Set Rs13=server.CreateObject("ADODB.recordset")
Set Rs13=cn3.Execute("CREATE TABLE "& Nombre &"( " &_
"TIPO VARCHAR (3) COLLATE Modern_Spanish_CI_AS NULL, " &_
"DIVISION VARCHAR (10) COLLATE Modern_Spanish_CI_AS NULL, " &_
"DOCUMENTO INT, " &_
"FECHA SMALLDATETIME NULL, " &_
"IMPORTE DECIMAL (18,4) NULL DEFAULT 0, " &_
"COSTO DECIMAL (18,4) NULL DEFAULT 0, " &_
"IMPORTENCR DECIMAL (18,4) NULL DEFAULT 0, " &_
"COSTONCR DECIMAL (18,4) NULL DEFAULT 0, " &_
"UTILIDAD DECIMAL (18,4) NULL DEFAULT 0 " &_
")" )
Response.Write("<p>Se ha creado la Tabla")
Response.Write("<p>" & Nombre)
set rs11 = server.CreateObject("ADODB.Recordset")
SQL11="insert into " & NOMBRE & " (TIPO, DIVISION, DOCUMENTO, FECHA, IMPORTE, COSTO) "&_
"select 'FA',DIVVEND, NUMFFACE, FECFFACE, subfface * tcafface, CPFFACE "&_
" from ffacenc, fant, clientes, vendedores WHERE numfface = nfaffacd and clacli = clifface and cvevend = vencli and CLACLI <> '0000SAI0' AND DIVVEND <> 'FILIALES' "&_
" and fecfface between '"& Finicial &"' and '"& Ffinal &"' and faccan is null;"
Cn3.Execute Sql11
Set Rs14=server.CreateObject("ADODB.recordset")
Sql14="UPDATE " & NOMBRE & " SET IMPORTENCR = IMPO FROM NCRIMPORTE "&_
"WHERE DOCNCR=DOCUMENTO AND MONTH(FECHA)=MES AND YEAR(FECHA)=AA AND TIPO='FA';"
Cn1.Execute Sql14
set rs15 = server.CreateObject("ADODB.Recordset")
SQL15="insert into " & NOMBRE & " (TIPO, DIVISION, DOCUMENTO, FECHA, IMPORTENCR) "&_
"SELECT 'NCR', DIVVEND, DOCNCR, MAX(FECNCR), SUM(SUBNCR * TCANCR) "&_
"FROM VENDEDORES INNER JOIN CLIENTES ON CVEVEND=VENCLI INNER JOIN CXCNCR ON CLACLI=CLINCR LEFT JOIN ADMINMEX ON CONVERT(VARCHAR (6),DOCNCR) = DOCUMENTO "&_
"WHERE FECNCR between '"& Finicial &"' and '"& Ffinal &"' AND TIPOD<>2 and CLACLI <> '0000SAI0' AND DIVVEND <> 'FILIALES' AND DOCUMENTO IS NULL AND SUBNCR * TCANCR > 0 "&_
"group BY DIVVEND, DOCNCR;"
Cn3.Execute Sql15
Set Rs16=server.CreateObject("ADODB.recordset")
Sql16="UPDATE " & NOMBRE & " SET COSTONCR = NCRCOS FROM NCRCOSTO "&_
"WHERE AntFdevd=DOCUMENTO AND MONTH(FECHA)=MES AND YEAR(FECHA)=AA;"
Cn1.Execute Sql16
Set Rs18=server.CreateObject("ADODB.recordset")
Sql18="UPDATE " & NOMBRE & " SET UTILIDAD = ((IMPORTE - COSTO)*100)/IMPORTE WHERE TIPO ='FA'; "
Cn1.Execute Sql18
Set Rs20=server.CreateObject("ADODB.recordset")
Sql20="UPDATE " & NOMBRE & " SET COSTONCR = 0 WHERE COSTONCR IS NULL; "
Cn1.Execute Sql20
Response.Redirect("FfVtasDiv.asp?Empresa="& Negocio &"&Tbl="& Nombre &"")
%>
</div>
</body>
</html>
<%
End Sub
'Add the chosen course to the cart
Call AddUsuario()
'Display contents of electronic shopping cart
Call DisplayUsuario()
%>