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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DBUtility;
using gregn6Lib;
 
namespace BaseSet
{
    public partial class OF_ReceiveExpressPassWord : Form
    {
        public OF_ReceiveExpressPassWord()
        {
            InitializeComponent();
        }
        private int HItemIDCol = 0;
        private int HUserNameCol = 0; 
        public DBUtility.frm_B_BillQueryCondition_New frmCondition;
        public const string ViewName = "h_v_OF_ReceiveExpressPassWordList";
        public string CheckProcName = "h_p_OF_ReceiveExpressPassWord"; //20141020
        public string ModName = "收件密码";
        public const string BillName = "OF_ReceiveExpressPassWord";
        public const string ModRightNameEdit = BillName + "_Edit";
        public const string ModRightNameDelete = BillName + "_Delete";
 
        public DBUtility.ClsPub.Enum_InputMode InputMode;  //录入状态标志(0-非录入状态 1-增加 2-修改)
        public long  HItemID;//项目ID
        public string sCondition; //过滤条件
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;     //单据状态(新增,修改,浏览,更新单价,变更)
        DAL.ClsOF_ReceiveExpressPassWord_Ctl oRouting = new DAL.ClsOF_ReceiveExpressPassWord_Ctl();
        DAL.ClsOF_ReceiveExpressPassWord_View oRoutingHlp = new DAL.ClsOF_ReceiveExpressPassWord_View();
        TreeNode CurNode = new TreeNode(); 
       
        public void Sub_ClearBill()
        {
            //DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
            //
            txtHUserName.Text = ClsPub.CurUserName;
        }
       
        #region 类的读写
 
        private bool AllowSave()
        {
            if (txtHUserName.Text.Trim() == "")
            {
                MessageBox.Show("用户名不能为空!", "提示");
                return false;
            }
            if (txtHExpressPsd.Text.Trim() == "")
            {
                MessageBox.Show("新密码不能为空!", "提示");
                return false;
            }
            //审核代码是否合理
            if (!DBUtility.ClsPub.AllowNumber(txtHExpressPsd.Text.Trim()))
            {
                MessageBox.Show("代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示");
                return false;
            }
 
           
            return true;
        }
 
        //读取类 到 控件
        private void ShowData(long sItemID)
        { 
            if (oRoutingHlp.GetInfoByID(sItemID))
            {
                txtHUserName.Text = ClsPub.CurUserName;
                
                HItemID = oRoutingHlp.omodel.HItemID;
            }
        }
        //写入类 从控件
        private bool WriteClass()
        { 
            //判断是否允许 保存
            if (!AllowSave())
            {
                return false;
            }
            //检查父级是否存在
            string sParent;
            sParent = DBUtility.ClsPub.GetParentCode(txtHUserName.Text.Trim());
            if (sParent.Trim() == "")
            {
                oRouting.oModel.HParentID = 0;
            }
            else
            {
                if (oRouting.HavParentCode(sParent.Trim(), HItemID))
                {
                    oRouting.oModel.HParentID = oRouting.oModel.HItemID;
                }
                else
                {
                    MessageBox.Show("上级代码不存在或被禁用!", "提示");
                    return false;
                }
            }
            //得到短代码
            string sShortNumber;
            sShortNumber = DBUtility.ClsPub.GetShortNumber(txtHUserName.Text.Trim());
            if (sShortNumber.Trim() == "")
            {
                return false;
            }
            //保存原代码
            if (oRoutingHlp.GetInfoByID(HItemID))
            {
                oRouting.HOldNumber = oRoutingHlp.omodel.HNumber;
                //是否新代码是自己子项目的 子项目
                if (sParent.Length >= oRouting.HOldNumber.Length)
                {
                    if (sParent.Substring(0, oRouting.HOldNumber.ToString().Length) == oRouting.HOldNumber.Trim())
                    {
                        MessageBox.Show("新代码不能是自己的下级的子项目!", "提示");
                        return false;
                    }
                }
            }
            else
            {
                oRouting.HOldNumber = "";
            }
 
            //写入信息
            oRouting.oModel.HShortNumber = sShortNumber;
            oRouting.oModel.HExpressPsd = txtHExpressPsd.Text.Trim();
            oRouting.oModel.HUserName = txtHUserName.Text.Trim();
            return true;
        }
        #endregion
     
        //保存
        private bool Save()
        {
            //判断权限
            if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return false;
            }
            
            //if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_Modify)
            //{
            if (!oRouting.AddNew())
                {
                    return false;
                }
                //Display();
            //}
            return true;
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.txtHExpressPsd.Text.Trim() == this.txtHExpressPsd2.Text.Trim())
            {
                if (!WriteClass())
                    return;
                if (Save())
                {
                    MessageBox.Show("保存完毕!", "提示");
                }
                else
                {
                    MessageBox.Show("保存失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
                }
                if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_Modify)
                {
                    InputMode = DBUtility.ClsPub.Enum_InputMode.InputMode_View;
                    //RefreshTool();
                }
            }
            else
            {
                txtHExpressPsd.Text = "";
                txtHExpressPsd2.Text = "";
                MessageBox.Show("二次密码不一致,请重新输入!");
            }
        }
 
        private void OF_ReceiveExpressPassWord_Load(object sender, EventArgs e)
        {
            Sub_ClearBill();
        }
 
 
        #region 界面控件处理
        
 
        #endregion
 
     
 
        
    }
}