Esempio n. 1
0
def main():
    if not os.path.isfile(
            'schedule.db'
    ):  # First time creating the database. Create the tables
        from Repository import repo
        repo.create_tables()
        config_file = open(sys.argv[1], 'r')
        for line in config_file:
            fields = line.split(',')
            if (fields[0].strip().__eq__('S')):
                student = DTO.Student(fields[1].strip(), fields[2].strip())
                repo.students.insert(student)
            elif (fields[0].strip().__eq__('R')):
                classroom = DTO.Classroom(fields[1].strip(), fields[2].strip(),
                                          0, 0)
                repo.classrooms.insert(classroom)
            else:
                course = DTO.Course(fields[1].strip(), fields[2].strip(),
                                    fields[3].strip(), int(fields[4].strip()),
                                    int(fields[5].strip()),
                                    int(fields[6].strip()))
                repo.courses.insert(course)

        config_file.close()
        repo.print_all()
Esempio n. 2
0
    def lire(self):
        curValue = self.connexion.cursor()
        curMess = self.connexion.cursor()

        # faire un try CAtch
        try:
            curValue.execute("select * from balance_setting")
            curMess.execute("Select * from balance_message_setting")

            dto = DTO()

            query_value = curValue.fetchall()
            query_mess = curMess.fetchall()

            for row in query_value:
                if (row[1] in dto.__dict__.keys()):
                    values = (row[2], row[3], row[4])

                    #dto.__dict__[key] =  values
                    dto.__dict__[row[1]] = values

            for row in query_mess:
                if (row[1] in dto.__dict__.keys()):
                    values = (row[2], row[3])
                    dto.__dict__[row[1]] = values

        except cx_Oracle.DatabaseError as err:
            error, = err.arg
            print("Oracle-Error-Code", error.code)
            print("Oracle-Error-Message", error.message)

        curValue.close()
        curMess.close()
        return dto
Esempio n. 3
0
	def lire(self):
		
		dto = DTO()

		
		filename = select_open_csv()
		if filename:
			with open(filename, "rb") as file:
				reader = csv.reader(file, dialect = "excel")

				for row in reader:
					if(row[0] in dto.__dict__.keys()):
						if(row[0] == 'mess_accueil_content' or row[0] == 'mess_startGame_content' or row[0] == 'mess_endGame_content'):
							try:							
								valeurs = (int(row[1]), row[2])
							except ValueError: 
								valeurs = (None, None)
							
						else:
							try:							
								valeurs = (float(row[1]), float(row[2]), float(row[3]))
							except ValueError:
								valeurs = (None, None, None)

						dto.__dict__[row[0]] =  valeurs
						

		return dto
Esempio n. 4
0
    def create_tables(self, path):
        self._conn.executescript("""
                CREATE TABLE Employees(
                    id INTEGER PRIMARY KEY, 
                    name TEXT NOT NULL,
                    salary REAL NOT NULL,
                    coffee_stand INTEGER REFERENCES Coffee_stands(id)        
                 );

                 CREATE TABLE Suppliers(
                    id INTEGER PRIMARY KEY,
                    name TEXT NOT NULL,
                    contact_information TEXT
                 );

                 CREATE TABLE Products(
                    id INTEGER PRIMARY KEY,
                    description TEXT NOT NULL,
                    price REAL NOT NULL,
                    quantity INTEGER NOT NULL
                 );

                 CREATE TABLE Coffee_stands(
                    id INTEGER PRIMARY KEY,
                    location TEXT NOT NULL,
                    number_of_employees INTEGER
                 );

                 CREATE TABLE Activities(
                    product_id INTEGER REFERENCES Products(id),
                    quantity INTEGER NOT NULL,
                    activator_id INTEGER NOT NULL,
                    date DATE NOT NULL
                 );
            """)

        text = open(path).readlines()
        for line in text:
            line = line.split(', ')
            for element in range(0, line.__len__()):
                line[element] = str(line[element]).replace("\n", '')

            if (line[0] == "C"):
                coffee_stand = DTO.Coffee_stand(int(line[1]), line[2],
                                                int(line[3]))
                self.coffee_stands.insert(coffee_stand)
            elif (line[0] == "S"):
                supplier = DTO.Supplier(int(line[1]), line[2], line[3])
                self.suppliers.insert(supplier)
            elif (line[0] == "E"):
                employee = DTO.Employee(int(line[1]), line[2], float(line[3]),
                                        int(line[4]))
                self.employees.insert(employee)
            elif (line[0] == "P"):
                product = DTO.Product(int(line[1]), line[2], float(line[3]), 0)
                self.products.insert(product)
