Датагрид с чекбоксами и второй датагрид - VB

Узнай цену своей работы

Формулировка задачи:

смысл запроса в кратце:
первое поле умножаем на второе поле, получаем нужное нам поле. запрос работает, но есть небольшая ошибка. Если в одном из полей есть дробное значение, то после вычислений получается 0. Как думаете почему так получается?

Решение задачи: «Датагрид с чекбоксами и второй датагрид»

textual
Листинг программы
<font color="blue">Call</font> conect

conn.Execute <font color="teal">"DELETE FROM TempDB2"</font>
conn.Execute <font color="teal">"DROP TABLE TempDB2"</font>


conn.Execute <font color="teal">"SELECT N_DOC, KPP, IN_POK, DATE, K_PRED, DOC_O1, DATE_O1, N_SHF, TMC1, ADR1, N_POK, KOLO11, KOLO12, KOLO13, KOLO14, KOLO15, KOLO16, KOLO21, KOLO22, KOLO23, KOLO24, KOLO25, KOLO26, KOLO31, KOLO32, KOLO33, KOLO34, KOLO35, KOLO36, KOLO41, KOLO42, KOLO43, KOLO44, KOLO45, KOLO46, SUMO1, SUMO2, SUMO3, SUMO4, KVO1, PNDS1, PNDS2, PNDS3,PNDS4, PNDS5, PNDS6, CEN1, CEN2, CEN3, CEN4, CEN5, CEN6, REG,"</font> _
& <font color="teal">"IIf(PNDS1=0, (KOLO11*CEN1), 0)+IIf(PNDS2=0, (KOLO12*CEN2), 0)+IIf(PNDS3=0, (KOLO13*CEN3), 0)+IIf(PNDS4=0, (KOLO14*CEN4), 0)+IIf(PNDS5=0, (KOLO15*CEN5) ,0)+IIf(PNDS6=0, (KOLO16*CEN6) ,0)+IIf(NDSTR=0, (PTR1), 0) AS SUMNDS0,"</font> _
& <font color="teal">"IIf(PNDS1=10, (PNDS1*KOLO11*CEN1/100), 0)+IIf(PNDS2=10, (PNDS2*KOLO12*CEN2/100), 0)+IIf(PNDS3=10, (PNDS3*KOLO13*CEN3/100), 0)+IIf(PNDS4=10, (PNDS4*KOLO14*CEN4/100), 0)+IIf(PNDS5=10, (PNDS5*KOLO15*CEN5/100) ,0)+IIf(PNDS6=10, (PNDS6*KOLO16*CEN6/100) ,0)+IIf(NDSTR=10, (PTR1*NDSTR/110), 0) AS SUMNDS10,"</font> _
& <font color="teal">"IIf(PNDS1=18, (PNDS1*KOLO11*CEN1/100), 0)+IIf(PNDS2=18, (PNDS2*KOLO12*CEN2/100), 0)+IIf(PNDS3=18, (PNDS3*KOLO13*CEN3/100), 0)+IIf(PNDS4=18, (PNDS4*KOLO14*CEN4/100), 0)+IIf(PNDS5=18, (PNDS5*KOLO15*CEN5/100) ,0)+IIf(PNDS6=18, (PNDS6*KOLO16*CEN6/100) ,0)+IIf(NDSTR=18, (PTR1*NDSTR/118), 0) AS SUMNDS18,"</font> _
& <font color="teal">"IIf(PNDS1=20, (PNDS1*KOLO11*CEN1/100), 0)+IIf(PNDS2=20, (PNDS2*KOLO12*CEN2/100), 0)+IIf(PNDS3=20, (PNDS3*KOLO13*CEN3/100), 0)+IIf(PNDS4=20, (PNDS4*KOLO14*CEN4/100), 0)+IIf(PNDS5=20, (PNDS5*KOLO15*CEN5/100) ,0)+IIf(PNDS6=20, (PNDS6*KOLO16*CEN6/100) ,0)+IIf(NDSTR=20, (PTR1*NDSTR/120), 0) AS SUMNDS20,"</font> _
& <font color="teal">"IIf(PNDS1=10, ((KOLO11*CEN1)-(PNDS1*KOLO11*CEN1/100)), 0)+IIf(PNDS2=10, ((KOLO12*CEN2)-(PNDS2*KOLO12*CEN2/100)), 0)+IIf(PNDS3=10, ((KOLO13*CEN2)-(PNDS3*KOLO13*CEN3/100)), 0)+IIf(PNDS4=10, ((KOLO14*CEN4)-(PNDS4*KOLO14*CEN4/100)), 0)+IIf(PNDS5=10, ((KOLO15*CEN5)-(PNDS5*KOLO15*CEN5/100)) ,0)+IIf(PNDS6=10, ((KOLO16*CEN6)-(PNDS6*KOLO16*CEN6/100)) ,0)+IIf(NDSTR=10, (PTR1*NDSTR/110*100), 0) AS BEZNDS10,"</font> _
& <font color="teal">"IIf(PNDS1=18, ((KOLO11*CEN1)-(PNDS1*KOLO11*CEN1/100)), 0)+IIf(PNDS2=18, ((KOLO12*CEN2)-(PNDS2*KOLO12*CEN2/100)), 0)+IIf(PNDS3=18, ((KOLO13*CEN2)-(PNDS3*KOLO13*CEN3/100)), 0)+IIf(PNDS4=18, ((KOLO14*CEN4)-(PNDS4*KOLO14*CEN4/100)), 0)+IIf(PNDS5=18, ((KOLO15*CEN5)-(PNDS5*KOLO15*CEN5/100)) ,0)+IIf(PNDS6=18, ((KOLO16*CEN6)-(PNDS6*KOLO16*CEN6/100)) ,0)+IIf(NDSTR=18, (PTR1*NDSTR/118*100), 0) AS BEZNDS18,"</font> _
& <font color="teal">"IIf(PNDS1=20, ((KOLO11*CEN1)-(PNDS1*KOLO11*CEN1/100)), 0)+IIf(PNDS2=20, ((KOLO12*CEN2)-(PNDS2*KOLO12*CEN2/100)), 0)+IIf(PNDS3=20, ((KOLO13*CEN2)-(PNDS3*KOLO13*CEN3/100)), 0)+IIf(PNDS4=20, ((KOLO14*CEN4)-(PNDS4*KOLO14*CEN4/100)), 0)+IIf(PNDS5=20, ((KOLO15*CEN5)-(PNDS5*KOLO15*CEN5/100)) ,0)+IIf(PNDS6=20, ((KOLO16*CEN6)-(PNDS6*KOLO16*CEN6/100)) ,0)+IIf(NDSTR=20, (PTR1*NDSTR/120*100), 0) AS BEZNDS20,"</font> _
& <font color="teal">"(SUMNDS10+SUMNDS0+SUMNDS18+SUMNDS20+BEZNDS10+BEZNDS18+BEZNDS20) AS SUMOPLSNDS INTO TempDB2 FROM DZ WHERE (tmc1 = '50' OR tmc1 = '51' OR tmc1 = '60' OR tmc1 = '61' OR tmc1 = '62') AND (TMC <> '19') AND (TMC <> '25') AND ((date_o1 >= # "</font> & date_us1 & <font color="teal">" #) AND (date_o1 <= # "</font> & date_us2 & <font color="teal">" #))"</font>


