/// <summary> /// 将导入学案生成新导航 /// </summary> public void importmenu(int Cid) { // 类型:活动1,调查2,讨论3,表单4,编程5,阅读6 string sql = "select * from Mission where Mdelete=0 and Mcid=" + Cid; DataTable cdt = DbHelperSQL.Query(sql).Tables[0]; int ccount = cdt.Rows.Count; Model.ListMenu lmode = new Model.ListMenu(); BLL.ListMenu lbll = new BLL.ListMenu(); if (ccount > 0) { for (int i = 0; i < ccount; i++) { int mid = Int32.Parse(cdt.Rows[i]["Mid"].ToString()); string mtitle = cdt.Rows[i]["Mtitle"].ToString(); int mcid = Int32.Parse(cdt.Rows[i]["Mcid"].ToString()); int msort = Int32.Parse(cdt.Rows[i]["Msort"].ToString()); bool mpublish = bool.Parse(cdt.Rows[i]["Mpublish"].ToString()); int mcategory = Int32.Parse(cdt.Rows[i]["Mcategory"].ToString()); lmode.Lcid = mcid; lmode.Lsort = msort; lmode.Ltype = 1; if (mcategory == 1) { lmode.Ltype = 6; } if (mcategory == 2) { lmode.Ltype = 5; } lmode.Lxid = mid; lmode.Lshow = mpublish; lmode.Ltitle = mtitle; lbll.Add(lmode);//将所有活动都添加到导航中 } } string sqltwo = "select * from Survey where Vcid=" + Cid; DataTable sdt = DbHelperSQL.Query(sqltwo).Tables[0]; int scount = sdt.Rows.Count; if (scount > 0) { for (int i = 0; i < scount; i++) { int vid = Int32.Parse(sdt.Rows[i]["Vid"].ToString()); string vtitle = sdt.Rows[i]["Vtitle"].ToString(); int vcid = Int32.Parse(sdt.Rows[i]["Vcid"].ToString()); bool vclose = bool.Parse(sdt.Rows[i]["Vclose"].ToString()); lmode.Lcid = vcid; lmode.Lsort = 6; lmode.Ltype = 2; lmode.Lxid = vid; lmode.Lshow = !vclose; lmode.Ltitle = vtitle; lbll.Add(lmode);//将所有调查都添加到导航中 } } string sqlthree = "select * from TopicDiscuss where Tcid=" + Cid; DataTable tdt = DbHelperSQL.Query(sqlthree).Tables[0]; int tcount = tdt.Rows.Count; if (tcount > 0) { for (int i = 0; i < tcount; i++) { int tid = Int32.Parse(tdt.Rows[i]["Tid"].ToString()); string ttitle = tdt.Rows[i]["Ttitle"].ToString(); int tcid = Int32.Parse(tdt.Rows[i]["Tcid"].ToString()); bool tclose = bool.Parse(tdt.Rows[i]["Tclose"].ToString()); lmode.Lcid = tcid; lmode.Lsort = 8; lmode.Ltype = 3; lmode.Lxid = tid; lmode.Lshow = !tclose; lmode.Ltitle = ttitle; lbll.Add(lmode);//将所有讨论都添加到导航中 } } string sqlfour = "select * from TxtForm where Mcid=" + Cid; DataTable fdt = DbHelperSQL.Query(sqlfour).Tables[0]; int fcount = fdt.Rows.Count; if (fcount > 0) { for (int i = 0; i < fcount; i++) { int mid = Int32.Parse(fdt.Rows[i]["Mid"].ToString()); string mtitle = fdt.Rows[i]["Mtitle"].ToString(); int mcid = Int32.Parse(fdt.Rows[i]["Mcid"].ToString()); bool mpublish = bool.Parse(fdt.Rows[i]["Mpublish"].ToString()); lmode.Lcid = mcid; lmode.Lsort = 9; lmode.Ltype = 4; lmode.Lxid = mid; lmode.Lshow = mpublish; lmode.Ltitle = mtitle; lbll.Add(lmode);//将所有讨论都添加到导航中 } } }
private static int ImportXml(string xmlPath, int cobj, int Hid) { int newCid = -1; string xmlFile = Checkbdir(xmlPath) + "Course.xml"; if (File.Exists(xmlFile)) { DataSet ds = new DataSet(); DataTable dtCourse = new DataTable(); DataTable dtMission = new DataTable(); DataTable dtTopicDicuss = new DataTable(); DataTable dtSurvey = new DataTable(); DataTable dtSurveyQuestion = new DataTable(); DataTable dtSurveyItem = new DataTable(); DataTable dtTxtForm = new DataTable(); DataTable dtListMenu = new DataTable(); ds.ReadXml(xmlFile);//读取xml文件到ds if (ds.Tables.Contains("Course")) { dtCourse = ds.Tables["Course"];//获得学案表course } if (ds.Tables.Contains("Mission")) { dtMission = ds.Tables["Mission"];//获得活动表mission } if (ds.Tables.Contains("TopicDiscuss")) { dtTopicDicuss = ds.Tables["TopicDiscuss"];//获得讨论表 } if (ds.Tables.Contains("Survey")) { dtSurvey = ds.Tables["Survey"];//获得调查表 } if (ds.Tables.Contains("SurveyQuestion")) { dtSurveyQuestion = ds.Tables["SurveyQuestion"];//获得调查试题表 } if (ds.Tables.Contains("SurveyItem")) { dtSurveyItem = ds.Tables["SurveyItem"];//获得调查试题选项表 } if (ds.Tables.Contains("TxtForm")) { dtTxtForm = ds.Tables["TxtForm"]; } if (ds.Tables.Contains("ListMenu")) { dtListMenu = ds.Tables["ListMenu"];//获得学案导航表 } if (dtCourse != null && dtMission != null) { newCid = CreateCourse(dtCourse, cobj, Hid); //创建新学案,返回学案编号 CreateMission(dtMission, newCid); //将活动添加到新学案下 if (dtTopicDicuss != null) { CreateTopicDiscuss(dtTopicDicuss, newCid, Hid); } if (dtSurvey != null) { CreateSurvey(dtSurvey, dtSurveyQuestion, dtSurveyItem, newCid, Hid);//循环解决三张表编号关联 } if (dtTxtForm != null) { CreateTxtForm(dtTxtForm, newCid); } //要重建导航内编号 LearnSite.BLL.ListMenu lbll = new BLL.ListMenu(); lbll.importmenu(newCid); if (dtListMenu != null) { lbll.importupsort(dtListMenu, newCid); } } dtCourse.Dispose(); dtMission.Dispose(); dtTopicDicuss.Dispose(); dtSurvey.Dispose(); dtSurveyQuestion.Dispose(); dtSurveyItem.Dispose(); dtTxtForm.Dispose(); dtListMenu.Dispose(); ds.Dispose(); } return(newCid); }
/// <summary> /// 将旧学案生成新导航 /// </summary> public void initbuildmenu() { // 类型:活动1,调查2,讨论3 string sql = "select Mid,Mtitle,Mcid,Msort,Mpublish from Mission where Mdelete=0"; DataTable cdt = DbHelperSQL.Query(sql).Tables[0]; int ccount = cdt.Rows.Count; Model.ListMenu lmode = new Model.ListMenu(); BLL.ListMenu lbll = new BLL.ListMenu(); if (ccount > 0) { for (int i = 0; i < ccount; i++) { int mid = Int32.Parse(cdt.Rows[i]["Mid"].ToString()); string mtitle = cdt.Rows[i]["Mtitle"].ToString(); int mcid = Int32.Parse(cdt.Rows[i]["Mcid"].ToString()); int msort = Int32.Parse(cdt.Rows[i]["Msort"].ToString()); bool mpublish = bool.Parse(cdt.Rows[i]["Mpublish"].ToString()); lmode.Lcid = mcid; lmode.Lsort = msort; lmode.Ltype = 1; lmode.Lxid = mid; lmode.Lshow = mpublish; lmode.Ltitle = mtitle; lbll.Add(lmode);//将所有活动都添加到导航中 } } string sqltwo = "select Vid,Vtitle,Vcid,Vclose from Survey "; DataTable sdt = DbHelperSQL.Query(sqltwo).Tables[0]; int scount = sdt.Rows.Count; if (scount > 0) { for (int i = 0; i < scount; i++) { int vid = Int32.Parse(sdt.Rows[i]["Vid"].ToString()); string vtitle = sdt.Rows[i]["Vtitle"].ToString(); int vcid = Int32.Parse(sdt.Rows[i]["Vcid"].ToString()); bool vclose = bool.Parse(sdt.Rows[i]["Vclose"].ToString()); lmode.Lcid = vcid; lmode.Lsort = 6; lmode.Ltype = 2; lmode.Lxid = vid; lmode.Lshow = !vclose; lmode.Ltitle = vtitle; lbll.Add(lmode);//将所有调查都添加到导航中 } } string sqlthree = "select Tid,Ttitle,Tcid,Tclose from TopicDiscuss"; DataTable tdt = DbHelperSQL.Query(sqlthree).Tables[0]; int tcount = tdt.Rows.Count; if (tcount > 0) { for (int i = 0; i < tcount; i++) { int tid = Int32.Parse(tdt.Rows[i]["Tid"].ToString()); string ttitle = tdt.Rows[i]["Ttitle"].ToString(); int tcid = Int32.Parse(tdt.Rows[i]["Tcid"].ToString()); bool tclose = bool.Parse(tdt.Rows[i]["Tclose"].ToString()); lmode.Lcid = tcid; lmode.Lsort = 8; lmode.Ltype = 3; lmode.Lxid = tid; lmode.Lshow = !tclose; lmode.Ltitle = ttitle; lbll.Add(lmode);//将所有讨论都添加到导航中 } } }