Esempio n. 5
0
def enter(entry, repo):
    if entry[0] == 'C':
        repo.coffeeStands.insert(DTO.CoffeeStand(entry[1], entry[2], entry[3]))
    elif entry[0] == 'E':
        repo.employees.insert(
            DTO.Employee(entry[1], entry[2], entry[3], entry[4]))
    elif entry[0] == 'P':
        repo.products.insert(DTO.Product(entry[1], entry[2], entry[3]))
    elif entry[0] == 'S':
        repo.suppliers.insert(DTO.Supplier(entry[1], entry[2], entry[3]))
Esempio n. 6
0
def main():
    repo = _Repository()
    repo.create_tables()

    # Parsing config file
    with open(sys.argv[1]) as config:
        lines = config.readlines()
        index = 1
        num_of_each = lines[0].split(",")
        vaccines = lines[index:index + int(num_of_each[0])]
        index = index + int(num_of_each[0])
        suppliers = lines[index:index + int(num_of_each[1])]
        index = index + int(num_of_each[1])
        clinics = lines[index:index + int(num_of_each[2])]
        index = index + int(num_of_each[2])
        logistics = lines[index:]
        for line in vaccines:
            line = line.replace("\n", "")
            args = line.split(",")
            repo.vac_dao.insert(
                DTO.Vaccine(int(args[0]), args[1], int(args[2]), int(args[3])))
        for line in suppliers:
            line = line.replace("\n", "")
            args = line.split(",")
            repo.sup_dao.insert(
                DTO.Supplier(int(args[0]), args[1], int(args[2])))
        for line in clinics:
            line = line.replace("\n", "")
            args = line.split(",")
            repo.clin_dao.insert(
                DTO.Clinic(int(args[0]), args[1], int(args[2]), int(args[3])))
        for line in logistics:
            line = line.replace("\n", "")
            args = line.split(",")
            repo.log_dao.insert(
                DTO.Logistic(int(args[0]), args[1], int(args[2]),
                             int(args[3])))

    # Executing orders from orders file
    with open(sys.argv[2]) as orders, open(sys.argv[3], "w") as output:
        lines = orders.readlines()
        for line in lines:
            args = line.split(",")
            if len(args) == 3:
                repo.receive_ship(args[0], int(args[1]), args[2])
            else:
                repo.send_ship(args[0], int(args[1]))
            a, b, c, d = repo.create_record()
            output.write("{},{},{},{}\n".format(a[0], b[0], c[0], d[0]))

    repo.close()
Esempio n. 7
0
def readConfig(filePath):
    with open(filePath, "r") as config:
        amountOfEachPart = config.readline()[0:-1].split(',')
        numOfVaccines = int(amountOfEachPart[0])
        # first read the vaccines
        for x in range(0, numOfVaccines):
            line = config.readline()
            # remove \n at the end of each line if exists
            if "\n" in line:
                vaccineDetails = line[0:-1].split(',')
            else:
                vaccineDetails = line.split(',')
            vaccine = DTO.Vaccine(*vaccineDetails)
            repo.vaccines.insert(vaccine)
            sum.totalInventory += int(vaccineDetails[3])
        # read the suppliers
        numOfSuppliers = int(amountOfEachPart[1])
        for i in range(0, numOfSuppliers):
            line = config.readline()
            # remove \n at the end of each line if exists
            if "\n" in line:
                supplierDetails = line[0:-1].split(',')
            else:
                supplierDetails = line.split(',')
            supplier = DTO.Supplier(*supplierDetails)
            repo.suppliers.insert(supplier)
        # read the clinics
        numOfClinics = int(amountOfEachPart[2])
        for i in range(0, numOfClinics):
            line = config.readline()
            # remove \n at the end of each line if exists
            if "\n" in line:
                clinicDetails = line[0:-1].split(',')
            else:
                clinicDetails = line.split(',')
            clinic = DTO.Clinic(*clinicDetails)
            repo.clinics.insert(clinic)
            sum.totalDemand += int(clinicDetails[2])
        # read the logistics
        numOfLogistics = int(amountOfEachPart[3])
        for i in range(0, numOfLogistics):
            line = config.readline()
            # remove \n at the end of each line if exists
            if "\n" in line:
                logisticDetails = line[0:-1].split(',')
            else:
                logisticDetails = line.split(',')
            logistic = DTO.Logistic(*logisticDetails)
            repo.logistics.insert(logistic)
Esempio n. 8
0
 def find(self, logistic):  # retrieve Logistic DTO
     c = self._dbcon.cursor()
     c.execute(
         """
         SELECT id, name FROM logistics WHERE id = ?
     """, [logistic])
     return DTO.Logistic(*c.fetchone())
Esempio n. 9
0
 def find(self, logistic_id):
     c = self._conn.cursor()
     c.execute(
         """
                 SELECT id FROM logistics WHERE id = ?
             """, [logistic_id])
     return DTO.logistics(*c.fetchone())
Esempio n. 10
0
    def find(self, clinic_id):
        c = self._dbcon.cursor()
        c.execute(
            """
            SELECT id, name FROM clinics WHERE id = ?
        """, [clinic_id])

        return DTO.Clinics(*c.fetchone())
Esempio n. 11
0
    def find(self, product_id):
        c = self._conn.cursor()
        c.execute(
            """
        SELECT id, name FROM Products WHERE id = ?
        """, [product_id])

        return DTO.Product(*c.fetchone())
Esempio n. 12
0
 def receive_shipment(self, arrOfCurrOrder):
     supplier = self.suppliers.findByName(arrOfCurrOrder[0])
     vaccToAdd = DTO.Vaccine(0, arrOfCurrOrder[2], supplier[0],
                             arrOfCurrOrder[1])
     self.vaccines.insert(vaccToAdd)
     logistic = self.logistics.findByID(supplier[2])
     self.logistics.updateReceivedCount(logistic[0], arrOfCurrOrder[1])
     self._conn.commit()
Esempio n. 13
0
 def find(self, vaccine_id):
     c = self._conn.cursor()
     c.execute(
         """
                 SELECT * FROM vaccines WHERE id = ?
             """, [vaccine_id])
     #print(type(*c.fetchone()))
     return DTO.vaccines(*c.fetchone())
Esempio n. 14
0
    def find(self, name):
        c = self._conn.cursor()
        c.execute(
            """
                    SELECT id FROM suppliers WHERE name = ?
                """, [name])

        return DTO.suppliers(*c.fetchone())
Esempio n. 15
0
def receive(order):
    name = order[0]
    amount = int(order[1])
    date = order[2].replace('\n','')
    id = repo.vaccines.last_id + 1
    supp = repo.suppliers.find(name=name)[0]
    repo.vaccines.insert(DTO.Vaccine(id, date, supp.id, amount))
    logi = repo.logistics.find(id=supp.logistic)[0]
    repo.logistics.update({'count_received': (logi.count_received + amount)}, {'id': logi.id})
Esempio n. 16
0
def read_suppliers(x, f):
    for i in range(x):
        s = f.readline()
        parser = s[0:-1].split(',')
        supplier_id = int(parser[0])
        name = parser[1]
        suppliers.append(name)
        logistic = int(parser[2])
        add_supplier(DTO.Supplier(supplier_id, name, logistic))
Esempio n. 17
0
def read_vaccines(x, f):
    for i in range(x):
        s = f.readline()
        parser = s[0:-1].split(',')
        vaccine_id = int(parser[0])
        c = parser[1][4]
        date = datetime.datetime.strptime(parser[1], "%Y" + c + "%m" + c + "%d")
        supplier = int(parser[2])
        quantity = int(parser[3])
        add_vaccine(DTO.Vaccine(vaccine_id, date, supplier, quantity))
