Пример #1
0
 def add_sale(self, id_entry, prod_entry, amount_entry, listbox):
     prod_arr = prod_entry.get().split(',')
     amount_arr = list(map(float, amount_entry.get().split(",")))
     new_sale = Sales(int(id_entry.get()), prod_arr, amount_arr)
     new_sale.init_sale()
     id_entry.delete(0, END)
     prod_entry.delete(0, END)
     amount_entry.delete(0, END)
     self.update_list(listbox)
Пример #2
0
 def manipulate_sales(self, sale):
     word_list = re.sub("[^\w]", " ", sale).split()
     sale_id = int(word_list[1])
     seller_id = int(word_list[4])
     MsgBox = messagebox.askquestion(
         "Delete sale",
         "Are you sure that you want to delete sale?",
         icon='warning')
     if MsgBox == 'yes':
         Sales.delete_sale_by_id(sale_id)
         self.update_list(self.allsales_listbox)
     else:
         self.update_list(self.allsales_listbox)
Пример #3
0
 def delete_sale(self):
     try:
         id = int(self.idEnter.text())
         Sales.delete_sale_by_id(id)
         self.update_all_sales()
         self.idEnter.setText("")
     except:
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Error")
         msg.setInformativeText('Please insert sale id!')
         msg.setWindowTitle("Error")
         msg.exec_()
Пример #4
0
 def update_all_sales(self):
     self.sale_list.setEditTriggers(QAbstractItemView.NoEditTriggers)
     model = QStandardItemModel(self.sale_list)
     for i in Sales.show_all_sales().split("\n"):
         item = QStandardItem(i)
         model.appendRow(item)
     self.sale_list.setModel(model)
Пример #5
0
def first_menu():
    while True:
        print("Select what you want to do: \n"
            "1. Work with Products \n"
            "2. Work with Sales \n"
            "3. Work with Sellers \n"
            "4. Show all products \n"
            "5. Show all sales \n"
            "6. Show all sellers \n"
            "-1 to quite \n")
        n = int(input("Enter your number:"))
        try:
            if n == -1:
                return
            elif n == 1:
                work_with_product()
            elif n == 2:
                work_with_sales()
            elif n == 3:
                work_with_seller()
            elif n == 4:
                print(Product.show_all_the_products())
            elif n == 5:
                print(Sales.show_all_sales())
            elif n == 6:
                print(Seller.show_all_sellers())
        except:
            print("Wrong input!")
Пример #6
0
 def add_sale(self):
     try:
         arr_prod = self.products.text().split(",")
         arr_amount = list(map(float, self.amounts.text().split(",")))
         new_sale = Sales(int(self.seller_id.text()), arr_prod, arr_amount)
         new_sale.init_sale()
         self.update_all_sales()
         self.seller_id.setText("")
         self.products.setText("")
         self.amounts.setText("")
     except:
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Error")
         msg.setInformativeText('Please insert data!')
         msg.setWindowTitle("Error")
         msg.exec_()
Пример #7
0
 def search_sale_on_click(self, listbox, entry_date):
     listbox.delete(0, END)
     try:
         self.find_list = Sales.find_sale_by_date(entry_date.get())
         listbox.insert(END, self.find_list)
     except IndexError:
         messagebox.showerror(
             "No such sale error!",
             "Incorrect sale date or such sale doesnt exist!")
     return
Пример #8
0
def work_with_sales():
    while True:
        print("Select what you want to do: \n"
              "1. Insert sale \n"
              "2. Find sale by id \n"
              "-1 to quite \n")
        n = int(input("Enter your number:"))
        try:
            if n == -1:
                return
            elif n == 1:
                seller_id = int(input("Enter seller`s id: "))
                arr_prod = input("Enter list of products splited by coma:").split(",")
                arr_amount = list(map(float, input("Enter list of amounts splited by coma: ").split(",")))
                new_sale = Sales(seller_id, arr_prod, arr_amount)
                new_sale.init_sale()
            elif n == 2:
                id = int(input("Enter sale`s id: "))
                print(Sales.find_sale_by_id(id))
        except:
            print("Wrong input!")
