Ejemplo n.º 1
0
def alterDay(arg):
    '''
    takes a DentistDay object tries to change the aday table
    returns an omSQLresult
    '''
    #-- this method is called from the apptOpenDay Dialog, which is deprecated!!
    print "DEPRECATED FUNCTION CALLED alterDay"
    db = connect()
    cursor = db.cursor()
    result = omSQLresult()
    query = 'SELECT flag FROM aday WHERE adate="%s" and apptix=%d' % (
        arg.date, arg.apptix)

    if cursor.execute(query):
        #-- dentists diary includes this date
        query = '''update aday set start=%s,end=%s,flag=%s, memo=%s
        where adate=%s and apptix=%s'''
        values = (arg.start, arg.end, arg.flag, arg.memo, arg.date, arg.ix)

        result.setNumber(cursor.execute(query, values))

        if result.getNumber() == 1:
            result.setMessage("Date sucessfully modified")
        else:
            result.setMessage("No changes applied - the values you supplied " +
                              "are the same as the existing.")

        db.commit()

    else:
        result.setMessage("The date you have tried to modify is " +
                          "beyond the dates opened for dentist %s" %
                          (localsettings.ops.get(arg.ix), ))

    return result
Ejemplo n.º 2
0
def updateAday(uddate, arg):
    '''
    takes an instance of the workingDay class
    and updates the database
    returns an omSQLresult
    '''
    db = connect()
    cursor = db.cursor()
    result = omSQLresult()
    query = '''insert into aday (memo, adate, apptix, start, end, flag)
    values (%s,%s, %s, %s, %s, %s)
    on duplicate key
    update memo=%s, adate=%s, apptix=%s, start=%s, end=%s, flag=%s'''

    values = (arg.memo, uddate, arg.apptix, arg.sqlStart(), arg.sqlFinish(),
              arg.active) * 2

    result.setNumber(cursor.execute(query, values))

    if result:
        db.commit()
    return result
Ejemplo n.º 3
0
def updateAday(uddate, arg):
    '''
    takes an instance of the workingDay class
    and updates the database
    returns an omSQLresult
    '''
    db = connect()
    cursor = db.cursor()
    result = omSQLresult()
    query = '''insert into aday (memo, adate, apptix, start, end, flag)
    values (%s,%s, %s, %s, %s, %s)
    on duplicate key
    update memo=%s, adate=%s, apptix=%s, start=%s, end=%s, flag=%s'''

    values = (arg.memo, uddate, arg.apptix, arg.sqlStart(), arg.sqlFinish(),
    arg.active)*2

    result.setNumber(cursor.execute(query, values))

    if result:
        db.commit()
    return result
Ejemplo n.º 4
0
def alterDay(arg):
    '''
    takes a DentistDay object tries to change the aday table
    returns an omSQLresult
    '''
    #-- this method is called from the apptOpenDay Dialog, which is deprecated!!
    print "DEPRECATED FUNCTION CALLED alterDay"
    db = connect()
    cursor = db.cursor()
    result = omSQLresult()
    query = 'SELECT flag FROM aday WHERE adate="%s" and apptix=%d'% (
    arg.date, arg.apptix)

    if cursor.execute(query):
        #-- dentists diary includes this date
        query = '''update aday set start=%s,end=%s,flag=%s, memo=%s
        where adate=%s and apptix=%s'''
        values = (arg.start, arg.end, arg.flag, arg.memo, arg.date,
        arg.ix)

        result.setNumber(cursor.execute(query,values))

        if result.getNumber() == 1:
            result.setMessage("Date sucessfully modified")
        else:
            result.setMessage(
            "No changes applied - the values you supplied " + \
            "are the same as the existing.")

        db.commit()

    else:
        result.setMessage("The date you have tried to modify is " + \
        "beyond the dates opened for dentist %s"%(
        localsettings.ops.get(arg.ix),))

    return result