班级信息收集系


 

 

班级信息收集系

 

 

班级信息收集系

 

 

import wx
from python实验2 import classinformation
class MyFrame(wx.Frame):
    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,title="班级信息收集程序",size=(600,400))
        pl = wx.Panel(self)
        self.title = wx.StaticText(pl,label="请输入要收集的班级、姓名、学号",pos=(200,20))
        self.label_id = wx.StaticText(pl,label="学号:",pos=(50,50))
        self.text_id = wx.TextCtrl(pl,pos=(100,50),size=(235,25),style=wx.TE_LEFT)
        self.label_bj = wx.StaticText(pl,label="班级:",pos=(50,90))
        self.text_bj = wx.TextCtrl(pl, pos=(100, 90), size=(235, 25), style=wx.TE_LEFT)
        self.label_xm = wx.StaticText(pl, label="姓名:", pos=(50, 130))
        self.text_xm = wx.TextCtrl(pl, pos=(100, 130), size=(235, 25), style=wx.TE_LEFT)
        self.bt_bc = wx.Button(pl,label="保存",pos=(100,170))
        self.bt_bc.Bind(wx.EVT_BUTTON,self.Baochun)
        self.bt_qx = wx.Button(pl,label="取消",pos=(200,170))
        self.bt_qx.Bind(wx.EVT_BUTTON, self.Cancel)

    def Baochun(self,event):
        id = self.text_id.GetValue()
        bj = self.text_bj.GetValue()
        xm = self.text_xm.GetValue()
        if id =='' or bj == '' or xm == '':
            message = '输入为空!'
        else:
            classinformation.baochuninformation(id,bj,xm)
            message = '保存成功!'
        wx.MessageBox(message)


    def Cancel(self,event):
        self.text_xm.SetValue('')
        self.text_bj.SetValue('')
        self.text_id.SetValue('')
        wx.MessageBox('取消成功!')


if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(parent=None,id=-1)
    frame.Show()
    app.MainLoop()
班级信息收集系 班级信息收集系
import wx
from python实验2 import classinformation
class MyFrame(wx.Frame):
    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,title="班级信息查询程序",size=(600,400))
        pl = wx.Panel(self)
        self.title = wx.StaticText(pl, label="班级信息查询程序", pos=(200, 20))
        self.label_id = wx.StaticText(pl, label="请输入要查询同学的学号:", pos=(100, 70))
        self.text_id = wx.TextCtrl(pl, pos=(100, 100), size=(235, 25), style=wx.TE_LEFT)
        self.bt_bc = wx.Button(pl, label="查询", pos=(100, 140))
        self.bt_bc.Bind(wx.EVT_BUTTON, self.Chaxun)
        self.bt_qx = wx.Button(pl, label="取消", pos=(200, 140))
        self.bt_qx.Bind(wx.EVT_BUTTON, self.Cancel)


    def Chaxun(self,event):

        id = self.text_id.GetValue()
        if id =='':
            message = '输入为空!'
        else:
            (a,b,c) = classinformation.chaxuninformation(id)
            message = """
            该同学姓名为: {:s}
            
            班级为:{:s}
            """.format(c,b)
        wx.MessageBox(message)

        pass

    def Cancel(self, event):

        self.text_id.SetValue('')
        wx.MessageBox('取消成功!')


if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(parent=None,id=-1)
    frame.Show()
    app.MainLoop()
班级信息收集系 班级信息收集系
import sqlite3



def baochuninformation(a,b,c):
        """
        :param a: 学生的学号 (id)
        :param b: 班级 (bj)
        :param c: 姓名 (xm)
        :return:
        """
        conn = sqlite3.connect('mrsoft.db')
        cursor = conn.cursor()
        e = (a,b,c)
        cursor.execute('insert into classinformation (id,bj,xm) values (?,?,?)', e)
        cursor.close()
        conn.commit()
        conn.close()

def chaxuninformation(a):
        '''
        :param a: 学号
        :return: 返回元组
        '''

        b=()
        conn = sqlite3.connect('mrsoft.db')
        cursor = conn.cursor()
        a=int(a)
        cursor.execute('select * from classinformation where id = ?', (a,))
        b= cursor.fetchone()
        cursor.close()
        conn.close()
        return b

        #b是一个元组



if __name__=='__main__':
    conn = sqlite3.connect('mrsoft.db')
    cursor = conn.cursor()
    # create table classinformation (id int(15) primary key, bj varchar (20), xm varchar (4))
    a = ('20', '信计1班', '李建宏')
    #cursor.execute('insert into classinformation (id,bj,xm) values (?,?,?)', a)
    #cursor.execute('delete from classinformation where id = ?', (20,))
    cursor.execute('select * from classinformation where id = ?', (20,))
    b = cursor.fetchone()
    print(b)
    cursor.close()
    conn.commit()
    conn.close()
上一篇:任务


下一篇:浅谈dataGridView使用,以及画面布局使用属性,对datagridview进行增删改查操作,以及委托使用技巧