예제 #1
0
파일: binList.py 프로젝트: lezzgiles/esp
            cursor.execute('INSERT INTO binItems (binId,itemId,quantity) VALUES (?,?,?)',(binId,delItem,binQty))

        if foundQty > totalToMove:
            cursor.execute('INSERT INTO binItems (binId,itemId,quantity) VALUES (?,?,?)',(delBin,delItem,foundQty-totalToMove))
            
        cursor.execute('''INSERT INTO history (historyDate,body) VALUES (DATETIME('now'),?)''',(history,))
        c.commit()
        # Redirect to same page, so page reload doesn't re-add move
        printRedirect('Move completed','binList.py',0)
        sys.exit()

    except Exception,e:
        c.rollback()
        errorString = "<p class=error>Problem with database update:</p><pre>%s</pre>"%str(sys.exc_info())
    
printHeader2('Bin/stock list',errorString)

#########################################    
cursor.execute('''
SELECT
    binId,itemId,Bin.name,Item.manufacturer,Item.brand,Item.name,SUM(quantity)
FROM
    Bin
    INNER JOIN BinItems using (binId)
    INNER JOIN Item USING (itemId)
GROUP BY binId,itemId
''')

binList = []
for binDetails in cursor: binList.append(binDetails)
예제 #2
0
파일: sales.py 프로젝트: lezzgiles/esp
            foundQty = int(foundQty)
            if foundQty < qty:
                raise ValueError,'<p class=error>Database changed - needed %s kit %s but only found %d - aborting sale</p>'%(qty,kitId,foundQty)
            cursor.execute('UPDATE Kit SET quantity = ? WHERE kitId = ?',(foundQty-qty,kitId))
                
        cursor.execute('''INSERT INTO history (historyDate,body) VALUES (DATETIME('now'),?)''',(history,))
        c.commit()
        # Redirect to same page, so page reload doesn't re-add sale
        printRedirect('Added Sale','sales.py',0)
        sys.exit()

    except Exception,e:
        c.rollback()
        errorString = "<p class=error>Problem with database update:</p><pre>%s</pre>"%str(sys.exc_info())

printHeader2('Sales',errorString)
    
################
# Get list of items for add sale form

cursor.execute("SELECT itemId,manufacturer,brand,name FROM item INNER JOIN binItems USING (itemId) WHERE quantity > 0 GROUP BY manufacturer,brand,name ORDER BY manufacturer,brand,name")
itemOptions = []
for (itemId,manufacturer,brand,name) in cursor:
    itemOptions.append('<OPTION VALUE=Item%s>%s</OPTION>'%(itemId,getItemName(manufacturer,brand,name)))
###################
# Get list of kits for add sale form

cursor.execute("SELECT kitId,name FROM Kit ORDER BY name")
for (kitId,name) in cursor:
    itemOptions.append('<OPTION VALUE=Kit%s>Kit: %s</OPTION>'%(kitId,getName(name)))
예제 #3
0
파일: kits.py 프로젝트: lezzgiles/esp
if form.has_key('setId'):
    try:
        setId = form['setId'].value
        setQty = form['setQty'].value
        cursor.execute('BEGIN IMMEDIATE TRANSACTION')
        cursor.execute('UPDATE Kit SET quantity = ? WHERE kitId = ?',(setQty,setId))
        c.commit()
        # redirect to same page, so reload doesn't re-add purchase
        printRedirect('Deleted kit','kits.py',0)
        sys.exit()

    except Exception,e:
        c.rollback()
        errorString = "<p class=error>Problem with database update:</p><pre>%s</pre>"%str(sys.exc_info())

printHeader2('Kits',errorString)

################
# Get list of items for add kit form

cursor.execute("SELECT itemId,manufacturer,brand,name FROM item ORDER BY manufacturer,brand,name")
itemOptions = []
for (itemId,manufacturer,brand,name) in cursor:
    itemOptions.append('<OPTION VALUE=%s>%s</OPTION>'%(itemId,getItemName(manufacturer,brand,name)))
    
#####
# Add form

