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
140
141
142
143
144
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;
using CY.Infrastructure.DESEncrypt;
 
namespace CY.WebForm.Pages.soft
{
    //吴辉
    //新增/修改软件客户    
    public partial class ClientAdd : BasePage
    {
        Soft_ClientBLL bll_Soft_ClientBLL = null;
        public string Province = ""; //接收值 Request["selectProvince"].ToString2();
        public string City = "";//接收值 Request["selectCity"].ToString2();
        public string County = "";//接收值 Request["selectCounty"].ToString2();
 
        //初始化
        public ClientAdd()
        {
            bll_Soft_ClientBLL = new Soft_ClientBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }
 
        //数据加载
        public void InitData()
        {
            Soft_Client m_Soft_Client = bll_Soft_ClientBLL.GetModelByKeyid(Request["keyid"].ToInt32());
            if (m_Soft_Client != null)
            {
                this.txtClientName.Value = m_Soft_Client.ClientName.ToString2();
                this.txtClientPhone.Value = m_Soft_Client.ClientPhone.ToString2();
                this.txtClientQQ.Value = m_Soft_Client.ClientQQ.ToString2();
                this.txtClientMobile.Value = m_Soft_Client.ClientMobile.ToString2();
                Province = m_Soft_Client.ClientProvince.ToString2();
                City = m_Soft_Client.ClientCity.ToString2();
                County = m_Soft_Client.ClientCountry.ToString2();
                this.txtClientAddress.Value = m_Soft_Client.ClientAddress.ToString2();
                this.txtClientPostcode.Value = m_Soft_Client.ClientPostcode.ToString2();
                this.txtLoginId.Value = m_Soft_Client.LoginId;
                this.txtRegDate.Value = m_Soft_Client.RegisterDate.Value.ToString("yyyy-MM-dd");
                this.txtEmail.Value = m_Soft_Client.ClientEmail;
                this.selPwdReset.Value = "1";
                this.selStatus.Value = (string.IsNullOrEmpty(m_Soft_Client.UseState.ToString2()) ? "1" : m_Soft_Client.UseState.ToString2());
            }
            else
            {
                this.txtEmail.Value = "";
                this.txtClientName.Value = "";
                this.txtClientPhone.Value = "";
                this.txtClientQQ.Value = "";
                this.txtClientMobile.Value = "";
                this.txtClientAddress.Value = "";
                this.txtClientPostcode.Value = "";
                this.txtLoginId.Value = "";
                this.selPwdReset.Value = "1";
                this.selStatus.Value = "1";
                this.txtRegDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
            }
        }
 
        //表单提交
        protected void btn_submit_form(object sender, EventArgs e)
        {
            try
            {
                DateTime nowTime = DateTime.Now;
                Soft_Client m_Soft_Client = bll_Soft_ClientBLL.GetModelByKeyid(Request["keyid"].ToInt32());
                if (m_Soft_Client == null)
                {
                    m_Soft_Client = new Soft_Client();
                    m_Soft_Client.ClientProxyId = 0;
                    m_Soft_Client.ClientStatus = 2;
                    m_Soft_Client.ClientType = 2;
                    m_Soft_Client.ClientIsMember = 1;
                    m_Soft_Client.ClientMemberId = Guid.NewGuid();
                    m_Soft_Client.ClientCreatTime = nowTime;
                    m_Soft_Client.Password = DESEncrypt.Encrypt("123456+");
                    m_Soft_Client.RegisterDate = nowTime;
                }
 
                if (this.selPwdReset.Value == "2" || string.IsNullOrEmpty(m_Soft_Client.Password))
                {
                    m_Soft_Client.Password = DESEncrypt.Encrypt("123456+");
                }
 
                m_Soft_Client.ClientName = this.txtClientName.Value.ToString2();
                m_Soft_Client.ClientPhone = this.txtClientPhone.Value.ToString2();
                m_Soft_Client.ClientQQ = this.txtClientQQ.Value.ToString2();
                m_Soft_Client.ClientMobile = this.txtClientMobile.Value.ToString2();
                m_Soft_Client.ClientProvince = Request["selectProvince"].ToString2();
                m_Soft_Client.ClientCity = Request["selectCity"].ToString2();
                m_Soft_Client.ClientCountry = Request["selectCounty"].ToString2();
                m_Soft_Client.ClientAddress = this.txtClientAddress.Value.ToString2();
                m_Soft_Client.ClientPostcode = this.txtClientPostcode.Value.ToString2();
                m_Soft_Client.ClientEndTime = nowTime;
                m_Soft_Client.LastUpdateTime = nowTime;
                m_Soft_Client.Operator = CurrentUser.ShortName;
                m_Soft_Client.LoginId = this.txtLoginId.Value;
                m_Soft_Client.UseState = this.selStatus.Value.ToInt32();
                m_Soft_Client.ClientEmail = this.txtEmail.Value;
 
                if (Request["keyid"].ToInt32() > 0)
                {
                    if (bll_Soft_ClientBLL.UpdateModel(m_Soft_Client))
                        JavaScript.MessageBox("更新成功", this, true, true);
                    else
                        JavaScript.MessageBox("更新失败", this);
                }
                else
                {
                    if (bll_Soft_ClientBLL.InsertModel(m_Soft_Client))
                    {
                        JavaScript.MessageBox("新增成功", this, false, true);
                        InitData();
                    }
                    else
                        JavaScript.MessageBox("新增失败", this);
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
    }
}