def EditService(code): AllServices = InvoicesAPI.GetAllServices() Service = InvoicesAPI.GetService(code) if request.method == 'POST': if request.form['submit'] == 'Submit': try: InvoicesAPI.UpdateService( session['username'], session['password'], code, request.form['servicename'], request.form['servicetype'], request.form['servicecost'], request.form['serviceprice'], request.form['description']) flash('Service updated successfully...', category='success') return redirect(url_for('invoices.Services')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('invoices.EditService', code=code)) return render_template('invoices/edit_service.html', username=session['username'], role=session['role'], AllServices=AllServices, Service=Service)
def Services(): AllServices = InvoicesAPI.GetAllServices() form = EnterForms.Services(request.form) if request.method == 'POST': if request.form['submit'] == 'Submit': try: InvoicesAPI.CreateService( session['username'], session['password'], request.form['servicename'], request.form['servicetype'], request.form['servicecost'], request.form['serviceprice'], request.form['description']) flash('Service Successfully created...', category='success') return redirect(url_for('invoices.Services')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('inoices.Services')) return render_template('invoices/services.html', username=session['username'], role=session['role'], form=form, AllServices=AllServices)