當前位置: 首頁>>代碼示例>>C#>>正文


C# DataTable.ToJSON方法代碼示例

本文整理匯總了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);
        }
開發者ID:ezimaxtechnologies,項目名稱:ASP.Net,代碼行數:26,代碼來源:CredentialTrackingReportPage.aspx.cs

示例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);
        }
開發者ID:ezimaxtechnologies,項目名稱:ASP.Net,代碼行數:25,代碼來源:CredentialTrackingReportPage.aspx.cs

示例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);
        }
開發者ID:ezimaxtechnologies,項目名稱:ASP.Net,代碼行數:35,代碼來源:CredentialTrackingReportPage.aspx.cs

示例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);
        }
開發者ID:ezimaxtechnologies,項目名稱:ASP.Net,代碼行數:9,代碼來源:CompetencyTrackingReportPage.aspx.cs

示例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);
        }
開發者ID:ezimaxtechnologies,項目名稱:ASP.Net,代碼行數:52,代碼來源:CompetencyTrackingReportPage.aspx.cs

示例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);
        }
開發者ID:ezimaxtechnologies,項目名稱:ASP.Net,代碼行數:20,代碼來源:CompetencyTrackingReportPage.aspx.cs

示例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);
        }
開發者ID:ezimaxtechnologies,項目名稱:ASP.Net,代碼行數:47,代碼來源:CompetencyTrackingReportPage.aspx.cs


注:本文中的System.Data.DataTable.ToJSON方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。