Exemple #1
0
def AddDep(request):
    dep_code = request.POST['dep_code']
    dep_name = request.POST['dep_name']
    dep_items = request.POST['dep_items']
    new = Department()
    new.department_code = dep_code
    new.department_name = dep_name
    new.slug = dep_name
    new.department_items = dep_items
    new.save()
    d = Department.objects.all()
    depo = []
    for i in d:
        depo.append(i.department_code)
        depo.append(i.department_name)
    neww = Actions()
    neww.action = 'New Department' + ' ' + str(new.id) + ' ' + 'added'
    neww.type = 'Department'
    neww.save()
    return render(request, 'dep.html', {'d': d, 'depo': json.dumps(depo)})
def Search(request):
    me = Medicine.objects.all()
    medi = []
    for i in me:
        medi.append(i.medicine_code)
        medi.append(i.medicine_name)

    med = request.POST['med']
    m = Medicine.objects.filter(Q(medicine_code=med) | Q(medicine_name=med))
    cart_product_form = CartAddProductForm()
    neww = Actions()
    neww.action = 'User Search for' + ' ' + med + ' ' + 'Medicine'
    neww.type = 'Medicine_Search'
    neww.save()
    context = {
        'm': m,
        'med': med,
        'cart_product_form': cart_product_form,
        'medi': json.dumps(medi)
    }
    return render(request, 'userhome.html', context)
Exemple #3
0
def SaveEditMed(request, id):
    dep_cod = request.POST['dep_code']
    depcode = Department.objects.get(department_code=dep_cod).id
    med_code = request.POST['med_code']
    med_name = request.POST['med_name']
    med_quant = request.POST['med_quant']
    med_price = request.POST['med_price']
    med_desc = request.POST['med_desc']
    new = Medicine.objects.get(id=id)
    new.department_id = depcode
    new.medicine_code = med_code
    new.medicine_name = med_name
    new.slug = med_name
    new.medicine_quantity = med_quant
    new.medicine_price = med_price
    new.medicine_desc = med_desc
    new.save()
    neww = Actions()
    neww.action = 'Medicine' + ' ' + str(new.id) + ' ' + 'updated'
    neww.type = 'Medicine'
    neww.save()
    return redirect('med')