username@email.com
2025-05-14 99ddfbcecf0fa2881eb3a91028257eef87dab6de
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using CY.Model;
using CY.BLL;
using CY.Infrastructure.Common;
using CY.Infrastructure.Query;
 
namespace CY.WebForm.Pages.soft
{
    //吴辉
    //新增/修改软件版本    
    public partial class VersionAdd : BasePage
    {
        Soft_VersionBLL bll_Soft_VersionBLL = null;
        Soft_ManageBLL bll_Soft_ManageBLL = null;
 
        //初始化
        public VersionAdd()
        {
            bll_Soft_VersionBLL = new Soft_VersionBLL();
            bll_Soft_ManageBLL = new Soft_ManageBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }
 
        //数据加载
        public void InitData()
        {
            Pagination pa = new Pagination();
            pa.PageSize = 500;
            pa.PageIndex = 1;
            this.txtSoftTypeId.DataSource = bll_Soft_ManageBLL.SelectModelPage(pa, null, null, null, null, null, null);
            this.txtSoftTypeId.DataTextField = "SoftName";
            this.txtSoftTypeId.DataValueField = "Keyid";
            this.txtSoftTypeId.DataBind();
            this.txtSoftTypeId.Items.Insert(0, new ListItem("请选择", ""));
 
            this.txtSoftTypeId.SelectedValue = "";
            this.txtSoftVersion.Value = "";
 
        }
 
        //表单提交
        protected void btn_submit_form(object sender, EventArgs e)
        {
            try
            {
                DateTime nowTime = DateTime.Now;
                Soft_Version m_Soft_Version = bll_Soft_VersionBLL.GetModelByKeyid(Request["keyid"].ToInt32());
                Soft_Manage m_Soft_Manage = bll_Soft_ManageBLL.GetModelByKeyid(this.txtSoftTypeId.SelectedValue.ToInt32());
                if (m_Soft_Version == null)
                {
                    m_Soft_Version = new Soft_Version();
                    m_Soft_Version.SoftCreatTime = nowTime;
                    m_Soft_Version.SoftUpCount = 0;
                }
 
                m_Soft_Version.SoftTypeId = this.txtSoftTypeId.SelectedValue.ToInt32();
                m_Soft_Version.SoftName = this.txtSoftTypeId.SelectedItem.Text.ToString2();
                m_Soft_Version.SoftVersion = this.txtSoftVersion.Value.ToString2();
 
                //图片上传
                CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult2 = CY.WebForm.cs.UploadCS.UploadSoftVersion("txtSoftUrl", m_Soft_Version.SoftVersion, m_Soft_Manage.SoftContent);
                m_Soft_Version.SoftUrl = m_Soft_Version.SoftUrl ?? "";
                if (_UpFileResult2.returnerror.Count == 0)
                {
                    if (_UpFileResult2.returnfilename.Count > 0)
                        m_Soft_Version.SoftUrl = _UpFileResult2.returnfilename[0].ToString2();
                }
                else
                {
                    JavaScript.MessageBox(string.Join("<br/>", (string[])_UpFileResult2.returnerror.ToArray(typeof(string))), this);
                    return;
                }
 
                m_Soft_Version.SoftUrl = this.txtSoftUrl.Value.ToString2();
 
                m_Soft_Version.SoftStoreAddress = "";
                m_Soft_Version.SoftContent = "";
                m_Soft_Version.LastUpdateTime = nowTime;
                m_Soft_Version.Operator = CurrentUser.ShortName;
 
                if (Request["keyid"].ToInt32() > 0)
                {
                    if (bll_Soft_VersionBLL.UpdateModel(m_Soft_Version))
                        JavaScript.MessageBox("更新成功", this, true, true);
                    else
                        JavaScript.MessageBox("更新失败", this);
                }
                else
                {
                    if (bll_Soft_VersionBLL.InsertModel(m_Soft_Version))
                    {
                        JavaScript.MessageBox("新增成功", this, false, true);
                        InitData();
                    }
                    else
                        JavaScript.MessageBox("新增失败", this);
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
 
        protected void txtSoftTypeId_SelectedIndexChanged(object sender, EventArgs e)
        {
            Pagination pa = new Pagination();
            pa.PageSize = 500;
            pa.PageIndex = 1;
            List<Soft_Version> m_Soft_VersionList = bll_Soft_VersionBLL.SelectModelPage(pa, this.txtSoftTypeId.SelectedValue.ToInt32(), "", "", "", "", "", null, null, null, null, null, null, "") as List<Soft_Version>;
            if (m_Soft_VersionList == null || m_Soft_VersionList.Count == 0)
            {
                this.txtSoftVersion.Value = "1.0";
            }
            else
            {
                string VerString = (m_Soft_VersionList[0].SoftVersion.Replace(".", "").ToInt32() + 1).ToString2();
                string newVerString = VerString.Insert((VerString.Length - 1),".");
                this.txtSoftVersion.Value = newVerString;
            }
        }
    }
}