/// <summary> /// 从学生表读取全部用户数据Snum Syear,Sclass /// 生成Ftp目录(目录顺序 学年->班级->学号) /// 如果某个学生转班,那会就重新生成该学生目录 /// </summary> /// <returns></returns> public static string CreateFtpDir() { int existdir = 0; int createdir = 0; string msg = ""; string mysql = "SELECT Snum,Syear,Sclass FROM Students";//读取用户数据 LearnSite.BLL.Students st = new LearnSite.BLL.Students(); DataSet ds = st.GetSqlList(mysql); int countis = ds.Tables[0].Rows.Count; string savepath = "~/FtpSpace/"; MakeNewDir(savepath); if (countis > 0) { for (int i = 0; i < countis; i++) { string Snum = ds.Tables[0].Rows[i]["Snum"].ToString(); string Syear = ds.Tables[0].Rows[i]["Syear"].ToString(); string Sclass = ds.Tables[0].Rows[i]["Sclass"].ToString(); if (Syear != "") { string Syearpath = savepath + Syear; MakeNewDir(Syearpath); if (Sclass != "") { string Sclasspath = Checkfatherdir(Syearpath) + Sclass; MakeNewDir(Sclasspath); if (Snum != "") { string Snumpath = Checkfatherdir(Sclasspath) + Snum; if (MakeDir(Snumpath)) { existdir += 1; } else { createdir += 1; } } } } } msg = "用户数为" + countis.ToString() + "位 新建目录" + createdir.ToString() + "个 已经存在" + existdir + "个"; } else { msg = "没有导入用户数据!"; } return(msg); }
/// <summary> /// 从学生表读取全部用户数据Snum Syear,Sclass /// 生成Ftp目录(目录顺序 学年->班级->学号) /// 如果某个学生转班,那会就重新生成该学生目录 /// </summary> /// <returns></returns> public static string CreateFtpDir() { int existdir = 0; int createdir = 0; string msg = ""; string mysql = "SELECT Snum,Syear,Sclass FROM Students";//读取用户数据 LearnSite.BLL.Students st = new LearnSite.BLL.Students(); DataSet ds = st.GetSqlList(mysql); int countis = ds.Tables[0].Rows.Count; string savepath = "~/FtpSpace/"; MakeNewDir(savepath); if (countis > 0) { for (int i = 0; i < countis; i++) { string Snum = ds.Tables[0].Rows[i]["Snum"].ToString(); string Syear= ds.Tables[0].Rows[i]["Syear"].ToString(); string Sclass = ds.Tables[0].Rows[i]["Sclass"].ToString(); if (Syear != "") { string Syearpath = savepath + Syear; MakeNewDir(Syearpath); if (Sclass != "") { string Sclasspath = Checkfatherdir(Syearpath) + Sclass; MakeNewDir(Sclasspath); if (Snum != "") { string Snumpath = Checkfatherdir(Sclasspath) + Snum; if(MakeDir(Snumpath)) { existdir+=1; } else { createdir += 1; } } } } } msg = "用户数为" + countis.ToString() + "位 新建目录" + createdir.ToString() + "个 已经存在"+existdir+"个"; } else { msg = "没有导入用户数据!"; } return msg; }
/// <summary> /// 将DataSet导入到临时表StudentsExcel中 /// </summary> /// <param name="upexcelpath"></param> public static string KaoxutoStudents(DataSet ds) { string msg = ""; if (ds != null) { int count = ds.Tables[0].Rows.Count; if (count > 0) { int columnscount = ds.Tables[0].Columns.Count; int isright = 0; string[] strColumn = { "报名序号", "姓名" }; for (int k = 0; k < columnscount; k++) { string strname = ds.Tables[0].Columns[k].ColumnName; foreach (string str in strColumn) { if (strname == str) { isright++; } } } if (isright == strColumn.Length) { LearnSite.BLL.Students stubll = new LearnSite.BLL.Students(); for (int i = 0; i < count; i++) { string kaoxu = ds.Tables[0].Rows[i]["报名序号"].ToString().Trim(); string sname = ds.Tables[0].Rows[i]["姓名"].ToString().Replace(" ", "").Trim(); stubll.UpdateKaoxu(kaoxu, sname); } } else { msg = "Excel数据格式不正确"; } } else { msg = "无数据!"; } } else { msg = "没有选择Excel上传或不是标准的Excel格式,<br/>请用Excel打开再保存试试!"; } return(msg); }