예제 #1
0
def carinisedit(cr):
    with UseDatabase(dbconfig) as cursor:
        # _SQL="""select * from  tb_biodata_siswa where nis like %s"""
        # cursor.execute(_SQL,("%" + cr + "%",))

        _SQL = """select * from  tb_biodata_siswa where nis=%s"""
        cursor.execute(_SQL, (cr, ))
        contents = cursor.fetchall()
        print(contents)
        tb_biodict = []
        for c in contents:
            tgl = c[9]
            # date,datetime.strftime('%Y-%m-%d')

            bio = {
                'nis': c[0],
                'nama': c[1],
                'jk': c[2],
                'tlahir': c[3],
                'alamat': c[4],
                'nohpsis': c[5],
                'noportu': c[6],
                'kelas': c[7],
                'tmasuk': c[8],
                'tgllahir': tgl.strftime('%d-%m-%Y'),
                'nisn': c[10],
                'stat': c[11],
                'img': c[12]
            }
            tb_biodict.append(bio)

    return jsonify(tb_biodict)
예제 #2
0
def editbio(img):

    with UseDatabase(dbconfig) as cursor:

        _SQL="UPDATE "+tbl.table+" SET "+ tbl.nama+"=%s,"+ tbl.jk+"=%s," \
             + tbl.tempat+"=%s,"+ tbl.ala+"=%s,"+ tbl.nohpsiswa+"=%s,"\
             + tbl.nohportu+"=%s,"+ tbl.idkelas+"=%s,"+ tbl.thnmasuk+"=%s,"\
             + tbl.tgllahir+"=%s,"+ tbl.nisn+"=%s,"\
             + tbl.stat+"=%s,"+ tbl.gbr+"=%s" + " WHERE  "+tbl.nis+"=%s"

        cursor.execute(_SQL, (
            request.form['nama'],
            request.form['jenis_kelamin'],
            request.form['tempat'],
            request.form['alamat'],
            request.form['nohpsiswa'],
            request.form['nohportu'],
            request.form['kelas'],
            request.form['tahun_masuk'],
            request.form['tgl_lahir'],
            request.form['nisn'],
            request.form['status'],
            request.form['nis'],
            img,
        ))
    return redirect('/inputsiswa')
예제 #3
0
def savedatasiswa(fname):
    with UseDatabase(dbconfig) as cursor:
        # try:
        f = (tbl.nis, tbl.nama, tbl.jk, tbl.tempat, tbl.ala, tbl.nohpsiswa,
             tbl.nohportu, tbl.idkelas, tbl.thnmasuk, tbl.tgllahir, tbl.nisn,
             tbl.stat, tbl.gbr)
        # isi=("909","adem","L")
        # tglh = datetime.strptime(request.form['tgl_lahir'], '%Y-%m-%d')
        tglh = datetime.strptime(request.form['tgl_lahir'], '%d/%m/%Y')
        isi = (
            str(request.form['nis']),
            str(request.form['nama']),
            str(request.form['jenis_kelamin']),
            str(request.form['tempat']),
            str(request.form['alamat']),
            str(request.form['nohpsiswa']),
            str(request.form['nohportu']),
            str(request.form['kelas']),
            str(request.form['tahun_masuk']),
            # str('1990/01/02'),
            str(tglh),
            str(request.form['nisn']),
            str(request.form['status']),
            str(fname))
        _SQL = tbl.insertsiswa(tbl.table) + str(f).replace(
            "'", "") + "VALUES" + str(isi)
        cursor.execute(_SQL)
예제 #4
0
def UpdateTap(status):
    with UseDatabase(dbconfig) as cursor:
        _SQL = """SELECT COUNT(*) AS tot FRom tb_cknf"""
        cursor.execute(_SQL)
        contents = cursor.fetchone()

        if contents[0] == 1:
            _SQL = """UPDATE tb_cknf SET status=%s"""
            cursor.execute(_SQL, (status,))
예제 #5
0
def jamtelat():
    with UseDatabase(dbconfig) as cursor:
        tgl=date.today()
        # '%m/%d/%Y'
        b=tgl.strftime('%Y-%m-%d')+" 08:00:00"
        t=datetime.today()
        _SQL="""SELECT TIMEDIFF(%s, %s)AS telat"""
        cursor.execute(_SQL,(t,b,))
        contents = cursor.fetchone()
        return contents[0]
예제 #6
0
def carialltbnis():
    with UseDatabase(dbconfig) as cursor:
        _SQL = """select * from  tb_biodata_siswa"""
        cursor.execute(_SQL)
        contents = cursor.fetchall()
        tb_biodict = []
        for c in contents:
            bio = {'nis': c[0], 'nama': c[1]}
            tb_biodict.append(bio)

    return jsonify(tb_biodict)
