private bool UpdateDateWithEntity(StuInfo stu)
        {
            SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@stuNo", stu.sno),
                new SqlParameter("@stuName", stu.name),
                new SqlParameter("@stuSex", stu.sex),
                new SqlParameter("@stuNation", stu.nation),
                new SqlParameter("@stuBirthDate", stu.birthDate),
                new SqlParameter("@stuBirthPlace", stu.birthPlace),
                new SqlParameter("@stuAdmissionTime", stu.admissionTime)
            };
            int rtn = SqlHelper.ExecuteNonQueryUsingProcedure("updateStuBySno", paras);

            return(rtn > 0 ? true : false);
        }
        private bool InsertDataWithEntity(StuInfo stu)
        {
            SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@stuNo", stu.sno),
                new SqlParameter("@stuName", stu.name),
                new SqlParameter("@stuSex", stu.sex),
                new SqlParameter("@stuNation", stu.nation),
                new SqlParameter("@stuBirthDate", stu.birthDate),
                new SqlParameter("@stuBirthPlace", stu.birthPlace),
                new SqlParameter("@stuAdmissionTime", stu.admissionTime),
                new SqlParameter("@stuDeptClassNo", stu.sDeptClassno),
                new SqlParameter("@stuRecordNo", stu.recordno)
            };
            int rtn = SqlHelper.ExecuteNonQueryUsingProcedure("insertStu", paras);

            return(rtn > 0 ? true : false);
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            StuInfo stu = new StuInfo();

            stu.sno          = TextBox1.Text.Trim();
            stu.name         = TextBox2.Text.Trim();
            stu.sex          = TextBox3.Text.Trim();
            stu.nation       = TextBox4.Text.Trim();
            stu.sDeptClassno = (int)DateTime.Now.Ticks;
            stu.recordno     = (int)DateTime.Now.Ticks; //这里使用了现在时间,保证了数字的不重复性(用来做其他表的主键)
            if ("".Equals(TextBox5.Text.Trim()))
            {
                stu.birthDate = DateTime.Parse("1997/1/1");
            }
            else
            {
                stu.birthDate = DateTime.Parse(TextBox5.Text.Trim());
            }
            stu.birthPlace = TextBox6.Text.Trim();
            if ("".Equals(TextBox7.Text.Trim()))
            {
                stu.admissionTime = DateTime.Parse("1997/1/1");
            }
            else
            {
                stu.admissionTime = DateTime.Parse(TextBox7.Text.Trim());
            }
            if (!ExistByNo(stu.name))
            {
                if (InsertDataWithEntity(stu))
                {
                    Response.Write("<script>alert('录入成功!');</script>");
                    DisplayData();
                }
                else
                {
                    Response.Write("<script>alert('录入失败!');</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('已存在!');</script>");
            }
        }