//以下操作为原子操作,涉及两个步骤
//Step1.将用户名、姓名、性别、启用状态、初始密码111111、学院代码写入S_user表
//Step2.更新table_xsxxb中XS_BZ1的状态为"已创建"
//Step3.分配角色
StringBuilder strStep1 = new StringBuilder();
strStep1.Append("insert into S_Users(");
strStep1.Append("Name,ChineseName,Password,Enabled,Gender,DeptID)");
strStep1.Append(" values ('" + xh + "','" + name + "','96e79218965eb72c92a549dd5a330112','1','" + xb + "','" + DeptID + "')");
StringBuilder strStep2 = new StringBuilder();
strStep2.Append("update Table_xsxxb set ");
strStep2.Append("XS_BZ1='已创建' ");
strStep2.Append(" where XS_XH='" + xh + "' ");
//Step3.分配角色
StringBuilder strStep3 = new StringBuilder();
strStep3.Append("insert into S_RoleUsers(RoleID, UserID) SELECT top 1 ID as roleId , (SELECT TOP 1 ID FROM S_Users where Name='" + xh + "') as userId FROM S_Roles where Name='学生'");
SQLStringList.Add(strStep1.ToString());//Step1
SQLStringList.Add(strStep2.ToString());//Step2
SQLStringList.Add(strStep3.ToString());//Step3
//调用事务处理,同步执行多条SQL语句
DbHelperSQL.ExecuteSqlTran(SQLStringList);