Exemplo n.º 1
0
        public bool AddJKINFO(MapApp.Entities.JKINFO OBJJKINFO, String MDBFileName)
        {
            String SQL = String.Format("INSERT INTO JKINFO (NDH,SBLX)values({0},{1})"
                                       , OBJJKINFO.NDH, OBJJKINFO.SBLX);

            return(MDBHelp.ExcuteSQL(MDBFileName, SQL));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string mdbFile = @"G:\Projects\Visual Studio Project\Phillip\AccessProject\mdb\Logger.mdb";           //默認路徑  

            MDBHelp   mdbHelp = new MDBHelp(mdbFile);
            DataTable dt      = null;

            try
            {
                mdbHelp.Open();     // 打開數據庫  

                dt = mdbHelp.GetDataTable("select* from events where datatime > '2005/08/23 08:47:46.734'");

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    foreach (DataColumn item in dt.Columns)
                    {
                        Console.Write(item.ColumnName + ":" + dt.Rows[i][item].ToString() + "\t");
                    }
                    Console.WriteLine();
                }

                mdbHelp.Close();    // 關閉數據庫  
            }
            finally
            {
                mdbHelp = null;
            }
            Console.ReadKey();
        }
Exemplo n.º 3
0
        public bool EditJKINFO(MapApp.Entities.JKINFO OBJJKINFO, String MDBFileName)
        {
            String SQL = String.Format("UPDATE JKINFO  SET NDH={0},SBLX={1} WHERE MAPINFO_ID ={2}"
                                       , OBJJKINFO.NDH, OBJJKINFO.SBLX, OBJJKINFO.MAPINFO_ID);

            return(MDBHelp.ExcuteSQL(MDBFileName, SQL));
        }
Exemplo n.º 4
0
        private void InputData(string gun, String db)
        {
            var    msg     = "";
            string mdbFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, db);  

            MDBHelp      mdbHelp   = new MDBHelp(mdbFile);
            SQLiteHelper sqlHelper = new SQLiteHelper();

            //sqlHelper.Execute("DROP TABLE 'SLR'");
            sqlHelper.Execute("CREATE TABLE \"" + gun + "\" ( \"ID\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \"dataNo\" TEXT ( 255 ), \"datas\" TEXT ( 255 ), \"descs\" TEXT ( 255 ) );");
            try
            {
                mdbHelp.Open();
                var d           = new Dictionary <string, string>();
                var ds1         = mdbHelp.GetDataSet("select *  from M24狙;");
                var ColumnsList = ds1.Tables[0].Columns;
                foreach (DataRow item in ds1.Tables[0].Rows)

                {
                    msg = "<ROW ";

                    d = new Dictionary <string, string>();

                    foreach (DataColumn item1 in ColumnsList)

                    {
                        var ColumnName = item1.ColumnName;

                        d.Add(ColumnName, item[ColumnName].ToString());
                    }

                    int    _id    = Convert.ToInt32(d["ID"]);
                    string dataNo = d["弹道编号"];
                    string datas  = d["弹道数据"];
                    string descs  = d["弹道备注"];
                    msg += string.Format("ID=\"{0}\" 弹道编号=\"{1}\" 弹道数据=\"{2}\"  弹道备注=\"{3}\" ", _id, dataNo, datas, descs);

                    msg += "></ROW>";

                    // 写入sqlite

                    string sql = string.Format("INSERT INTO \"" + gun + "\" (\"ID\", \"dataNo\", \"datas\", \"descs\") VALUES ({0}, '{1}', '{2}', '{3}');", _id, dataNo, datas, descs);
                    int    i   = sqlHelper.Execute(sql);
                    //LogHelper.ShowLog("row info: {0}", msg);
                    //LogHelper.ShowLog("inset status: {0}", i);
                }
            } catch (Exception e)
            {
                LogHelper.ShowLog("open MDB {0}", e.Message);
            } finally
            {
                /**
                 * mdbHelp.Close();
                 * mdbHelp = null;
                 * sqlHelper.Close();
                 * sqlHelper = null;
                 **/
            }
            LogHelper.ShowLog("{0} 数据导入完成", gun);
        }
Exemplo n.º 5
0
        public bool DeleteJKINFO(Int32 NDH, String MDBFileName)
        {
            MapApp.Entities.JKINFO OBJJKINFO = new MapApp.Entities.JKINFO();
            String SQL = String.Format("DELETE FROM JKINFO WHERE NDH={0}"
                                       , NDH);

            return(MDBHelp.ExcuteSQL(MDBFileName, SQL));
        }