Esempio n. 18
0
def read_clinics(x, f):
    for i in range(x):
        s = f.readline()
        parser = s[0:-1].split(',')
        clinic_id = int(parser[0])
        location = parser[1]
        locations.append(location)
        demand = int(parser[2])
        logistic = int(parser[3])
        add_clinic(DTO.Clinic(clinic_id, location, demand, logistic))
Esempio n. 19
0
def receive_shipment(lst):
    supplier = get_supplier(lst[0], "name")
    supplier_id = supplier.id
    amount = int(lst[1])
    c = lst[2][4]
    date = datetime.datetime.strptime(lst[2], "%Y" + c + "%m" + c + "%d")
    vaccine_id = DTO.Vaccine.counter + 1
    add_vaccine(DTO.Vaccine(vaccine_id, date, supplier_id, amount))
    logistic_id = supplier.logistic
    update_logistic(logistic_id, amount)
Esempio n. 20
0
 def receive_shipment(self, name, amount, date):
     self._output.increase_total_inventory(amount)
     self._output.increase_total_received(amount)
     id_supplier = self.suppliers.find_by_name(name).id
     cursor = self._con.cursor()
     next_id = self.vaccines.get_new_index(cursor)
     self.vaccines.insert(DTO.Vaccine(next_id, date, id_supplier, amount))
     logistic_id = self.suppliers.find_by_name(name).logistic
     self.logistics.increase_count_received(amount, logistic_id)
     self._output.update_output()
Esempio n. 21
0
 def receive_shipment(self, name, amount, date):
     cursor = self._dbcon.cursor()
     # finding the unique id
     id = DAO.Vaccines.counter
     supp_id = DAO.Suppliers.find(self.suppliers, name)
     new_row_vaccine = DTO.Vaccines(id, date, supp_id, amount)
     DAO.Vaccines.insert(self.vaccines, new_row_vaccine)
     cursor.execute("""SELECT logistic FROM suppliers WHERE name=(?)""",
                    [name])
     sup_logistic_id = cursor.fetchone()[0]
     self.update_count_suppliers(sup_logistic_id, int(amount))
Esempio n. 22
0
def read_logistics(x, f):
    for i in range(x):
        s = f.readline()
        parser = s[0:-1].split(',')
        if i == x - 1:
            parser = s.split(',')
        logistic_id = int(parser[0])
        name = parser[1]
        count_sent = int(parser[2])
        count_received = int(parser[3])
        add_logistic(DTO.Logistic(logistic_id, name, count_sent, count_received))
Esempio n. 23
0
 def InsertActivities(self, path):
     text = open(path).readlines()
     for line in text:
         line.replace(' ', '')  ## remove all whitespaces
         line = line.split(',')
         product_id = int(line[0])
         units_quantity = int(line[1])
         supplier_id = int(line[2])
         date_string = line[3]
         cur = self._conn.cursor()
         q = self.products.find(product_id)
         if units_quantity > 0:  ## suply
             a = DTO.Activity(product_id, units_quantity, supplier_id,
                              date_string)
             self.activities.insert(a)
             self.products.update_quantity(units_quantity, product_id)
         elif int(q) + units_quantity >= 0:  ## sell legal
             a = DTO.Activity(product_id, units_quantity, supplier_id,
                              date_string)
             self.activities.insert(a)
             self.products.update_quantity(units_quantity, product_id)
Esempio n. 24
0
def main(actions_file):
    with open(actions_file, 'r') as f:
        for line in f.readlines():
            args = line.split(',')
            args = [arg.strip() for arg in args]
            activity = DTO.Activity(*args)
            curr_quantity = repo.products.get_quantity(activity.product_id)
            new_quantity = curr_quantity + int(activity.quantity)
            if new_quantity >= 0:
                repo.activities.insert(activity)
                repo.products.update(activity.product_id, activity.quantity)
    printdb.main()