<font color="00AA00">'conn.Execute <font color="teal">"INSERT INTO TempDB2 SELECT N_DOC, KPP, IN_POK, DATE, K_PRED, DATE_O1, N_SHF, ADR1, N_POK, KVO1, PNDS1, PNDS2, PNDS3,PNDS4, PNDS5, PNDS6, CEN1, CEN2, CEN3, CEN4, CEN5, CEN6, REG,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=0, (KOL1*CEN1), 0)+IIf(PNDS2=0, (KOL2*CEN2), 0)+IIf(PNDS3=0, (KOL3*CEN3), 0)+IIf(PNDS4=0, (KOL4*CEN4), 0)+IIf(PNDS5=0, (KOL5*CEN5) ,0)+IIf(PNDS6=0, (KOL6*CEN6) ,0)+IIf(NDSTR=0, (PTR), 0) AS SUMNDS0,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=10, (PNDS1*KOL1*CEN1/100), 0)+IIf(PNDS2=10, (PNDS2*KOL2*CEN2/100), 0)+IIf(PNDS3=10, (PNDS3*KOL3*CEN3/100), 0)+IIf(PNDS4=10, (PNDS4*KOL4*CEN4/100), 0)+IIf(PNDS5=10, (PNDS5*KOL5*CEN5/100) ,0)+IIf(PNDS6=10, (PNDS6*KOL6*CEN6/100) ,0)+IIf(NDSTR=10, (PTR*NDSTR/110), 0) AS SUMNDS10,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=18, (PNDS1*KOL1*CEN1/100), 0)+IIf(PNDS2=18, (PNDS2*KOL2*CEN2/100), 0)+IIf(PNDS3=18, (PNDS3*KOL3*CEN3/100), 0)+IIf(PNDS4=18, (PNDS4*KOL4*CEN4/100), 0)+IIf(PNDS5=18, (PNDS5*KOL5*CEN5/100) ,0)+IIf(PNDS6=18, (PNDS6*KOL6*CEN6/100) ,0)+IIf(NDSTR=18, (PTR*NDSTR/118), 0) AS SUMNDS18,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=20, (PNDS1*KOL1*CEN1/100), 0)+IIf(PNDS2=20, (PNDS2*KOL2*CEN2/100), 0)+IIf(PNDS3=20, (PNDS3*KOL3*CEN3/100), 0)+IIf(PNDS4=20, (PNDS4*KOL4*CEN4/100), 0)+IIf(PNDS5=20, (PNDS5*KOL5*CEN5/100) ,0)+IIf(PNDS6=20, (PNDS6*KOL6*CEN6/100) ,0)+IIf(NDSTR=20, (PTR*NDSTR/120), 0) AS SUMNDS20,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=10, ((KOL1*CEN1)-(PNDS1*KOL1*CEN1/100)), 0)+IIf(PNDS2=10, ((KOL2*CEN2)-(PNDS2*KOL2*CEN2/100)), 0)+IIf(PNDS3=10, ((KOL3*CEN2)-(PNDS3*KOL3*CEN3/100)), 0)+IIf(PNDS4=10, ((KOL4*CEN4)-(PNDS4*KOL4*CEN4/100)), 0)+IIf(PNDS5=10, ((KOL5*CEN5)-(PNDS5*KOL5*CEN5/100)) ,0)+IIf(PNDS6=10, ((KOL6*CEN6)-(PNDS6*KOL6*CEN6/100)) ,0)+IIf(NDSTR=10, (PTR*NDSTR/110*100), 0) AS BEZNDS10,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=18, ((KOL1*CEN1)-(PNDS1*KOL1*CEN1/100)), 0)+IIf(PNDS2=18, ((KOL2*CEN2)-(PNDS2*KOL2*CEN2/100)), 0)+IIf(PNDS3=18, ((KOL3*CEN2)-(PNDS3*KOL3*CEN3/100)), 0)+IIf(PNDS4=18, ((KOL4*CEN4)-(PNDS4*KOL4*CEN4/100)), 0)+IIf(PNDS5=18, ((KOL5*CEN5)-(PNDS5*KOL5*CEN5/100)) ,0)+IIf(PNDS6=18, ((KOL6*CEN6)-(PNDS6*KOL6*CEN6/100)) ,0)+IIf(NDSTR=18, (PTR*NDSTR/118*100), 0) AS BEZNDS18,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=20, ((KOL1*CEN1)-(PNDS1*KOL1*CEN1/100)), 0)+IIf(PNDS2=20, ((KOL2*CEN2)-(PNDS2*KOL2*CEN2/100)), 0)+IIf(PNDS3=20, ((KOL3*CEN2)-(PNDS3*KOL3*CEN3/100)), 0)+IIf(PNDS4=20, ((KOL4*CEN4)-(PNDS4*KOL4*CEN4/100)), 0)+IIf(PNDS5=20, ((KOL5*CEN5)-(PNDS5*KOL5*CEN5/100)) ,0)+IIf(PNDS6=20, ((KOL6*CEN6)-(PNDS6*KOL6*CEN6/100)) ,0)+IIf(NDSTR=20, (PTR*NDSTR/120*100), 0) AS BEZNDS20,"</font> _</font>
<font color="00AA00">'& <font color="teal">"(SUMNDS0+SUMNDS10+SUMNDS18+SUMNDS20+BEZNDS10+BEZNDS18+BEZNDS20) AS SUMOPLSNDS FROM DZ WHERE (tmc = '19' OR tmc = '25') AND ((REG < 100) Or (REG Between 200 And 206)) AND ((date_o1 >= # "</font> & date_us1 & <font color="teal">" #) AND (date_o1 <= # "</font> & date_us2 & <font color="teal">" #))"</font></font>

