コード例 #1
0
def ItemRecipeListData(PageIndex=1,
                       PageSize=None,
                       item_uid='',
                       item_code='',
                       SearchBy=None,
                       Keywords=None):
    db = dbm.dbcmd()
    db.commandText = 'usp_mst_item_recipe_ListData'
    db.commandType = 'StoredProcedure'
    db.addInParameter('PageIndex', PageIndex)
    db.addInParameter('PageSize', PageSize)
    db.addInParameter('item_uid', item_uid)
    db.addInParameter('item_code', item_code)
    db.addInParameter('SearchBy', SearchBy)
    db.addInParameter('Keywords', Keywords)
    db.addOutParameter('RecordCount', 0)
    result = db.Execute()
    RecordCount = result.out['RecordCount']
    db.clearParameter()

    db.closeConnection()

    data = {
        'recipeDetailList': result.record,
        'recipeDetailTotalRecords': RecordCount
    }

    return data
コード例 #2
0
def SaveUpdate(header):
    saveParam = [
        'uid', 'bahan_code', 'bahan_name', 'stock_qty', 'rowstatus',
        'modified_by'
    ]  # ini parameter yg dikirim ke sp saveupdate
    header = common.PrepareModelDict(saveParam, header)

    if not header['uid']:
        header['uid'] = common.Guid()
        header['bahan_code'] = common.AutoCounter(
            'bahan_code', 'mst_bahan', 'bahan_code', '', 5
        )  # FieldName, TableName, FieldCriteria, ValueCriteria, LengthOfString
        print(header['bahan_code'])

    db = dbm.dbcmd()
    db.commandText = 'usp_mst_bahan_SaveUpdate'
    db.commandType = 'StoredProcedure'
    db.addInParameter('uid', header['uid'])
    db.addInParameter('bahan_code', header['bahan_code'])
    db.addInParameter('bahan_name', header['bahan_name'])
    db.addInParameter('stock_qty', header['stock_qty'])
    db.addInParameter('rowstatus', header['rowstatus'])
    db.addInParameter('modified_by', header['modified_by'])
    db.ExecuteNonResult()
    db.closeConnection()

    return header
コード例 #3
0
def ItemSaveUpdate(header, detail):
    headerSaveParam = [
        'uid', 'item_code', 'item_name', 'price', 'item_type', 'rowstatus',
        'modified_by'
    ]  # ini parameter yg dikirim ke sp saveupdate
    header = common.PrepareModelDict(headerSaveParam, header)

    if not header['uid']:
        header['uid'] = common.Guid()
        header['item_code'] = common.AutoCounter(
            'item_code', 'mst_item', 'item_code', 'ITM', 4
        )  # FieldName, TableName, FieldCriteria, ValueCriteria, LengthOfString
        print(header['item_code'])

    db = dbm.dbcmd()
    db.commandText = 'usp_mst_item_SaveUpdate'
    db.commandType = 'StoredProcedure'
    db.addInParameter('uid', header['uid'])
    db.addInParameter('item_code', header['item_code'])
    db.addInParameter('item_name', header['item_name'])
    db.addInParameter('price', header['price'])
    db.addInParameter('item_type', header['item_type'])
    db.addInParameter('rowstatus', header['rowstatus'])
    db.addInParameter('modified_by', header['modified_by'])
    db.ExecuteNonResult()
    db.clearParameter()

    detailSaveParam = [
        'uid', 'item_uid', 'item_code', 'item_name', 'bahan_uid', 'bahan_code',
        'bahan_name', 'qty', 'unit_code', 'rowstatus', 'modified_by'
    ]
    for row in detail:
        row['item_uid'] = header['uid']
        row['item_code'] = header['item_code']
        row['item_name'] = header['item_name']
        row['modified_by'] = header['modified_by']

        row = common.PrepareModelDict(detailSaveParam, row)

        db.commandText = 'usp_mst_item_recipe_SaveUpdate'
        db.commandType = 'StoredProcedure'
        db.addInParameter('uid', row['uid'] if row['uid'] else common.Guid())
        db.addInParameter('item_uid', row['item_uid'])
        db.addInParameter('item_code', row['item_code'])
        db.addInParameter('item_name', row['item_name'])
        db.addInParameter('bahan_uid', row['bahan_uid'])
        db.addInParameter('bahan_code', row['bahan_code'])
        db.addInParameter('bahan_name', row['bahan_name'])
        db.addInParameter('qty', row['qty'])
        db.addInParameter('unit_code', row['unit_code'])
        db.addInParameter('rowstatus', row['rowstatus'])
        db.addInParameter('modified_by', row['modified_by'])
        db.ExecuteNonResult()
        db.clearParameter()

    db.closeConnection()

    return header
コード例 #4
0
def GetOptions(table_name, id_field, name_field):
    fields = id_field + ' id,' + name_field + ' name '

    db = dbm.dbcmd()
    db.commandText = 'proc_GetData'
    db.commandType = 'StoredProcedure'
    db.addInParameter('table_name', table_name)
    db.addInParameter('fields', fields)
    result = db.Execute()
    db.clearParameter()
    db.closeConnection(False)

    result = result.record
    return result
コード例 #5
0
def AutoCounter(FieldName, TableName, FieldCriteria, ValueCriteria, LengthOfString, NumericOnly=0):
    db = dbm.dbcmd()
    db.commandText = 'proc_AutoCounter'
    db.commandType = 'StoredProcedure'
    db.addInParameter('FieldName', FieldName)
    db.addInParameter('TableName', TableName)
    db.addInParameter('FieldCriteria', FieldCriteria)
    db.addInParameter('ValueCriteria', ValueCriteria)
    db.addInParameter('LengthOfString', LengthOfString)
    db.addInParameter('NumericOnly', NumericOnly)
    result = db.Execute()
    db.clearParameter()
    db.closeConnection(False)

    result = result.record[0]
    return result['AutoCode']
コード例 #6
0
def ListData(PageIndex=1, PageSize=None, SearchBy=None, Keywords=None):
    db = dbm.dbcmd()
    db.commandText = 'usp_mst_unit_ListData'
    db.commandType = 'StoredProcedure'
    db.addInParameter('PageIndex', PageIndex)
    db.addInParameter('PageSize', PageSize)
    db.addInParameter('SearchBy', SearchBy)
    db.addInParameter('Keywords', Keywords)
    db.addOutParameter('RecordCount', 0)
    result = db.Execute()
    RecordCount = result.out['RecordCount']
    db.clearParameter()

    db.closeConnection()

    data = {'List': result.record, 'TotalRecords': RecordCount}

    return data
コード例 #7
0
def SaveUpdate(header):
    saveParam = ['uid', 'unit_code', 'unit_name', 'rowstatus',
                 'modified_by']  # ini parameter yg dikirim ke sp saveupdate
    header = common.PrepareModelDict(saveParam, header)

    if not header['unit_code']:
        raise ValueError('Unit Code cannot be null.')

    if not header['uid']:
        header['uid'] = common.Guid()

    db = dbm.dbcmd()
    db.commandText = 'usp_mst_unit_SaveUpdate'
    db.commandType = 'StoredProcedure'
    db.addInParameter('uid', header['uid'])
    db.addInParameter('unit_code', header['unit_code'])
    db.addInParameter('unit_name', header['unit_name'])
    db.addInParameter('rowstatus', header['rowstatus'])
    db.addInParameter('modified_by', header['modified_by'])
    db.ExecuteNonResult()
    db.closeConnection()

    return header