Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TravelAgent.Model.CarClass GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

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

            TravelAgent.Model.CarClass model = new TravelAgent.Model.CarClass();
            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.ClassName = ds.Tables[0].Rows[0]["ClassName"].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.CarClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CarClass(");
            strSql.Append("ClassName,Sort)");
            strSql.Append(" values (");
            strSql.Append("@ClassName,@Sort)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ClassName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Sort",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ClassName;
            parameters[1].Value = model.Sort;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         if (Request.QueryString["classid"] != null)
         {
             TravelAgent.Model.CarClass model = CityBll.GetModel(Convert.ToInt32(Request.QueryString["classid"]));
             if (model != null)
             {
                 this.txtClassName.Text = model.ClassName;
                 this.txtSort.Text      = model.Sort.ToString();
                 this.hidId.Value       = model.Id.ToString();
             }
         }
         else
         {
             this.txtSort.Text = (CityBll.GetMaxID("Sort") + 1).ToString();
         }
     }
 }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TravelAgent.Model.CarClass model)
        {
            StringBuilder strSql = new StringBuilder();

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

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #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.CarClass model)
 {
     DAL.Update(model);
 }
Пример #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TravelAgent.Model.CarClass model)
 {
     DAL.Add(model);
     return(DAL.GetMaxID("Id"));
 }