Exemplo n.º 6
0
        public DataSet GetList(String MDBFileName, String Where)
        {
            String SQL = "SELECT * FROM JKINFO ";

            if (!String.IsNullOrEmpty(Where) && Where != "*")
            {
                SQL += " WHERE " + Where;
            }
            return(MDBHelp.GetDataSet(MDBFileName, SQL));
        }
Exemplo n.º 7
0
        public DataSet Query(string tableNameSQL, string orderSQL, string conditionSQL)
        {
            DataSet ds = new DataSet();

            string[] names      = tableNameSQL.Split(_separator);
            string[] orders     = null;
            string[] conditions = null;
            if (orderSQL != null)
            {
                orders = orderSQL.Split(_separator);
            }
            if (conditionSQL != null)
            {
                conditions = conditionSQL.Split(_separator);
            }
            for (int i = 0; i < names.Count(); ++i)
            {
                string tableName = TableNamePrex + names[i];
                string strCmd    = "";

                if (conditions != null && i < conditions.Count())
                {
                    string cond = conditions[i];
                    strCmd = getSelectCmd(tableName, cond);
                }
                else
                {
                    strCmd = "SELECT * FROM " + tableName + "";
                }
                if (orders != null && i < orders.Count())
                {
                    strCmd += OrderSQL(orders[i]);
                }
                DataSet _ds = MDBHelp.Query(strCmd);
                if (_ds.Tables.Count > 0)
                {
                    DataTable dt = _ds.Tables[0];
                    _ds.Tables.RemoveAt(0);
                    dt.TableName = tableName;
                    ds.Tables.Add(dt);
                }
            }
            return(ds);
        }
Exemplo n.º 8
0
 public void initializeDataService(string dbFilePath)
 {
     MDBHelp.SetConncetionString(dbFilePath);
 }
Exemplo n.º 9
0
 // Get record count of a table
 int getRecordCount(string tableNameSQL)
 {
     return(MDBHelp.GetRecordCount(tableNameSQL));
 }
Exemplo n.º 10
0
        public MapApp.Entities.JKINFO GetJKINFO(Int32 NDH, String MDBFileName)
        {
            MapApp.Entities.JKINFO OBJJKINFO = new MapApp.Entities.JKINFO();
            String SQL = String.Format("SELECT * FROM JKINFO WHERE NDH={0}"
                                       , NDH);
            DataSet ds = MDBHelp.GetDataSet(MDBFileName, SQL);

            if (ds == null || ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            else
            {
                OBJJKINFO.ADDR = ds.Tables[0].Rows[0]["ADDR"].ToString();
                try
                {
                    OBJJKINFO.BJZ = Convert.ToInt32(ds.Tables[0].Rows[0]["BJZ"].ToString());
                }
                catch
                { }
                try
                {
                    OBJJKINFO.DDZ = Convert.ToInt32(ds.Tables[0].Rows[0]["DDZ"].ToString());
                }
                catch
                { }
                try
                {
                    OBJJKINFO.DKH = Convert.ToInt32(ds.Tables[0].Rows[0]["DKH"].ToString());
                }
                catch
                { }
                OBJJKINFO.DW = ds.Tables[0].Rows[0]["DW"].ToString();
                try
                {
                    OBJJKINFO.FZH = Convert.ToInt32(ds.Tables[0].Rows[0]["FZH"].ToString());
                }
                catch
                { }
                try
                {
                    OBJJKINFO.MAPINFO_ID = Convert.ToInt32(ds.Tables[0].Rows[0]["MAPINFO_ID"].ToString());
                }
                catch
                { }
                try
                {
                    OBJJKINFO.NDH = Convert.ToInt32(ds.Tables[0].Rows[0]["NDH"].ToString());
                }
                catch
                { }
                try
                {
                    OBJJKINFO.SBLX = Convert.ToInt32(ds.Tables[0].Rows[0]["SBLX"].ToString());
                }
                catch
                { }
                OBJJKINFO.SJ = ds.Tables[0].Rows[0]["SJ"].ToString();
                try
                {
                    OBJJKINFO.ZT = Convert.ToInt32(ds.Tables[0].Rows[0]["ZT"].ToString());
                }
                catch
                { }

                return(OBJJKINFO);
            }
        }