zoukankan      html  css  js  c++  java
  • 【原创】 ASP.NET + C# + WEBSERVICE 返回表数据和记录数据

    public static List<string[]> LoadDataTable(string tablename)
        {
            DataTable dt = Admin.GetDataTable("select * from " + tablename + " order by id desc");
            if (dt.Rows.Count > 0)
            {
                List<string[]> list = new List<string[]>();

                DataTable dt_title = Admin.GetTableSchema(tablename);
                if (dt_title.Rows.Count > 0)
                {
                    string[] fieldname = new string[dt_title.Rows.Count];
                    for (int f = 0; f < dt_title.Rows.Count; f++)
                    {
                        fieldname.SetValue(dt_title.Rows[f][2].ToString().Trim(), f);
                    }
                    list.Add(fieldname);
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string[] fieldvalue = new string[dt.Columns.Count];
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        fieldvalue.SetValue(dt.Rows[i][j].ToString().Trim().Replace("00:00:00", "").Replace("0:00:00", ""), j);
                    }
                    list.Add(fieldvalue);
                }
                return list;
            }
            else
            {
                return null;
            }
        }

        public static List<string[]> LoadDataRow(string tablename, string id)
        {
            if (WService.Check())
            {
                DataRow dr = Admin.GetDataRow("select * from " + tablename + " where id = " + id);
                if (dr != null)
                {
                    List<string[]> list = new List<string[]>();
                    for (int i = 0; i < dr.Table.Columns.Count; i++)
                    {
                        string[] str = { dr.Table.Columns[i].ColumnName, dr[i].ToString().Trim().Replace("00:00:00", "").Replace("0:00:00", "") };
                        list.Add(str);
                    }
                    return list;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                //List<string[]> list = new List<string[]>();
                //string[] nopower = { "没有登录或登录超时,请重新登录!" };
                //list.Add(nopower);
                //return list;
                return null;
            }
        }

        [WebMethod]
        public List<string[]> LoadTable_Yuekan(string id)
        {
            return LoadDataTable("yuekan");
        }

        [WebMethod]
        public List<string[]> LoadRow_Yuekan(string id)
        {
            return LoadDataRow("yuekan", id);
        }

  • 相关阅读:
    音频算法之我思
    图像去模糊算法 循序渐进 附完整代码
    音频算法之小黄人变声 附完整C代码
    RocketMQ(2)---核心概念、特性、使用等
    RocketMQ(1)---架构原理及环境搭建
    RabbitMQ(2)---高级使用
    面试问题---JAVA程序CPU占用过高怎么定位
    RabbitMQ(1)---基本概念及简单demo
    JUC(4)---java线程池原理及源码分析
    JUC(3)---CountDownLatch、CyclicBarrier和AQS
  • 原文地址:https://www.cnblogs.com/cosiray/p/1562988.html
Copyright © 2011-2022 走看看