コード例 #1
0
        protected void queryAvgBt_Click(object sender, EventArgs e)
        {
            foreach (ListItem li in RadioButtonList1.Items)
            {
                if (li.Selected)
                {
                    foreach (EntityCour c in list)
                    {
                        if (c.getCname() == li.Value.ToString())
                        {
                            string avgSql = "select sid, cno, avg(grade) from sc_v" + c.getCno();
                            //Response.Write(avgSql);
                            DBconnetor        conn    = new DBconnetor(avgSql);
                            List <EntityBase> avgList = conn.getList(new EntitySC());
                            EntitySC          sc      = (EntitySC)avgList.ElementAt(0);
                            this.AvgLable.Text = sc.getGrade().ToString();

                            string maxSql = "select sid, cno, max(grade) from sc_v" + c.getCno();
                            //Response.Write(maxSql);
                            DBconnetor        conn1   = new DBconnetor(maxSql);
                            List <EntityBase> maxList = conn1.getList(new EntitySC());
                            sc = (EntitySC)maxList.ElementAt(0);
                            this.MaxLable.Text = sc.getGrade().ToString();

                            string minSql = "select sid, cno, min(grade) from sc_v" + c.getCno();
                            //Response.Write(minSql);
                            DBconnetor        conn2   = new DBconnetor(minSql);
                            List <EntityBase> minList = conn2.getList(new EntitySC());
                            sc = (EntitySC)minList.ElementAt(0);
                            this.MinLable.Text = sc.getGrade().ToString();
                        }
                    }
                }
            }
        }
コード例 #2
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            Master.FindControl("AdminBar").Visible = true;
            Master.FindControl("NavBar").Visible   = false;
            string     sql  = "select distinct * from c";
            DBconnetor conn = new DBconnetor(sql);

            list = conn.getList(new EntityCour());
            if (!IsPostBack)
            {
                foreach (EntityCour c in list)
                {
                    this.RadioButtonList1.Items.Add(c.getCname());
                }
            }
        }
コード例 #3
0
        protected void submitBt_Click(object sender, EventArgs e)
        {
            string            cno;
            string            sql     = "select max(cast(cno as signed)), cname, ccredit from c";
            DBconnetor        co      = new DBconnetor(sql);
            List <EntityBase> cnoList = co.getList(new EntityCour());
            EntityCour        c       = (EntityCour)cnoList.ElementAt(0);
            int maxCno = int.Parse(c.getCno());

            maxCno++;
            cno = maxCno.ToString();
            string cname   = this.CnameTB.Text;
            float  ccredit = float.Parse(this.CcreditTB.Text);
            string sqlsen  = "insert into c value (\"" + cno + "\", \"" + cname + "\", " + ccredit + ")";
            //Response.Write(sqlsen);
            DBconnetor conn = new DBconnetor(sqlsen);

            conn.updata();
            Response.Redirect("../Admin/AddCour.aspx");
        }
コード例 #4
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            Master.FindControl("NavBar").Visible   = true;
            Master.FindControl("AdminBar").Visible = false;

            string     sql  = "select c.* from c,sc where sc.cno = c.cno and sid = \"" + Session["ID"] + "\"";
            DBconnetor conn = new DBconnetor(sql);

            CList = conn.getList(new EntityCour());
            if (CList.Count() == 0)
            {
                Response.Write(sql);
                Response.Write("<script>alert('选课记录为空!')</script>");
            }
            else
            {
                if (!IsPostBack)
                {
                    foreach (EntityCour c in CList)
                    {
                        string s = "select * from sc where cno = \"" + c.getCno() + "\" and sid = \"" + Session["ID"] + "\"";
                        //Response.Write(s);
                        DBconnetor cc = new DBconnetor(s);
                        SClist = cc.getList(new EntitySC());
                        if (SClist.Count == 0 || SClist == null)
                        {
                            this.BulletedList1.Items.Add(c.getCname() + "\t\t\t\t成绩:\t\t\t\t" + "N/A");
                        }
                        else
                        {
                            EntitySC sc = (EntitySC)SClist.ElementAt(0);
                            this.BulletedList1.Items.Add(c.getCname() + "\t\t\t\t成绩:\t\t\t\t" + sc.getGrade().ToString());
                        }
                    }
                }
            }
        }
