0

我有 3 层,在业务层中执行我的代码我运行代码进行更新

public override bool LoadProperties2List(string TypeOfOperation)
{
  SortedList Sl = new SortedList();

  Sl.Add("@CommandType", TypeOfOperation);
  Sl.Add("@UserName",UserName);
  Sl.Add("@SecondarySchool",SecondarySchool);
  Sl.Add("@University",University);
  Sl.Add("@Qualification",Qualification);
  Sl.Add("@JobTitle",JobTitle);
  Sl.Add("@Company",Company);
  Sl.Add("@PhotoUrl", PhotoUrl);

  ProcedureName = "MangeUserInfo";
  if (db.RunProcedure(ProcedureName, Sl) == 1)
  return true;
  else
  return false;
}

public bool updateUser(string User, string SecondaryS, string Unvi, string Qua, string jobtitle, string company)
{
  this.UserName = User;
  this.SecondarySchool = SecondaryS;
  this.University = Unvi;
  this.Qualification = Qua;
  this.JobTitle = jobtitle;
  this.Company = company;

  if (Update())
  return true;
  else
  return false;
 }

在数据访问层

public void ConnectDB(CommandType CT,string ProNameSQl)
{
  cn = new SqlConnection("Data Source=.;Initial Catalog=Conversation;Integrated Security=True");
  cmd = new SqlCommand();

  cmd.Connection = cn;
  cmd.CommandType = CT;
  cmd.CommandText = ProNameSQl;
  cn.Open();
}

public int RunProcedure(string ProcedureName, SortedList Paraval)
{
  ConnectDB(CommandType.StoredProcedure, ProcedureName);

  for (int x = 0; x < Paraval.Count; x++)
  {
  try
  {

  cmd.Parameters.AddWithValue(Paraval.GetKey(x).ToString(), Paraval.GetByIndex(x));
  }
  catch
  {
  ;
  }
  }
  return ExceNoneQuery();
}

然后在另一层我使用这个方法来调用程序进程类型并运行

public bool Update()
{
  return LoadProperties2List("u");
  }

最后一层表示层

我这样做

protected void btnsave_Click(object sender, EventArgs e)
{
  //upadate info
  bool Result = false;
  UsersInfo Upd = new UsersInfo();

  try
  {
  Result = Upd.updateUser(username, TxtSecondarySchool.Text, TxtUniversity.Text, TxtQualification.Text, TxtJobTitle.Text, TxtCompany.Text);
  if (Result==true)

  lblMessage.Text = "Record Updated Successfully.";

  else

  lblMessage.Text = "Record couldn't updated";

  }
  catch (Exception ee)
  {
  lblMessage.Text = ee.Message.ToString();
  }  finally
  {
  Upd = null;
  }
}

当我运行代码时,只有结果是

lblMessage.Text = "Record couldn't updated"; 

导致它无法正常工作的错误是什么?

我还发现一些奇怪的东西,文本框不采用新值它传递相同的值,尽管改变了为什么?我需要帮助

4

1 回答 1

2

错误是文本框加载到 Page 的 Startup 事件中的例程中,而例程放置在 If IsNotPostback 循环之外。因此,每次刷新页面时默认值都会重新加载,因此看起来是“不可更改的”。

于 2013-08-05T15:53:18.507 回答