예제 #7
0
def carinis(cr):
    with UseDatabase(dbconfig) as cursor:
        # _SQL="""select * from  tb_biodata_siswa where nis like %s"""
        # cursor.execute(_SQL,("%" + cr + "%",))

        _SQL = """select * from  tb_biodata_siswa where nis=%s"""
        cursor.execute(_SQL, (cr, ))
        contents = cursor.fetchone()
        print(contents)
        if contents != None:
            return jsonify({'result': 'Mohon maaf Nis tersebut sudah Ada!'})
        else:
            return jsonify({'result': 'ok'})
예제 #8
0
def delsiswa(rw):

    with UseDatabase(dbconfig) as cursor:
        _SQL = """delete from  tb_biodata_siswa where nis=%s"""
        cursor.execute(_SQL, (rw, ))

    with UseDatabase(dbconfig) as cursor:
        # _SQL = """SELECT * FRom tb_biodata_siswa where nis=%s and Date(tgl_absen)=%s"""
        _SQL = """SELECT * FRom tb_biodata_siswa"""
        cursor.execute(_SQL)
        contents = cursor.fetchall()
        _SQL = """SELECT * FRom tb_kelas"""
        cursor.execute(_SQL)
        contentskelas = cursor.fetchall()
        _SQL = """SELECT * FRom tb_status"""
        cursor.execute(_SQL)
        contentsstatus = cursor.fetchall()
    return render_template('inputdatasiswa.html',
                           the_title="Input Data Siswa!",
                           rows=contents,
                           rowskelas=contentskelas,
                           rowsstatus=contentsstatus,
                           tb=2)
예제 #9
0
def caritbnis(cr):
    with UseDatabase(dbconfig) as cursor:
        _SQL = """select * from  tb_biodata_siswa where nis like %s or nama like %s"""
        cursor.execute(_SQL, (
            "%" + cr + "%",
            "%" + cr + "%",
        ))
        contents = cursor.fetchall()
        tb_biodict = []
        for c in contents:
            bio = {'nis': c[0], 'nama': c[1]}
            tb_biodict.append(bio)

    return jsonify(tb_biodict)
예제 #10
0
def InsertPresensi(nis):
    with UseDatabase(dbconfig) as cursor:
        tgl = date.today()

        id = tgl.strftime('%Y-%m-%d') + "-" + nis

        _SQL = """SELECT * FRom tb_absensi where nis=%s and Date(tgl_absen)=%s"""
        cursor.execute(_SQL, (nis,tgl,))
        contents = cursor.fetchone()
        print(contents)

        if contents == None:
            _SQL = """INSERT INTO tb_absensi(id_absensi,nis,terlambat,hadir) VALUES (%s,%s,%s,%s)"""
            cursor.execute(_SQL, (id,nis,jamtelat(),1,))
예제 #11
0
def InsertTap(nis):
    with UseDatabase(dbconfig) as cursor:

        # _SQL="""SELECT * FRom tb_cknf where nis=%s"""
        _SQL = """SELECT COUNT(*) AS tot FRom tb_cknf"""
        cursor.execute(_SQL)
        contents = cursor.fetchone()
        print (contents[0])
        if  contents[0]==0:
            _SQL = """INSERT INTO tb_cknf(nis) VALUES (%s)"""
            cursor.execute(_SQL, (nis,))

        elif contents[0]==1:
            print ("tess")
            _SQL = """DELETE FRom tb_cknf"""
            cursor.execute(_SQL)
            _SQL = """INSERT INTO tb_cknf(nis) VALUES (%s)"""
            cursor.execute(_SQL, (nis,))
예제 #12
0
def inputdatasiswa():

    with UseDatabase(dbconfig) as cursor:
        # _SQL = """SELECT * FRom tb_biodata_siswa where nis=%s and Date(tgl_absen)=%s"""
        _SQL = """SELECT * FRom tb_biodata_siswa"""
        cursor.execute(_SQL)
        contents = cursor.fetchall()
        # print("biodata",contents)
        _SQL = """SELECT * FRom tb_kelas"""
        cursor.execute(_SQL)
        contentskelas = cursor.fetchall()
        _SQL = """SELECT * FRom tb_status"""
        cursor.execute(_SQL)
        contentsstatus = cursor.fetchall()

    return render_template('inputdatasiswa.html',
                           the_title="Input Data Siswa!",
                           rows=contents,
                           rowskelas=contentskelas,
                           rowsstatus=contentsstatus,
                           jalur=request.url_rule,
                           tb=1)
예제 #13
0
def cek_login():
    user_n = request.form['user_n']
    lgn = request.form['lgn']

    with UseDatabase(dbconfig) as cursor:
        _SQL = """select *, CAST(AES_DECRYPT(pass, '456') AS CHAR(255))
        xcd from tb_usx_l where
        username=%s"""
        cursor.execute(_SQL, (user_n, ))
        contents = cursor.fetchone()
        print(contents)
        if contents != None:
            if contents[3] == lgn:
                session['cekcok_login'] = True
                return redirect('/dashboard_sch')
            else:
                return render_template('login.html',
                                       the_title="login dulu!",
                                       salah="Password salah!")
        else:
            return render_template('login.html',
                                   the_title="login dulu!",
                                   salah="Password salah!")