Esempio n. 25
0
 def populate_db(self, vacs, sups, clis, logs):
     for i in vacs:
         i = i.split(',')
         vaccine = DTO.vaccines(*i)
         insert_vac = DAO._vaccines(self._conn)
         insert_vac.insert(vaccine)
     for i in sups:
         i = i.split(',')
         supplier = DTO.suppliers(*i)
         insert_sup = DAO._suppliers(self._conn)
         insert_sup.insert(supplier)
     for i in clis:
         i = i.split(',')
         clinic = DTO.clinics(*i)
         insert_clinic = DAO._clinics(self._conn)
         insert_clinic.insert(clinic)
     for i in logs:
         i = i.split(',')
         logistic = DTO.logistics(*i)
         insert_logistic = DAO._logistics(self._conn)
         insert_logistic.insert(logistic)
Esempio n. 26
0
    def receive_shipment(self, name, amount, date):
        cursor = self._conn.cursor()
        # cursor.execute("SELECT * FROM vaccines ORDER BY id DESC LIMIT 1")
        if (self.are_any_vaccine_left() == True):
            cursor.execute("""SELECT MAX(id) FROM vaccines""")
            last = cursor.fetchone()[0] + 1
        else:
            last = 1
        cursor.execute("""SELECT id FROM suppliers WHERE name=(?)""", [name])
        supp_id = cursor.fetchone()[0]
        amount = int(amount)

        # TODO: make this object datetime
        # date = datetime.strptime(date, '%Y-%m-%d')
        vaccine_to_add = DTO.vaccines(last, date, supp_id, amount)
        adding_vaccine = DAO._vaccines(cursor)
        adding_vaccine.insert(vaccine_to_add)
        self.update_logistics_count_received(supp_id, amount)
Esempio n. 27
0
    def receiveShipment(self, nameOfSup, amount, date):
        # insert the next vaccine to the vaccine table
        # get the id of the logistics from the suppliers table using the name

        supplier = self.suppliers.find(name=nameOfSup)
        supplierIndex = supplier[0].id
        # get the id of the last inserted line to create a new id for the new vaccine
        lastId = self.vaccines.getLastInsertedId()
        newId = lastId[0] + 1
        newVaccine = DTO.Vaccine(newId, date, supplierIndex, amount)
        self.vaccines.insert(newVaccine)

        idOfLogistics = supplier[0].logistic

        # update the count_received of this logistics company in logistics table
        logistic = self.logistics.find(id=idOfLogistics)
        currCountRec = logistic[0].count_Received
        set_value = {'count_received': currCountRec + int(amount)}

        # only where the id = idOfLogistics we got from the find query
        cond = {'id': idOfLogistics}
        self.logistics.update(set_value, cond)
Esempio n. 28
0
    def read_insert(self, config_file):
        with open(config_file) as f:
            f = f.readlines()  # f stands for file -- make my file a list
        config_first_line = f[0]
        config_first_line = config_first_line[:-1]
        split_config_first_line = config_first_line.split(",")

        list_entries_vaccines = []
        list_entries_suppliers = []
        list_entries_clinics = []
        list_entries_logistics = []
        lines_to_read_vac = int(split_config_first_line[0])
        lines_to_read_sup = int(split_config_first_line[1])
        lines_to_read_clin = int(split_config_first_line[2])
        lines_to_read_log = int(split_config_first_line[3])
        range1 = range(1, 1 + lines_to_read_vac)
        range2 = range(1 + lines_to_read_vac,
                       lines_to_read_sup + 1 + lines_to_read_vac)
        range3 = range(
            lines_to_read_sup + 1 + lines_to_read_vac,
            lines_to_read_sup + 1 + lines_to_read_vac + lines_to_read_clin)
        range4 = range(
            lines_to_read_sup + 1 + lines_to_read_vac + lines_to_read_clin,
            lines_to_read_sup + 1 + lines_to_read_vac + lines_to_read_clin +
            lines_to_read_log)

        for i in range1:
            list_entries_vaccines.append(f[i])
        for i in range2:
            list_entries_suppliers.append(f[i])
        for i in range3:
            list_entries_clinics.append(f[i])
        for i in range4:
            list_entries_logistics.append(f[i])

        for i in list_entries_vaccines:
            i = i[:-1]
            i = i.split(',')
            vaccine = DTO.Vaccines(*i)
            insert_vac = DAO.Vaccines(self._dbcon)
            insert_vac.insert(vaccine)

        for i in list_entries_suppliers:
            i = i[:-1]
            i = i.split(',')
            supplier = DTO.Suppliers(*i)
            insert_sup = DAO.Suppliers(self._dbcon)
            insert_sup.insert(supplier)

        for i in list_entries_clinics:
            i = i[:-1]
            i = i.split(',')
            clinic = DTO.Clinics(*i)
            insert_cli = DAO.Clinics(self._dbcon)
            insert_cli.insert(clinic)

        for i in list_entries_logistics:
            if i[-1] == '\n':
                i = i[:-1]
            i = i.split(',')
            logistic = DTO.Logistic(*i)
            insert_log = DAO.Logistics(self._dbcon)
            insert_log.insert(logistic)
