⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clsdbpub.cs.svn-base

📁 以构建的方式来实现对通用的查询统计
💻 SVN-BASE
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.IO;
using System.Data.OleDb;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace dist.hb.EnvQueryStat.Pub
{
  public class BaseDataDef
  {
    public static double ZERO = 0.000000001;
    public static string QueryStatTempTable = "FS_QueryStatTemp";
    public static int ScreenBufferR = 15;
    public static string EVN_TEMP_ACCESS = "EnvStatDB.mdb";
  }

  public class ConstDataType
  {
    public static string CString =  "字符";
    public static string CInt = "整形";
    public static string CFloat = "浮点";
    public static string CData = "日期";
  }

  public class XXQH_TYPE
  {
    public static String CPROV = "省级行政区划";
    public static String CDIST = "地级行政区划";
    public static String CCNTY = "县级行政区划";
  }

  public class MAPDRAW_TYPE
  {
    public static String MAPDRAW_POINT = "点";
    public static String MAPDRAW_LINE = "线";
    public static String MAPDRAW_POLYGON = "多边形";
    public static String MAPDRAW_RECT = "矩形";
    public static String MAPDRAW_CIRCLE = "圆";
  }

  public class MAPSELECT_OBJECT
  {
    public static String MAPSELECT_TEMP = "临时图层";
    public static String MAPSELECT_SELECTION = "当前图层";
    public static String MAPDRAW_XXQH = "地区编码";
  }

  public class DictItem
  {
    public string code;
    public string name;
    public override string ToString()
    {
      return name;
    }
  }

  public class clsDbPub
  {
    //属性过滤的取最大值,作为行的ID
    public static int GetMaxValue(OleDbConnection conn, string strTbl, string strField)
    {
      int iReturn = 0;
      if (conn == null) return iReturn;
      using (OleDbConnection connection = new OleDbConnection(conn.ConnectionString))
      {
        string strSQL = "SELECT MAX(" + strField + ") AS index1 FROM " + strTbl;
        OleDbCommand command = new OleDbCommand(strSQL, connection);
        connection.Open();
        OleDbDataReader reader = command.ExecuteReader();
        if (reader.Read())
        {
          object obj = reader[0];
          string strValue = obj.ToString();
          if (strValue != "") iReturn = (int)reader[0];
        }
        reader.Close();
      }
      return iReturn;
    }
    public static DataTable GetDataTable(OleDbConnection conn, string sql)
    {
      if (conn == null) return null;
      try
      {
        DataSet ds = new DataSet();
        System.Data.OleDb.OleDbDataAdapter Adapter = new System.Data.OleDb.OleDbDataAdapter(sql, conn);
        string DataTable1 = "DataTable1";
        Adapter.Fill(ds, DataTable1);
        return ds.Tables[DataTable1];
      }
      catch(Exception e)
      {
        MessageBox.Show("打开数据表失败!  "+ sql);
        return null;
      }
    }

    public static void SaveTextToFile(string strTxt)
    {
      string sqlFile = System.Windows.Forms.Application.StartupPath + "\\SQL.txt";
      // Create the new, empty data file.
      if (File.Exists(sqlFile))
      {
        File.Delete(sqlFile);
        Console.WriteLine("{0} already exists!Deleted!", sqlFile);
      }
      using (StreamWriter sw = File.CreateText(sqlFile))
      {
        sw.WriteLine(strTxt);
        sw.Close();
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -