Example #1
0
 public void ModifyCity(CityObj cityObj)
 {
     using (helper = new SqlHelper())
     {
         helper.AddIntParameter("@CityID", cityObj.CityID);
         helper.AddIntParameter("@ProvinceID", cityObj.ProvinceID);
         helper.AddStringParameter("@CityName", 100, cityObj.CityName);
         string sql = "update City set CityName=@CityName,ProvinceID=@ProvinceID where CityID=@CityID";
         helper.ExecuteNonQuery(sql, CommandType.Text);
     }
 }
Example #2
0
        public void AddCity(CityObj cityObj)
        {
            using (helper = new SqlHelper())
            {
                SqlParameter idParam = helper.AddOutputParameter("@CityID");
                helper.AddStringParameter("@CityName", 100, cityObj.CityName);
                helper.AddIntParameter("@ProvinceID", cityObj.ProvinceID);

                helper.ExecuteNonQuery("insert into City (CityName,ProvinceID) values (@CityName,@ProvinceID) select @CityID=@IDENTITY", CommandType.Text);

                cityObj.CityID = (int)idParam.Value;
            }
        }
Example #3
0
 public CityObj GetCity(int cityId)
 {
     using (helper = new SqlHelper())
     {
         helper.AddIntParameter("@CityID", cityId);
         string sql = "select ProvinceID,CityName from City where CityID=@CityID";
         using (SqlDataReader dr = helper.ExecuteReader(sql, CommandType.Text))
         {
             if (dr.HasRows && dr.Read())
             {
                 CityObj cityObj = new CityObj();
                 cityObj.CityID     = cityId;
                 cityObj.ProvinceID = (int)dr[0];
                 cityObj.CityName   = (string)dr[1];
                 return(cityObj);
             }
             return(null);
         }
     }
 }
Example #4
0
 public void ModifyCity(CityObj cityObj)
 {
     dal.ModifyCity(cityObj);
 }
Example #5
0
 public void AddCity(CityObj cityObj)
 {
     dal.AddCity(cityObj);
 }