<font color="00AA00">'ïî âòîðîé îïëàòå</font>
<font color="00AA00">'conn.Execute <font color="teal">"INSERT INTO TempDB2 SELECT N_DOC, KPP, IN_POK, DATE, K_PRED, DOC_O1, N_SHF, TMC1, ADR1, N_POK, KOLO11, KOLO12, KOLO13, KOLO14, KOLO15, KOLO16, SUMO1, SUMO2, SUMO3, SUMO4, KVO1, PNDS1, PNDS2, PNDS3,PNDS4, PNDS5, PNDS6, CEN1, CEN2, CEN3, CEN4, CEN5, CEN6, REG,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=0, (KOLO21*CEN2), 0)+IIf(PNDS2=0, (KOLO22*CEN2), 0)+IIf(PNDS3=0, (KOLO23*CEN3), 0)+IIf(PNDS4=0, (KOLO24*CEN4), 0)+IIf(PNDS5=0, (KOLO25*CEN5), 0)+IIf(PNDS6=0, (KOLO26*CEN6), 0)+IIf(NDSTR=0, (PTR2), 0) AS SUMNDS0, (Date_o2) as Date_o1,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=10, (PNDS1*KOLO21*CEN1/100), 0)+IIf(PNDS2=10, (PNDS2*KOLO22*CEN2/100), 0)+IIf(PNDS3=10, (PNDS3*KOLO23*CEN3/100), 0)+IIf(PNDS4=10, (PNDS4*KOLO24*CEN4/100), 0)+IIf(PNDS5=10, (PNDS5*KOLO25*CEN5/100) ,0)+IIf(PNDS6=10, (PNDS6*KOLO26*CEN6/100) ,0)+IIf(NDSTR=10, (PTR2*NDSTR/110), 0) AS SUMNDS10,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=18, (PNDS1*KOLO21*CEN1/100), 0)+IIf(PNDS2=18, (PNDS2*KOLO22*CEN2/100), 0)+IIf(PNDS3=18, (PNDS3*KOLO23*CEN3/100), 0)+IIf(PNDS4=18, (PNDS4*KOLO24*CEN4/100), 0)+IIf(PNDS5=18, (PNDS5*KOLO25*CEN5/100) ,0)+IIf(PNDS6=18, (PNDS6*KOLO26*CEN6/100) ,0)+IIf(NDSTR=18, (PTR2*NDSTR/118), 0) AS SUMNDS18,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=20, (PNDS1*KOLO21*CEN1/100), 0)+IIf(PNDS2=20, (PNDS2*KOLO22*CEN2/100), 0)+IIf(PNDS3=20, (PNDS3*KOLO23*CEN3/100), 0)+IIf(PNDS4=20, (PNDS4*KOLO24*CEN4/100), 0)+IIf(PNDS5=20, (PNDS5*KOLO25*CEN5/100) ,0)+IIf(PNDS6=20, (PNDS6*KOLO26*CEN6/100) ,0)+IIf(NDSTR=20, (PTR2*NDSTR/120), 0) AS SUMNDS20,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=10, ((KOLO21*CEN1)-(PNDS1*KOLO21*CEN1/100)), 0)+IIf(PNDS2=10, ((KOLO22*CEN2)-(PNDS2*KOLO22*CEN2/100)), 0)+IIf(PNDS3=10, ((KOLO23*CEN2)-(PNDS3*KOLO23*CEN3/100)), 0)+IIf(PNDS4=10, ((KOLO24*CEN4)-(PNDS4*KOLO24*CEN4/100)), 0)+IIf(PNDS5=10, ((KOLO25*CEN5)-(PNDS5*KOLO25*CEN5/100)) ,0)+IIf(PNDS6=10, ((KOLO26*CEN6)-(PNDS6*KOLO26*CEN6/100)) ,0)+IIf(NDSTR=10, (PTR2*NDSTR/110*100), 0) AS BEZNDS10,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=18, ((KOLO21*CEN1)-(PNDS1*KOLO21*CEN1/100)), 0)+IIf(PNDS2=18, ((KOLO22*CEN2)-(PNDS2*KOLO22*CEN2/100)), 0)+IIf(PNDS3=18, ((KOLO23*CEN2)-(PNDS3*KOLO23*CEN3/100)), 0)+IIf(PNDS4=18, ((KOLO24*CEN4)-(PNDS4*KOLO24*CEN4/100)), 0)+IIf(PNDS5=18, ((KOLO25*CEN5)-(PNDS5*KOLO25*CEN5/100)) ,0)+IIf(PNDS6=18, ((KOLO26*CEN6)-(PNDS6*KOLO26*CEN6/100)) ,0)+IIf(NDSTR=18, (PTR2*NDSTR/118*100), 0) AS BEZNDS18,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=20, ((KOLO21*CEN1)-(PNDS1*KOLO21*CEN1/100)), 0)+IIf(PNDS2=20, ((KOLO22*CEN2)-(PNDS2*KOLO22*CEN2/100)), 0)+IIf(PNDS3=20, ((KOLO23*CEN2)-(PNDS3*KOLO23*CEN3/100)), 0)+IIf(PNDS4=20, ((KOLO24*CEN4)-(PNDS4*KOLO24*CEN4/100)), 0)+IIf(PNDS5=20, ((KOLO25*CEN5)-(PNDS5*KOLO25*CEN5/100)) ,0)+IIf(PNDS6=20, ((KOLO26*CEN6)-(PNDS6*KOLO26*CEN6/100)) ,0)+IIf(NDSTR=20, (PTR2*NDSTR/120*100), 0) AS BEZNDS20,"</font> _</font>
<font color="00AA00">'& <font color="teal">"(SUMNDS10+SUMNDS0+SUMNDS18+SUMNDS20+BEZNDS10+BEZNDS18+BEZNDS20) AS SUMOPLSNDS FROM DZ WHERE (tmc2 = '50' OR tmc2 = '51' OR tmc2 = '60' OR tmc2 = '61' OR tmc2 = '62') AND (TMC <> '19') AND (TMC <> '25') AND ((date_o2 >= # "</font> & date_us1 & <font color="teal">" #) AND (date_o2 <= # "</font> & date_us2 & <font color="teal">" #))"</font></font>


