예제 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TravelAgent.Model.CarCity GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from CarCity ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            TravelAgent.Model.CarCity model = new TravelAgent.Model.CarCity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.CityName = ds.Tables[0].Rows[0]["CityName"].ToString();
                if (ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                {
                    model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(TravelAgent.Model.CarCity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CarCity(");
            strSql.Append("CityName,Sort)");
            strSql.Append(" values (");
            strSql.Append("@CityName,@Sort)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CityName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Sort",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CityName;
            parameters[1].Value = model.Sort;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TravelAgent.Model.CarCity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CarCity set ");
            strSql.Append("CityName=@CityName,");
            strSql.Append("Sort=@Sort");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CityName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Sort",     SqlDbType.Int,       4),
                new SqlParameter("@Id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CityName;
            parameters[1].Value = model.Sort;
            parameters[2].Value = model.id;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         if (Request.QueryString["cityid"] != null)
         {
             TravelAgent.Model.CarCity model = CityBll.GetModel(Convert.ToInt32(Request.QueryString["cityid"]));
             if (model != null)
             {
                 this.txtCityName.Text = model.CityName;
                 this.txtSort.Text     = model.Sort.ToString();
                 this.hidId.Value      = model.id.ToString();
             }
         }
         else
         {
             this.txtSort.Text = (CityBll.GetMaxID("Sort") + 1).ToString();
         }
     }
 }
예제 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         if (Request["tag"] != null)
         {
             string strTag = Request["tag"];
             if (strTag == "city_save")//租车城市保存
             {
                 int city_editid = Convert.ToInt32(Request["hidId"]);
                 TravelAgent.Model.CarCity model = new TravelAgent.Model.CarCity();
                 model.CityName = Request["txtCityName"];
                 model.Sort     = Convert.ToInt32(Request["txtSort"]);
                 try
                 {
                     if (city_editid != 0)
                     {
                         model.id = city_editid;
                         CityBll.Update(model);
                     }
                     else
                     {
                         CityBll.Add(model);
                     }
                     Response.Write("true");
                 }
                 catch
                 {
                     Response.Write("false");
                 }
             }
             else if (strTag == "city_delete")//租车城市删除
             {
                 int cityid = Convert.ToInt32(Request["cityid"]);
                 try
                 {
                     CityBll.Delete(cityid);
                     Response.Write("true");
                 }
                 catch
                 {
                     Response.Write("false");
                 }
             }
             else if (strTag == "brand_save")//租车品牌保存
             {
                 int brand_editid = Convert.ToInt32(Request["hidId"]);
                 TravelAgent.Model.CarBrand model = new TravelAgent.Model.CarBrand();
                 model.BrandName = Request["txtBrandName"];
                 model.BrandPic  = Request["txtImgUrl"];
                 model.Sort      = Convert.ToInt32(Request["txtSort"]);
                 try
                 {
                     if (brand_editid != 0)
                     {
                         model.Id = brand_editid;
                         BrandBll.Update(model);
                     }
                     else
                     {
                         BrandBll.Add(model);
                     }
                     Response.Write("true");
                 }
                 catch
                 {
                     Response.Write("false");
                 }
             }
             else if (strTag == "brand_delete")//租车品牌删除
             {
                 int themeid = Convert.ToInt32(Request["brandid"]);
                 try
                 {
                     BrandBll.Delete(themeid);
                     Response.Write("true");
                 }
                 catch
                 {
                     Response.Write("false");
                 }
             }
             else if (strTag == "class_save")//车辆级别保存
             {
                 int city_editid = Convert.ToInt32(Request["hidId"]);
                 TravelAgent.Model.CarClass model = new TravelAgent.Model.CarClass();
                 model.ClassName = Request["txtClassName"];
                 model.Sort      = Convert.ToInt32(Request["txtSort"]);
                 try
                 {
                     if (city_editid != 0)
                     {
                         model.Id = city_editid;
                         ClassBll.Update(model);
                     }
                     else
                     {
                         ClassBll.Add(model);
                     }
                     Response.Write("true");
                 }
                 catch
                 {
                     Response.Write("false");
                 }
             }
             else if (strTag == "class_delete")//车辆级别删除
             {
                 int cityid = Convert.ToInt32(Request["classid"]);
                 try
                 {
                     ClassBll.Delete(cityid);
                     Response.Write("true");
                 }
                 catch
                 {
                     Response.Write("false");
                 }
             }
             else if (strTag == "num_save")//汽车厢数保存
             {
                 int city_editid = Convert.ToInt32(Request["hidId"]);
                 TravelAgent.Model.CarNumber model = new TravelAgent.Model.CarNumber();
                 model.NumName = Request["txtNumName"];
                 model.Sort    = Convert.ToInt32(Request["txtSort"]);
                 try
                 {
                     if (city_editid != 0)
                     {
                         model.Id = city_editid;
                         NumBll.Update(model);
                     }
                     else
                     {
                         NumBll.Add(model);
                     }
                     Response.Write("true");
                 }
                 catch
                 {
                     Response.Write("false");
                 }
             }
             else if (strTag == "num_delete")//汽车厢数删除
             {
                 int cityid = Convert.ToInt32(Request["numid"]);
                 try
                 {
                     NumBll.Delete(cityid);
                     Response.Write("true");
                 }
                 catch
                 {
                     Response.Write("false");
                 }
             }
         }
     }
 }
예제 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(TravelAgent.Model.CarCity model)
 {
     CityDAL.Update(model);
 }
예제 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TravelAgent.Model.CarCity model)
 {
     CityDAL.Add(model);
     return(CityDAL.GetMaxID("Id"));
 }