/// <summary> /// ����Ա���༶ɾ��ѧ��(����) /// </summary> /// <param name="iClassIdArray">��ɾ����ѧ���İ༶��Id����</param> public void DeleteStudentsByClass(int[] iStudentIdArray) { SqlParameter param = new SqlParameter("@stuId", SqlDbType.Int); SqlConnection conn = new SqlConnection(SQLHelper.ConnectionStringSTEduSys); conn.Open(); SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted); try { SearchDA sd = new SearchDA(); foreach (int iClassId in iStudentIdArray) { DataTable dt = sd.GetStudentsByClass(iClassId); for (int i = 0; i < dt.Rows.Count; i++) { param.Value = dt.Rows[i][0]; SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringSTEduSys, CommandType.StoredProcedure, "SP_DelStuByID", param); } } trans.Commit(); } catch (Exception e) { trans.Rollback(); throw new ApplicationException(e.Message); } finally { conn.Close(); } }
/// <summary> /// ����Ա���������༶��ѧ��������(����) /// </summary> /// <param name="iClassIdArray">����������İ༶��Id����</param> public void ResetStudentsPwdByClass(int[] iClassIdArray) { MD5CryptoServiceProvider HashMD5 = new MD5CryptoServiceProvider(); string pwd = ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes("888888"))); //SqlParameter param = new SqlParameter("@stuId", SqlDbType.Int); SqlParameter[] parms = { new SqlParameter("@stuID",SqlDbType.Int), }; SqlConnection conn = new SqlConnection(SQLHelper.ConnectionStringSTEduSys); conn.Open(); SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted); try { SearchDA sd = new SearchDA(); foreach (int iClassId in iClassIdArray) { DataTable dt = sd.GetStudentsByClass(iClassId); for (int i = 0; i < dt.Rows.Count; i++) { //param.Value = dt.Rows[i][0]; parms[0].Value=dt.Rows[i][0]; //parms[1].Value = pwd; //SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringSTEduSys, // CommandType.StoredProcedure, "SP_ResetStuPwdByStuID", param); SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringSTEduSys, CommandType.StoredProcedure, "SP_ResetStuPwdByStuID", parms); } } trans.Commit(); } catch (Exception e) { trans.Rollback(); throw new ApplicationException(e.Message); } finally { conn.Close(); } }
/// <summary> /// ����Ա���������༶��ѧ����ʹ������(����) /// </summary> /// <param name="iClassIdArray">������ʹ�����İ༶��Id����</param> /// <param name="dtStartTime">��ʼ����</param> /// <param name="dtEndTime">��ֹ����</param> public void ChangeStuTimeLimitByClass(int[] iClassIdArray,DateTime dtStartTime,DateTime dtEndTime) { SqlParameter[] parms = { new SqlParameter("@stuId",SqlDbType.Int), new SqlParameter("@startDate",dtStartTime), new SqlParameter("@endDate",dtEndTime) }; SqlConnection conn = new SqlConnection(SQLHelper.ConnectionStringSTEduSys); conn.Open(); SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted); try { SearchDA sd = new SearchDA(); foreach (int iClassId in iClassIdArray) { DataTable dt = sd.GetStudentsByClass(iClassId); for (int i = 0; i < dt.Rows.Count; i++) { parms[0].Value = dt.Rows[i][0]; SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringSTEduSys, CommandType.StoredProcedure, "SP_ChangeTimeLimitByStuID", parms); } } trans.Commit(); } catch (Exception e) { trans.Rollback(); throw new ApplicationException(e.Message); } finally { conn.Close(); } }