<font color="00AA00">'conn.Execute <font color="teal">"INSERT INTO TempDB2 SELECT N_DOC, KPP, IN_POK, DATE, K_PRED, DOC_O1, N_SHF, TMC1, ADR1, N_POK, KOLO11, KOLO12, KOLO13, KOLO14, KOLO15, KOLO16, SUMO1, SUMO2, SUMO3, SUMO4, KVO1, PNDS1, PNDS2, PNDS3,PNDS4, PNDS5, PNDS6, CEN1, CEN2, CEN3, CEN4, CEN5, CEN6, REG,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=0, (KOLO31*CEN2), 0)+IIf(PNDS2=0, (KOLO32*CEN2), 0)+IIf(PNDS3=0, (KOLO33*CEN3), 0)+IIf(PNDS4=0, (KOLO34*CEN4), 0)+IIf(PNDS5=0, (KOLO35*CEN5) ,0)+IIf(PNDS6=0, (KOLO36*CEN6) ,0)+IIf(NDSTR=0, (PTR3), 0) AS SUMNDS0, (Date_o3) as Date_o1,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=10, (PNDS1*KOLO31*CEN1/100), 0)+IIf(PNDS2=10, (PNDS2*KOLO32*CEN2/100), 0)+IIf(PNDS3=10, (PNDS3*KOLO33*CEN3/100), 0)+IIf(PNDS4=10, (PNDS4*KOLO34*CEN4/100), 0)+IIf(PNDS5=10, (PNDS5*KOLO35*CEN5/100) ,0)+IIf(PNDS6=10, (PNDS6*KOLO36*CEN6/100) ,0)+IIf(NDSTR=10, (PTR3*NDSTR/110), 0) AS SUMNDS10,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=18, (PNDS1*KOLO31*CEN1/100), 0)+IIf(PNDS2=18, (PNDS2*KOLO32*CEN2/100), 0)+IIf(PNDS3=18, (PNDS3*KOLO33*CEN3/100), 0)+IIf(PNDS4=18, (PNDS4*KOLO34*CEN4/100), 0)+IIf(PNDS5=18, (PNDS5*KOLO35*CEN5/100) ,0)+IIf(PNDS6=18, (PNDS6*KOLO36*CEN6/100) ,0)+IIf(NDSTR=18, (PTR3*NDSTR/118), 0) AS SUMNDS18,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=20, (PNDS1*KOLO31*CEN1/100), 0)+IIf(PNDS2=20, (PNDS2*KOLO32*CEN2/100), 0)+IIf(PNDS3=20, (PNDS3*KOLO33*CEN3/100), 0)+IIf(PNDS4=20, (PNDS4*KOLO34*CEN4/100), 0)+IIf(PNDS5=20, (PNDS5*KOLO35*CEN5/100) ,0)+IIf(PNDS6=20, (PNDS6*KOLO36*CEN6/100) ,0)+IIf(NDSTR=20, (PTR3*NDSTR/120), 0) AS SUMNDS20,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=10, ((KOLO31*CEN1)-(PNDS1*KOLO31*CEN1/100)), 0)+IIf(PNDS2=10, ((KOLO32*CEN2)-(PNDS2*KOLO32*CEN2/100)), 0)+IIf(PNDS3=10, ((KOLO33*CEN2)-(PNDS3*KOLO33*CEN3/100)), 0)+IIf(PNDS4=10, ((KOLO34*CEN4)-(PNDS4*KOLO34*CEN4/100)), 0)+IIf(PNDS5=10, ((KOLO35*CEN5)-(PNDS5*KOLO35*CEN5/100)) ,0)+IIf(PNDS6=10, ((KOLO36*CEN6)-(PNDS6*KOLO36*CEN6/100)) ,0)+IIf(NDSTR=10, (PTR3*NDSTR/110*100), 0) AS BEZNDS10,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=18, ((KOLO31*CEN1)-(PNDS1*KOLO31*CEN1/100)), 0)+IIf(PNDS2=18, ((KOLO32*CEN2)-(PNDS2*KOLO32*CEN2/100)), 0)+IIf(PNDS3=18, ((KOLO33*CEN2)-(PNDS3*KOLO33*CEN3/100)), 0)+IIf(PNDS4=18, ((KOLO34*CEN4)-(PNDS4*KOLO34*CEN4/100)), 0)+IIf(PNDS5=18, ((KOLO35*CEN5)-(PNDS5*KOLO35*CEN5/100)) ,0)+IIf(PNDS6=18, ((KOLO36*CEN6)-(PNDS6*KOLO36*CEN6/100)) ,0)+IIf(NDSTR=18, (PTR3*NDSTR/118*100), 0) AS BEZNDS18,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=20, ((KOLO31*CEN1)-(PNDS1*KOLO31*CEN1/100)), 0)+IIf(PNDS2=20, ((KOLO32*CEN2)-(PNDS2*KOLO32*CEN2/100)), 0)+IIf(PNDS3=20, ((KOLO33*CEN2)-(PNDS3*KOLO33*CEN3/100)), 0)+IIf(PNDS4=20, ((KOLO34*CEN4)-(PNDS4*KOLO34*CEN4/100)), 0)+IIf(PNDS5=20, ((KOLO35*CEN5)-(PNDS5*KOLO35*CEN5/100)) ,0)+IIf(PNDS6=20, ((KOLO36*CEN6)-(PNDS6*KOLO36*CEN6/100)) ,0)+IIf(NDSTR=20, (PTR3*NDSTR/120*100), 0) AS BEZNDS20,"</font> _</font>
<font color="00AA00">'& <font color="teal">"(SUMNDS10+SUMNDS0+SUMNDS18+SUMNDS20+BEZNDS10+BEZNDS18+BEZNDS20) AS SUMOPLSNDS FROM DZ WHERE (tmc3 = '50' OR tmc3 = '51' OR tmc3 = '60' OR tmc3 = '61' OR tmc3 = '62') AND (TMC <> '19') AND (TMC <> '25') AND ((date_o3 >= # "</font> & date_us1 & <font color="teal">" #) AND (date_o3 <= # "</font> & date_us2 & <font color="teal">" #))"</font></font>


