protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { DataBindNav(); if (Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); TravelAgent.Model.VisaCountry model = bll.GetModel(id); if (model != null) { this.hidId.Value = id.ToString(); this.ddlAreaCountry.SelectedValue = model.ParentId.ToString(); this.txtName.Text = model.Name; this.txtTips.Value = model.Tips; this.txtImgUrl.Text = model.PicUrl; this.txtEnglishName.Text = model.EnglishName; this.txtFristWord.Text = model.FirstWord; this.txtSort.Text = model.Sort.ToString(); this.chkState.Checked = model.isLock == 1; } } else { this.txtSort.Text = (bll.GetMaxID("Sort") + 1).ToString(); } } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(TravelAgent.Model.VisaCountry model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into VisaCountry("); strSql.Append("Name,PicUrl,Tips,EnglishName,FirstWord,Sort,isLock,ParentId,ClassList,ClassLayer)"); strSql.Append(" values ("); strSql.Append("@Name,@PicUrl,@Tips,@EnglishName,@FirstWord,@Sort,@isLock,@ParentId,@ClassList,@ClassLayer)"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@PicUrl", SqlDbType.VarChar, 50), new SqlParameter("@Tips", SqlDbType.Text), new SqlParameter("@EnglishName", SqlDbType.VarChar, 50), new SqlParameter("@FirstWord", SqlDbType.VarChar, 50), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@isLock", SqlDbType.Int, 4), new SqlParameter("@ParentId", SqlDbType.Int, 4), new SqlParameter("@ClassList", SqlDbType.VarChar, 50), new SqlParameter("@ClassLayer", SqlDbType.Int, 4) }; parameters[0].Value = model.Name; parameters[1].Value = model.PicUrl; parameters[2].Value = model.Tips; parameters[3].Value = model.EnglishName; parameters[4].Value = model.FirstWord; parameters[5].Value = model.Sort; parameters[6].Value = model.isLock; parameters[7].Value = model.ParentId; parameters[8].Value = model.ClassList; parameters[9].Value = model.ClassLayer; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public TravelAgent.Model.VisaCountry GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,Name,PicUrl,Tips,EnglishName,FirstWord,Sort,isLock,ParentId,ClassList,ClassLayer from VisaCountry "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; TravelAgent.Model.VisaCountry model = new TravelAgent.Model.VisaCountry(); 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.Name = ds.Tables[0].Rows[0]["Name"].ToString(); model.PicUrl = ds.Tables[0].Rows[0]["PicUrl"].ToString(); model.Tips = ds.Tables[0].Rows[0]["Tips"].ToString(); model.EnglishName = ds.Tables[0].Rows[0]["EnglishName"].ToString(); model.FirstWord = ds.Tables[0].Rows[0]["FirstWord"].ToString(); if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } if (ds.Tables[0].Rows[0]["isLock"].ToString() != "") { model.isLock = int.Parse(ds.Tables[0].Rows[0]["isLock"].ToString()); } if (ds.Tables[0].Rows[0]["ParentId"].ToString() != "") { model.ParentId = int.Parse(ds.Tables[0].Rows[0]["ParentId"].ToString()); } model.ClassList = ds.Tables[0].Rows[0]["ClassList"].ToString(); if (ds.Tables[0].Rows[0]["ClassLayer"].ToString() != "") { model.ClassLayer = int.Parse(ds.Tables[0].Rows[0]["ClassLayer"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(TravelAgent.Model.VisaCountry model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update VisaCountry set "); strSql.Append("Name=@Name,"); strSql.Append("PicUrl=@PicUrl,"); strSql.Append("Tips=@Tips,"); strSql.Append("EnglishName=@EnglishName,"); strSql.Append("FirstWord=@FirstWord,"); strSql.Append("Sort=@Sort,"); strSql.Append("isLock=@isLock,"); strSql.Append("ParentId=@ParentId,"); strSql.Append("ClassList=@ClassList,"); strSql.Append("ClassLayer=@ClassLayer"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@PicUrl", SqlDbType.VarChar, 50), new SqlParameter("@Tips", SqlDbType.Text), new SqlParameter("@EnglishName", SqlDbType.VarChar, 50), new SqlParameter("@FirstWord", SqlDbType.VarChar, 50), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@isLock", SqlDbType.Int, 4), new SqlParameter("@ParentId", SqlDbType.Int, 4), new SqlParameter("@ClassList", SqlDbType.VarChar, 50), new SqlParameter("@ClassLayer", SqlDbType.Int, 4), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.Name; parameters[1].Value = model.PicUrl; parameters[2].Value = model.Tips; parameters[3].Value = model.EnglishName; parameters[4].Value = model.FirstWord; parameters[5].Value = model.Sort; parameters[6].Value = model.isLock; parameters[7].Value = model.ParentId; parameters[8].Value = model.ClassList; parameters[9].Value = model.ClassLayer; parameters[10].Value = model.Id; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
protected void Page_Load(object sender, EventArgs e) { int.TryParse(Request.QueryString["countryid"], out countryid); if (!this.IsPostBack) { TravelAgent.Model.InfoSetting info = new TravelAgent.Model.InfoSetting(); info.ds = bll.GetList(); divZYSX.InnerHtml = info.getValue("VisaZYSX"); if (countryid > 0) { TravelAgent.Model.VisaCountry country = CountryBll.GetModel(countryid); if (country != null) { strPicUrl = country.PicUrl; strVisaName = country.Name; this.Title = country.Name + "签证-" + Master.webinfo.WebName; } } } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(TravelAgent.Model.VisaCountry model) { VCDAL.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TravelAgent.Model.VisaCountry model) { VCDAL.Add(model); return(VCDAL.GetMaxID("Id")); }
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.VisaCity model = new TravelAgent.Model.VisaCity(); model.CityName = Request["txtCityName"]; model.Tips = Request["txtTips"]; model.Sort = Convert.ToInt32(Request["txtSort"]); model.isLock = Request["chkState"] == null?0:1; 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 == "country")//签证国家区域管理 { int c_editid = Convert.ToInt32(Request["hidId"]); int cId; int parentId = Convert.ToInt32(Request["ddlAreaCountry"]); //上一级目录 int Layer = 1; //栏目深度 string List = ""; TravelAgent.Model.VisaCountry country = new TravelAgent.Model.VisaCountry(); country.Name = Request["txtName"]; country.ParentId = parentId; country.PicUrl = Request["txtImgUrl"]; country.Tips = Request["txtTips"]; country.EnglishName = Request["txtEnglishName"]; country.FirstWord = Request["txtFristWord"]; country.ClassList = ""; country.Sort = Convert.ToInt32(Request["txtSort"]); country.isLock = Request["chkState"] == null?0:1; if (c_editid == 0) { //添加 cId = CountryBll.Add(country); } else { cId = c_editid; } //修改 if (parentId > 0) { DataSet ds = CountryBll.GetListByClassId(parentId); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; List = dr["ClassList"].ToString().Trim() + cId + ","; Layer = Convert.ToInt32(dr["ClassLayer"]) + 1; } } else { List = "," + cId + ","; Layer = 1; } country.Id = cId; country.ClassList = List; country.ClassLayer = Layer; try { CountryBll.Update(country); Response.Write("true"); } catch { Response.Write("false"); } } else if (strTag == "country_delete")//删除 { int destid = Convert.ToInt32(Request["countryid"]); try { CountryBll.Delete(destid); Response.Write("true"); } catch { Response.Write("false"); } } else if (strTag == "type_save")//签证类型保存 { int type_editid = Convert.ToInt32(Request["hidId"]); TravelAgent.Model.VisaType model = new TravelAgent.Model.VisaType(); model.Name = Request["txtName"]; model.Sort = Convert.ToInt32(Request["txtSort"]); model.isLock = Request["chkState"] == null?0:1; try { if (type_editid != 0) { model.Id = type_editid; TypeBll.Update(model); } else { TypeBll.Add(model); } Response.Write("true"); } catch { Response.Write("false"); } } else if (strTag == "type_delete")//签证类型删除 { int cityid = Convert.ToInt32(Request["typeid"]); try { TypeBll.Delete(cityid); Response.Write("true"); } catch { Response.Write("false"); } } else if (strTag == "visa_delete")//签证删除 { int visaid = Convert.ToInt32(Request["visaid"]); try { VisaBll.Delete(visaid); Response.Write("true"); } catch { Response.Write("false"); } } } } }