def __poRequest__(self,user_bean): id=valid.Validataion().__inputIdValidataion__(6) if int(id)==1: menu.InventoryModuleMenu().__poRequestListMenu__() id=valid.Validataion().__inputIdValidataion__(4) if int(id)==1: dao.InventoryDAO().__poRequestList__(1,1) elif int(id)==2: dao.InventoryDAO().__poRequestList__(1,2) elif int(id)==3: dao.InventoryDAO().__poRequestList__(1,3) elif int(id)==4: InventoryModule().__menuMethod__(5,user_bean) elif int(id)==2: dao.InventoryDAO().__addPORequest__(user_bean) elif int(id)==3: dao.InventoryDAO().__poRequestList__(1,1) poRequestId=dao.InventoryDAO().__selectUpdatePORequestId__() dao.InventoryDAO().__updatePORequest__(poRequestId,user_bean,1) elif int(id)==4: if user_bean[1]!=3: dao.InventoryDAO().__poRequestList__(1,1) poRequestId=dao.InventoryDAO().__selectUpdatePORequestId__() dao.InventoryDAO().__updatePORequest__(poRequestId,user_bean,2) else: print("Error : You can't able to delete.") elif int(id)==5: print("========") elif int(id)==6: InventoryModule().initCall(user_bean) menu.InventoryModuleMenu().__poMenuList__() InventoryModule().__poRequest__(user_bean)
def __menuMethod__(self,id,user_bean): if int(id)==1: menu.InventoryModuleMenu().__itemListMenu__() id=valid.Validataion().__inputIdValidataion__(2) if int(id)==1: dao.InventoryDAO().__allItemList__(1) else: dao.InventoryDAO().__isCount0ItemList__() elif int(id)==2: print("---------------------- New Item ---------------------") dao.InventoryDAO().__addItem__(user_bean) elif int(id)==3: print("---------------------- Update Item -------------------") dao.InventoryDAO().__allItemList__(2) item_id=dao.InventoryDAO().__selectUpdateItemId__() dao.InventoryDAO().__updateItem__(item_id,user_bean,1) elif int(id)==4: if user_bean[1]!=3: print("----------------------- Delete Item -------------------") dao.InventoryDAO().__allItemList__(1) #we don't detete the itme. we just update the item_status =0 item_id=dao.InventoryDAO().__selectUpdateItemId__() dao.InventoryDAO().__updateItem__(item_id,user_bean,2) else: print("Error : You can't able to delete.") elif int(id)==5: print("-----------------------PO Request ---------------------------------") menu.InventoryModuleMenu().__poMenuList__() InventoryModule().__poRequest__(user_bean) elif int(id)==6: print("---------------------- Main Menu ----------------------------------") login.Login().initialCall(self.user) self.initCall(self.user)
def initCall(self, user): user_bean=[] self.user=user user_bean.insert(0,user['user_id'][0]) user_bean.insert(1,user['role_id'][0]) menu.InventoryModuleMenu().__mainMuen__() id=valid.Validataion().__inputIdValidataion__(6) self.__menuMethod__(id,user_bean)
def __addItem__(self,user_bean): try: item= vaild.Validataion().__addItemValidation__() insert_query = 'insert into inv_item(item_name,item_description,item_status,created_by,created_on) values("'+str(item[0])+'","'+str(item[1])+'",2,"'+str(user_bean[0])+'",now())' cursor = connection.cursor() result = cursor.execute(insert_query) connection.commit() print ("\nRecord inserted successfully into inventory table") except Exception as error : print("Failed inserting record into inventory table ",error) connection.rollback() #rollback if any exception occured finally: #closing database connection. if(connection.is_connected()): cursor.close()
def __updateItem__(self,id,user_bean,methodId): item= [] try: insert_query="" if int(methodId)==1: item=vaild.Validataion().__addItemValidation__() insert_query = 'update inv_item set item_name="'+item[0]+'" ,item_description="'+item[1]+'",updated_on=now(), updated_by="'+str(user_bean[0])+'" where inv_item_id="'+str(id)+'"' else : insert_query = 'update inv_item set is_active=0 ,updated_on=now(),updated_by="'+str(user_bean[0])+'" where inv_item_id="'+str(id)+'"' cursor = connection.cursor() result = cursor.execute(insert_query) connection.commit() print ("Record updated successfully into inventory table") except mysql.connector.Error as error : connection.rollback() #rollback if any exception occured print("Failed updating record into inventory table {}".format(error)) finally: #closing database connection. if(connection.is_connected()): cursor.close()
def __updatePORequest__(self,id,user_bean,methodId): try: query="" if methodId==1: po= vaild.Validataion().__addPORequestValidation__() query = ' update po_request set inv_item_id="'+po[0]+'",po_request_quantity="'+po[1]+'" , updated_by="'+str(user_bean[0])+'",updated_on=now() where po_request_id='+str(id) else: query = 'update po_request set updated_by="'+str(user_bean[0])+'",updated_on=now(),is_active=0 where po_request_id='+str(id) cursor = connection.cursor() result = cursor.execute(query) connection.commit() print ("Record updated successfully into PO table") except mysql.connector.Error as error : connection.rollback() #rollback if any exception occured print("Failed updated record into PO table {}".format(error)) finally: #closing database connection. if(connection.is_connected()): cursor.close()
def __addPORequest__(self,user_bean): i=0 InventoryDAO.__allItemList__(self,2) while i==0: po= vaild.Validataion().__addPORequestValidation__() try: insert_query = ' insert into po_request(inv_item_id,po_request_quantity,created_by,created_on) values("'+po[0]+'","'+po[1]+'","'+str(user_bean[0])+'",now())' cursor = connection.cursor() result = cursor.execute(insert_query) connection.commit() print ("Record inserted successfully into PO table") i=1 except Exception as error : connection.rollback() #rollback if any exception occured print('Error :Enter correct item id',error) finally: #closing database connection. if(connection.is_connected()): cursor.close() if i==1: break
def __selectUpdateItemId__(self) : item_id="" i=0 while i==0: item_id=vaild.Validataion().__selectUpdateItem__() lst="" try: cursor = connection.cursor() sql="select inv_item_id,item_name,item_description from inv_item where is_active=1 and inv_item_id="+str(item_id) cursor.execute(sql) lst=cursor.fetchall() print(tabulate(lst, headers=['Item Id', 'Item Name','Item Description'])) except Exception as error: print("Failed {}".format(error)) finally: if(connection.is_connected()): cursor.close() if len(lst)==0: print("Enter valid id") else: break return item_id
def __selectUpdatePORequestId__(self) : poRequestId="" i=0 while i==0: poRequestId=vaild.Validataion().__enterUpdatePORequest__() lst="" try: cursor = connection.cursor() sql="select po.po_request_id,itm.inv_item_id,itm.item_name,po.po_request_quantity,s.status,cb.name as created_by,po.created_on,ub.name as updated_by, po.updated_on from po_request po inner join inv_item itm on itm.inv_item_id=po.inv_item_id inner join users cb on cb.user_id=itm.created_by left join users ub on ub.user_id=itm.updated_by inner join status s on s.status_id=po.status_id where po.is_active=1 and po.po_request_id="+str(poRequestId) cursor.execute(sql) lst=cursor.fetchall() print(tabulate(lst, headers=['PO Request Id','Item Id','Item Name', 'PO Request Quantity','Status','Created By','Created On', 'Updated By', 'Updated On'])) except mysql.connector.Error as error: print("Failed {}".format(error)) finally: if(connection.is_connected()): cursor.close() if len(lst)==0: print("Enter valid id") else: break return poRequestId