-
Notifications
You must be signed in to change notification settings - Fork 0
/
loan.py
198 lines (172 loc) · 7.16 KB
/
loan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# GUI module generated by PAGE version 4.26
# in conjunction with Tcl version 8.6
# Oct 25, 2019 11:16:07 PM IST platform: Linux
import os
import sys
from subprocess import call
import MySQLdb
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
from tkinter import messagebox
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
import loan_support
def click_home():
global root
root.destroy()
root = None
def click_register():
call['python3','register.py']
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = tk.Tk()
loan_support.set_Tk_var()
top = loan (root)
loan_support.init(root, top)
root.mainloop()
w = None
def create_loan(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = tk.Toplevel (root)
loan_support.set_Tk_var()
top = loan (w)
loan_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_loan():
global w
w.destroy()
w = None
class loan:
def request_loan(self):
lic = {'tractor loan': '1','Kisan Credit Card': '2','Gold loan':'3','Harvesting Loan':'4','Allied loan':'5','Marketing Loan':'6'}
amount = {'tractor loan': '100000','Kisan Credit Card': '200000','Gold loan':'300000','Harvesting Loan':'400000','Allied loan':'500000','Marketing Loan':'600000'}
l = []
aadhar = self.adhar.get()
loan_name = self.TCombobox1.get()
l.append(aadhar)
l.append(loan_name)
for i in l:
if len(i) == 0:
messagebox.showerror("Loan Error", "All fields are mandatory")
return
if not len(aadhar) == 12:
messagebox.showerror("Loan Error", "12 Digit Aadhaar Number is required")
return
loan = amount[loan_name]
lid = lic[loan_name]
self.cursor_loan.execute("SELECT aid FROM farmer WHERE aid = {}".format(aadhar))
result = self.cursor_loan.fetchone()
try:
if result is None:
messagebox.showerror("Loan Error", "Farmer not registered")
return
except:
messagebox.showerror("Loan Error", "Incorrect Aadhaar Number")
return
try:
self.cursor_loan.execute("INSERT INTO scheme VALUES (%s, %s, %s)",(lid, loan_name, loan))
self.cursor_loan.execute("INSERT INTO takes VALUES (%s, %s)",(aadhar, lid))
messagebox.showinfo("Loan Info", "Loan for " + aadhar + " is successfully registered")
except:
try:
self.cursor_loan.execute("INSERT INTO takes VALUES (%s, %s)",(aadhar, lid))
except:
messagebox.showinfo("Loan Info", "Loan for " + aadhar + " is already registered")
return
self.db_loan.commit()
def __init__(self, top=None):
try:
self.db_loan = MySQLdb.connect("localhost","shivam","","FARMER")
self.cursor_loan = self.db_loan.cursor()
except:
print('hi')
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#ececec' # Closest X11 color: 'gray92'
font9 = "-family gothic -size 15 -weight normal -slant roman " \
"-underline 0 -overstrike 0"
self.style = ttk.Style()
if sys.platform == "win32":
self.style.theme_use('winnative')
self.style.configure('.',background=_bgcolor)
self.style.configure('.',foreground=_fgcolor)
self.style.configure('.',font="TkDefaultFont")
self.style.map('.',background=
[('selected', _compcolor), ('active',_ana2color)])
top.geometry("725x573+391+117")
top.minsize(1, 1)
top.maxsize(1351, 738)
top.resizable(1, 1)
top.title("Manage Your Loan")
self.register = tk.Label(top)
self.register.place(relx=0.317, rely=0.07, height=65, width=249)
self.register.configure(background="#84cad8")
self.register.configure(font=font9)
self.register.configure(text='''Loan Registration''')
self.Scheme = tk.Label(top)
self.Scheme.place(relx=0.179, rely=0.554, height=55, width=169)
self.Scheme.configure(background="#d88338")
self.Scheme.configure(font=font9)
self.Scheme.configure(text='''Scheme Name''')
self.TCombobox1 = ttk.Combobox(top)
self.TCombobox1.place(relx=0.497, rely=0.571, relheight=0.061
, relwidth=0.479)
self.value_list = ['tractor loan','Kisan Credit Card','Gold loan','Harvesting Loan','Allied loan','Marketing Loan']
self.TCombobox1.configure(values=self.value_list)
self.TCombobox1.configure(state='readonly')
self.TCombobox1.configure(textvariable=loan_support.combobox)
self.TCombobox1.configure(foreground="#a48bbc")
self.TCombobox1.configure(background="#b2d6ca")
self.TCombobox1.configure(takefocus="")
'''self.amount = tk.Label(top)
self.amount.place(relx=0.179, rely=0.646, height=55, width=169)
self.amount.configure(activebackground="#f9f9f9")
self.amount.configure(background="#d88338")
self.amount.configure(font="-family {gothic} -size 15")
self.amount.configure(text=''''''Enter Amount'''''')
self.rupees = tk.Entry(top)
self.rupees.place(relx=0.497, rely=0.663,height=37, relwidth=0.298)
self.rupees.configure(background="white")
self.rupees.configure(font=font9)'''
self.Aadhaar = tk.Label(top)
self.Aadhaar.place(relx=0.179, rely=0.279, height=55, width=169)
self.Aadhaar.configure(activebackground="#f9f9f9")
self.Aadhaar.configure(background="#d88338")
self.Aadhaar.configure(font="-family {gothic} -size 15")
self.Aadhaar.configure(text='''Aadhaar No''')
self.adhar = tk.Entry(top)
self.adhar.place(relx=0.497, rely=0.297,height=37, relwidth=0.298)
self.adhar.configure(background="white")
self.adhar.configure(font=font9)
self.adhar.configure(selectbackground="#c4c4c4")
self.Home = tk.Button(top)
self.Home.place(relx=0.138, rely=0.838, height=45, width=90)
self.Home.configure(background="#6ad871")
self.Home.configure(font=font9)
self.Home.configure(text='''Home''')
self.Home.configure(command=click_home)
self.Request = tk.Button(top)
self.Request.place(relx=0.745, rely=0.838, height=45, width=90)
self.Request.configure(activebackground="#f9f9f9")
self.Request.configure(background="#6ad871")
self.Request.configure(font="-family {gothic} -size 15")
self.Request.configure(text='''Request''')
self.Request.configure(command=self.request_loan)
if __name__ == '__main__':
vp_start_gui()