62,046
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (Session["id"] == null)
{
Response.Redirect("login.aspx");
}
if (!IsPostBack)
{
//获取用户信息
username = ClassLibrary2.test.getusername(Session["id"].ToString().Trim());
DataSet ds = ClassLibrary2.test.getdefinfo(Session["id"].ToString(),Session["compid"].ToString());
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
GridView2.DataSource = ds.Tables[1];
GridView2.DataBind();
GridView3.DataSource = ds.Tables[2];
GridView3.DataBind();
GridView4.DataSource = ds.Tables[3];
GridView4.DataBind();
// usertype = ClassLibrary2.test.getusertype(Session["id"].ToString().Trim());
}
}
static public DataSet getdefinfo(string id, string compid)
{
DataSet ds = new DataSet();
string strcon = System.Configuration.ConfigurationManager.AppSettings["conn"];
using (SqlConnection conn = new SqlConnection(strcon))
{
SqlCommand comm = new SqlCommand("getdefinfo", conn);
comm.CommandType = CommandType.StoredProcedure;
if (compid != "")
{
SqlParameter p2 = new SqlParameter("@compid", SqlDbType.NVarChar, 50);
p2.Direction = ParameterDirection.Input;
p2.Value = compid;
comm.Parameters.Add(p2);
}
if (id != "")
{
SqlParameter p2 = new SqlParameter("@id", SqlDbType.NVarChar, 50);
p2.Direction = ParameterDirection.Input;
p2.Value = id;
comm.Parameters.Add(p2);
}
try
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(comm);
da.Fill(ds);
}
catch (Exception ex)
{ throw ex; }
finally
{
conn.Close();
}
}
return ds;
}