<%
Option Explicit
Session.LCID = 2058
'***** SI NO HA INICIADO SESION ***
If Session("Mybussiness") = "" then
Response.redirect("default.asp")
Else
Session.Timeout = 1200
'******* EN CASO DE ERROR ****
Err.Clear
On Error Resume Next
'*** REMPLAZA
Function Sanea(Texto)
Sanea = Replace(Texto, "'", "''")
End Function
%>
<!DOCTYPE html>
<HTML>
<HEAD>
<meta charset="ISO-8859-1" />
<TITLE>SISTEMA MIM <%= Session("Mybussiness") %> USUARIO: <%= Session("MyName") %></TITLE>
<link href="css/Modulos.css" rel="stylesheet" />
<link href="css/Buscador.css" rel="stylesheet" />
</HEAD>
<BODY>
<%
'***** Variables a la base de datos ****
Dim Cn1
Dim Rs11, Rs12, Rs13, Rs14, Rs15, Rs16, Rs17, Rs18, Rs19, Rs20, Rs21, Rs22, Rs23, Rs24, Rs25, Rs26, Rs27, Rs28, Rs29, Rs30
Dim Sql11, Sql12, Sql13, Sql14, Sql15, Sql16, Sql17, Sql18, Sql19, Sql20, Sql21, Sql22, Sql23, Sql24, Sql25, Sql26, Sql27, Sql28, Sql29, Sql30
'***** Conexion a la Base de Datos
Set Cn1 = Server.CreateObject( "ADODB.Connection" )
Cn1.Open "DRIVER={SQL Server};SERVER=172.17.0.5;UID="& Session("MyName") &";PWD="& Session("MyPass") &";Database="& Session("Mybussiness") &""
'***** Conexion A la Tabla Empresa ****
Set Rs11 = Server.CreateObject("ADODB.Recordset")
Sql11="Select * from Empresa;"
Rs11.Open Sql11,Cn1,1,2
%>
<SECTION Class="HeaderGes">
<div Id="DivHeadGes">
<%= Rs11("Nombre") %><br>
<%= Rs11("Direccion") %>, <%= Rs11("colonia") %><br>
<%= Rs11("Poblacion") %>
</div>
</SECTION>
<SECTION>
<center>
<br>
<B>***** AGREGAR UNA RECEPCION *****</B>
<BR><BR>
<%
Dim Provee, Mone, Refe, vflete, Vfactura, Pflete, subtotal, Ivt, Total, Pane, Tpedimento, TotalG, Edirecto, FechaDoc
Dim Doc, Folio, Sec, Fcom, Dcre, Status, movcxp, Tcam, Impesos, Idcxpg
Dim DIASCXPG, ppagoCXPG, condiCXPG, DESCCXPG
Dim Anticipo, Amortizacion
Provee = Request("Provee")
Mone = Request("Mone")
Refe = Request("Refe")
Vflete = Request("Vflete")
Vfactura = Request("Vfactura")
If Vflete = 0 and Vfactura = 0 then
Pflete = 0
else
Pflete = (Vflete/Vfactura) * 100
end If
Subtotal = Request("Subtotal")
Ivt = Request("Ivt")
Total = Request("Total")
Doc = session.sessionid
Sec = 0
fcom = date()
Status = 0
Tpedimento = Request("Tpedimento")
Edirecto = Request("Edirecto")
FechaDoc = Request("FechaDoc")
If Fechadoc = "" Or Isnull(FechaDoc) Then
FechaDoc = date()
Else
FechaDoc = FechaDoc
End If
Pane = Request("pane")
Set Rs12 = server.CreateObject("ADODB.Recordset")
Sql12="Select Compras from Consecutivos;"
Rs12.Open Sql12, Cn1, 1, 2
Folio = Rs12("Compras")
Folio = Folio + 1
set Rs13 = server.CreateObject("ADODB.Recordset")
set Rs14 = server.CreateObject("ADODB.Recordset")
set Rs15 = server.CreateObject("ADODB.Recordset")
set Rs16 = server.CreateObject("ADODB.Recordset")
set Rs17 = server.CreateObject("ADODB.Recordset")
set Rs18 = server.CreateObject("ADODB.Recordset")
set Rs19 = server.CreateObject("ADODB.Recordset")
set Rs20 = server.CreateObject("ADODB.Recordset")
set Rs21 = server.CreateObject("ADODB.Recordset")
Dim results, element, testing, existe, cosprom
for each element in request("chk")
Sec = Sec + 1
Sql13="Insert into crecdet (numrdet, secrdet, panrdet, almrdet, codrdet, crerdet, punrdet, monrdet, tcardet, pinrdet, " &_
"ppirdet, obsrdet, Pedimento) select "& Folio &", "& Sec &", pantrec, almtrec, codtrec, cretrec, puntrec, montrec, tcatrec, " &_
"pintrec, ppitrec, obstrec, '"& Tpedimento &"' from crecdtem where regtrec = "& Request("txt_"&element) &";"
Cn1.Execute Sql13
Sql14="Update corddet set nreord = '"& Folio &"', csuord = (csuord + cretrec), " &_
"cpeord = (cpeord - cretrec) from crecdtem where regord = pantrec and regtrec = "& Request("txt_"&element) &";"
Cn1.Execute Sql14
Sql15="Insert into MovInv (TmoMinv, Docminv, FecMinv, AlmMinv, CodMinv, CanMinv, ExiMinv, PrVMInv, UcoMinv, CpMinv, " &_
"PgaMinv, MonMinv, TcaMinv, CPRMinv, VenMinv, ObsMinv, UsrMinv, Pedimento) " &_
"Select 1, '"& Folio &"', '"& fcom &"', Almtrec, Codtrec, CreTrec, (exiRmul + Cretrec), 0, (puntrec * TCATREC), " &_
"(((exiRmul * cpmul) + (cretrec * puntrec * TCATREC)) / (exiRmul + cretrec)), " &_
"0, "& Mone &", tcatrec, '"& Provee &"', 0, Obstrec, '"& Session("MyName") &"', '"& Tpedimento &"' from crecdtem, multialmacen " &_
"where regtrec = "& Request("txt_"&element) &" and almmul = almtrec and artmul = codtrec;"
Cn1.Execute Sql15
Sql16="Update Inventarios set cpinv = (((exiRinv * cpinv) + (cretrec * puntrec * TCATREC)) / ((exiRinv + cretrec))), " &_
"ultcinv = (puntrec * TCATREC), cominv = (cominv - cretrec), ExiRinv = (ExiRinv + cretrec) " &_
"from crecdtem where cveinv = codtrec and regtrec = "& Request("txt_"&element) &";"
Cn1.Execute Sql16
Sql17="Update Inventarios set Exiinv = (exiinv + cretrec) from crecdtem where cveinv = codtrec " &_
"and regtrec = "& Request("txt_"&element) &";"
Cn1.Execute Sql17
Sql18="Update Multialmacen set cpmul = (((exiRmul * cpmul) + (cretrec * puntrec * TCATREC)) / ((exiRmul + cretrec))), " &_
"cxrmul = (cxrmul - cretrec), fucmul = '"& Fcom &"', ucomul = (puntrec * TCATREC), ExiRmul = (ExiRmul + Cretrec) " &_
"from crecdtem where almmul = almtrec and artmul = codtrec and regtrec = "& Request("txt_"&element) &";"
Cn1.Execute Sql18
Sql19="Update Multialmacen set eximul = (eximul + cretrec) " &_
"from crecdtem where almmul = almtrec and artmul = codtrec and regtrec = "& Request("txt_"&element) &";"
Cn1.Execute Sql19
Sql20="Insert Into Ueps (FecUeps, ComUeps, Almueps, codueps, canueps, punueps, pinueps, ppiueps, pedimento) " &_
"Select '"& Fcom &"', '"& Folio &"', Almtrec, Codtrec, cretrec, (puntrec * TCATREC), pintrec, ppitrec, '"& Tpedimento &"' " &_
"From crecdtem where regtrec = "& Request("txt_"&element) &";"
Cn1.Execute Sql20
Sql21="Insert Into Uepsc (FecUepsc, ComUepsc, Almuepsc, coduepsc, canuepsc, punuepsc, pinuepsc, pedimento) " &_
"Select '"& Fcom &"', '"& Folio &"', Almtrec, Codtrec, cretrec, (puntrec * TCATREC), pintrec, '"& Tpedimento &"' " &_
"From crecdtem where regtrec = "& Request("txt_"&element) &";"
Cn1.Execute Sql21
next
Set Rs22 = server.CreateObject("ADODB.Recordset")
Sql22="Select Cveprv, salprv, ucoprv, diaprv from proveedores where cveprv = '"& Provee &"';"
Rs22.Open Sql22, Cn1, 1, 2
Set Rs23 = server.CreateObject("ADODB.Recordset")
Sql23="Insert into crecenc (numrenc, Ocorenc, fecrenc, prorenc, ivarenc, fparenc, refrenc, monrenc, tcarenc, " &_
"subrenc, ivtrenc, totrenc, starenc, usurenc, pgarenc, reggas, vfactu, Vflete, Pflete, Edirecto, FechaDoc, DiasRenc, " &_
"Ppagorenc, Condicrenc, Descrenc, AntCrec, AmoCrenc) " &_
"select '"& Folio &"', numore, getdate(), '"& Provee &"', ivaore, getdate() + Diasore, '"& Refe &"', monore, tcadiv, " &_
"'"& Subtotal &"', '"& Ivt &"', '"& Total &"', '"& Status &"', '"& Session("MyName") &"', 0, 0, "& Vfactura &", "& Vflete&", " &_
""& Pflete &", "& Edirecto &", '"& FechaDoc &"', Diasore, PPagoOre, Condiciones, Descore, AntOre, AmoOre " &_
"from corddet, cordenc, monedas where regord = '"& Pane &"' and numore = numord and monore = cladiv;"
Cn1.Execute Sql23
Set Rs24 = server.CreateObject("ADODB.Recordset")
Sql24 = "select Cladiv, DesDiv, Sigdiv, Tcadiv from Monedas where Cladiv = '"& Mone &"';"
Rs24.open Sql24,cn1,1,2
Tcam= Rs24("Tcadiv")
TotalG = (Cdbl(Subtotal) - Cdbl(Vflete)) * 1.16
Impesos = Cdbl(TotalG) * Cdbl(Rs24("Tcadiv"))
Idcxpg = 1 & "-" & Folio
movcxp = 1
'******* PARA SACAR LOS DATOS DE CUENTAS POR PAGAR
Set Rs30 = server.CreateObject("ADODB.Recordset")
Sql30 = "Select DiasRenc, Ppagorenc, Condicrenc, DESCRENC, AntCrec, AmoCrenc " &_
"From CrecEnc " &_
"Where Numrenc = "& Folio &";"
Rs30.open Sql30,cn1,1,2
DIASCXPG = Rs30("DiasRenc")
ppagoCXPG = Rs30("Ppagorenc")
condiCXPG = Rs30("Condicrenc")
DESCCXPG = Rs30("DESCRENC")
Anticipo = Rs30("AntCrec")
Amortizacion = Rs30("AmoCrenc")
dcre = DATE() + Cdbl(DIASCXPG)
Set Rs25 = server.CreateObject("ADODB.Recordset")
Sql25 = "Insert into cxpgen (Movcxpg, Prvcxpg, Nrecxpg, refcxpg, Frecxpg, fpacxpg, moncxpg, impcxpg, salcxpg, " &_
"IMTCXPG, Pagcxpg, tcacxpg, DOCCXPG, Idrcxpg, DIASCXPG, ppagoCXPG, condiCXPG, DESCCXPG, AntCxpg, AmoCxpg)" &_
"values ('"& Movcxp &"', '"& Provee &"', '"& Folio &"', '"& Refe &"', '"& Fcom &"', '"& Dcre &"', "& Mone &", "& TotalG &", "& TotalG &", " &_
""& IMPESOS &", 0, "& Tcam &", "& Folio &", '"& Idcxpg &"', "& DIASCXPG &", "& ppagoCXPG &", '"& Sanea(condiCXPG) &"', "& DESCCXPG &", "& Anticipo &", '"& Amortizacion &"');"
Cn1.Execute Sql25
Set Rs26 = server.CreateObject("ADODB.Recordset")
Sql26 = "Insert into cxpdet (Movcxpd, Prvcxpd, Nrecxpd, Refcxpd, doccxpd, Frecxpd, fpacxpd, moncxpd, tcacxpd, IMPCXPD, imdcxpd, Idrcxpd)" &_
"values ('"& Movcxp &"', '"& Provee &"', '"& Folio &"', '"& Refe &"', '"& Folio &"', '"& Fcom &"', '"& Dcre &"'," &_
"'"& Mone &"', '"& Tcam &"', '"& iMPESOS &"', '"& TotalG &"', '"& Idcxpg &"');"
Cn1.Execute Sql26
Set Rs27 = server.CreateObject("ADODB.Recordset")
Sql27 = "Update Proveedores set Salprv = (Salprv + '"& Impesos &"'), Ucoprv = '"& Fcom &"' where Cveprv = '"& Provee &"';"
Cn1.Execute Sql27
Set Rs28 = server.CreateObject("ADODB.Recordset")
Sql28="Update consecutivos set Compras = '"& Folio &"';"
Cn1.Execute Sql28
Set Rs29 = server.CreateObject("ADODB.Recordset")
Sql29="delete crecdtem where doctrec = '"& Doc &"';"
Cn1.Execute Sql29
Response.Redirect("Recesp.asp?NumRec="& Folio &"&Empresa="& Session("Mybussiness") &"")
'Response.Redirect("Reclotes.asp?NumRec="& Folio &"")
%>
</SECTION>
<%
If Err.Number <> 0 Then
%>
<br><br>
Número de Error: <%= Err.Number %><BR>
Descripción: <%= Err.Description %><BR>
Origen: <%= Err.Source %><BR>
Linea: <%= Err.Line %><BR>
<br>
<%
Else
'****** FIN DE LOS ERRORES ***
End If
%>
</BODY>
</HTML>
<%
'FIN DE SESION
End If
%>