public static int Insert(Database db, MapInfo mapInfo)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO MapInfo(");
            sbValue.Append("values(");
            sbField.Append("Name");
            sbValue.AppendFormat("'{0}'", mapInfo.Name);
            sbField.Append(",Width");
            sbValue.AppendFormat(",{0}", mapInfo.Width);
            sbField.Append(",Height");
            sbValue.AppendFormat(",{0}", mapInfo.Height);
            sbField.Append(",FileName)");
            sbValue.AppendFormat(",'{0}')", mapInfo.FileName);
             string cmdText = sbField + " " + sbValue;
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Beispiel #2
0
        public int Insert(ref string errMessage, MapInfo mapInfo)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                return MapDataAccess.Insert(db, mapInfo);

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return -1;
            }
        }
        public static int Update(Database db, MapInfo mapInfo)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("update MapInfo set");
            sb.AppendFormat(" Name={0}", mapInfo.Name);
            sb.AppendFormat(",X={0}", mapInfo.Width);
            sb.AppendFormat(",Y={0} ", mapInfo.Height);
            sb.AppendFormat(",FileName='{0}' ", mapInfo.FileName);
            sb.AppendFormat(" where Id={0}", mapInfo.Id);
            string cmdText = sb.ToString();
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Beispiel #4
0
        public Dictionary<int, MapInfo> GetAllMapInfo(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            Dictionary<int, MapInfo> list = new Dictionary<int, MapInfo>();
            try
            {
                MapInfo mapInfo;
                DataSet ds = MapDataAccess.GetAllMapInfo(db);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    mapInfo = new MapInfo(ds.Tables[0].Rows[i]);
                    list.Add(mapInfo.Id, mapInfo);
                }
                return list;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
Beispiel #5
0
 private void btnAddMap_Click(object sender, EventArgs e)
 {
     MapInfo mapInfo = new MapInfo();
     mapInfo.Name = teMapName.Text;
     mapInfo.Width = CurrentImage.Width;
     mapInfo.Height = CurrentImage.Height;
     mapInfo.FileName ="img\\maps\\" + Path.GetFileName(CurrentFileName);
     File.Copy(CurrentFileName, Path.Combine(Application.StartupPath,mapInfo.FileName));
     MapBusiness.Instance.Insert(ref errMessage, mapInfo);
     BuildMapTree();
 }
Beispiel #6
0
        //���ӵ�ͼ
        private void tvMap_DoubleClick_1(object sender, EventArgs e)
        {
            string str = tvMap.FocusedNode.Tag.ToString();
            if (str.IndexOf("d") >= 0)
            {
                string[] strs = str.Split(';');
                CurrentMapInfo = _listMapInfo[int.Parse(strs[0])];
                pictureBoxMap.Image = Image.FromFile(Path.Combine(Application.StartupPath, CurrentMapInfo.FileName));
                teMapName.Text = CurrentMapInfo.Name;

            }
        }