print "<div class=addthing>"
print "<H2>New kit</H2>"
print "<FORM name=addKit>"
예제 #4
0
파일: expenses.py 프로젝트: lezzgiles/esp
        editAmt  = form['amount'].value
        expenseId = form['edit'].value
        cursor.execute('BEGIN IMMEDIATE TRANSACTION')
        cursor.execute('UPDATE Expense SET expDate = ?, description =?, amount = ? WHERE expenseId =?',
                       (editDate,editDesc,dollarStringToCents(editAmt),expenseId))
        c.commit()
        printRedirect('Modified expense','expenses.py',0)
        sys.exit()

    except Exception,e:
        c.rollback()
        errorString = "<p class=error>Problem with database update:</p><pre>%s</pre>"%str(sys.exc_info())

####################

printHeader2('Expenses & Fees',errorString)
    
####################
# Add form
print '''
<div class=addthing>
<FORM>
<H2>Add new fee or expense</H2>
<table>
<tr><td align=right>Date:</td><td><INPUT TYPE=TEXT NAME=date ID=date SIZE=20></INPUT> Format: YYYY-MM-DD</td></tr>
<tr><td align=right>Description:</td><td><INPUT TYPE=TEXT NAME=description ID=description SIZE=70></INPUT></td></tr>
<tr><td align=right>Amount:</td><td><INPUT TYPE=TEXT NAME=amount ID=amount VALUE=0.00 SIZE=5 onBlur='moneyFormat(event.target)'/>Enter negative amount for a credit</td></tr>
<INPUT TYPE=hidden NAME=add VALUE=1/>
</table>
<INPUT TYPE=SUBMIT VALUE='Add new expense or fee' onClick='return validateForm();' />
</FORM>
예제 #5
0
if form.has_key('tracking'):
    try:
        tracking = form['tracking'].value
        actualShipping = dollarStringToCents(form['actualShipping'].value)
        cursor.execute('BEGIN IMMEDIATE TRANSACTION')
        cursor.execute('UPDATE Trans SET tracking=?, actualShipping=? WHERE tranId = ?',(tracking,actualShipping,tranId))
        c.commit()
        # redirect to page, so page reload doesn't re-add change
        printRedirect('Updating Sale','sales.py',0)
        sys.exit()
    except Exception,e:
        c.rollback()
        errorString = "<p class=error>Problem with database updte:</p><pre></pre>"%str(sys.exc_info())

printHeader2('Sale Details',errorString)

cursor.execute('SELECT type,direction,tranDate,description,shipping,actualShipping,tracking FROM Trans where tranId = ?',(tranId,))
(type,direction,tranDate,description,shipping,actualShipping,tracking) = cursor.fetchone()


mytype = getTranType(type,direction)

print '<H2>Details for %s: %s</H2>'%(mytype,description)
print '<p>Date: %s</p>'%tranDate

cursor.execute('SELECT manufacturer,brand,name,quantity,pricePerItem FROM TransItem LEFT JOIN Item USING (itemId) WHERE tranId = ?',
               (tranId,))

print '<TABLE BORDER=1><TR><TH>Item</TH><TH>qty</TH><TH>unit price</TH><TH>tot price</TH>'
totalPrice = 0
예제 #6
0
파일: purchases.py 프로젝트: lezzgiles/esp
                pricePerItem = dollarStringToCents(form['pricePerItem-'+str(i)].value)
                cursor.execute('INSERT INTO TransItem (tranId,itemId,quantity,pricePerItem) VALUES (?,?,?,?)',
                               (tranId,itemId,quantity,pricePerItem))
                cursor.execute('INSERT INTO binItems (binId,itemId,quantity) VALUES (1,?,?)',(itemId,quantity))

        cursor.execute('''INSERT INTO history (historyDate,body) VALUES (DATETIME('now'),?)''',(history,))
        c.commit()
        # redirect to same page, so reload doesn't re-add purchase
        printRedirect('Added purchase','purchases.py',0)
        sys.exit()

    except Exception,e:
        c.rollback()
        errorString = "<p class=error>Problem with database updte:</p><pre>%s</pre>"%str(sys.exc_info())

printHeader2('Purchases',errorString)

################
# Get list of items for add purchase form

cursor.execute("SELECT itemId,manufacturer,brand,name FROM item ORDER BY manufacturer,brand,name")
itemOptions = []
for (itemId,manufacturer,brand,name) in cursor:
    itemOptions.append('<OPTION VALUE=%s>%s</OPTION>'%(itemId,getItemName(manufacturer,brand,name)))
    
#####
# Add form

print '''
<div class=addthing>
<H2>New purchase</H2>