Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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);
            }
        }