SHARE
TWEET

Untitled

a guest Aug 23rd, 2018 167 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Select bo  userf=Alltrim(m.m_chnome)  stamp1 = Alltrim(bo.bostamp)  num0 = bo.ndos  num1 = Alltrim(astr(bo.ndos))  nome1 = Alltrim(astr(bo.nmdos))    If num0>1     Create Cursor xVars ( no N(5), tipo c(1), Nome c(40), Pict c(100), lOrdem N(10), nValor N(18,5), cValor c(250), mValor m(10), lValor l, dValor d )   Select xVars   Append Blank   Replace xVars.no With 1   Replace xVars.tipo With "D"   Replace xVars.Nome With "Data"   Replace xVars.Pict With ""   Replace xVars.lOrdem With 1   Replace xVars.dValor With Date()     m.Escolheu = .F.     m.mCaption = "Data"     docomando("do form usqlvar with 'xvars',m.mCaption")     If Not m.Escolheu    mensagem("Atribuição interrompida!","DIRECTA")    Return .F.   Else    Select xVars    Locate    data1=Alltrim(dtosql(xVars.dValor))    Select xVars   Endif       aa = [delete bi where (qtt=0 or qtt<0) and ref<>'' and ndos=] + num1 + [ and ]   aa = aa + [convert(nvarchar(15),dataobra,112)=convert(nvarchar(15),'] +  data1 + [',112) ]     u_sqlexec(aa)     bb = "delete bo where bostamp not in "   bb = bb + "(select bostamp from bi (nolock))"     u_sqlexec(bb)       bb = [and ndos in (12,13,14,16,17,18) and ]   bb = bb + [convert(nvarchar(15),dataobra,112)=convert(nvarchar(15),'] +  data1 + [',112) ]       aa = [update bi set edebito=(case when cl.preco=1 then st.epv1 ]   aa = aa + [when cl.preco=2 then st.epv2 ]   aa = aa + [when cl.preco=3 then st.epv3 ]   aa = aa + [when cl.preco=4 then st.epv4 ]   aa = aa + [else st.epv5 end),]   aa = aa + [ivaincl=(case when cl.preco=1 then st.iva1incl ]   aa = aa + [when cl.preco=2 then st.iva2incl ]   aa = aa + [when cl.preco=3 then st.iva3incl ]   aa = aa + [when cl.preco=4 then st.iva4incl ]   aa = aa + [else st.iva5incl end),]   aa = aa + [desconto= cl.desconto from cl, bi, st(nolock) where ]   aa = aa + [bi.ref=st.ref and bi.no=cl.no and bi.estab=cl.estab and bi.qtt<>0 ] + bb   u_sqlexec(aa)     aa = [update bi set desconto=dfcl.desc1 from bi,cl,dfcl,st (nolock) where ]   aa = aa + [st.ref=bi.ref and bi.no=cl.no and bi.estab=cl.estab and bi.qtt<>0 and ]   aa = aa + [dfcl.ref=st.tipodesc and dfcl.tipodesc=cl.tipodesc ] + bb   u_sqlexec(aa)         aa = [update bi set ettdeb=(case when desconto>0 then ]   aa = aa + [ round(edebito*qtt*(1-(desconto/100)),2) else ]   aa = aa + [ round(edebito*qtt,2) end ),]   aa = aa + [debito=edebito, epu=edebito, eprorc=edebito ]   aa = aa + [where qtt<>0 ] + bb   u_sqlexec(aa)     aa = [update bi set bi.peso=st.peso from bi,st where st.ref=bi.ref and ]   aa = aa + [bi.qtt<>0 ] + bb   u_sqlexec(aa)         bb = [bo.ndos in (12,13,14,16,17) and ]   bb = bb + [convert(nvarchar(15),bo.dataobra,112)=convert(nvarchar(15),'] +  data1 + [',112) ]     aa = [drop view one2]   u_sqlexec(aa)     aa = [create view one2 as select ]   aa = aa + [totaldeb=sum(bi.ettdeb),]   aa = aa + [etotaldeb=sum(bi.ettdeb),]   aa = aa + [total=sum(bi.ettdeb),]   aa = aa + [etotal=sum(bi.ettdeb),]   aa = aa + [ebo_totp1=sum(bi.edebito*bi.qtt),]   aa = aa + [descc=sum(bi.edebito*bi.qtt)-sum(bi.ettdeb),]   aa = aa + [edescc=sum(bi.edebito*bi.qtt)-sum(bi.ettdeb),]   aa = aa + [ebo_2Tdes1=sum(bi.edebito*bi.qtt)-sum(bi.ettdeb),]   aa = aa + [bo.bostamp from bi,bo where bi.bostamp=bo.bostamp and ]  + bb   aa = aa + [ group by bo.bostamp ]   u_sqlexec(aa)     aa = [update bo set totaldeb=one2.totaldeb,]   aa = aa + [etotaldeb=one2.etotaldeb,]   aa = aa + [total=one2.total,]   aa = aa + [etotal=one2.etotal,]   aa = aa + [ebo_totp1=one2.ebo_totp1,]   aa = aa + [descc=one2.descc,]   aa = aa + [edescc=one2.edescc,]   aa = aa + [ebo_2Tdes1=one2.ebo_2Tdes1 ]   aa = aa + [from bo,one2 ]   aa = aa + [where one2.bostamp=bo.bostamp ]   u_sqlexec(aa)      *************actualiza embalados noite     ult = [update bi set u_embala=1 from bi,cl,st where bi.ref=st.ref and ]     ult = ult + [st.u_embalado=1 and bi.no=cl.no and bi.estab=cl.estab and ]     ult = ult + [cl.u_embalado=1 and bi.ndos=14 and ]     ult = ult + [convert(nvarchar(15),bi.dataobra,112)=convert(nvarchar(15),'] +  data1 + [',112) ]     u_sqlexec(ult)           aa = [update bo set bo.u_qfecha=']+userf+[',u_diafecha=1 where ndos=] + num1 + [ and ]   aa = aa + [convert(nvarchar(15),dataobra,112)=convert(nvarchar(15),'] +  data1 + [',112) ]     u_sqlexec(aa)     Query=[update bo2 set bo2.area=cl.area from bo,cl,bo2 where bo.no=cl.no and bo.estab=cl.estab ]   Query=Query+[and bo.ndos=14 and bo2.bo2stamp=bo.bostamp and len(ltrim(rtrim(bo2.area)))=0 ]   Query=Query+[and len(ltrim(rtrim(cl.area)))>0 and bo.fechada=0]   u_sqlexec(Query)       updt1 = [update producao set qtt=0,kg=0]     u_sqlexec(updt1)     dropv = [drop view te]     u_sqlexec(dropv)     View = [create view te as ]   View = View + [select sum(bi.qtt) as qtt,ref,sum(bi.qtt)*(select peso from st where st.ref=bi.ref) as kg]   View = View + [ from bi (nolock) where bi.ndos=14 and ]   View = View + [convert(nvarchar(15),dataobra,112)=convert(nvarchar(15),getdate(),112) group by bi.ref]         u_sqlexec(View)     updt = [update producao set qtt=te.qtt,producao.kg=te.kg,producao.dataprod=']+dtosql(Date())+[' from producao,te where ]   updt = updt + [te.ref=producao.ref and producao.qtt<>te.qtt]     u_sqlexec(updt)     TEXT to queryInsert textmerge noshow  insert into producao( producaostamp, ref, design, qtt, datains, dataprod,kg)  select left(newId(),25), te.ref, (select design from st where ref = te.ref), te.qtt, getDate(), '<<dtosql(Date())>>',te.kg  from te  where te.ref not in (select distinct ref from producao)   ENDTEXT     u_sqlexec(queryInsert)     msg("Dia Fechado")  Else   msg("Deverá posicionar-se num dossier.")  Endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top