public static void AddProgramFunction(PFunction pFunction) { paper.Add(pFunction); }
private List<PFunction> DataSetToListFunProgram(DataSet Ds) { DataTable p_Data = Ds.Tables[0]; // 返回值初始化 List<PFunction> result = new List<PFunction>(); for (int j = 0; j < p_Data.Rows.Count; j++) { PFunction problem=new PFunction(ProblemType.CProgramFun); PLanguage language=(PLanguage)Convert.ToInt32(p_Data.Rows[j]["Language"]); switch (language) { case PLanguage.C: problem = new PFunction(ProblemType.CProgramFun); break; case PLanguage.CPP: problem = new PFunction(ProblemType.CppProgramFun); break; case PLanguage.VB: problem = new PFunction(ProblemType.VbProgramFun); break; } problem.problemId = Convert.ToInt32(p_Data.Rows[j]["PID"]); problem.problem = p_Data.Rows[j]["PContent"].ToString(); problem.unit.UnitId = Convert.ToInt32(p_Data.Rows[j]["Unit"]); problem.unit.UnitName = p_Data.Rows[j]["UnitName"].ToString(); problem.Plevel = Convert.ToInt32(p_Data.Rows[j]["PLevel"]); //for (int i = 0; i < p_Data.Columns.Count; i++) //{ // if (p_Data.Columns[i].ToString() == "Id") // problem.problemId = Convert.ToInt32(p_Data.Rows[j][i]); // if (p_Data.Columns[i].ToString() == "Problem_Content") // problem.problem = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "File_Path") // problem.path = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "In1") // problem.inp1 = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "In2") // problem.inp2 = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "In3") // problem.inp3 = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "Out1") // problem.outp1 = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "Out2") // problem.outp2 = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "Out3") // problem.outp3 = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "CorrectC") // problem.correctC = (string)p_Data.Rows[j][i]; // if (p_Data.Columns[i].ToString() == "Kind") // problem.kind = (bool)p_Data.Rows[j][i]; //} result.Add(problem); } return result; }
private List<ProgramProblem> DataSetToListProgram(DataSet Ds) { DataTable p_Data = Ds.Tables[0]; // 返回值初始化 List<ProgramProblem> result = new List<ProgramProblem>(); for (int j = 0; j < p_Data.Rows.Count; j++) { ProgramProblem problem = new ProgramProblem(); PLanguage language=(PLanguage)Convert.ToInt32(p_Data.Rows[j]["Language"]); ProgramPType type = (ProgramPType)Convert.ToInt32(p_Data.Rows[j]["Type"]); switch (language) { case PLanguage.C: switch (type) { case ProgramPType.Completion: problem = new PCompletion(ProblemType.CProgramCompletion); break; case ProgramPType.Modify: problem = new PModif(ProblemType.CProgramModification); break; case ProgramPType.Function: problem = new PFunction(ProblemType.CProgramFun); break; } break; case PLanguage.CPP: switch (type) { case ProgramPType.Completion: problem = new PCompletion(ProblemType.CppProgramCompletion); break; case ProgramPType.Modify: problem = new PModif(ProblemType.CppProgramModification); break; case ProgramPType.Function: problem = new PFunction(ProblemType.CppProgramFun); break; } break; case PLanguage.VB: switch (type) { case ProgramPType.Completion: problem = new PCompletion(ProblemType.VbProgramCompletion); break; case ProgramPType.Modify: problem = new PModif(ProblemType.VbProgramModification); break; case ProgramPType.Function: problem = new PFunction(ProblemType.VbProgramFun); break; } break; } problem.problemId = Convert.ToInt32(p_Data.Rows[j]["PID"]); problem.problem = p_Data.Rows[j]["PContent"].ToString(); problem.unit.UnitId = Convert.ToInt32(p_Data.Rows[j]["Unit"]); problem.unit.UnitName = p_Data.Rows[j]["UnitName"].ToString(); problem.Plevel = Convert.ToInt32(p_Data.Rows[j]["PLevel"]); result.Add(problem); } return result; }
public List<PFunction> GetPFunctionProbelm() { List<PFunction> list = new List<PFunction>(); foreach (XmlNode xnn in xd.ChildNodes.Item(1).ChildNodes) { if (xnn.Name == "CProgramFun") { PFunction c = new PFunction(ProblemType.CProgramFun); c.problemId = Convert.ToInt32(xnn.Attributes["ProblemId"].Value); c.orderId = Convert.ToInt32(xnn.Attributes["OrderId"].Value); foreach (XmlNode option in xnn.ChildNodes) { if (option.ChildNodes.Item(0) != null) { switch (option.Name) { case "Problem": c.problem = option.ChildNodes.Item(0).Value; break; } } } list.Add(c); } else if (xnn.Name == "CppProgramFun") { PFunction c = new PFunction(ProblemType.CppProgramFun); c.problemId = Convert.ToInt32(xnn.Attributes["ProblemId"].Value); c.orderId = Convert.ToInt32(xnn.Attributes["OrderId"].Value); foreach (XmlNode option in xnn.ChildNodes) { if (option.ChildNodes.Item(0) != null) { switch (option.Name) { case "Problem": c.problem = option.ChildNodes.Item(0).Value; break; } } } list.Add(c); } else if (xnn.Name == "VbProgramFun") { PFunction c = new PFunction(ProblemType.VbProgramFun); c.problemId = Convert.ToInt32(xnn.Attributes["ProblemId"].Value); c.orderId = Convert.ToInt32(xnn.Attributes["OrderId"].Value); foreach (XmlNode option in xnn.ChildNodes) { if (option.ChildNodes.Item(0) != null) { switch (option.Name) { case "Problem": c.problem = option.ChildNodes.Item(0).Value; break; } } } list.Add(c); } } return list; }