-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathItsOurMain.py
9140 lines (7792 loc) · 500 KB
/
ItsOurMain.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
import os
import sys
import re
import datetime
import time
from io import StringIO
from datetime import date
from datetime import timedelta
from dateutil.relativedelta import relativedelta
import gc
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from pytimekr import pytimekr
import pyodbc
import pandas as pd
import numpy as np
import openpyxl
from threading import Thread
class Communicate(QObject):
def resource_path(self, relative_path):
try:
# PyInstaller에 의해 임시폴더에서 실행될 경우 임시폴더로 접근하는 함수
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
closeApp = pyqtSignal()
closeApp2 = pyqtSignal(str)
class Calendar(QDialog):
def resource_path(self, relative_path):
try:
# PyInstaller에 의해 임시폴더에서 실행될 경우 임시폴더로 접근하는 함수
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def __init__(self, parent):
super(Calendar, self).__init__(parent)
self.MyApp = MyApp
self.setGeometry(1050, 400, 400, 200)
self.setWindowTitle("Calendar")
self.setWindowIcon(QIcon(self.resource_path("./EY_logo.png")))
self.setWindowModality(Qt.NonModal)
self.setWindowFlag(Qt.FramelessWindowHint)
vbox = QVBoxLayout()
hbox = QHBoxLayout()
self.calendar = QCalendarWidget()
self.calendar.setGridVisible(True)
self.calendar.setVerticalHeaderFormat(QCalendarWidget.NoVerticalHeader)
self.closebtn = QPushButton("Close")
hbox.addStretch(3)
hbox.addWidget(self.closebtn)
vbox.addWidget(self.calendar)
vbox.addLayout(hbox)
self.setLayout(vbox)
class Form(QGroupBox):
def resource_path(self, relative_path):
try:
# PyInstaller에 의해 임시폴더에서 실행될 경우 임시폴더로 접근하는 함수
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def __init__(self, parent):
super(Form, self).__init__(parent)
grid = QGridLayout()
qh = QHBoxLayout()
self.setLayout(grid)
self.btnSelect = QPushButton("Select All")
self.btnSelect.resize(65, 22)
self.btnSelect.clicked.connect(self.select_all)
self.btnSelect.clicked.connect(self.get_selected_leaves)
self.btnSelect.setStyleSheet('color:white; background-color : #2E2E38')
font11 = self.btnSelect.font()
font11.setBold(True)
self.btnSelect.setFont(font11)
self.btnUnselect = QPushButton("Unselect All")
self.btnUnselect.resize(65, 22)
self.btnUnselect.clicked.connect(self.unselect_all)
self.btnUnselect.clicked.connect(self.get_selected_leaves)
self.btnUnselect.setStyleSheet('color:white; background-color : #2E2E38')
font11 = self.btnUnselect.font()
font11.setBold(True)
self.btnUnselect.setFont(font11)
self.setStyleSheet('QGroupBox {color: white; background-color: white}')
self.tree = QTreeWidget(self)
self.tree.setStyleSheet("border-style: outset; border-color : white; background-color:white;")
headerItem = QTreeWidgetItem()
item = QTreeWidgetItem()
qh.addWidget(self.btnSelect)
qh.addWidget(self.btnUnselect)
grid.addLayout(qh, 0, 0)
grid.addWidget(self.tree, 1, 0)
self.tree.setHeaderHidden(True)
self.tree.itemClicked.connect(self.get_selected_leaves)
def unselect_all(self):
def recurse_unselect(parent):
for i in range(parent.childCount()):
child = parent.child(i)
for j in range(child.childCount()):
grandchild = child.child(j)
grandgrandchild = grandchild.childCount()
if grandgrandchild > 0:
recurse_unselect(grandchild)
else:
if grandchild.checkState(0) == Qt.Checked:
grandchild.setCheckState(0, Qt.Unchecked)
recurse_unselect(self.tree.invisibleRootItem())
def select_all(self):
def recurse_select(parent):
for i in range(parent.childCount()):
child = parent.child(i)
for j in range(child.childCount()):
grandchild = child.child(j)
grandgrandchild = grandchild.childCount()
if grandgrandchild > 0:
recurse_select(grandchild)
else:
if grandchild.checkState(0) == Qt.Unchecked:
grandchild.setCheckState(0, Qt.Checked)
recurse_select(self.tree.invisibleRootItem())
def get_selected_leaves(self):
checked_items = []
def recurse(parent):
for i in range(parent.childCount()):
child = parent.child(i)
for j in range(child.childCount()):
grandchild = child.child(j)
grandgrandchild = grandchild.childCount()
if grandgrandchild > 0:
recurse(grandchild)
else:
if grandchild.checkState(0) == Qt.Checked:
checked_items.append(grandchild.text(0).split(' ')[0])
recurse(self.tree.invisibleRootItem())
global checked_name
checked_name = ''
for i in checked_items:
checked_name = checked_name + ',' + '\'' + i + '\''
checked_name = checked_name[1:]
global checked_account
global checked_account_A
global checked_account_12
checked_account = 'AND JournalEntries.GLAccountNumber IN (' + checked_name + ')'
checked_account_12 = 'AND LVL4.GL_Account_Number IN (' + checked_name + ')'
checked_account_A = 'AND LVL4.GL_Account_Number IN (' + checked_name + ')'
class Form1(QGroupBox):
def resource_path(self, relative_path):
try:
# PyInstaller에 의해 임시폴더에서 실행될 경우 임시폴더로 접근하는 함수
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def __init__(self, parent):
super(Form1, self).__init__(parent)
grid = QGridLayout()
qh = QHBoxLayout()
self.setLayout(grid)
self.btnSelect = QPushButton("Select All")
self.btnSelect.resize(65, 22)
self.btnSelect.clicked.connect(self.select_all)
self.btnSelect.clicked.connect(self.get_selected_leaves_1)
self.btnSelect.setStyleSheet('color:white; background-color : #2E2E38')
font11 = self.btnSelect.font()
font11.setBold(True)
self.btnSelect.setFont(font11)
self.btnUnselect = QPushButton("Unselect All")
self.btnUnselect.resize(65, 22)
self.btnUnselect.clicked.connect(self.unselect_all)
self.btnUnselect.clicked.connect(self.get_selected_leaves_1)
self.btnUnselect.setStyleSheet('color:white; background-color : #2E2E38')
font11 = self.btnUnselect.font()
font11.setBold(True)
self.btnUnselect.setFont(font11)
self.setStyleSheet('QGroupBox {color: white; background-color: white}')
self.tree = QTreeWidget(self)
self.tree.setStyleSheet("border-style: outset; border-color : white; background-color:white;")
headerItem = QTreeWidgetItem()
item = QTreeWidgetItem()
qh.addWidget(self.btnSelect)
qh.addWidget(self.btnUnselect)
grid.addLayout(qh, 0, 0)
grid.addWidget(self.tree, 1, 0)
self.tree.setHeaderHidden(True)
self.tree.itemClicked.connect(self.get_selected_leaves_1)
def unselect_all(self):
def recurse_unselect(parent):
for i in range(parent.childCount()):
child = parent.child(i)
for j in range(child.childCount()):
grandchild = child.child(j)
grandgrandchild = grandchild.childCount()
if grandgrandchild > 0:
recurse_unselect(grandchild)
else:
if grandchild.checkState(0) == Qt.Checked:
grandchild.setCheckState(0, Qt.Unchecked)
recurse_unselect(self.tree.invisibleRootItem())
def select_all(self):
def recurse_select(parent):
for i in range(parent.childCount()):
child = parent.child(i)
for j in range(child.childCount()):
grandchild = child.child(j)
grandgrandchild = grandchild.childCount()
if grandgrandchild > 0:
recurse_select(grandchild)
else:
if grandchild.checkState(0) == Qt.Unchecked:
grandchild.setCheckState(0, Qt.Checked)
recurse_select(self.tree.invisibleRootItem())
def get_selected_leaves_1(self):
checked_items = []
def recurse(parent):
for i in range(parent.childCount()):
child = parent.child(i)
for j in range(child.childCount()):
grandchild = child.child(j)
grandgrandchild = grandchild.childCount()
if grandgrandchild > 0:
recurse(grandchild)
else:
if grandchild.checkState(0) == Qt.Checked:
checked_items.append(grandchild.text(0).split(' ')[0])
recurse(self.tree.invisibleRootItem())
global checked_name
checked_name = ''
for i in checked_items:
checked_name = checked_name + ',' + '\'' + i + '\''
checked_name = checked_name[1:]
global checked_account_B
checked_account_B = 'AND LVL4.Analysis_GL_Account_Number NOT IN (' + checked_name + ')'
class Preparer(QGroupBox):
def resource_path(self, relative_path):
try:
# PyInstaller에 의해 임시폴더에서 실행될 경우 임시폴더로 접근하는 함수
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def __init__(self, parent):
super(Preparer, self).__init__(parent)
grid = QGridLayout()
qh = QHBoxLayout()
self.setLayout(grid)
self.setStyleSheet('QGroupBox {color: white; background-color: white}')
self.prep = QTreeWidget(self)
self.prep.setStyleSheet("border-style: outset; border-color : white; background-color:white;")
headerItem = QTreeWidgetItem()
item = QTreeWidgetItem()
self.btnSelectp = QPushButton("Select All")
self.btnSelectp.resize(65, 22)
self.btnSelectp.clicked.connect(self.select_all)
self.btnSelectp.clicked.connect(self.get_selected_leaves)
self.btnSelectp.setStyleSheet('color:white; background-color : #2E2E38')
font11 = self.btnSelectp.font()
font11.setBold(True)
self.btnSelectp.setFont(font11)
self.btnUnselectp = QPushButton("Unselect All")
self.btnUnselectp.resize(65, 22)
self.btnUnselectp.clicked.connect(self.unselect_all)
self.btnUnselectp.clicked.connect(self.get_selected_leaves)
self.btnUnselectp.setStyleSheet('color:white; background-color : #2E2E38')
font11 = self.btnUnselectp.font()
font11.setBold(True)
self.btnUnselectp.setFont(font11)
qh.addWidget(self.btnSelectp)
qh.addWidget(self.btnUnselectp)
grid.addLayout(qh, 0, 0)
grid.addWidget(self.prep, 1, 0)
self.prep.setHeaderHidden(True)
self.prep.itemClicked.connect(self.get_selected_leaves)
def unselect_all(self):
for i in range(self.prep.topLevelItemCount()):
self.prep.topLevelItem(i).setCheckState(0, Qt.Unchecked)
def select_all(self):
for i in range(self.prep.topLevelItemCount()):
self.prep.topLevelItem(i).setCheckState(0, Qt.Checked)
def get_selected_leaves(self):
checked_items = []
# checked_items = [self.prep.topLevelItem(i).text(0).split(' ')[0] for i in range(self.prep.topLevelItemCount()) if self.prep.topLevelItem(i).checkState(0) == Qt.Checked]
for i in range(self.prep.topLevelItemCount()):
if self.prep.topLevelItem(i).checkState(0) == Qt.Checked:
checked_items.append(self.prep.topLevelItem(i).text(0).split(' ')[0])
global checked_prep
np_y = 0 # 공란 있음
np_n = 0 # 공란 없음
checked_prep = ''
for i in checked_items:
if i == '전표입력자':
np_y = 1
else:
checked_prep = checked_prep + ', N' + '\'' + i + '\''
np_n = 1
checked_prep = checked_prep[1:]
global checked_preparer
if np_y == 0 and np_n == 0:
checked_preparer = 'AND JournalEntries.PreparerID IN (' + checked_prep + ')' # 어느것도 선택 X
elif np_y == 0 and np_n == 1:
checked_preparer = 'AND JournalEntries.PreparerID IN (' + checked_prep + ')' # 공란 선택 X
elif np_y == 1 and np_n == 1:
checked_preparer = 'AND ((JournalEntries.PreparerID IN (' + checked_prep + ')) OR (JournalEntries.PreparerID = ' + "'" + "'" + '))'
elif np_y == 1 and np_n == 0:
checked_preparer = 'AND JournalEntries.PreparerID = ' + "'" + "'" # 공란만 선택
class DataFrameModel(QAbstractTableModel):
DtypeRole = Qt.UserRole + 1000
ValueRole = Qt.UserRole + 1001
def resource_path(self, relative_path):
try:
# PyInstaller에 의해 임시폴더에서 실행될 경우 임시폴더로 접근하는 함수
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def __init__(self, df=pd.DataFrame(), parent=None):
super(DataFrameModel, self).__init__(parent)
self._dataframe = df
def setDataFrame(self, dataframe):
self.beginResetModel()
self._dataframe = dataframe.copy()
self.endResetModel()
def dataFrame(self):
return self._dataframe
dataFrame = pyqtProperty(pd.DataFrame, fget=dataFrame, fset=setDataFrame)
@pyqtSlot(int, Qt.Orientation, result=str)
def headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.DisplayRole):
if role == Qt.DisplayRole:
if orientation == Qt.Horizontal:
return self._dataframe.columns[section]
else:
return str(self._dataframe.index[section])
return QVariant()
def rowCount(self, parent=QModelIndex()):
if parent.isValid():
return 0
return len(self._dataframe.index)
def columnCount(self, parent=QModelIndex()):
if parent.isValid():
return 0
return self._dataframe.columns.size
def data(self, index, role=Qt.DisplayRole):
if not index.isValid() or not (0 <= index.row() < self.rowCount() and 0 <= index.column() < self.columnCount()):
return QVariant()
row = self._dataframe.index[index.row()]
col = self._dataframe.columns[index.column()]
dt = self._dataframe[col].dtype
val = self._dataframe.iloc[row][col]
if role == Qt.DisplayRole:
return str(val)
elif role == DataFrameModel.ValueRole:
return val
if role == DataFrameModel.DtypeRole:
return dt
return QVariant()
def roleNames(self):
roles = {
Qt.DisplayRole: b'display',
DataFrameModel.DtypeRole: b'dtype',
DataFrameModel.ValueRole: b'value'
}
return roles
class ListBoxWidget(QListWidget):
def resource_path(self, relative_path):
try:
# PyInstaller에 의해 임시폴더에서 실행될 경우 임시폴더로 접근하는 함수
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def __init__(self, parent=None):
super().__init__(parent)
self.setAcceptDrops(True)
self.resize(600, 600)
def dragEnterEvent(self, event):
if event.mimeData().hasUrls:
event.accept()
else:
event.ignore()
def dragMoveEvent(self, event):
if event.mimeData().hasUrls():
event.setDropAction(Qt.CopyAction)
event.accept()
else:
event.ignore()
def dropEvent(self, event):
if event.mimeData().hasUrls():
event.setDropAction(Qt.CopyAction)
event.accept()
links = []
for url in event.mimeData().urls():
if url.isLocalFile():
links.append(str(url.toLocalFile()))
else:
links.append(str(url.toString()))
self.addItems(links)
else:
event.ignore()
class MyApp(QWidget):
# Resource
def resource_path(self, relative_path):
try:
# PyInstaller에 의해 임시폴더에서 실행될 경우 임시폴더로 접근하는 함수
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def __init__(self):
super().__init__()
self.init_UI()
##Initialize Variables
self.selected_project_id = None
self.selected_server_name = "--서버 목록--"
self.dataframe = None
self.dataframe_refer = None
self.cnxn = None
self.my_query = None
self.selected_scenario_subclass_index = 0
self.scenario_dic = {}
self.new_calendar = None
self.new_tree = None
self.new_prep = None
self.dateList = []
self.string_date_list = []
self.finalDate = []
self.dialoglist = set()
self.timerVar = QTimer()
self.timerVar.setInterval(1000)
self.timerVar.timeout.connect(self.printTime)
##다이얼로그별 시그널 생성
self.communicate4 = Communicate()
self.communicate4.closeApp.connect(self.doneAction4)
self.communicate5_Non_SAP = Communicate()
self.communicate5_Non_SAP.closeApp.connect(self.doneAction5_Non_SAP)
self.communicate5_SAP = Communicate()
self.communicate5_SAP.closeApp.connect(self.doneAction5_SAP)
self.communicate6 = Communicate()
self.communicate6.closeApp.connect(self.doneAction6)
self.communicate7 = Communicate()
self.communicate7.closeApp.connect(self.doneAction7)
self.communicate8 = Communicate()
self.communicate8.closeApp.connect(self.doneAction8)
self.communicate9 = Communicate()
self.communicate9.closeApp.connect(self.doneAction9)
self.communicate10 = Communicate()
self.communicate10.closeApp.connect(self.doneAction10)
self.communicate11 = Communicate()
self.communicate11.closeApp.connect(self.doneAction11)
self.communicate12 = Communicate()
self.communicate12.closeApp.connect(self.doneAction12)
self.communicate13 = Communicate()
self.communicate13.closeApp.connect(self.doneAction13)
self.communicate14 = Communicate()
self.communicate14.closeApp.connect(self.doneAction14)
self.communicateC = Communicate()
self.communicateC.closeApp2.connect(self.doneActionC)
def return_print(self, *message):
self.io = StringIO()
print(*message, file=self.io, end="")
return self.io.getvalue()
def MessageBox_Open(self, text):
self.msg = QMessageBox()
self.msg.setIcon(QMessageBox.Information)
self.msg.setWindowTitle("Warning")
self.msg.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.msg.setText(text)
self.msg.exec_()
def MessageBox_Open2(self, text):
self.msg = QMessageBox()
self.msg.setIcon(QMessageBox.Information)
self.msg.setWindowTitle("Project Connected")
self.msg.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.msg.setText(text)
self.msg.exec_()
def alertbox_open(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('필수 입력값 누락')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText('필수 입력값이 누락되었습니다.')
self.alt.exec_()
def alertbox_open2(self, state):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
txt = state
self.alt.setWindowTitle('필수 입력값 타입 오류')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText(txt + ' 값을 숫자로만 입력해주시기 바랍니다.')
self.alt.exec_()
def alertbox_open3(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('최대 라인 수 초과 오류')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText('최대 라인 수가 초과 되었습니다.')
self.alt.exec_()
def alertbox_open4(self, state):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
txt = state
self.alt.setWindowTitle('입력값 타입 오류')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText(txt)
self.alt.exec_()
def alertbox_open5(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('시트명 중복')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText('이미 해당 시트명이 존재합니다.')
self.alt.exec_()
def alertbox_open6(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('구분자 선택 오류')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText('기능영역과 회계일자 중 하나만 선택하세요.')
self.alt.exec_()
def alertbox_open10(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('SKA1 파일 선택 오류')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText('SKA1 파일만을 드롭하세요.')
self.alt.exec_()
def alertbox_open11(self, state):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
txt = state
self.alt.setWindowTitle('SKA1 파일 내부 필드값 부재')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText(txt)
self.alt.exec_()
def alertbox_open12(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('필수 입력값 오류')
self.alt.setWindowIcon(QIcon(self.resource_path("./EY_logo.png")))
self.alt.setText('T일은 0이상 70만 미만의 정수로만 입력 바랍니다.')
self.alt.exec_()
def alertbox_open13(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('필수 입력값 오류')
self.alt.setWindowIcon(QIcon(self.resource_path("./EY_logo.png")))
self.alt.setText('N일은 0이상 70만 미만의 정수로만 입력 바랍니다.')
self.alt.exec_()
def alertbox_open14(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('전 후 선택 오류')
self.alt.setWindowIcon(QIcon(self.resource_path("./EY_logo.png")))
self.alt.setText('T일 이전 및 T일 이후가 선택되어 있지 않습니다.')
self.alt.exec_()
def alertbox_open15(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('자릿수 포맷 오류')
self.alt.setWindowIcon(QIcon(self.resource_path("./EY_logo.png")))
self.alt.setText('연속된 자릿수는 6자리 이상으로 입력해주세요.')
self.alt.exec_()
def alertbox_open16(self):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('Account 파일 선택 오류')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText('Account 파일만을 드롭하세요.')
self.alt.exec_()
def alertbox_open17(self, state):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
txt = state
self.alt.setWindowTitle('필드값 부재')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText(txt)
self.alt.exec_()
def alertbox_open18(self, state):
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
txt = state
self.alt.setWindowTitle('필수값 형식 오류')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText(txt + ' 에 비연속 값이 포함되어 있습니다.')
self.alt.exec_()
def alertbox_open20(self): # 19번은 시나리오 15번 관련 alert이니 숫자를 바꾸지 마세요!
self.alt = QMessageBox()
self.alt.setIcon(QMessageBox.Information)
self.alt.setWindowTitle('구분자 선택 오류')
self.alt.setWindowIcon(QIcon(self.resource_path('./EY_logo.png')))
self.alt.setText('해당 프로젝트는 기능영역이 존재하지 않습니다.')
self.alt.exec_()
def init_UI(self):
image = QImage(self.resource_path('./dark_gray.png'))
scaledImg = image.scaled(QSize(1000, 900))
palette = QPalette()
palette.setBrush(10, QBrush(scaledImg))
self.setPalette(palette)
pixmap = QPixmap(self.resource_path('./title.png'))
lbl_img = QLabel()
lbl_img.setPixmap(pixmap)
lbl_img.setStyleSheet("background-color:#000000")
widget_layout = QBoxLayout(QBoxLayout.TopToBottom)
self.splitter_layout = QSplitter(Qt.Vertical)
self.splitter_layout.addWidget(lbl_img)
self.splitter_layout.addWidget(self.Connect_ServerInfo_Group())
self.splitter_layout.addWidget(self.Show_DataFrame_Group())
self.splitter_layout.addWidget(self.Save_Buttons_Group())
self.splitter_layout.setHandleWidth(0)
self.splitter_layout.setStretchFactor(0, 3)
self.splitter_layout.setStretchFactor(1, 2)
self.splitter_layout.setStretchFactor(2, 4)
self.splitter_layout.setStretchFactor(3, 1)
widget_layout.addWidget(self.splitter_layout)
self.setLayout(widget_layout)
self.setWindowIcon(QIcon(self.resource_path("./EY_logo.png")))
self.setWindowTitle('Scenario')
self.setGeometry(300, 100, 1000, 900)
self.show()
def connectButtonClicked(self):
password = ''
ecode = self.line_ecode.text().strip() ##leading/trailing space 포함시 제거
user = 'guest'
server = self.selected_server_name
db = 'master'
# 예외처리 - 서버 선택
if server == "--서버 목록--":
self.MessageBox_Open("서버가 선택되어 있지 않습니다.")
return
# 예외처리 - Ecode 이상
elif ecode.isdigit() is False:
self.MessageBox_Open("Engagement Code가 잘못되었습니다.")
self.ProjectCombobox.clear()
self.ProjectCombobox.addItem("프로젝트가 없습니다.")
return
server_path = f"DRIVER={{SQL Server}};SERVER={server};uid={user};pwd={password};DATABASE={db};trusted_connection=yes"
# 예외처리 - 접속 정보 오류
try:
self.cnxn = pyodbc.connect(server_path)
except:
QMessageBox.about(self, "Warning", "접속에 실패하였습니다.")
return
cursor = self.cnxn.cursor()
sql_query = f"""
SELECT ProjectName
From [DataAnalyticsRepository].[dbo].[Projects]
WHERE EngagementCode IN ({ecode})
AND DeletedBy IS NULL
"""
try:
selected_project_names = pd.read_sql(sql_query, self.cnxn)
except:
self.MessageBox_Open("Engagement Code를 입력하세요.")
self.ProjectCombobox.clear()
self.ProjectCombobox.addItem("프로젝트가 없습니다")
return
# 예외처리 - 해당 ecode에 아무런 프로젝트가 없는 경우
if len(selected_project_names) == 0:
self.MessageBox_Open("해당 Engagement Code 내 프로젝트가 존재하지 않습니다.")
self.ProjectCombobox.clear()
self.ProjectCombobox.addItem("프로젝트가 없습니다.")
return
else:
self.MessageBox_Open2("프로젝트가 연결되었습니다.")
## 서버 연결 시 - 기존 저장 정보를 초기화(메모리 관리)
del self.selected_project_id, self.dataframe, self.scenario_dic, self.my_query
self.my_query = pd.DataFrame(columns=["Sheet name", "Scenario number", "Query"])
self.ProjectCombobox.clear()
self.ProjectCombobox.addItem("--프로젝트 목록--")
for i in range(len(selected_project_names)):
self.ProjectCombobox.addItem(selected_project_names.iloc[i, 0])
self.combo_sheet.clear()
self.selected_project_id = None
self.dataframe = None
self.dataframe_refer = None
self.viewtable.setModel(self.dataframe)
self.scenario_dic = {}
self.string_date_list = []
self.finalDate = []
self.clickCount = 0
gc.collect()
def Server_ComboBox_Selected(self, text):
self.selected_server_name = text
def Project_ComboBox_Selected(self, text):
## 예외처리 - 서버가 연결되지 않은 상태로 Project name Combo box를 건드리는 경우
if self.cnxn is None:
return
ecode = self.line_ecode.text().strip() # leading/trailing space 제거
pname = text
self.pname_year = "20" + str(pname)[2:4] # str
cursor = self.cnxn.cursor()
sql_query = f"""
SELECT Project_ID
FROM [DataAnalyticsRepository].[dbo].[Projects]
WHERE ProjectName IN (\'{pname}\')
AND EngagementCode IN ({ecode})
AND DeletedBy is Null
"""
## 예외처리 - 에러 표시인 "프로젝트가 없습니다"가 선택되어 있는 경우
try:
self.selected_project_id = pd.read_sql(sql_query, self.cnxn).iloc[0, 0]
except:
self.selected_project_id = None
def Connect_ServerInfo_Group(self):
groupbox = QGroupBox('접속 정보')
self.setStyleSheet('QGroupBox {color: white;}')
font_groupbox = groupbox.font()
font_groupbox.setBold(True)
groupbox.setFont(font_groupbox)
##labels 생성 및 스타일 지정
label1 = QLabel('Server : ', self)
label2 = QLabel('Engagement Code : ', self)
label3 = QLabel('Project Name : ', self)
label4 = QLabel('Scenario : ', self)
font1 = label1.font()
font1.setBold(True)
label1.setFont(font1)
font2 = label2.font()
font2.setBold(True)
label2.setFont(font2)
font3 = label3.font()
font3.setBold(True)
label3.setFont(font3)
font4 = label4.font()
font4.setBold(True)
label4.setFont(font4)
label1.setStyleSheet("color: white;")
label2.setStyleSheet("color: white;")
label3.setStyleSheet("color: white;")
label4.setStyleSheet("color: white;")
##서버 선택 콤보박스
self.cb_server = QComboBox(self)
self.cb_server.addItem('--서버 목록--')
for i in [1, 2, 3, 4, 6, 7, 8]:
self.cb_server.addItem(f'KRSEOVMPPACSQ0{i}\INST1')
### Scenario 유형 콤보박스 - 소분류 수정
self.comboScenario = QComboBox(self)
self.comboScenario.addItem('--시나리오 목록--')
self.comboScenario.addItem('04 : 계정 사용빈도 N번 이하인 계정이 포함된 전표리스트')
self.comboScenario.addItem('05 : 당기 생성된 계정리스트 추출')
self.comboScenario.addItem('06 : 결산일 전후 T일 입력 전표')
self.comboScenario.addItem('07 : 비영업일 전기/입력 전표')
self.comboScenario.addItem('08 : 효력, 입력 일자 간 차이가 N일 이상인 전표')
self.comboScenario.addItem('09 : 전표 작성 빈도수가 N회 이하인 작성자에 의한 생성된 전표')
self.comboScenario.addItem('10 : 특정 전표 입력자(W)에 의해 생성된 전표')
self.comboScenario.addItem('11-12 : 특정 계정(A) 상대계정 리스트 검토')
self.comboScenario.addItem('13 : 연속된 숫자로 끝나는 금액 검토')
self.comboScenario.addItem('14 : 전표 description에 공란 또는 특정단어(key word)가 입력되어 있는 전표 리스트 (중요성 금액 제시 가능)')
self.ProjectCombobox = QComboBox(self)
##Engagement code 입력 line
self.line_ecode = QLineEdit(self)
self.line_ecode.setText("")
##Project Connect 버튼 생성 및 스타일 지정
btn_connect = QPushButton(' Project Connect', self)
font_btn_connect = btn_connect.font()
font_btn_connect.setBold(True)
btn_connect.setFont(font_btn_connect)
btn_connect.setStyleSheet('color:white; background-image : url(./bar.png)')
##Input Conditions 버튼 생성 및 스타일 지정
btn_condition = QPushButton(' Input Conditions', self)
font_btn_condition = btn_condition.font()
font_btn_condition.setBold(True)
btn_condition.setFont(font_btn_condition)
btn_condition.setStyleSheet('color:white; background-image : url(./bar.png)')
### Signal 함수들
self.comboScenario.activated[str].connect(self.ComboSmall_Selected)
self.cb_server.activated[str].connect(self.Server_ComboBox_Selected)
btn_connect.clicked.connect(self.connectButtonClicked)
btn_connect.setShortcut("Ctrl+P") # remove sheet 업데이트 부분
self.ProjectCombobox.activated[str].connect(self.Project_ComboBox_Selected)
btn_condition.clicked.connect(self.connectDialog)
##layout 쌓기
grid = QGridLayout()
grid.addWidget(label1, 0, 0)
grid.addWidget(label2, 1, 0)
grid.addWidget(label3, 2, 0)
grid.addWidget(label4, 3, 0)
grid.addWidget(self.cb_server, 0, 1)
grid.addWidget(btn_connect, 1, 2)
grid.addWidget(self.comboScenario, 3, 1)
grid.addWidget(btn_condition, 3, 2)
grid.addWidget(self.line_ecode, 1, 1)
grid.addWidget(self.ProjectCombobox, 2, 1)
groupbox.setLayout(grid)
return groupbox
def ComboSmall_Selected(self, text):
self.selected_scenario_subclass_index = self.comboScenario.currentIndex()
def connectDialog(self):
if self.cnxn is None:
self.MessageBox_Open("SQL 서버가 연결되어 있지 않습니다.")
return
elif self.selected_project_id is None:
self.MessageBox_Open("프로젝트가 선택되지 않았습니다.")
return
elif self.selected_scenario_subclass_index == 0:
self.MessageBox_Open("시나리오가 선택되지 않았습니다.")
return
else:
try:
cursor = self.cnxn.cursor()
sql = '''
SELECT
*
FROM [{field}_Import_CY_01].[dbo].[pbcChartOfAccounts] COA
'''.format(field=self.selected_project_id)
accountsname = pd.read_sql(sql, self.cnxn)
if self.selected_scenario_subclass_index == 1:
self.Dialog4()
elif self.selected_scenario_subclass_index == 2:
self.Dialog5()
elif self.selected_scenario_subclass_index == 3:
self.Dialog6()
elif self.selected_scenario_subclass_index == 4:
self.Dialog7()