def accountinput_del_submit(request): try: person_show=name = request.session["Uid"] except: return render_to_response( "login.html",{'nameerror':'非法'}) bill_sqlid=request.POST["bill_sqlid"] pwd=request.POST["pwd"] obj1 = Bill.objects.get(id = bill_sqlid) fini_person=obj1.transactor obj2 = User.objects.get(uid=fini_person) if obj2.password != pwd: error='密码不正确' accountedit=Account.objects.all().order_by("project_id") return render_to_response("accountinput_edit.html",locals()) obj3=Prokindaccount.objects.get( proid = obj1.proid , payname = obj1.paykind ) obj3.money_cost=obj3.money_cost - obj1.money obj3.save() obj4=Account.objects.get( project_id =obj1.proid ) obj4.money_cost = obj4.money_cost - obj1.money obj4.save() obj5 = Billchange_record(transactor = obj1.transactor,billsql_id = obj1.id,time = datetime.datetime.now(),proid = obj1.proid,operation= u'删除',) obj5.save() device_del = Billdevice_record.objects.filter(Bill_sqlid = bill_sqlid) device_del.delete() obj1.delete() error='删除成功' accountedit=Account.objects.all().order_by("project_id") return render_to_response("accountinput_edit.html",locals())
def accountinput_edit_submit(request): try: person_show=name = request.session["Uid"] except: return render_to_response( "login.html",{'nameerror':'非法'}) billid = request.POST["billid"] money = request.POST["money"] time = request.POST["time"] payname = request.POST["payname"] note = request.POST["note"] namecontent = request.POST["namecontent"] numbercontent = request.POST["numbercontent"] bill_sqlid = request.POST["bill_sqlid"] pwd = request.POST["pwd"] obj1 = Bill.objects.get(id = bill_sqlid) fini_person=obj1.transactor obj2 = User.objects.get(uid=fini_person) if obj2.password != pwd: error='密码不正确' accountedit=Account.objects.all().order_by("project_id") return render_to_response("accountinput_edit.html",locals()) obj3=Prokindaccount.objects.get( proid = obj1.proid , payname = obj1.paykind ) obj3.money_cost=obj3.money_cost - obj1.money obj3.save() obj6=Prokindaccount.objects.get( proid = obj1.proid , payname = payname ) obj6.money_cost=obj6.money_cost + string.atof(money) obj6.save() obj4=Account.objects.get( project_id =obj1.proid ) obj4.money_cost = obj4.money_cost - obj1.money + string.atof(money) obj4.save() obj5 = Billchange_record(transactor = obj1.transactor,billsql_id = obj1.id,time = datetime.datetime.now(),proid = obj1.proid,operation= u'修改',) obj5.save() obj1.money=string.atof(money) obj1.time = time obj1.note=note obj1.paykind=payname obj1.name=namecontent obj1.bill_id=billid obj1.change=True obj1.save() device_del = Billdevice_record.objects.filter(Bill_sqlid = bill_sqlid) device_del.delete() str1=namecontent str2=numbercontent s1 = str1.split(',') s2 = str2.split(',') for i in range(0,len(s2)-1): bsave = Billdevice_record(Bill_sqlid = obj1.id, proid = obj1.proid,name = s1[i],number = string.atof(s2[i]),paykind = payname,) bsave.save() error='修改成功' accountedit=Account.objects.all().order_by("project_id") return render_to_response("accountinput_edit.html",locals())