예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.Request.Cookies["susername"] != null)
            {
                admin_name.InnerHtml = HttpContext.Current.Request.Cookies["susername"].Value.Trim();
            }
            if (mainId != 0)
            {
                aStudent stu = bll.getStudent(mainId);

                sname.Value       = stu.name;
                stime.Value       = stu.time.ToString();
                classid.Value     = stu.classId.ToString();
                studid.Value      = stu.studId.ToString();
                ssex.Value        = stu.sex;
                sbirthdate.Value  = stu.birthDate.ToString();
                idnumber.Value    = stu.idNumber.ToString();
                snation.Value     = stu.nation;
                sbirthplace.Value = stu.birthPlace;
                //smajor.InnerHtml = bll.getMajorName(stu.mlId);
                HiddenField1.Value = bll.getMajorName(stu.mlId);
                saddress.Value     = stu.address;
                sphone.Value       = stu.phone.ToString();
            }
        }
예제 #2
0
        protected void btn_sub_ServerClick(object sender, EventArgs e)
        {
            aStudent stu = new aStudent();

            stu.idNumber   = long.Parse(idnumber.Value);
            stu.name       = sname.Value;
            stu.time       = DateTime.Parse(stime.Value);
            stu.sex        = ssex.Value;
            stu.birthDate  = DateTime.Parse(sbirthdate.Value);
            stu.nation     = snation.Value;
            stu.birthPlace = sbirthplace.Value;
            stu.mlId       = bll.getMajorNum(Request.Form["smajor"]);
            stu.studId     = int.Parse(studid.Value);
            stu.classId    = int.Parse(classid.Value);

            if (saddress.Value != "")
            {
                stu.address = saddress.Value;
            }

            if (sphone.Value != "")
            {
                stu.phone = long.Parse(sphone.Value);
            }

            bll.updateStudent(stu);
        }
예제 #3
0
        protected void btn_sub_ServerClick(object sender, EventArgs e)
        {
            aStudent stu = new aStudent();

            stu.idNumber   = long.Parse(idnumber.Value);
            stu.name       = sname.Value;
            stu.time       = DateTime.Parse(stime.Value);
            stu.sex        = ssex.Value;
            stu.birthDate  = DateTime.Parse(sbirthdate.Value);
            stu.nation     = snation.Value;
            stu.birthPlace = sbirthplace.Value;
            stu.mlId       = bll.getMajorNum(Request.Form["smajor"]);

            if (saddress.Value != "")
            {
                stu.address = saddress.Value;
            }

            if (sphone.Value != "")
            {
                stu.phone = long.Parse(sphone.Value);
            }

            bll.insertStudent(stu);
            this.ClientScript.RegisterStartupScript(this.GetType(), "error", "<script>alert('" + "插入成功" + "!')</script>");
        }
예제 #4
0
 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         int      i     = e.RowIndex;                             //获取选中行的索引
         string   idStr = GridView1.DataKeys[i].Value.ToString(); //DataKeyNames="ID"获取主键的值
         long     id    = Convert.ToInt64(idStr);
         aStudent stu   = new aStudent();
         stu.mainKey = id;
         bll.deleteStudent(stu);
         GridView1.DataSource = bll.getAll();
         GridView1.DataBind();
     }
     catch (Exception exce)
     {
         this.ClientScript.RegisterStartupScript(this.GetType(), "error", "<script>alert('" + exce.Message + "!')</script>");
     }
 }