Beispiel #1
0
        /// <summary>
        /// 逻辑删除
        /// </summary>
        private void isDelSql(int ID)
        {
            string delSql = "UPDATE studentInfo set isDelete = 1 where ID = " + ID + ";";

            if (OperaterBase.CommitBySql(delSql) > 0)
            {
                string DelSql = "SELECT  ID, studentName, studentNum, studentSex, mobile, password,birthday, province, city, district, isDelete from studentInfo where isDelete = 0;";
                getStudentList(DelSql);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 添加一个学生信息
        /// </summary>
        private void AddUser()
        {
            studentModel stu = FillStudentModelData();

            if (stu == null)
            {
                return;
            }
            if (Button2.CommandName == "insert")
            {
                //判断学号或手机号是否唯一
                if (IsMobile(stu.StudentNum, stu.Mobile))
                {
                    //如果学号或手机号码 不是唯一的 进行 insert 语句拼接 并执行
                    string sql = @"INSERT INTO studentInfo (studentName,studentNum,studentSex,mobile,password,birthday,province,city,district,classId) VALUES  (N'" + stu.StudentName + "',N'" + stu.StudentNum + "',N'" + stu.StudentSex + "',N'" + stu.Mobile + "',N'"
                                 + stu.Pwd + "','" + stu.Birthday + "',N'" + stu.Province + "',N'" + stu.City + "',N'" + stu.District + "', N'" + stu.ClassId + "')";
                    if (OperaterBase.CommitBySql(sql) > 0)
                    {
                        Label11.Text = "插入成功";
                        // 跳转
                        Response.Redirect("/studentInfo.aspx");
                    }
                }
                else
                {
                    Label11.Text = "插入失败 。。。。";
                }
            }
            else if (Button2.CommandName == "updata")
            {
                // 更新数据
                string upData = "update studentInfo set studentName = N'" + stu.StudentName + "', studentNum = N'" + stu.StudentNum + "' ,studentSex = N'" + stu.StudentSex + "', mobile = N'" + stu.Mobile + "' , password = N'" + stu.Pwd + "', birthday = N'" + stu.Birthday + "',pro" +
                                "vince = N' " + stu.Province + "', city = N'" + stu.City + "',district = N'" + stu.District + " ', classId = 'N" + stu.ClassId + "'";
                if (OperaterBase.CommitBySql(upData) > 0)
                {
                    Label11.Text = "修改成功";
                }
            }
        }