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); } } } }