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
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.DESEncrypt;
using CY.Infrastructure.Query;
using CY.Infrastructure;
 
namespace CY.WebForm.Pages.soft
{
    //吴辉
    //新增/修改软件激活码    
    public partial class KeyCodeAdd : BasePage
    {
        Soft_KeyCodeBLL bll_Soft_KeyCodeBLL = null;
        Soft_ManageBLL bll_Soft_ManageBLL = null;
 
        //初始化
        public KeyCodeAdd()
        {
            bll_Soft_KeyCodeBLL = new Soft_KeyCodeBLL();
            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("请选择", ""));
        }
 
        //表单提交
        protected void btn_submit_form(object sender, EventArgs e)
        {
            try
            {
                DateTime nowTime = DateTime.Now;
                Soft_KeyCode m_Soft_KeyCode = new Soft_KeyCode();
 
                m_Soft_KeyCode.KeyMachineCode = "";
                m_Soft_KeyCode.KeyUseIP = "";
                m_Soft_KeyCode.KeyClientId = 0;
                m_Soft_KeyCode.KeyClientName = "";
                m_Soft_KeyCode.LastUpdateTime = nowTime;
                m_Soft_KeyCode.Operator = CurrentUser.ShortName;
                m_Soft_KeyCode.KeySoftId = this.txtSoftTypeId.SelectedValue.ToInt32();
                m_Soft_KeyCode.KeySoftName = this.txtSoftTypeId.SelectedItem.Text;
                m_Soft_KeyCode.KeyStatus = 1;
                m_Soft_KeyCode.KeyProxyId = 0;
                m_Soft_KeyCode.KeyCreatTime = nowTime;
                m_Soft_KeyCode.KeyOutTime = nowTime;
                m_Soft_KeyCode.KeyUseTime = nowTime;
                m_Soft_KeyCode.KeyWord = this.txtKeyWord.Value;
                m_Soft_KeyCode.KeyOldNum = this.txtKeyUseIP.Value.ToInt32();
                m_Soft_KeyCode.KeyNewNum = this.txtKeyUseIP.Value.ToInt32();
                m_Soft_KeyCode.KeyUpTime = nowTime;
                m_Soft_KeyCode.KeyTryTime = nowTime;
 
                for (int i = 0; i < this.txtNum.Value.ToInt32(); i++)
                {
                    m_Soft_KeyCode.KeyCode = MathRandom.RandomStringBig(4) + "-" + MathRandom.RandomStringBig(4) + "-" + MathRandom.RandomStringBig(4) + "-" + MathRandom.RandomStringBig(4);
                    if (!bll_Soft_KeyCodeBLL.InsertModel(m_Soft_KeyCode))
                    {
                        JavaScript.MessageBox("生成失败", this);
                        return;
                    }
                }
                JavaScript.MessageBox("生成成功", this, true, true);
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("生成失败", this);
            }
        }
    }
}