Пример #1
0
 // 添加一个城市记录
 /// <summary>
 /// 添加一个城市记录
 /// </summary>
 /// <param name="cityName">新增的城市名称</param>
 /// <returns>返回受影响的记录数;1:成功添加;0:已存在;-1:Error</returns>
 public int AddCity(string cityName, out string errMsg)
 {
     errMsg = "";
     try
     {
         //若城市已存在,则返回数值0
         if (IsCityExist(cityName))
         {
             errMsg = "The city has been exist!";
             return(0);
         }
         //新增成功,返回数值1
         string query = "INSERT INTO dbo_LoadCity (LoadCity, LangType, IsDefault) VALUES ('"
                        + cityName + "','" + _lang + "',0)";
         return(_dao.ExecuteSql(query, _dao.GetConnLoadIndex()));
     }
     catch (Exception exc)
     {
         errMsg = exc.Message;
         return(-1);
     }
 }