代码段1
protected void ButtonModifyPwd_Click(object sender, EventArgs e)
        {            
            bool result = BusinessFacade.UpdateCustomerPassWordstrCustomer, TextBoxNewPwd.Text);
            if (result == true)
            {
                Common.RegScript(Page, "密码修改成功!");
            }
            else
            {
                Common.RegScript(Page, "密码修改失败!");
            }
        }
代码段2,类属于BusinessFacade
public static bool UpdateCustomerPassWord(string strCustomerName, string strCustomerPassWord)
        {
            if (strCustomerName == "" || strCustomerPassWord == "")
                return false;
            using (DataAccess myDA = new DataAccess())
            {
                return myDA.UpdateCustomerPassWord(strCustomerName, strCustomerPassWord);
    
            }
        }
代码段3 类属于DataAccess中 public bool UpdateCustomerPassWord(string strCustomerName, string strCustomerPassWord)
        {
            bool Tag = false;
            SqlCommand comm = new SqlCommand("UpdateCustomerPassword", conn);
            comm.Parameters.AddWithValue("@strCustomerID", strCustomerName);
            comm.Parameters.AddWithValue("@strCustomerPassword", strCustomerPassWord);
            comm.CommandType = CommandType.StoredProcedure;
            conn.Open();
            if (comm.ExecuteNonQuery() > 0)
            {
                Tag = true;
            }
            comm.Dispose();
            conn.Close();
            return Tag;
        }
三段代码。我先自己分析一下,看有什么不对,大家给指正,
代码1里,定义了一个布尔变量result 并把后面调用代码2中方法的结果赋给它。
如果代码2里,strCustomerName和strCustomerPassWord都是空,则返回结果为fales.则代码里result的值也是fales,然后代码1显示的是修改密码失败
如果不为空,代码二调用代码三的方法,若代码三中ExecuteNonQuery() 返回值大于0,说明操作成功,则得到TURE结果。则代码1的result赋值为ture,然后显示修改成功。
我这个思路对么,请教高手