<%
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 style="position:absolute; top:34px; left:1">
<!--#include file="mpro.asp"-->
</div>
<div class="normal" style="position:absolute; top:80px; left:10">
<center>
<%
Dim Rs11, Sql11, Rs12, Sql12, Rs13, Sql13, Rs14, Sql14, Rs15, Sql15
Dim Rs16, Sql16, Rs17, Sql17, Rs18, Sql18, Rs19, Sql19, Rs20, Sql20
Dim Rs21, Sql21, Rs22, Sql22
Dim TipoM, Almacen, Codigo, Cantidad, Costo, Proveedor
Dim Najuste, Factual
Dim AlmaU, CodeU, CanU
Dim AlmaUC, CodeUC, CanUC
Dim UepsCan, CostoUeps, UepsIndex, CanCap, NewUeps, Csol
Dim UepsCanC, CostoUepsC, UepsIndexC, CanCapC, NewUepsC, CsolC
TipoM = Request("TipoM")
Almacen = Request("Almacen")
Codigo = Request("Codigo")
Cantidad = Request("Cantidad")
Costo = Request("Costo")
Factual = Date()
Proveedor = "000000"
If Cantidad = 0 or Isnull(Cantidad) or Cantidad = "" then
%>
La Cantidad No Puede ser Cero o Vacio
<%
Else
Set Rs11 = server.CreateObject("ADODB.Recordset")
Sql11="Select Ajustes from consecutivos;"
Rs11.open Sql11,cn1,1,2
Najuste = Rs11("Ajustes") +1
If TipoM = 12 Then
Set Rs12 = server.CreateObject("ADODB.Recordset")
Sql12="Insert Into Ueps " &_
"(Fecueps, Comueps, Almueps, Codueps, Canueps, Punueps, Pinueps, PPiueps) " &_
"Values ('"& Factual &"', "& Najuste &", "& Almacen &", '"& Codigo &"', "& Cantidad &", "& Costo &", 0, 0);"
Cn1.Execute Sql12
Set Rs13 = server.CreateObject("ADODB.Recordset")
Sql13="Insert Into Uepsc " &_
"(Fecuepsc, Comuepsc, Almuepsc, Coduepsc, Canuepsc, Punuepsc, Pinuepsc) " &_
"Values ('"& Factual &"', "& Najuste &", "& Almacen &", '"& Codigo &"', "& Cantidad &", "& Costo &", 0);"
Cn1.Execute Sql13
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14="Insert Into Movinv " &_
"(TmomInv, Docminv, FecMinv, Almminv, CodMinv, CanMinv, ExiMinv, PrvMinv, UcoMinv, CpMinv, PgaMinv, " &_
"MonMinv, TcaMinv, Cprminv, Venminv, UsrMinv) " &_
"Select "& TipoM &", "& Najuste &", '"& Factual &"', "& Almacen &", '"& Codigo &"', "& Cantidad &", " &_
"(exirmul + "& Cantidad &"), 0, "& Costo &", (((Cpmul * Exirmul) + ("& Cantidad &" * "& Costo &")) / (Exirmul + "& Cantidad &")), " &_
"0, 1, 1, '"& Proveedor &"', 0, '"& Nombre &"' From Multialmacen where Almmul = "& Almacen &" and Artmul = '"& Codigo &"';"
Cn1.Execute Sql14
Set Rs15 = server.CreateObject("ADODB.Recordset")
Sql15="Update Inventarios " &_
"Set Exiinv = (Exiinv + "& Cantidad &"), Exirinv = (Exirinv + "& Cantidad &"), " &_
"Cpinv = (((Cpinv * Exirinv) + ("& Cantidad &" * "& Costo &")) / (Exirinv + "& Cantidad &")), Ultcinv = "& Costo &" " &_
"where cveinv = '"& Codigo &"';"
Cn1.Execute Sql15
Set Rs16 = server.CreateObject("ADODB.Recordset")
Sql16="Update Multialmacen " &_
"Set Eximul = (Eximul + "& Cantidad &"), Exirmul = (Exirmul + "& Cantidad &"), " &_
"Cpmul = (((Cpmul * Exirmul) + ("& Cantidad &" * "& Costo &")) / (Exirmul + "& Cantidad &")), Ucomul = "& Costo &" " &_
"where artmul = '"& Codigo &"' and almmul = "& Almacen &";"
Cn1.Execute Sql16
Set Rs17 = server.CreateObject("ADODB.Recordset")
Sql17="Update Consecutivos set Ajustes = "& Najuste &";"
Cn1.Execute Sql17
Set Rs18 = server.CreateObject("ADODB.Recordset")
Sql18 = "delete ueps where canueps = 0;"
Cn1.Execute Sql18
Response.redirect("AjusteP.asp?Code="& Codigo &"&Alma="& Almacen&"&NumAju="& Najuste &"&TipoM="& TipoM &"&Empresa="& Negocio &"")
Else If TipoM = 55 Then
Set Rs12 = server.CreateObject("ADODB.Recordset")
Sql12="select almueps as Almacen, codueps as Codigo, sum(canueps) as Cantidad from ueps " &_
"where Almueps = "& Almacen &" and Codueps = '"& Codigo &"' group By almueps, codueps;"
Rs12.Open Sql12, Cn1
AlmaU = Rs12("Almacen")
CodeU = Rs12("Codigo")
CanU = Rs12("Cantidad")
Csol = Cdbl(Cantidad)
If Cdbl(Cantidad) > Cdbl(Canu) then
Response.Write("La Cantidad es mayor a la existencia. no se puede realizar el ajuste")
Else
Set Rs13 = server.CreateObject("ADODB.Recordset")
Sql13 ="Select * from ueps where almueps = "& Almacen &" and Codueps = '"& Codigo &"' " &_
"order by regueps desc;"
Rs13.Open Sql13, Cn1
While (Not RS13.eof)
Uepscan = rs13("canueps")
Costoueps = rs13("punueps")
UepsIndex = rs13("regueps")
'************ COSTO TABLA UEPS **************
If Cdbl(Csol) < Cdbl(Uepscan) and Cdbl(Csol) > 0 then
CanCap = Cdbl(Csol)
NewUeps = Cdbl(UepsCan) - Cdbl(Cancap)
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14 = "Update ueps set canueps = "& Newueps &" where almueps = "& almacen &" and codueps = '"& codigo &"' " &_
"and regueps = "& UepsIndex &";"
Cn1.Execute Sql14
Csol = 0
'--------------- SEGUNDO IF SI LO SOLICITADO ES IGUAL A LA CAPA UEPS ----------------
Else If Cdbl(Csol) = Cdbl(Uepscan) and Cdbl(Csol) > 0 then
Cancap = Cdbl(Csol)
NewUeps = 0
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14 = "Update ueps set canueps = "& Newueps &" where almueps = "& Almacen &" and codueps = '"& Codigo &"' " &_
"and regueps = "& UepsIndex &";"
Cn1.Execute Sql14
Csol = 0
'--------------- TERCER IF SI LO SOLICITADO ES MAYOR A LA CAPA UEPS ----------------
Else If Cdbl(Csol) > Cdbl(Uepscan) and Cdbl(Csol) > 0 then
Cancap = Cdbl(Uepscan)
NewUeps = 0
Set Rs14 = server.CreateObject("ADODB.Recordset")
Sql14 = "Update ueps set canueps = "& Newueps &" where almueps = "& Almacen &" and codueps = '"& Codigo &"' " &_
"and regueps = "& UepsIndex &";"
Cn1.Execute Sql14
Csol = Cdbl(Csol) - Cdbl(Uepscan)
End If
End If
End If
Rs13.movenext
Wend
End If
'*********************************** EL OTRO DO WHILE *********************
Set Rs15 = server.CreateObject("ADODB.Recordset")
Sql15="select almuepsC as AlmacenC, coduepsc as CodigoC, sum(canuepsC) as CantidadC from uepsC " &_
"where AlmuepsC = "& Almacen &" and CoduepsC = '"& Codigo &"' group By almuepsC, coduepsC;"
Rs15.Open Sql15, Cn1
AlmaUC = Rs15("Almacenc")
CodeUC = Rs15("Codigoc")
CanUC = Rs15("Cantidadc")
CsolC = Cdbl(Cantidad)
If Cdbl(Cantidad) > Cdbl(CanuC) then
Response.Write("La Cantidad es mayor a la existencia. no se puede realizar el ajuste (2do Proceso)")
Else
Set Rs16 = server.CreateObject("ADODB.Recordset")
Sql16 ="Select * from uepsC where almuepsC = "& Almacen &" and CoduepsC = '"& Codigo &"' " &_
"order by reguepsC desc;"
Rs16.Open Sql16, Cn1
Do While (Not RS16.eof)
UepscanC = Rs16("canuepsc")
CostouepsC = Rs16("punuepsc")
UepsIndexC = Rs16("reguepsc")
'************ COSTO TABLA UEPS **************
If Cdbl(CsolC) < Cdbl(UepscanC) and Cdbl(CsolC) > 0 then
CanCapC = Cdbl(CsolC)
NewUepsC = Cdbl(UepsCanC) - Cdbl(CancapC)
Set Rs20 = server.CreateObject("ADODB.Recordset")
Sql20 = "Insert into movinv (tmominv, docminv, fecminv, almminv, codminv, canminv, eximinv, prvminv, ucominv, " &_
"pgaminv, monminv, tcaminv, cprminv, venminv, usrminv, CpMinv) " &_
"Select "& TipoM &", "& Najuste &", '"& Factual &"', "& Almacen &", '"& Codigo &"', "& CancapC &", " &_
"(exirmul - "& Cancapc &"), 0, "& CostoUepsC &", 0, 0, 0, '000000', 0, '"& Nombre &"', " &_
"cpmul from multialmacen where almmul = "& Almacen &" and artmul = '"& Codigo &"';"
Cn1.Execute Sql20
Set Rs17 = server.CreateObject("ADODB.Recordset")
Sql17 = "Update uepsC set canuepsC = "& NewuepsC &" where almuepsC = "& almacen &" and coduepsC = '"& codigo &"' " &_
"and reguepsC = "& UepsIndexC &";"
Cn1.Execute Sql17
Set Rs18 = server.CreateObject("ADODB.Recordset")
Sql18 = "Update Multialmacen set Eximul = (Eximul - "& CanCapC &"), Exirmul = (Exirmul - "& CanCapC &") " &_
"where Almmul = "& Almacen &" and Artmul = '"& Codigo &"';"
Cn1.Execute Sql18
Set Rs19 = server.CreateObject("ADODB.Recordset")
Sql19 = "Update Inventarios set Exiinv = (Exiinv - "& CanCapC &"), Exirinv = (ExirInv - "& CanCapC &") " &_
"where CveInv = '"& Codigo &"';"
Cn1.Execute Sql19
CsolC = 0
Set Rs21 = server.CreateObject("ADODB.Recordset")
Sql21 = "delete uepsc where canuepsc = 0;"
Cn1.Execute Sql21
'--------------- SEGUNDO IF SI LO SOLICITADO ES IGUAL A LA CAPA UEPS ----------------
Else If Cdbl(CsolC) = Cdbl(UepscanC) and Cdbl(CsolC) > 0 then
CancapC = Cdbl(CsolC)
NewUepsC = 0
Set Rs20 = server.CreateObject("ADODB.Recordset")
Sql20 = "Insert into movinv (tmominv, docminv, fecminv, almminv, codminv, canminv, eximinv, prvminv, ucominv, " &_
"pgaminv, monminv, tcaminv, cprminv, venminv, usrminv, CpMinv) " &_
"Select "& TipoM &", "& Najuste &", '"& Factual &"', "& Almacen &", '"& Codigo &"', "& CancapC &", " &_
"(exirmul - "& Cancapc &"), 0, "& CostoUepsC &", 0, 0, 0, '000000', 0, '"& Nombre &"', " &_
"cpmul from multialmacen where almmul = "& Almacen &" and artmul = '"& Codigo &"';"
Cn1.Execute Sql20
Set Rs17 = server.CreateObject("ADODB.Recordset")
Sql17 = "Update uepsC set canuepsC = "& NewuepsC &" where almuepsC = "& Almacen &" and coduepsC = '"& Codigo &"' " &_
"and reguepsC = "& UepsIndexC &";"
Cn1.Execute Sql17
Set Rs18 = server.CreateObject("ADODB.Recordset")
Sql18 = "Update Multialmacen set Eximul = (Eximul - "& CanCapC &"), Exirmul = (Exirmul - "& CanCapC &") " &_
"where Almmul = "& Almacen &" and Artmul = '"& Codigo &"';"
Cn1.Execute Sql18
Set Rs19 = server.CreateObject("ADODB.Recordset")
Sql19 = "Update Inventarios set Exiinv = (Exiinv - "& CanCapC &"), Exirinv = (ExirInv - "& CanCapC &") " &_
"where CveInv = '"& Codigo &"';"
Cn1.Execute Sql19
CsolC = 0
Set Rs21 = server.CreateObject("ADODB.Recordset")
Sql21 = "delete uepsc where canuepsc = 0;"
Cn1.Execute Sql21
'--------------- TERCER IF SI LO SOLICITADO ES MAYOR A LA CAPA UEPS ----------------
Else If Cdbl(Csolc) > Cdbl(UepscanC) and Cdbl(Csolc) > 0 then
CancapC = Cdbl(UepscanC)
NewUepsC = 0
Set Rs20 = server.CreateObject("ADODB.Recordset")
Sql20 = "Insert into movinv (tmominv, docminv, fecminv, almminv, codminv, canminv, eximinv, prvminv, ucominv, " &_
"pgaminv, monminv, tcaminv, cprminv, venminv, usrminv, CpMinv) " &_
"Select "& TipoM &", "& Najuste &", '"& Factual &"', "& Almacen &", '"& Codigo &"', "& CancapC &", " &_
"(exirmul - "& Cancapc &"), 0, "& CostoUepsC &", 0, 0, 0, '000000', 0, '"& Nombre &"', " &_
"cpmul from multialmacen where almmul = "& Almacen &" and artmul = '"& Codigo &"';"
Cn1.Execute Sql20
Set Rs17 = server.CreateObject("ADODB.Recordset")
Sql17 = "Update uepsC set canuepsC = "& NewuepsC &" where almuepsC = "& Almacen &" and coduepsC = '"& Codigo &"' " &_
"and reguepsC = "& UepsIndexC &";"
Cn1.Execute Sql17
CsolC = Cdbl(CsolC) - Cdbl(UepscanC)
Set Rs18 = server.CreateObject("ADODB.Recordset")
Sql18 = "Update Multialmacen set Eximul = (Eximul - "& CanCapC &"), Exirmul = (Exirmul - "& CanCapC &") " &_
"where Almmul = "& Almacen &" and Artmul = '"& Codigo &"';"
Cn1.Execute Sql18
Set Rs19 = server.CreateObject("ADODB.Recordset")
Sql19 = "Update Inventarios set Exiinv = (Exiinv - "& CanCapC &"), Exirinv = (ExirInv - "& CanCapC &") " &_
"where CveInv = '"& Codigo &"';"
Cn1.Execute Sql19
CsolC = Cdbl(CsolC) - Cdbl(UepscanC)
Set Rs21 = server.CreateObject("ADODB.Recordset")
Sql21 = "delete uepsc where canuepsc = 0;"
Cn1.Execute Sql21
End If
End If
End If
Rs16.movenext
Loop
Set Rs22 = server.CreateObject("ADODB.Recordset")
Sql22="Update Consecutivos set Ajustes = "& Najuste &";"
Cn1.Execute Sql22
End If
Response.redirect("AjusteP.asp?Code="& Codigo &"&Alma="& Almacen&"&NumAju="& Najuste &"&TipoM="& TipoM &"&Empresa="& Negocio &"")
End If
End If
End If
%>
<hr>
</div>
</body>
</html>
<%
End Sub
'Add the chosen course to the cart
Call AddUsuario()
'Display contents of electronic shopping cart
Call DisplayUsuario()
%>