public DataSet GetTcBaseList() { DataSet tcBaseInfoList; using (TeacherBaseDataAccess tcBaseDA = new TeacherBaseDataAccess()) { tcBaseInfoList = tcBaseDA.GetTcBaseList(); } return(tcBaseInfoList); }
//查询连续的工号 //changed version for ranging the teacher numbers from 01-70 //9270 is the max number allowed public string getSerialTcNumber() { //获取所有工号 DataSet getSerialNumber = teacherBaseDA.GetTcBaseList(); //初始化第一个工号为00号 int firNumber = 9100; //当前教师数不为零 if (getSerialNumber.Tables[0].Rows.Count != 0) { //当前教师数量为1名以上情况 if (getSerialNumber.Tables[0].Rows.Count > 1) { //循环查询找出两个工号不相邻的情况 for (int i = 0; i < getSerialNumber.Tables[0].Rows.Count; i++) { int secNumber = Convert.ToInt32(getSerialNumber.Tables[0].Rows[i][1]); if (secNumber - firNumber > 1) { if (++firNumber > 9170 && !isNextRanger) { firNumber = 9201; isNextRanger = true; if (secNumber - firNumber > 0) { tchBase.TNumber = Convert.ToString(firNumber); break; } else { if (i == getSerialNumber.Tables[0].Rows.Count - 1) { if (secNumber < 9201) { tchBase.TNumber = "9201"; } else { tchBase.TNumber = Convert.ToString(secNumber + 1); break; } } } } else { tchBase.TNumber = Convert.ToString(firNumber); break; } } if (i == getSerialNumber.Tables[0].Rows.Count - 1) { if (secNumber == 9170) { tchBase.TNumber = "9201"; } else { tchBase.TNumber = Convert.ToString(secNumber + 1); } } firNumber = Convert.ToInt32(getSerialNumber.Tables[0].Rows[i][1].ToString()); } } //只有一名教师的情况 else { //如果01号教师没有被使用,则赋予该教师为01号 if (Convert.ToInt32(getSerialNumber.Tables[0].Rows[0][1]) - firNumber > 1) { tchBase.TNumber = Convert.ToString(firNumber + 1); } else { tchBase.TNumber = Convert.ToString(Convert.ToInt32(getSerialNumber.Tables[0].Rows[0][1].ToString()) + 1); } } } else { tchBase.TNumber = (firNumber + 1).ToString(); } if (Convert.ToInt32(tchBase.TNumber) > 9270) { tchBase.TNumber = "-1"; } return(tchBase.TNumber); }
//查询连续的工号 //9570 is the max number allowed public string getSerialTcNumber() { //获取所有工号 DataSet getSerialNumber = teacherBaseDA.GetTcBaseList(); //初始化第一个工号为00号 int firNumber = 9100; //当前教师数不为零 if (getSerialNumber.Tables[0].Rows.Count != 0) { //当前教师数量为1名以上情况 if (getSerialNumber.Tables[0].Rows.Count > 1) { //循环查询找出两个工号不相邻的情况 for (int i = 0; i < getSerialNumber.Tables[0].Rows.Count; i++) { int teacherNumber = Convert.ToInt32(getSerialNumber.Tables[0].Rows[i][1]); //已经是最后一个,当前值+1,10位数和个位数相加最多只能70 if (i == getSerialNumber.Tables[0].Rows.Count - 1) { if ((++teacherNumber - 70) % 100 == 1) { teacherNumber = teacherNumber + 30; //跳到下一轮 } tchBase.TNumber = teacherNumber.ToString(); break; } else { int next = Convert.ToInt32(getSerialNumber.Tables[0].Rows[i + 1][1]); if (next - teacherNumber > 1) { if ((next - 1) % 100 != 0) { if ((++teacherNumber - 70) % 100 == 1) { teacherNumber = teacherNumber + 30; } tchBase.TNumber = teacherNumber.ToString(); break; } else { if ((++teacherNumber - 70) % 100 != 1) { teacherNumber = teacherNumber++; tchBase.TNumber = teacherNumber.ToString(); break; } } } } } } //只有一名教师的情况 else { //如果01号教师没有被使用,则赋予该教师为01号 if (Convert.ToInt32(getSerialNumber.Tables[0].Rows[0][1]) - firNumber > 1) { tchBase.TNumber = Convert.ToString(firNumber + 1); } else { int teacherNumber = Convert.ToInt32(getSerialNumber.Tables[0].Rows[0][1]); if ((++teacherNumber - 70) % 100 == 1) { teacherNumber = teacherNumber + 30; } tchBase.TNumber = teacherNumber.ToString(); } } } else { tchBase.TNumber = (firNumber + 1).ToString(); } if (Convert.ToInt32(tchBase.TNumber) > 9999) { tchBase.TNumber = "-1"; } return(tchBase.TNumber); }