Пример #9
0
 def find_sale(self):
     try:
         model = QStandardItemModel(self.search_sale_list)
         item = QStandardItem(Sales.find_sale_by_date(self.choseDate.date().toString("dd.MM.yyyy")))
         model.appendRow(item)
         self.search_sale_list.setModel(model)
     except:
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Error")
         msg.setInformativeText('Please insert data!')
         msg.setWindowTitle("Error")
         msg.exec_()
Пример #10
0
    def form_exel_report(self):
        wb = openpyxl.load_workbook('Reports\\All_info.xlsx')
        if 'Sales' not in wb.sheetnames:
            wb.create_sheet("Sales")
        ws = wb["Sales"]
        ws.delete_cols(1, 5)
        ws.delete_rows(1, 100)
        sales_list = Sales.show_all_sales().split("\n")
        del sales_list[-1]
        for i in range(len(sales_list)):
            result_id = re.search('Id: (.*), seller id:', sales_list[i]).group(1)
            result_seller_id = re.search('seller id: (.*), ', sales_list[i]).group(1)
            result_date = re.search('datetime:(.*)', sales_list[i]).group(1)
            ws.cell(row=i + 1, column=1).value = result_id
            ws.cell(row=i + 1, column=2).value = result_seller_id
            ws.cell(row=i + 1, column=3).value = result_date

        wb.save('Reports\\All_info.xlsx')
Пример #11
0
 def update_list(self, listbox):
     listbox.delete(0, END)
     self.sales_list = Sales.show_all_sales().split('\n')
     for sale in self.sales_list:
         self.allsales_listbox.insert(END, sale)
     return
Пример #12
0
    def __init__(self, *args, **kwargs):
        Page.__init__(self, *args, **kwargs)

        window = Toplevel(self)
        window.title("Sales window")
        window.state('zoomed')

        all_sales = Frame(window)
        all_sales.pack(side=LEFT, fill=Y)
        Label(all_sales,
              text="All avaliable sellers(double click to delete)").pack()
        self.allsales_listbox = Listbox(all_sales, width=80)
        self.allsales_listbox.bind('<Double-1>', self.all_list_on_click)
        self.sales_list = Sales.show_all_sales().split("\n")
        self.sales_list.pop(-1)
        for sale in self.sales_list:
            self.allsales_listbox.insert(END, sale)
        self.allsales_listbox.pack(side="top", fill="both")
        all_docx = Button(all_sales,
                          text="Export info in docx about all sales",
                          command=self.form_docx_report())
        all_docx.pack()
        all_exel = Button(all_sales,
                          text="Export info in exel about all sales",
                          command=self.form_exel_report())
        all_exel.pack()

        search_sale = Frame(window)
        search_sale.pack(side=LEFT, fill=Y)
        Label(search_sale, text="Search sale by date").pack()
        date_entry = Entry(search_sale)
        date_entry.pack()
        self.find_listbox = Listbox(search_sale, width=80)
        self.find_listbox.bind('<Double-1>', self.find_list_on_click)
        find_sale = partial(self.search_sale_on_click, self.find_listbox,
                            date_entry)
        search_btn = Button(search_sale, text="Search", command=find_sale)
        search_btn.pack()
        self.find_listbox.pack()

        add_sale = Frame(window)
        add_sale.pack(side=LEFT, fill=Y)
        Label(add_sale, text="Add new sale").grid(row=0,
                                                  column=0,
                                                  columnspan=3)
        seller_id = Label(add_sale, text="Enter sellers` id:")
        prod_label = Label(add_sale, text="Enter products splited by coma:")
        amount_label = Label(add_sale,
                             text="Enter amounts of each product by coma:")
        id_entry = Entry(add_sale)
        prod_entry = Entry(add_sale)
        amount_entry = Entry(add_sale)
        new_sale_add = partial(self.add_sale, id_entry, prod_entry,
                               amount_entry, self.allsales_listbox)
        add_btn = Button(add_sale, text="Add", command=new_sale_add)
        seller_id.grid(row=1, column=0)
        prod_label.grid(row=2, column=0)
        amount_label.grid(row=3, column=0)
        id_entry.grid(row=1, column=1)
        prod_entry.grid(row=2, column=1)
        amount_entry.grid(row=3, column=1)
        add_btn.grid(row=5, column=1)
Пример #13
0
 def form_docx_report(self):
     sales_list = Sales.show_all_sales().split("\n")
     del sales_list[-1]
     for i in sales_list:
         self.sale_export(i)