コード例 #5
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            Master.FindControl("NavBar").Visible   = true;
            Master.FindControl("AdminBar").Visible = false;
            string     sqlSentence = "select c.* from sc, c where sc.cno = c.cno and sc.sid = \"" + Session["ID"] + "\"";
            DBconnetor conn        = new DBconnetor(sqlSentence);

            list = conn.getList(new EntityCour());


            string     leftListSql = "select distinct * from c where cno not in (select c.cno from c,sc where c.cno = sc.cno and sid = \"" + Session["ID"] + "\")";
            DBconnetor conn2       = new DBconnetor(leftListSql);

            leftList = conn2.getList(new EntityCour());

            if (list == null || leftList == null)
            {
                Response.Write("<script>alert('信息查询失败!')</script>");
                return;
            }
            else
            {
                if (!IsPostBack)
                {
                    foreach (EntityCour c in list)
                    {
                        this.CheckBoxList2.Items.Add(c.getCname());
                    }

                    foreach (EntityCour c in leftList)
                    {
                        this.CheckBoxList1.Items.Add(c.getCname());
                    }
                }
            }
        }
コード例 #6
0
ファイル: Login.aspx.cs プロジェクト: LancerBear/DBDemo
        protected void submit_Click(object sender, EventArgs e)
        {
            if (this.txtUserName.Text == "Admin" && this.txtPassWord.Text == "Admin")
            {
                Session["ID"] = "Admin";
                Response.Redirect("../Admin/AdminDefault.aspx");
            }
            byte[] result = Encoding.Default.GetBytes(this.txtPassWord.Text);
            MD5    md5    = new MD5CryptoServiceProvider();

            byte[] output = md5.ComputeHash(result);
            string pwd    = BitConverter.ToString(output).Replace("-", "");

            pwd = pwd.ToLower();
            string            sqlSentence = "select * from pwd where sid = \"" + this.txtUserName.Text + "\"";
            DBconnetor        conenctor   = new DBconnetor(sqlSentence);
            List <EntityBase> list        = conenctor.getList(new EntityPwd());

            if (list.Count() == 0)
            {
                Response.Write("<script>alert('学号或密码错误!')</scri  pt>");
            }
            else
            {
                EntityPwd entity = (EntityPwd)list.ElementAt(0);
                if (entity.getPwd() == pwd)
                {
                    Session["ID"] = this.txtUserName.Text;
                    Response.Redirect("./SelCourse.aspx");
                }
                else
                {
                    Response.Write("<script>alert('学号或密码错误!')</script>");
                }
            }
        }
コード例 #7
0
        protected void submitIDBt_Click(object sender, EventArgs e)
        {
            string     sid  = this.stuIDTB.Text;
            string     sql  = "select c.* from c,sc where sc.cno = c.cno and sid = \"" + sid + "\"";
            DBconnetor conn = new DBconnetor(sql);

            list = conn.getList(new EntityCour());
            if (list == null)
            {
                Response.Write("<script>alert('数据查询失败!')</script>");
            }
            else if (list.Count() == 0)
            {
                Response.Write("<script>alert('该生没有选课!')</script>");
            }
            //if (!IsPostBack)
            {
                this.RadioButtonList1.Items.Clear();
                foreach (EntityCour c in list)
                {
                    this.RadioButtonList1.Items.Add(c.getCname());
                }
            }
        }
コード例 #8
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            Master.FindControl("NavBar").Visible   = true;
            Master.FindControl("AdminBar").Visible = false;
            string            sqlSentence = "select * from s where sid = \"" + Session["ID"] + "\"";
            DBconnetor        conn        = new DBconnetor(sqlSentence);
            List <EntityBase> list        = conn.getList(new EntityStu());

            if (list == null || list.Count() == 0)
            {
                Response.Write("<script>alert('信息查询错误!')</script>");
                return;
            }
            else
            {
                EntityStu entity = (EntityStu)list.ElementAt(0);
                this.sidLable.Text    = entity.getSid();
                this.snameLable.Text  = entity.getSname();
                this.ssexLable.Text   = entity.getSsex();
                this.sbirthLable.Text = entity.getSbirth();
                this.sdeptLable.Text  = entity.getSdept();
            }
        }