用类写一个课程信息系统实现增加和查找

class Course():
    def __init__(self,course_number,course_name,tearcher,address):
        self.course_number = course_number
        self.course_name = course_name
        self.tearcher = tearcher
        self.__address = address   #私有变量

    def printinfo(self):
        print('course_number:'+self.course_number)
        print('course_name:'+self.course_name)
        print('teacher:'+self.tearcher)
        print('address:'+self.__address)

information = input(“课程码,课程名称,老师,上课地点用空格隔开”).split(" ")   
course1 = Course(*information)   #解包传参
course1.printinfo()
查询功能代码(包括普通查询和全部查询):protected void Button2_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); DataBS(ds, strsql); GridView1.DataSource = ds.Tables["table"]; GridView1.DataBind(); DropDownList1.SelectedValue = "不限"; DropDownList2.SelectedValue = "不限"; DropDownList3.SelectedValue = "不限"; DropDownList4.SelectedValue = "不限"; DropDownList5.SelectedValue = "不限"; Label8.Text = "查询结果: 共" + ds.Tables[0].Rows.Count + "条记录"; } protected void Button1_Click(object sender, EventArgs e) { string str = ""; string str1 = ""; if (DropDownList1.SelectedItem.Text != "不限") str += " and CourseGrade='" + DropDownList1.SelectedValue + "'"; if (DropDownList2 .SelectedItem .Text !="不限") str +=" and CourseTerm='" + DropDownList2.SelectedValue + "'"; if (DropDownList3.SelectedItem.Text != "不限") str += " and CourseSort='" + DropDownList3.SelectedValue + "'"; if (DropDownList4.SelectedItem.Text != "不限") str += " and SpecialtyDirection='" + DropDownList4.SelectedValue + "'"; if (DropDownList5.SelectedItem.Text != "不限") str += " and CourseTeacher='" + DropDownList5.SelectedValue + "'"; if (str != "") { str1 = str.Substring(5); strsql += " where " + str1; } DataSet ds = new DataSet(); DataBS(ds, strsql); if (ds.Tables[0].Rows.Count != 0) { GridView1.DataSource = ds.Tables["table"]; GridView1.DataBind(); } else { Response.Write("<script language=JavaScript>alert('没有符合条件的记录!');</script>"); GridView1.Visible = true ; } Label8.Text = "查询结果: 共" + ds.Tables[0].Rows.Count + "条记录"; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

super_vab

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值