<font color="00AA00">'conn.Execute <font color="teal">"INSERT INTO TempDB2 SELECT N_DOC, KPP, IN_POK, DATE, K_PRED, DOC_O1, N_SHF, TMC1, ADR1, N_POK, KOLO11, KOLO12, KOLO13, KOLO14, KOLO15, KOLO16, SUMO1, SUMO2, SUMO3, SUMO4, KVO1, PNDS1, PNDS2, PNDS3,PNDS4, PNDS5, PNDS6, CEN1, CEN2, CEN3, CEN4, CEN5, CEN6, REG,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=0, (KOLO41*CEN2), 0)+IIf(PNDS2=0, (KOLO42*CEN2), 0)+IIf(PNDS3=0, (KOLO43*CEN3), 0)+IIf(PNDS4=0, (KOLO44*CEN4), 0)+IIf(PNDS5=0, (KOLO45*CEN5) ,0)+IIf(PNDS6=0, (KOLO46*CEN6) ,0)+IIf(NDSTR=0, (PTR4), 0) AS SUMNDS0, (Date_o4) as Date_o1,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=10, (PNDS1*KOLO41*CEN1/100), 0)+IIf(PNDS2=10, (PNDS2*KOLO42*CEN2/100), 0)+IIf(PNDS3=10, (PNDS3*KOLO43*CEN3/100), 0)+IIf(PNDS4=10, (PNDS4*KOLO44*CEN4/100), 0)+IIf(PNDS5=10, (PNDS5*KOLO45*CEN5/100) ,0)+IIf(PNDS6=10, (PNDS6*KOLO46*CEN6/100) ,0)+IIf(NDSTR=10, (PTR4*NDSTR/110), 0) AS SUMNDS10,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=18, (PNDS1*KOLO41*CEN1/100), 0)+IIf(PNDS2=18, (PNDS2*KOLO42*CEN2/100), 0)+IIf(PNDS3=18, (PNDS3*KOLO43*CEN3/100), 0)+IIf(PNDS4=18, (PNDS4*KOLO44*CEN4/100), 0)+IIf(PNDS5=18, (PNDS5*KOLO45*CEN5/100) ,0)+IIf(PNDS6=18, (PNDS6*KOLO46*CEN6/100) ,0)+IIf(NDSTR=18, (PTR4*NDSTR/118), 0) AS SUMNDS18,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=20, (PNDS1*KOLO41*CEN1/100), 0)+IIf(PNDS2=20, (PNDS2*KOLO42*CEN2/100), 0)+IIf(PNDS3=20, (PNDS3*KOLO43*CEN3/100), 0)+IIf(PNDS4=20, (PNDS4*KOLO44*CEN4/100), 0)+IIf(PNDS5=20, (PNDS5*KOLO45*CEN5/100) ,0)+IIf(PNDS6=20, (PNDS6*KOLO46*CEN6/100) ,0)+IIf(NDSTR=20, (PTR4*NDSTR/120), 0) AS SUMNDS20,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=10, ((KOLO41*CEN1)-(PNDS1*KOLO41*CEN1/100)), 0)+IIf(PNDS2=10, ((KOLO42*CEN2)-(PNDS2*KOLO42*CEN2/100)), 0)+IIf(PNDS3=10, ((KOLO43*CEN2)-(PNDS3*KOLO43*CEN3/100)), 0)+IIf(PNDS4=10, ((KOLO44*CEN4)-(PNDS4*KOLO44*CEN4/100)), 0)+IIf(PNDS5=10, ((KOLO45*CEN5)-(PNDS5*KOLO45*CEN5/100)) ,0)+IIf(PNDS6=10, ((KOLO46*CEN6)-(PNDS6*KOLO46*CEN6/100)) ,0)+IIf(NDSTR=10, (PTR4*NDSTR/110*100), 0) AS BEZNDS10,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=18, ((KOLO41*CEN1)-(PNDS1*KOLO41*CEN1/100)), 0)+IIf(PNDS2=18, ((KOLO42*CEN2)-(PNDS2*KOLO42*CEN2/100)), 0)+IIf(PNDS3=18, ((KOLO43*CEN2)-(PNDS3*KOLO43*CEN3/100)), 0)+IIf(PNDS4=18, ((KOLO44*CEN4)-(PNDS4*KOLO44*CEN4/100)), 0)+IIf(PNDS5=18, ((KOLO45*CEN5)-(PNDS5*KOLO45*CEN5/100)) ,0)+IIf(PNDS6=18, ((KOLO46*CEN6)-(PNDS6*KOLO46*CEN6/100)) ,0)+IIf(NDSTR=18, (PTR4*NDSTR/118*100), 0) AS BEZNDS18,"</font> _</font>
<font color="00AA00">'& <font color="teal">"IIf(PNDS1=20, ((KOLO41*CEN1)-(PNDS1*KOLO41*CEN1/100)), 0)+IIf(PNDS2=20, ((KOLO42*CEN2)-(PNDS2*KOLO42*CEN2/100)), 0)+IIf(PNDS3=20, ((KOLO43*CEN2)-(PNDS3*KOLO43*CEN3/100)), 0)+IIf(PNDS4=20, ((KOLO44*CEN4)-(PNDS4*KOLO44*CEN4/100)), 0)+IIf(PNDS5=20, ((KOLO45*CEN5)-(PNDS5*KOLO45*CEN5/100)) ,0)+IIf(PNDS6=20, ((KOLO46*CEN6)-(PNDS6*KOLO46*CEN6/100)) ,0)+IIf(NDSTR=20, (PTR4*NDSTR/120*100), 0) AS BEZNDS20,"</font> _</font>
<font color="00AA00">'& <font color="teal">"(SUMNDS10+SUMNDS0+SUMNDS18+SUMNDS20+BEZNDS10+BEZNDS18+BEZNDS20) AS SUMOPLSNDS FROM DZ WHERE (tmc4 = '50' OR tmc4 = '51' OR tmc4 = '60' OR tmc4 = '61' OR tmc3 = '62') AND (TMC <> '19') AND (TMC <> '25') AND ((date_o4 >= # "</font> & date_us1 & <font color="teal">" #) AND (date_o4 <= # "</font> & date_us2 & <font color="teal">" #))"</font></font>

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

10   голосов , оценка 3.7 из 5
Похожие ответы