-
Notifications
You must be signed in to change notification settings - Fork 0
/
business.py
215 lines (188 loc) · 7.79 KB
/
business.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#! /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:22:38 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 business_support
def click_home():
global root
root.destroy()
root = None
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = tk.Tk()
business_support.set_Tk_var()
top = business (root)
business_support.init(root, top)
root.mainloop()
w = None
def create_business(root, *args, **kwargs):
'''Starting point when module is imported by another program.'''
global w, w_win, rt
rt = root
w = tk.Toplevel (root)
business_support.set_Tk_var()
top = business (w)
business_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_business():
global w
w.destroy()
w = None
class business:
def register_business(self):
l = []
inc = {'Local': '20000', 'Primary':'40000', 'Secondary':'60000', 'Tertiary':'80000'}
aadhar = self.reg_2.get()
region = self.reg.get()
pincode = self.pin.get()
service_type = self.type.get()
l.append(aadhar)
l.append(region)
l.append(pincode)
l.append(service_type)
for i in l:
if len(i) == 0:
messagebox.showerror("Business failure", "All fields are mandatory")
return
if not len(aadhar) == 12:
messagebox.showerror("Business Error", "12 Digit Aadhaar Number is required")
return
if not len(pincode) == 6:
messagebox.showerror("Business Error", "6 Digit Pincode is required")
return
income = inc[service_type]
self.cursor_bus.execute("SELECT aid FROM farmer WHERE aid = {}".format(aadhar))
result = self.cursor_bus.fetchone()
try:
if result is None:
messagebox.showerror("Business Error", "Farmer not registered")
return
except:
messagebox.showerror("Business Error", "Incorrect Aadhaar Number")
return
try:
self.cursor_bus.execute("INSERT INTO service VALUES (%s, %s, %s)", (region, service_type, pincode))
except:
pass
try:
self.cursor_bus.execute("INSERT INTO business VALUES (%s, %s, %s, %s)", (aadhar, service_type, pincode, income))
self.db_bus.commit()
messagebox.showinfo("Business Error", "Farmer not registered")
except:
messagebox.showerror("Business Info", "Farmer is already registered")
return
def __init__(self, top=None):
try:
self.db_bus = MySQLdb.connect("localhost","shivam","","FARMER")
self.cursor_bus = self.db_bus.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("Business")
top.configure(highlightcolor="black")
self.Label1 = tk.Label(top)
self.Label1.place(relx=0.331, rely=0.052, height=42, width=234)
self.Label1.configure(activebackground="#f9f9f9")
self.Label1.configure(background="#87d877")
self.Label1.configure(font="-family {gothic} -size 15")
self.Label1.configure(text='''Make Business Here''')
self.region = tk.Label(top)
self.region.place(relx=0.124, rely=0.349, height=35, width=199)
self.region.configure(activebackground="#f9f9f9")
self.region.configure(background="#5647d8")
self.region.configure(font="-family {gothic} -size 15")
self.region.configure(text='''Region of Business''')
self.service = tk.Label(top)
self.service.place(relx=0.124, rely=0.663, height=35, width=199)
self.service.configure(activebackground="#f9f9f9")
self.service.configure(background="#5647d8")
self.service.configure(font="-family {gothic} -size 15")
self.service.configure(text='''Service Type''')
self.pincode = tk.Label(top)
self.pincode.place(relx=0.124, rely=0.506, height=35, width=199)
self.pincode.configure(activebackground="#f9f9f9")
self.pincode.configure(background="#5647d8")
self.pincode.configure(font="-family {gothic} -size 15")
self.pincode.configure(text='''Pincode(6 digits)''')
self.reg = tk.Entry(top)
self.reg.place(relx=0.538, rely=0.349,height=37, relwidth=0.215)
self.reg.configure(background="white")
self.reg.configure(font="-family {gothic} -size 15")
self.reg.configure(selectbackground="#c4c4c4")
self.pin = tk.Entry(top)
self.pin.place(relx=0.538, rely=0.506,height=37, relwidth=0.215)
self.pin.configure(background="white")
self.pin.configure(font="-family {gothic} -size 15")
self.pin.configure(selectbackground="#c4c4c4")
self.type = ttk.Combobox(top)
self.type.place(relx=0.538, rely=0.663, relheight=0.061, relwidth=0.217)
self.value_list = ['Local','Primary','Secondary','Tertiary',]
self.type.configure(values=self.value_list)
self.type.configure(font="-family {gothic} -size 15")
self.type.configure(state='readonly')
self.type.configure(textvariable=business_support.combobox)
self.type.configure(takefocus="")
self.aadhaar = tk.Label(top)
self.aadhaar.place(relx=0.124, rely=0.192, height=35, width=199)
self.aadhaar.configure(activebackground="#f9f9f9")
self.aadhaar.configure(background="#5647d8")
self.aadhaar.configure(font="-family {gothic} -size 15")
self.aadhaar.configure(text='''Aadhaar No''')
self.reg_2 = tk.Entry(top)
self.reg_2.place(relx=0.538, rely=0.192,height=37, relwidth=0.284)
self.reg_2.configure(background="white")
self.reg_2.configure(font=font9)
self.reg_2.configure(selectbackground="#c4c4c4")
self.home = tk.Button(top)
self.home.place(relx=0.138, rely=0.855, height=35, width=100)
self.home.configure(background="#6cbbd8")
self.home.configure(font=font9)
self.home.configure(text='''Home''')
self.home.configure(command=click_home)
self.Register = tk.Button(top)
self.Register.place(relx=0.703, rely=0.855, height=35, width=100)
self.Register.configure(activebackground="#f9f9f9")
self.Register.configure(background="#6cbbd8")
self.Register.configure(font=font9)
self.Register.configure(text='''Register''')
self.Register.configure(command=self.register_business)
if __name__ == '__main__':
vp_start_gui()