本文整理匯總了C#中System.Data.DataTable.ToJSON方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.ToJSON方法的具體用法?C# DataTable.ToJSON怎麽用?C# DataTable.ToJSON使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Data.DataTable
的用法示例。
在下文中一共展示了DataTable.ToJSON方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetStudentListBySchoolTeacherAndClass
public static string GetStudentListBySchoolTeacherAndClass(int schoolID, int teacherPage, int classId)
{
if (schoolID < 0) return null;
DataTable studentListBySchoolTeacherAndClass = new DataTable();
using (SqlConnection conn = new SqlConnection(AppSettings.ConnectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand
{
CommandType = CommandType.StoredProcedure,
CommandText = "E3_GetStudentListBySchoolIdTeacherIdAndClassId",
Connection = conn
};
cmd.Parameters.Add(new SqlParameter { ParameterName = "School", Value = schoolID });
cmd.Parameters.Add(new SqlParameter { ParameterName = "TeacherPage", Value = teacherPage });
cmd.Parameters.Add(new SqlParameter { ParameterName = "ClassId", Value = classId });
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(studentListBySchoolTeacherAndClass);
}
return studentListBySchoolTeacherAndClass.ToJSON(false);
}
示例2: GetClassListBySchoolAndTeacher
public static string GetClassListBySchoolAndTeacher(int schoolId, int teacherId)
{
if (schoolId < 0) return null;
DataTable classListBySchoolAndTeacher = new DataTable();
using (SqlConnection conn = new SqlConnection(AppSettings.ConnectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand
{
CommandType = CommandType.StoredProcedure,
CommandText = "E3_GetCVTEClassesForSchoolTeacherForCTR",
Connection = conn
};
cmd.Parameters.Add(new SqlParameter { ParameterName = "SchoolId", Value = schoolId });
cmd.Parameters.Add(new SqlParameter { ParameterName = "TeacherId", Value = teacherId });
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(classListBySchoolAndTeacher);
}
return classListBySchoolAndTeacher.Rows.Count <= 0 ? null : classListBySchoolAndTeacher.ToJSON(false);
}
示例3: GetTeacherListForSchool
public static string GetTeacherListForSchool(int schoolID)
{
if (schoolID < 0) return null;
DataTable teacherListForSchool = new DataTable();
//set teacher dropdown to the current user if they are a teacher
if (_loggedOnUserRoleName != null && _loggedOnUserRoleName.Equals("Teacher", StringComparison.InvariantCultureIgnoreCase))
{
if (!string.IsNullOrEmpty(_loggedOnUser.UserFullName) || !string.IsNullOrEmpty(_loggedOnUser.Page.ToString()))
{
return "[{\"TeacherName\":\"" + _loggedOnUser.UserFullName + "\",\"TeacherPage\":\"" + _loggedOnUser.Page + "\"}]";
}
return teacherListForSchool.ToJSON(false); //user was a teacher but SessionObject.LoggedInUser object had null values (return new 'empty' datatable')
}
using (SqlConnection conn = new SqlConnection(AppSettings.ConnectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand
{
CommandType = CommandType.StoredProcedure,
CommandText = "E3_GetTeacherListBySchoolId",
Connection = conn
};
cmd.Parameters.Add(new SqlParameter { ParameterName = "School", Value = schoolID });
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(teacherListForSchool);
}
return teacherListForSchool.ToJSON(false);
}
示例4: GetStudentListBySchoolTeacherAndClass
public static string GetStudentListBySchoolTeacherAndClass(int schoolID, int teacherPage, int classId)
{
if (schoolID < 0) return null;
DataTable studentListBySchoolTeacherAndClass = new DataTable();
Base.Classes.CompetencyTracking.CompetencyTrackingReport oCTR = new Base.Classes.CompetencyTracking.CompetencyTrackingReport();
studentListBySchoolTeacherAndClass = oCTR.GetStudentListBySchoolTeacherAndClass(schoolID, teacherPage, classId);
return studentListBySchoolTeacherAndClass.ToJSON(false);
}
示例5: GetClassListBySchoolAndTeacher
public static string GetClassListBySchoolAndTeacher(int schoolId, int teacherId)
{
// DataTable classListBySchoolAndTeacher = new DataTable();
// CompetencyTrackingReportPage obj=new CompetencyTrackingReportPage();
// if (_loggedOnUserRoleName.ToLower() == Convert.ToString(RolePortal.Teacher).ToLower())
// {
// classListBySchoolAndTeacher = obj.GetClassesForTeacherOnly();
// }
// else
// {
// if (schoolId < 0) return null;
// Base.Classes.CompetencyTracking.CompetencyTrackingReport oCTR = new Base.Classes.CompetencyTracking.CompetencyTrackingReport();
// classListBySchoolAndTeacher = oCTR.GetClassListBySchoolAndTeacher(schoolId, teacherId);
//}
// return classListBySchoolAndTeacher.Rows.Count <= 0 ? null : classListBySchoolAndTeacher.ToJSON(false);
if (schoolId < 0) return null;
DataTable classListBySchoolAndTeacher = new DataTable();
//using (SqlConnection conn = new SqlConnection(AppSettings.ConnectionString))
//{
// conn.Open();
// SqlCommand cmd = new SqlCommand
// {
// CommandType = CommandType.StoredProcedure,
// CommandText = "E3_GetCVTEClassesForSchoolTeacherForCTR",
// Connection = conn
// };
// cmd.Parameters.Add(new SqlParameter { ParameterName = "SchoolId", Value = schoolId });
// cmd.Parameters.Add(new SqlParameter { ParameterName = "TeacherId", Value = teacherId });
// SqlDataAdapter da = new SqlDataAdapter(cmd);
// da.Fill(classListBySchoolAndTeacher);
//}
var clsssList = Thinkgate.Base.Classes.Class.GetClassesForTeacher(teacherId, 0);
clsssList = clsssList.Where(x => x.SchoolID == schoolId).ToList();
classListBySchoolAndTeacher.Columns.Add("FriendlyName");
classListBySchoolAndTeacher.Columns.Add("ID");
foreach (var s in clsssList)
{
classListBySchoolAndTeacher.Rows.Add(s.FriendlyName, s.ID);
}
return classListBySchoolAndTeacher.Rows.Count <= 0 ? null : classListBySchoolAndTeacher.ToJSON(false);
}
示例6: GetTeacherListForSchool
public static string GetTeacherListForSchool(int schoolID)
{
if (schoolID < 0) return null;
DataTable teacherListForSchool = new DataTable();
//set teacher dropdown to the current user if they are a teacher
if (_loggedOnUserRoleName != null && _loggedOnUserRoleName.Equals("Teacher", StringComparison.InvariantCultureIgnoreCase))
{
if (!string.IsNullOrEmpty(_loggedOnUser.UserFullName) || !string.IsNullOrEmpty(_loggedOnUser.Page.ToString()))
{
return "[{\"TeacherName\":\"" + _loggedOnUser.UserFullName + "\",\"TeacherPage\":\"" + _loggedOnUser.Page + "\"}]";
}
return teacherListForSchool.ToJSON(false); //user was a teacher but SessionObject.LoggedInUser object had null values (return new 'empty' datatable')
}
Base.Classes.CompetencyTracking.CompetencyTrackingReport oCTR = new Base.Classes.CompetencyTracking.CompetencyTrackingReport();
teacherListForSchool = oCTR.GetTeacherListBySchool(schoolID);
return teacherListForSchool.ToJSON(false);
}
示例7: GetCompetencyList
public static string GetCompetencyList()
{
string[] StrResourcesToShowOnTile;
string ResourceToShow = string.Empty;
ResourceToShow = "Thinkgate.CompetencyList";
DataSet resourcesToShow = KenticoHelper.GetTileMapLookupDataSet(ResourceToShow);
StrResourcesToShowOnTile = resourcesToShow.Tables[0]
.AsEnumerable()
.OrderBy(p => p["ItemOrder"].ToString())
.Select(s => s.Field<string>("KenticoDocumentTypeToShow"))
.ToArray();
KenticoHelper kHelper = new KenticoHelper();
List<UserNodeList> nodeList = kHelper.GetCompetencyList(StrResourcesToShowOnTile);
CompetencyTrackingReportPage trackingPage = new CompetencyTrackingReportPage();
nodeList = trackingPage.FilterByStandard(nodeList);
var result = (from t in nodeList
select new { t.NodeId, t.FriendlyName }).ToArray();
DataTable dtNodeList = new DataTable();
dtNodeList.Columns.Add(
new DataColumn()
{
DataType = System.Type.GetType("System.String"),
ColumnName = "DocumentId"
}
);
dtNodeList.Columns.Add(
new DataColumn()
{
DataType = System.Type.GetType("System.String"),
ColumnName = "FriendlyName"
}
);
foreach (var element in result)
{
var row = dtNodeList.NewRow();
row["DocumentId"] = element.NodeId.ToString();
row["FriendlyName"] = element.FriendlyName.ToString();
dtNodeList.Rows.Add(row);
}
return dtNodeList.ToJSON(false);
}