Esempio n. 29
0
 def receive_ship(self, _name, amount, date):
     sup_id = self.sup_dao.get_sup_id(_name)
     max_id = self.vac_dao.max_id()
     self.vac_dao.insert(DTO.Vaccine(max_id[0] + 1, date, sup_id, amount))
     log_id = self.sup_dao.get_log_id(sup_id)
     self.log_dao.update_count_r(log_id, amount)
Esempio n. 30
0
def agregarFichadesdeExcel(archivo, idCategoria, idCliente):
    nombre_archivo = u'{0}'.format(archivo) + '.xlsx'
    wb = load_workbook(filename=nombre_archivo)
    sheet = wb.get_sheet_by_name(u'Hoja1')
    "Construccion de Datos de la ficha"
    ficha = DTO.FichaTecnica()
    ficha.setEtiqueta(str(sheet['B2'].value).decode(encoding="cp1252"))
    if sheet['B3'].value == None:
        pedido = "SIN PEDIDO"
    else:
        pedido = str(sheet['B3'].value)
    ficha.setPedido(pedido)
    fecha = sheet['G2'].value.strftime("%d/%m/%Y")
    ficha.setFecha(fecha)
    velocidad = float(sheet['F40'].value)
    ficha.setVelocidad(velocidad)
    clisse = False
    if sheet['C40'].value != None:
        clisse = True
    ficha.setClisse(clisse)
    maquina = str(sheet['G3'].value).decode(encoding="cp1252")
    maquinaReal = DTO.Maquina()
    maquinaReal.setCodigo(maquina)
    maquinaReal = DAO.Maquina(maquinaReal)
    maquinaReal.leerMaquina()
    ficha.setIdMaquina(maquinaReal.getMaquina().getIdMaquina())
    ficha.setIdCliente(idCliente)
    ficha.setIdCategoria(idCategoria)
    "Generar lista de materiales"
    listaMateriales = list()
    for i in range(6, 9):
        material = DTO.Material()
        if sheet['A{0}'.format(i)].value == None or sheet['B{0}'.format(
                i)].value == None:
            break
        else:
            material.setNombre(
                str(sheet['A{0}'.format(i)].value).decode(encoding="cp1252"))
            material.setCodigo(
                str(sheet['B{0}'.format(i)].value).decode(encoding="cp1252"))
            material.setProveedor(
                str(sheet['C{0}'.format(i)].value).decode(encoding="cp1252"))
            material.setAncho(float(sheet['D{0}'.format(i)].value))
            tc = False
            if (sheet['E6'].value == 'SI' or sheet['E6'].value == 'si'
                    or sheet['E6'].value == 'Si'):
                tc = True
            material.setTC(tc)

            listaMateriales.append(material)
    "Generar lista de tintas"
    listaTintas = list()
    for i in range(15, 23):
        if sheet['B{0}'.format(i)].value == None:
            break
        else:
            tinta = DTO.Tinta()
            tinta.setColor(
                str(sheet['B{0}'.format(i)].value).decode(encoding="cp1252"))
            tinta.setTipo(
                str(sheet['C{0}'.format(i)].value).decode(encoding="cp1252"))
            tinta.setAnilox(
                str(sheet['D{0}'.format(i)].value).decode(encoding="cp1252"))
            tinta.setProveedor1(
                str(sheet['E{0}'.format(i)].value).decode(encoding="cp1252"))
            tinta.setProveedor2(
                str(sheet['F{0}'.format(i)].value).decode(encoding="cp1252"))
            tinta.setProveedor3(
                str(sheet['G{0}'.format(i)].value).decode(encoding="cp1252"))
            listaTintas.append(tinta)
    "generar lista de mallas"
    listaMallas = list()
    for i in range(11, 13):
        if sheet['B{0}'.format(i)].value == None:
            break
        else:
            malla = DTO.Malla()
            malla.setTipo(str(sheet['B{0}'.format(i)].value))
            interno = False
            if str(sheet['C{0}'.format(i)].value) == None:
                interno = True

            malla.setInterno(interno)

            listaMallas.append(malla)

        pass
    "generar lista de adhesivos lam"
    listaadlam = list()
    for i in range(25, 27):
        if str(sheet['A{0}'.format(i)].value) == "NO" or sheet['A{0}'.format(
                i)].value == None:
            break
        else:
            adlam = DTO.AdhesivoLaminacion()
            adlam.setProveedor(str(sheet['B{0}'.format(i)].value))
            adlam.setAnilox(str(sheet['C{0}'.format(i)].value))
            listaadlam.append(adlam)
        pass
    "generar lista de adhesivos cold foil"
    listaadcofo = list()
    for i in range(29, 31):
        if str(sheet['A{0}'.format(i)].value) == "NO" or sheet['A{0}'.format(
                i)].value == None:
            break
        else:
            adcofo = DTO.AdhesivoColdFoil()
            adcofo.setProveedor(str(sheet['B{0}'.format(i)].value))
            adcofo.setAnilox(str(sheet['C{0}'.format(i)].value))
            listaadcofo.append(adcofo)
        pass
    "generar lista de films de micronaje"
    listafilmi = list()
    for i in range(25, 27):
        if str(sheet['E{0}'.format(i)].value) == "NO" or sheet['E{0}'.format(i)].value == None \
                or str(sheet['E{0}'.format(i)].value) == "no":
            break
        else:
            filmi = DTO.FilmMicronaje()
            proveedor = str(sheet['E{0}'.format(i)].value) + " " + str(
                sheet['F{0}'.format(i)].value)
            filmi.setProveedor(proveedor)
            filmi.setAncho(float(sheet['G{0}'.format(i)].value))
            listafilmi.append(filmi)

        pass
    "generar lista de cold foil"
    listacoldfoil = list()
    for i in range(29, 31):
        if str(sheet['E{0}'.format(i)].value) == "NO" or sheet['E{0}'.format(i)].value == None or \
                        sheet['F{0}'.format(i)].value == None or str(sheet['E{0}'.format(i)].value) == "no":
            break
        else:
            coldfoil = DTO.ColdFoil()
            proveedor = str(sheet['F{0}'.format(i)].value)
            coldfoil.setProveedor(proveedor)
            coldfoil.setAncho(float(sheet['G{0}'.format(i)].value))
            listacoldfoil.append(coldfoil)

        pass
        pass
    "generar lista de tipos de barniz"
    listatbarniz = list()
    for i in range(33, 38):
        if str(sheet['E{0}'.format(i)].value) == "NO" or sheet['E{0}'.format(
                i)].value == None:
            break
        else:
            tbarniz = DTO.TipoBarniz()
            tbarniz.setTipo(str(sheet['E{0}'.format(i)].value))
            tbarniz.setProveedor(str(sheet['F{0}'.format(i)].value))
            tbarniz.setAnilox(str(sheet['G{0}'.format(i)].value))
            listatbarniz.append(tbarniz)
        pass
    "generar lista de troquel"
    listatroquel = list()
    for i in range(33, 38):
        if str(sheet['A{0}'.format(i)].value) == "NO" or sheet['A{0}'.format(
                i)].value == None:
            break
        else:
            troquel = DTO.Troquel()

            proveedor = str(sheet['B{0}'.format(i)].value)
            troquel.setProveedor(proveedor)
            observacion = ""
            if sheet['A{0}'.format(i)].value != None:
                observacion += str(sheet['A{0}'.format(i)].value)
            if sheet['C{0}'.format(i)].value != None:
                if str(sheet['C{0}'.format(i)].value).find('/') != -1:
                    observacion += " " + sheet['C{0}'.format(
                        i)].value.strftime("%d/%m/%Y")
                else:
                    observacion += " " + str(sheet['C{0}'.format(i)].value)
            if len(observacion) == 0:
                observacion = "SIN OBSERVACION"
            troquel.setObservacion(observacion)
            listatroquel.append(troquel)
        pass
    if (DAO.FichaTecnica(ficha).insertarFichaTecnica()):
        pass
    else:
        pass
    ficha = DAO.FichaTecnica()
    ultimoId = DAO.FichaTecnica().idUltimaFicha()
    ficha.getFichaTecnica().setIdFicha(ultimoId)
    ficha.leerFichaTecnicaidFicha()
    for mat in listaMateriales:
        if (DAO.Material(mat).insertarMaterial()):
            pass
            referencia = DAO.MaterialFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdMaterial(
                DAO.Material().idUltimoMaterialInsertada())
            referencia.insertarMaterialFicha()
        else:
            pass
    for tinta in listaTintas:
        if (DAO.Tinta(tinta).ingresarTinta()):
            pass
            referencia = DAO.TintaFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdTinta(DAO.Tinta().idUltimaTinta())
            referencia.insertarTintaFicha()
        else:
            pass
    for malla in listaMallas:
        if (DAO.Malla(malla).ingresarMalla()):
            pass
            referencia = DAO.MallaFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdMalla(DAO.Malla().idUltimaMallaInsertada())
            referencia.insertarMallaFicha()
        else:
            pass
    for adlam in listaadlam:
        if (DAO.AdhesivoLaminacion(adlam).ingresarAdhLam()):
            pass
            referencia = DAO.AdhLamFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdAdhLam(DAO.AdhesivoLaminacion().idUltimoAdhLam())
            referencia.insertarAdhLamFicha()
        else:
            pass
    for adcofo in listaadcofo:
        if (DAO.AdhesivoColdFoil(adcofo).ingresarAdhCoFo()):
            pass
            referencia = DAO.AdhCoFoFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdAdhCoFo(DAO.AdhesivoColdFoil().idUltimoAdhCoFo())
            referencia.insertarAdhCoFoFicha()
        else:
            pass
    for filmi in listafilmi:
        if (DAO.FilmMicronaje(filmi).ingresarFilmMi()):
            pass
            referencia = DAO.FilmMiFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdFilmMi(DAO.FilmMicronaje().idUltimoFilmMi())
            referencia.insertarFilmMiFicha()
        else:
            pass
    for coldfoil in listacoldfoil:
        if (DAO.ColdFoil(coldfoil).ingresarColdFoil()):
            pass
            referencia = DAO.ColdFoilFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdColdFoil(DAO.ColdFoil().idUltimoColdFoil())
            referencia.insertarColdFoilFicha()
        else:
            pass
    for tbarniz in listatbarniz:
        if (DAO.TipoBarniz(tbarniz).ingresarTBarniz()):
            pass
            referencia = DAO.TBarnizFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdTBarniz(DAO.TipoBarniz().idUltimoTBarniz())
            referencia.insertarTBarnizFicha()
        else:
            pass
    for troquel in listatroquel:
        if (DAO.Troquel(troquel).ingresarTroquel()):
            pass
            referencia = DAO.TroquelFicha()
            referencia.setIdFicha(ficha.getFichaTecnica().getIdFicha())
            referencia.setIdTroquel(DAO.Troquel().idUltimoTroquel())
            referencia.insertarTroquelFicha()
        else:
            pass