示例#1
0
def query(m, v, root, pid, name, date, time, topic):
    if name == "" or date == "" or time == "" or topic == "":  #condition to check empty field
        messagebox.showerror("ERROR3", "Each Field is Mandatory")
    else:
        if valid.checkdate(date) == False:
            messagebox.showerror(
                "ERROR5",
                "Date Format Error\n\tOR\nDate Value Error\nDate Format : yyyy-mm-dd"
            )
        elif valid.checktime(time) == False:
            messagebox.showerror(
                "ERROR6",
                "Time Format Error\n\tOR\nTime Value Error\nTime Format : hh:mm"
            )
        else:
            c.execute(
                'select meeting_date,meeting_time from meeting where project_id is not '
                + pid)
            res = c.fetchall()
            flag = 0
            for row in res:  #check if similar date and time exists
                if row[0] == date and row[1] == time:
                    flag = 1
                    messagebox.showerror(
                        "ERROR2",
                        "Meeting at Given \nDate and Time Already Exists")
                    break
            if flag == 0:  #update into DB
                c.execute(
                    'update meeting set meeting_date=?,meeting_time=?,meeting_topic=?,project_name=? where project_id=?',
                    (date, time, topic, name, pid))
                con.commit()
                messagebox.showerror("Success", "Meeting successfully updated")
                m.destroy()  #update the result
                update_db(root)  #after successful updation
示例#2
0
def do(s, e1, e2, v1=1, v2=1):  #Enter Possible Queries in this Function
    if v1.get() == 1 and v2.get() == 0:  #Condition for Search by Name
        result = c.execute(
            "select meeting_date,meeting_time,project_name,meeting_topic from meeting where project_name like '"
            + e1.get() + "%' or project_name like '" + e1.get().lower() +
            "%' or project_name like '" + e1.get().upper() +
            "%'order by date(meeting_date),time(meeting_time);")
        result = c.fetchall()
        show(s, result)

    if v2.get() == 1 and v1.get() == 0:  #Condition for Search by Date
        if valid.checkdate(e2.get()) == False:
            messagebox.showerror(
                "ERROR5",
                "Date Format Error\n\tOR\nDate Value Error\nDate Format : yyyy-mm-dd"
            )
        else:
            result = c.execute(
                "select meeting_date,meeting_time,project_name,meeting_topic from meeting where meeting_date='"
                + e2.get() +
                "' order by date(meeting_date),time(meeting_time);")
            result = c.fetchall()
            show(s, result)

    if v2.get() == 1 and v1.get(
    ) == 1:  #Condition for Search by Both Name and User
        if valid.checkdate(e2.get()) == False:
            messagebox.showerror(
                "ERROR5",
                "Date Format Error\n\tOR\nDate Value Error\nDate Format : yyyy-mm-dd"
            )
        else:
            result = c.execute(
                "select meeting_date,meeting_time,project_name,meeting_topic from meeting where meeting_date='"
                + e2.get() + "' and project_name='" + e1.get() +
                "' order by date(meeting_date),time(meeting_time);")
            result = c.fetchall()
            show(s, result)

    if v2.get() == 0 and v1.get() == 0:  #IF no fields are selected
        messagebox.showerror("ERROR1", "No Fields Selected")
示例#3
0
 def voucher(name, desig):
     flag = False
     if e1.get() == "" or e3.get() == "" or e4.get(
     ) == "":  #Condition to check Empty Fields
         messagebox.showinfo("ERROR3", "Each Field is Mandatory")
     else:
         if name != e1.get():
             messagebox.showinfo("ERROR", "Username Do Not Match")
         elif desig != tkvar.get():
             messagebox.showinfo("ERROR", "Designation Do Not Match")
         elif valid.checkdate(e3.get()) == False:
             messagebox.showinfo(
                 "ERROR", "Date Format Error\nDate Format :dd-mm-yyyy")
         else:
             flag = False
             p.execute(
                 "select expense_date from applyvoucher where username='******';")
             res = p.fetchall()
             for row in res:
                 if row[0] == e3.get():
                     flag = True
             if flag == True:
                 messagebox.showinfo(
                     "ERROR",
                     "Cannot apply more than one voucher on the same day")
             elif flag == False:
                 result = p.execute('''select * from applyvoucher''')
                 if m.get() == 1:
                     int_voucher = 5000
                 elif m.get() == 2:
                     int_voucher = 10000
                 else:
                     int_voucher = 15000
                     #Add New Entry to Database
                 p.execute(
                     '''insert into applyvoucher (username,designation,expense_date,expense_purpose,voucher,payment,status) values ( ?,?,?,?,?,?,? )''',
                     (e1.get(), tkvar.get(), e3.get(), e4.get(),
                      int_voucher, tkvar1.get(), "Pending"))
                 con.commit()
                 messagebox.showinfo("Success", "Voucher Applied")
                 e1.delete(0, 'end')
                 #e2.delete(0,'end')
                 e3.delete(0, 'end')
                 e4.delete(0, 'end')
示例#4
0
    def store():
        flag = False
        if e1.get() == "" or e2.get() == "" or e3.get() == "" or e4.get(
        ) == "":  #Condition to check Empty Fields
            messagebox.showerror("ERROR3", "Each Field is Mandatory")
        else:
            if valid.checkdate(e2.get()) == False:
                messagebox.showerror(
                    "ERROR5",
                    "Date Format Error\n\tOR\nDate Value Error\nDate Format : yyyy-mm-dd"
                )
                n.wait_window()
            elif valid.checktime(e3.get()) == False:
                messagebox.showerror(
                    "ERROR6",
                    "Time Format Error\n\tOR\nTime Value Error\nTime Format : hh:mm"
                )
                n.wait_window()
            else:
                c = con.cursor()
                c.execute('''select meeting_date,meeting_time from meeting'''
                          )  #Fetch Date and Time from DB
                res = c.fetchall()
                for row in res:  #Check if Similar Date and Time Exists
                    if row[0] == e2.get() and row[1] == e3.get():
                        flag = True
                        messagebox.showerror(
                            "ERROR2",
                            "Meeting at Given \nDate and Time Already Exists")
                        n.wait_window()
                        break

                if flag == False:  #Add New Entry to Database
                    c.execute(
                        '''insert into meeting (project_name, meeting_time, meeting_date, meeting_topic) values ( ?,?,?,? )''',
                        (e1.get(), e3.get(), e2.get(), e4.get()))
                    messagebox.showerror("Success", "Succesfully Added")
                    n.wait_window()
                    con.commit()
                    n.destroy()
                    u.deiconify()