Mas em Fevereiro que tem 28 dias ele muda certo so que no mês subseqüente
Ele torna colocar o dia 28 sendo que marco tem 31 dias e no mês subseqüente ele coloca certo sendo o dia 30.
A função usada e a DateAdd (código utlizado : dateadd("M", 1,mesdefinido))
EM ANEXO O SCRIPT ASP
Parcela de Curso 1 30/1/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 2 28/2/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 3 28/3/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 4 30/4/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 5 30/5/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 6 30/6/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 7 30/7/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 8 30/8/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 9 30/9/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 10 30/10/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 11 30/11/2010 15,00 Boleto 0,00 Aberto
Parcela de Curso 12 30/12/2010 15,00 Boleto 0,00 Aberto
<%option explicit%>
<!-- #include file = "include/generico_data.inc" -->
<%dim nr_processo
if request("operacao") = "D" then
nr_processo=22
else
nr_processo=21
end if
%>
<!-- #include file = "include/valida_acesso.inc" -->
<%
dim sql, id_matricula, rsMatricula, aux_volta, dt_vencimento
dim i
dim rsAcesso
id_matricula = request.form("id_matricula")
if id_matricula = 0 then
'Valida Aluno
dim rsAluno
sql = "SELECT * from parceiro where id_parceiro = " & Request.Form("id_parceiro")
set rsAluno = GetRS(sql)
if rsAluno.eof then
Response.write "Aluno não encontrado."
Response.End
end if
if rsAluno("CPF") = "" and rsAluno("respnome") = "" and rsAluno("respCPF") = "" then
Response.write "CPF do Aluno ou Responsavel não preenchido"
Response.End
end if
'Acha proximo numero de matricula
sql = "select max(id_matricula) as id_matricula from matricula"
rsMatricula = getrs(sql)
if isnull(rsMatricula("id_matricula")) then
id_matricula = 1
else
id_matricula = rsMatricula("id_matricula") + 1
end if
sql = "insert into matricula( "
sql = sql & " id_matricula,"
sql = sql & " id_aluno,"
sql = sql & " id_turma,"
sql = sql & " vr_curso,"
sql = sql & " vr_desconto,"
sql = sql & " nr_parcelas,"
sql = sql & " vr_taxa_matricula,"
sql = sql & " observacao,"
sql = sql & " dt_matricula,"
sql = sql & " id_usuario,"
sql = sql & " situacao,"
sql = sql & " forma_pagamento,"
sql = sql & " dt_parcela,"
sql = sql & " nr_parcelas_taxa)"
sql = sql & " VALUES ("
sql = sql & id_matricula & ","
sql = sql & Request.Form("id_parceiro") & ","
sql = sql & Request.Form("id_turma") & ","
sql = sql & replace(request.form("vr_curso"),",",".") & ","
if request.form("vr_desconto") = "" then
sql = sql & "0" & ","
else
sql = sql & replace(request.form("vr_desconto"),",",".") & ","
end if
sql = sql & Request.Form("nr_parcelas") & ","
sql = sql & replace(request.form("vr_taxa_matricula"),",",".") & ","
' sql = sql & "'" & Request.Form("observacao") & "',"
sql = sql & "'',"
sql = sql & "'" & now() & "',"
sql = sql & "" & session("id_usuario") & ","
sql = sql & "'A',"
sql = sql & "'" & Request.Form("forma_pagamento") & "',"
sql = sql & "'" & Request.Form("dt_parcela") & "',"
sql = sql & Request.Form("nr_parcelas_taxa") & ")"
call executecmd(sql)
elseif request("operacao") = "D" then
'Apaga Lancamentos
sql = "delete from lancamento "
sql = sql & " where id_matricula = " & request.form("id_matricula")
call executecmd(sql)
sql = "delete from matricula "
sql = sql & " where id_matricula = " & id_matricula
call executecmd(sql)
Response.Redirect "matricula_lista.asp?id_aluno=" & Request.Form("id_aluno")
Response.End
else
sql = "update matricula set "
sql = sql & " id_turma = " & Request.Form("id_turma") & ","
sql = sql & " vr_curso = " & replace(replace(request.form("vr_curso"),".",""),",",".") & ","
if request.form("vr_desconto") = "" then
sql = sql & " vr_desconto = 0" & ","
else
sql = sql & " vr_desconto = " & replace(request.form("vr_desconto"),",",".") & ","
end if
sql = sql & " nr_parcelas = " & Request.Form("nr_parcelas") & ","
sql = sql & " vr_taxa_matricula = " & replace(request.form("vr_taxa_matricula"),",",".") & ","
sql = sql & " nr_parcelas_taxa = " & Request.Form("nr_parcelas_taxa") & ","
sql = sql & "observacao =" & """" & replace(request("observacao"),"""","'") & ""","
sql = sql & "dt_matricula = " & "'" & now() & "',"
sql = sql & "forma_pagamento = " & "'" & Request.Form("forma_pagamento") & "',"
sql = sql & "dt_parcela = " & "'" & Request.Form("dt_parcela") & "'"
sql = sql & " where id_matricula = " & id_matricula
call executecmd(sql)
end if
'Fechamento de Matricula
' if request("operacao") = "C" then
'Traz registro de matricula
sql = "SELECT * from matricula where id_matricula = " & id_matricula
set rsMatricula = GetRS(sql)
'Apaga Lancamentos antigos
sql = "delete from lancamento "
sql = sql & " where id_matricula = " & request.form("id_matricula")
call executecmd(sql)
'Taxa de Matricula
if rsMatricula("vr_taxa_matricula") > 0 then
dt_vencimento = formatdatetime(now(),2)
for i = 1 to rsMatricula("nr_parcelas_taxa")
if i > 1 then
' dt_vencimento = "15" & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
dt_vencimento = day(dt_vencimento) & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
dt_vencimento = dateadd("M", 1, dt_vencimento)
end if
sql = "insert into lancamento (tp_lancamento, id_parceiro, nr_parcela, "
sql = sql & " dt_lancamento, dt_vencimento, vr_parcela, vr_desconto, forma_pagamento, "
sql = sql & " nr_documento, vr_tx_boleto, id_situacao_lancamento, id_matricula)"
sql = sql & " values("
sql = sql & "5" & ","
sql = sql & rsMatricula("id_aluno") & ","
sql = sql & cstr(i) & ","
sql = sql & "'" & now() & "',"
sql = sql & "'" & dt_vencimento & "',"
sql = sql & replace(rsMatricula("vr_taxa_matricula")/rsMatricula("nr_parcelas_taxa"),",",".") & ","
sql = sql & "0" & ","
sql = sql & "'" & rsMatricula("forma_pagamento") & "',"
' sql = sql & "'" & right("000000" + cstr(rsMatricula("id_matricula")),6) & "05" & right("00" + cstr(i),2) & "',"
' sql = sql & "'" & right("0000" + cstr(rsMatricula("id_matricula")),4) & right("00" + cstr(day(dt_vencimento)), 2) & right("00" + cstr(month(dt_vencimento)),2) & right("00" + cstr(year(dt_vencimento)),2) & "',"
sql = sql & "null,"
' if rsMatricula("forma_pagamento") = "B" then
' sql = sql & "2.4,"
' else
sql = sql & "0,"
' end if
sql = sql & "1" & ","
sql = sql & rsMatricula("id_matricula") & ")"
call executecmd(sql)
next
end if
'Gera lançamentos
dt_vencimento = rsMatricula("dt_parcela")
Session("DataVenc") = day(dt_vencimento)
' response.Write(Session("DataVenc") & "<br>")
' response.Write(Session("DataVenc") & "<br>")
' response.Write(month(dt_vencimento) & "<br>")
' response.End()
' response.End()
for i = 1 to rsMatricula("nr_parcelas")
if i > 1 then
if day(dt_vencimento) <> Session("DataVenc") then
Select Case month(dt_vencimento)
case 1
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 2
dt_vencimento = day(dt_vencimento) & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 3
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 4
dt_vencimento = day(dt_vencimento) & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 5
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 6
dt_vencimento = day(dt_vencimento) & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 7
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 8
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 9
dt_vencimento = day(dt_vencimento) & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 10
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 11
dt_vencimento = day(dt_vencimento) & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
case 12
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
Case else
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
End Select
else
dt_vencimento = Session("DataVenc") & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
end if
' dt_vencimento = "15" & "/" & month(dt_vencimento) & "/" & year(dt_vencimento)
' dt_vencimento = dateadd("M", 1, dt_vencimento)
dt_vencimento = dateadd("M", 1, dt_vencimento)
end if
sql = "insert into lancamento (tp_lancamento, id_parceiro, nr_parcela, "
sql = sql & " dt_lancamento, dt_vencimento, vr_parcela, vr_desconto, forma_pagamento, "
sql = sql & " nr_documento, vr_tx_boleto, id_situacao_lancamento, id_matricula)"
sql = sql & " values("
sql = sql & "1" & ","
sql = sql & rsMatricula("id_aluno") & ","
sql = sql & cstr(i) & ","
sql = sql & "'" & now() & "',"
sql = sql & "'" & dt_vencimento & "',"
sql = sql & replace((rsMatricula("vr_curso")/rsMatricula("nr_parcelas")),",",".") & ","
sql = sql & replace((rsMatricula("vr_desconto")/rsMatricula("nr_parcelas")),",",".") & ","
sql = sql & "'" & rsMatricula("forma_pagamento") & "',"
' sql = sql & "'" & right("000000" + cstr(rsMatricula("id_matricula")),6) & "01" & right("00" + cstr(i),2) & "',"
' sql = sql & "'" & right("0000" + cstr(rsMatricula("id_matricula")),4) & right("00" + cstr(day(dt_vencimento)), 2) & right("00" + cstr(month(dt_vencimento)),2) & right("00" + cstr(year(dt_vencimento)),2) & "',"
sql = sql & "null,"
' if rsMatricula("forma_pagamento") = "B" then
' sql = sql & "2.4,"
' else
sql = sql & "0,"
' end if
sql = sql & "1" & ","
sql = sql & rsMatricula("id_matricula") & ")"
'response.Write(sql & "<br>")
call executecmd(sql)
next
'response.End()
'Altera situacao da matricula
' sql = "update matricula set "
' sql = sql & "situacao = " & "'F'"
' sql = sql & " where id_matricula = " & request.form("id_matricula")
' call executecmd(sql)
'Insere Atendimento no aluno
sql = "insert into parceiro_historico ( "
sql = sql & " id_parceiro,"
sql = sql & " dt_historico,"
sql = sql & " tipo_atendimento,"
sql = sql & " ds_observacao,"
sql = sql & " id_parceiro_usuario)"
sql = sql & " VALUES ("
sql = sql & rsMatricula("id_aluno") & ","
sql = sql & "'" & now() & "',"
sql = sql & "'P',"
sql = sql & "'Matricula n. " & cstr(rsMatricula("id_matricula")) & "',"
sql = sql & "" & session("id_usuario") & ")"
call executecmd(sql)
'Altera Tipo de Parceiro
sql = "update parceiro set "
sql = sql & "tipo = " & "'A'"
sql = sql & " where id_parceiro = " & rsMatricula("id_aluno")
call executecmd(sql)
' end if
' end if
Response.Redirect "matricula_detalhe.asp?id_matricula=" & id_matricula
Response.End
%>
<script LANGUAGE=VBSCRIPT>
sub window_onload()
<%if request("operacao") = "D" or request("operacao") = "C" or request.form("id_matricula") = 0 then %>
call window.history.go(-2)
<%else%>
call window.history.go(-1)
<%end if%>
end sub
</SCRIPT>
Attached Files
Edição feita por: Renan L. Queiroz, 07/04/2010, 15:00.
Inclusão da tag [ code ] para postagem de scripts











