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