using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.Infrastructure.Common; using CY.Model; using CY.BLL.Info; using CY.BLL; using CY.BLL.Sys; namespace CY.WebForm.Pages.member { public partial class Info_CompanyAdEdit : BasePage { Sys_DictionaryBLL _Sys_DictionaryBLL = null; Info_CompanyAdBLL _Info_CompanyAdBLL = null; public Info_CompanyAdEdit() { _Sys_DictionaryBLL = new Sys_DictionaryBLL(); _Info_CompanyAdBLL = new Info_CompanyAdBLL(); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { InitialData(); if (Request["Keyid"].ToInt32() > 0) { InitialModifyData(); } } } //下拉列表里面的数据 protected void InitialData() { this.selType.DataSource = _Sys_DictionaryBLL.GetDataByType("商家展示图片类型"); this.selType.DataTextField = "Name"; this.selType.DataValueField = "Keyid"; this.selType.DataBind(); this.selType.Items.Insert(0, new ListItem("请选择", "")); } protected void InitialModifyData() { Info_CompanyAd model = _Info_CompanyAdBLL.SelectSingleModel(Request["Keyid"].ToString2()); this.selType.Value = model.Type.ToString2(); this.txtLinkAdress.Value = model.LinkUrl; this.txtTittle.Value = model.Tittle; this.imgFileId.Src = model.PicUrl; this.trImg.Visible = string.IsNullOrEmpty(model.PicUrl) ? false : true; } protected void btn_Submit_Click(object sender, EventArgs e) { Info_CompanyAd model = new Info_CompanyAd(); if (Request["Keyid"].ToString2() != "") { model = _Info_CompanyAdBLL.SelectSingleModel(Request["Keyid"].ToString2()); } //else //{ //} //if (model == null) //{ // model = new Info_CompanyAd(); //} //图片上传 CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult2 = CY.WebForm.cs.UploadCS.Upload("FileId", model.PicUrl); model.PicUrl = model.PicUrl ?? ""; if (_UpFileResult2.returnerror.Count == 0) { if (_UpFileResult2.returnfilename.Count > 0) model.PicUrl = _UpFileResult2.returnfilename[0].ToString2(); } else { JavaScript.MessageBox(string.Join("
", (string[])_UpFileResult2.returnerror.ToArray(typeof(string))), this); return; } model.LinkUrl = txtLinkAdress.Value; model.Operator = CurrentUser.ShortName; model.Tittle = txtTittle.Value; model.Type = selType.Value.ToInt32(); model.CreateTime = DateTime.Now; model.FirmId = CurrentUser.MemberId; if (Request["Keyid"].ToInt32() > 0) { if (_Info_CompanyAdBLL.UpdateModel(model)) JavaScript.RefreshDIVOpener(this); else JavaScript.MessageBox("更新失败", this); } else { if (_Info_CompanyAdBLL.InsertModel(model)) JavaScript.MessageBox("添加成功", this, false,true); else JavaScript.MessageBox("操作失败", this); } } } }