Exemplo n.º 1
0
    protected void Btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            //取得登入user資料
            databind();

            #region 取得畫面元件的值

            //新密碼 = 登入者帳號 
            DateTime processtime = DateTime.Now;

            //密碼解密
            SYSModel.CryptographyHelper Cry = new SYSModel.CryptographyHelper();
            string UserPwd = Cry.Decrypt(dt_Result.Rows[0]["PASSWORD"].ToString());

            #endregion


            if (TextBoxOldPassword.Text != UserPwd)
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('舊密碼不正確');", true);
            }

            else if (TextBoxNewPassword.Text != TextBoxConfirmNewPassword.Text)
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('新密碼與確認新密碼不一致');", true);
            }
            else if (TextBoxNewPassword.Text.Length < 8)
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('新密碼不可小於8碼');", true);            
            }
            else
            {

                //密碼加密
                string CryPassword = Cry.Encrypt(TextBoxNewPassword.Text);

                #region 加入更新條件

                ParameterList.Clear();

                //舊值
                ParameterList.Add(dt_Result.Rows[0]["ID"]);
                ParameterList.Add(dt_Result.Rows[0]["CODE"]);
                ParameterList.Add(dt_Result.Rows[0]["NAME"]);
                ParameterList.Add(dt_Result.Rows[0]["CREATEDATE"]);
                ParameterList.Add(dt_Result.Rows[0]["CREATEUID"]);
                ParameterList.Add(dt_Result.Rows[0]["UPDATEDATE"]);
                ParameterList.Add(dt_Result.Rows[0]["UPDATEUID"]);
                ParameterList.Add(dt_Result.Rows[0]["ENABLE"]);
                ParameterList.Add(dt_Result.Rows[0]["PASSWORD"]);
                ParameterList.Add(dt_Result.Rows[0]["MEMO"]);

                //需要更新值
                ParameterList.Add(dt_Result.Rows[0]["NAME"]);
                ParameterList.Add(processtime);
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(CryPassword);
                ParameterList.Add(dt_Result.Rows[0]["MEMO"]);
                #endregion


                SYSModel.MaintainUser BCO = new SYSModel.MaintainUser(ConnectionDB);

                int UpdateRecord = BCO.UpdateUser(ParameterList, null);

                if (UpdateRecord == 0)
                {
                    throw new Exception("更新0筆資料!");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('更改完成');", true);
                }
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;            
        }

    }
Exemplo n.º 2
0
    /// <summary>
    /// 複製鈕 帶入新增資料
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void FormView1_DataBound(object sender, EventArgs e)
    {
        //密碼解密
        if (FormView1.CurrentMode == FormViewMode.Edit)// || FormView1.CurrentMode == FormViewMode.ReadOnly)
        {
            SYSModel.CryptographyHelper Cry = new SYSModel.CryptographyHelper();
            ((TextBox)FormView1.FindControl("TextBoxPassword")).Text =
               Cry.Decrypt(((TextBox)FormView1.FindControl("TextBoxPassword")).Text);

        }
    }
Exemplo n.º 3
0
    }//end EditUserButton_Click

    /// <summary>
    /// 複製鈕 帶入新增資料
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void FormView1_DataBound(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";
        //密碼解密
        if (FormView1.CurrentMode == FormViewMode.Edit) //|| FormView1.CurrentMode == FormViewMode.ReadOnly)
        {
            try
            {
                SYSModel.CryptographyHelper Cry = new SYSModel.CryptographyHelper();
                ((TextBox)FormView1.FindControl("TextBoxPassword")).Text =
                   Cry.Decrypt(((TextBox)FormView1.FindControl("TextBoxPassword")).Text);
            }
            catch (Exception ex)
            {
                // 如果不是用加密insert資料 檢視時不解密                        
            }
        }
    }