def OnClose(self, event): dlg = wx.MessageDialog(parent=None, message=u"Voulez vous sauvegarder cet achat ?", caption=u"Sauvegarde de l'achat", style=wx.YES_NO|wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.OnSauvegarder(event) else: DATABASE.rollback() self.EndModal(wx.ID_CANCEL)
def OnClose(self, event): dlg = wx.MessageDialog(parent=None, message=u"Voulez vous sauvegarder cet achat ?", caption=u"Sauvegarde de l'achat", style=wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.OnSauvegarder(event) else: DATABASE.rollback() self.EndModal(wx.ID_CANCEL)
def OnDestroy(self, event): if self.commande.fournisseur != None: dlg = wx.MessageDialog(parent=None, message=u"Voulez vous sauvegarder la commande ?", caption=u"Sauvegarde de la commande", style=wx.YES_NO|wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.OnSauvegarder(None) else: DATABASE.rollback() dlg.Destroy() event.Skip()
def OnDestroy(self, event): if not self.inventaire.is_valide: dlg = wx.MessageDialog(parent=None, message=u"Voulez vous sauvegarder l'inventaire ?", caption=u"Sauvegarde de l'inventaire", style=wx.YES_NO|wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.inventaire.date = date.today() self.inventaire.save() DATABASE.commit() else: DATABASE.rollback() dlg.Destroy() event.Skip()
def OnDestroy(self, event): if self.commande.fournisseur != None: dlg = wx.MessageDialog( parent=None, message=u"Voulez vous sauvegarder la commande ?", caption=u"Sauvegarde de la commande", style=wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.OnSauvegarder(None) else: DATABASE.rollback() dlg.Destroy() event.Skip()
def OnClose(self, event): DATABASE.rollback() event.Skip()
def OnImpressionEtiquettes(self, event): lst = [] ligne_etiquettes = [] tableau_etiquettes = [] tableau_style = [] hauteurs_lignes = [] tableau_style.append(('VALIGN', (0, 0), (-1, -1), 'MIDDLE')) tableau_style.append(('TOPPADDING', (0, 0), (-1, -1), 0)) tableau_style.append(('BOTTOMPADDING', (0, 0), (-1, -1), 0)) tableau_style.append(('LEFTPADDING', (0, 0), (-1, -1), 2)) tableau_style.append(('RIGHTPADDING', (0, 0), (-1, -1), 2)) tableau_style.append(('BOX', (0, 0), (-1, -1), 2, colors.black)) tableau_style.append(('INNERGRID', (0, 0), (-1, -1), 2, colors.black)) n_produit = 0 ref_style = ParagraphStyle('RefProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=14) nom_style = ParagraphStyle('NomProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=12) prix_style = ParagraphStyle('PrixProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=14) liste_produits_etiquettes = [] for produit in self.liste_produits.GetObjects(): if produit.a_etiquetter: n_produit += 1 if n_produit%2 == 0: x = 3 else: x = 0 y = (n_produit-1)/2 ligne_etiquettes.append(Paragraph(produit.ref_GASE, ref_style)) ligne_etiquettes.append(Paragraph(produit.nom, nom_style)) ligne_etiquettes.append(Paragraph(produit.prix_vente_format, prix_style)) tableau_style.append(('BACKGROUND', (x, y), (x+2, y), produit.fournisseur.couleur)) if n_produit%2 == 0: tableau_etiquettes.append(ligne_etiquettes) hauteurs_lignes.append(2*cm) ligne_etiquettes = [] produit.a_etiquetter = False liste_produits_etiquettes.append(produit) #Si aucun produit n'est selectionnee on ne continue pas if n_produit > 0: if n_produit%2 != 0: ligne_etiquettes.append("") ligne_etiquettes.append("") ligne_etiquettes.append("") tableau_etiquettes.append(ligne_etiquettes) hauteurs_lignes.append(2*cm) table_etiquettes = Table(tableau_etiquettes, colWidths=[2*cm, 5.5*cm, 2*cm, 2*cm, 5.5*cm, 2*cm], rowHeights=hauteurs_lignes) table_etiquettes.setStyle(TableStyle(tableau_style)) lst.append(table_etiquettes) #Création des répertoires si ils n'existent pas rep = os.path.dirname(os.getcwd() + "/Etiquettes/") if not os.path.exists(rep): os.makedirs(rep) date_jour = datetime.now() chemin_fichier = os.path.join(rep, "Etiquettes - " + date_jour.strftime("%d-%m-%Y %H-%M-%S") + ".pdf") doc = SimpleDocTemplate(chemin_fichier, title="Etiquettes - " + date_jour.strftime("%d-%m-%Y %H-%M-%S"), pagesize=A4, topMargin=2*cm, bottomMargin=2*cm, leftMargin=1.5*cm, rightMargin=1.5*cm) doc.build(lst) #session.commit() self.liste_produits.RefreshObjects(self.liste_produits.GetObjects()) '''preview_pdf = PreviewPDF(chemin_fichier) preview_pdf.ShowModal() preview_pdf.Destroy()''' desktop.open(chemin_fichier) try: for p in liste_produits_etiquettes: p.save() DATABASE.commit() except: DATABASE.rollback()
def OnClose(self, event): DATABASE.rollback() event.Skip()