计算机毕业设计介绍:
5.3 利用存储过程管理角色部分代码
con.ConnectionString = db.getconstr();
sqlstr = "select * from vwRole where roleName='" + this.droprole.SelectedItem.Text + "' and 用户序号='" + Session["uid"].ToString() + "'";
ds = db.getdatadysql(sqlstr);
if (ds.Tables[0].Rows.Count != 0)
{
this.labmsg.Text = "";
}
else
{
if (Session["j"].Equals("1"))
{
com = new SqlCommand("proInsertRole", con);
com.CommandType = CommandType.StoredProcedure;
param = com.Parameters.Add("@urolename", SqlDbType.NVarChar, 50);
param.Value = this.droprole.SelectedItem.Text.ToString();
param = com.Parameters.Add("@uid", SqlDbType.Int);
param.Value = int.Parse(Session["uid"].ToString());
param = com.Parameters.Add("@ulimit", SqlDbType.NVarChar, 50);
param.Value = this.tbulimit.Text.ToString();
con.Open();
com.ExecuteNonQuery();
con.Close();
this.labmsg.Text = "";
this.Panel1.Visible = false;
}
else
{
com = new SqlCommand("proUpdateRole", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@urolename", SqlDbType.NVarChar, 50);
com.Parameters.Add("@uid", SqlDbType.Int);
com.Parameters.Add("@ulimit", SqlDbType.NVarChar, 50);
com.Parameters.Add("@uroleid", SqlDbType.Int);
com.Parameters["@urolename"].Value = this.droprole.SelectedItem.Text.ToString();
com.Parameters["@uid"].Value = int.Parse(Session["uid"].ToString());
com.Parameters["@ulimit"].Value = this.tbulimit.Text.ToString();
com.Parameters["@uroleid"].Value = int.Parse(Session["rid"].ToString());
con.Open();
com.ExecuteNonQuery();
con.Close();
this.labmsg.Text = "";
this.Panel1.Visible = false;
}
sqlstr = "select * from vwRole where 用户序号='" + Session["uid"].ToString() + "'";
databind();
}
Session["rid"] = null;
<责任编辑:计算机毕业设计网(http://www.xiaoniu168.com)>