username@email.com
2025-05-12 ae6e40362a745caef9ead36f81f38313fb8c2c66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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("<br/>", (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);
            }
        }
    }
}