Commit 5e639e7d authored by panos's avatar panos Committed by Georgios Dagkakis

Bug fixed in the interface to update the database in Jobshop

parent 565c7677
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
''' '''
Created on 1 Jun 2014 Created on 23 March 2015
@author: Panos @author: Panos
''' '''
import Tkinter as tk import Tkinter as tk
from Tkinter import * from Tkinter import *
import pyodbc import ImportDatabase
import tkMessageBox import tkMessageBox
from datetime import datetime from datetime import datetime
...@@ -125,11 +144,10 @@ class TIMEIN(Frame): ...@@ -125,11 +144,10 @@ class TIMEIN(Frame):
return return
def checkInsertedWP(self): def checkInsertedWP(self):
cnxn =pyodbc.connect("Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=leo_database2;UID=root; PASSWORD=Pitheos10; ") cnxn=ImportDatabase.ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\JobShop', implicitExt='txt', number_of_cursors=6)
cursor1 = cnxn.cursor() cursor=cnxn.getCursors()
cursor2 = cnxn.cursor()
a=cursor1.execute(""" a=cursor[0].execute("""
select WP_id, PartCode select WP_id, PartCode
from sequence from sequence
""") """)
...@@ -141,7 +159,7 @@ class TIMEIN(Frame): ...@@ -141,7 +159,7 @@ class TIMEIN(Frame):
#and create a dictionary order #and create a dictionary order
availableWP.append(ind1.WP_id) availableWP.append(ind1.WP_id)
b=cursor2.execute(""" b=cursor[1].execute("""
select WP_id select WP_id
from prod_status from prod_status
""") """)
...@@ -161,22 +179,21 @@ class TIMEIN(Frame): ...@@ -161,22 +179,21 @@ class TIMEIN(Frame):
return availableWP return availableWP
def updateDatabase(self): def updateDatabase(self):
cnxn =pyodbc.connect("Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=leo_database2;UID=root; PASSWORD=Pitheos10; ") cnxn=ImportDatabase.ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\JobShop', implicitExt='txt', number_of_cursors=5)
cursor = cnxn.cursor() cursor=cnxn.getCursors()
cursor1 = cnxn.cursor()
update_order= ("INSERT INTO prod_status(`status_id`, `WP_id`, `PersonnelCode`, `MachineName`, `TIMEIN`) VALUES (?, ?, ?, ?, ?)") update_order= ("INSERT INTO prod_status(`status_id`, `WP_id`, `PersonnelCode`, `MachineName`, `TIMEIN`) VALUES (?, ?, ?, ?, ?)")
cursor.execute("SELECT @@IDENTITY AS ID") cursor[0].execute("SELECT @@IDENTITY AS ID")
a = cursor1.execute(""" a = cursor[1].execute("""
select WP_id, Order_id select WP_id, Order_id
from sequence where WP_id=? from sequence where WP_id=?
""", self.WPOption.get()) """, self.WPOption.get())
order = a.fetchone()[1] order = a.fetchone()[1]
row = cursor.fetchone() row = cursor[0].fetchone()
order_ref = row.ID order_ref = row.ID
status1 = 'in progress' status1 = 'in progress'
cursor.execute(update_order, (order_ref, self.WPOption.get(), self.personnelOption.get(), self.machineOption.get(), str(datetime.now()))) cursor[2].execute(update_order, (order_ref, self.WPOption.get(), self.personnelOption.get(), self.machineOption.get(), str(datetime.now())))
cursor.execute("UPDATE orders SET `Status`=? WHERE Order_id=? ", status1, order) cursor[3].execute("UPDATE orders SET `Status`=? WHERE Order_id=? ", status1, order)
cursor.commit() cursor[4].commit()
self.close_window() self.close_window()
return return
...@@ -258,10 +275,10 @@ class TIMEOUT(Frame): ...@@ -258,10 +275,10 @@ class TIMEOUT(Frame):
return return
def checkInsertedWP(self): def checkInsertedWP(self):
cnxn =pyodbc.connect("Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=leo_database2;UID=root; PASSWORD=Pitheos10; ") cnxn=ImportDatabase.ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\JobShop', implicitExt='txt', number_of_cursors=6)
cursor1 = cnxn.cursor() cursor=cnxn.getCursors()
b=cursor1.execute(""" b=cursor[0].execute("""
select WP_id select WP_id
from prod_status from prod_status
""") """)
...@@ -274,7 +291,7 @@ class TIMEOUT(Frame): ...@@ -274,7 +291,7 @@ class TIMEOUT(Frame):
finishedWP=[] finishedWP=[]
c=cursor1.execute(""" c=cursor[1].execute("""
select WP_id, TIMEIN, TIMEOUT select WP_id, TIMEIN, TIMEOUT
from prod_status from prod_status
""") """)
...@@ -296,15 +313,14 @@ class TIMEOUT(Frame): ...@@ -296,15 +313,14 @@ class TIMEOUT(Frame):
return insertedWP return insertedWP
def updateDatabase(self): def updateDatabase(self):
cnxn =pyodbc.connect("Driver={MySQL ODBC 3.51 Driver};SERVER=localhost; PORT=3306;DATABASE=leo_database2;UID=root; PASSWORD=Pitheos10; ") cnxn=ImportDatabase.ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\JobShop', implicitExt='txt', number_of_cursors=6)
cursor = cnxn.cursor() cursor=cnxn.getCursors()
cursor1 = cnxn.cursor() a = cursor[0].execute("""
a = cursor1.execute("""
select WP_id, Order_id select WP_id, Order_id
from sequence where WP_id=? from sequence where WP_id=?
""", self.WPOption.get()) """, self.WPOption.get())
order = a.fetchone()[1] order = a.fetchone()[1]
b = cursor1.execute(""" b = cursor[1].execute("""
select WP_id, Order_id, PartName select WP_id, Order_id, PartName
from sequence where Order_id=? from sequence where Order_id=?
""", order) """, order)
...@@ -312,10 +328,10 @@ class TIMEOUT(Frame): ...@@ -312,10 +328,10 @@ class TIMEOUT(Frame):
ind1=b.fetchone() ind1=b.fetchone()
lastWP = ind1.WP_id lastWP = ind1.WP_id
status2 = 'finished' status2 = 'finished'
cursor.execute("UPDATE prod_status SET `TIMEOUT`=? , `statusName`=? , `Remarks`=? WHERE WP_id=? ", str(datetime.now()), self.statusOption.get(), self.comments.get(), self.WPOption.get() ) cursor[2].execute("UPDATE prod_status SET `TIMEOUT`=? , `statusName`=? , `Remarks`=? WHERE WP_id=? ", str(datetime.now()), self.statusOption.get(), self.comments.get(), self.WPOption.get() )
if self.WPOption.get() == lastWP: if self.WPOption.get() == lastWP:
cursor.execute("UPDATE orders SET `Status`=? WHERE Order_id=? ", status2, order) cursor[3].execute("UPDATE orders SET `Status`=? WHERE Order_id=? ", status2, order)
cursor.commit() cursor[4].commit()
self.close_window() self.close_window()
return return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment