17,741
社区成员
发帖
与我相关
我的任务
分享
private void Fopenoa_Load(object sender, EventArgs e)
{
//取得用户名密码
string filetext = "";
string filepath = path + "//config.txt";
string username = "";
string pwd = "";
FileStream fs1 = new FileStream(filepath, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs1, System.Text.Encoding.GetEncoding("GB2312"));
string line = sr.ReadLine();
int i = 1;
while (line != null)
{
filetext += line + " ";
line = sr.ReadLine();
if (i == 1)
{
username = filetext;
}
else
{
pwd = filetext;
}
filetext = "";
i = i + 1;
}
sr.Close();
fs1.Close();
webBrowser1.Navigate("http://127.0.0.1/mainfram_oa.aspx?tusername=" + username + "&" + "tpwd=" + pwd + "");
}
protected void Page_Load(object sender, EventArgs e)
{
Session.Clear();
string username = Request.QueryString["tusername"].ToString();
string pwd = Request.QueryString["tpwd"].ToString();
if (username.ToString().Trim() == "")
{
Response.Write("<script>function window.onload(){mainfram.location.href='login.aspx';}</script>");
return;
}
if (username.ToString().Trim() == "姓名")
{
Response.Write("<script>function window.onload(){mainfram.location.href='login.aspx';}</script>");
return;
}
DateTime ndate = DateTime.Now;
//密码使用md5加密
iSunHash my_iSunHash_class = new iSunHash();
pwd = my_iSunHash_class.strHashMd5(pwd, Encoding.ASCII);
string strSQL = "SELECT * FROM dbo.tb_user INNER JOIN dbo.tb_department ON dbo.tb_user.departmentcode = dbo.tb_department.departmentcode INNER JOIN dbo.Tb_role ON dbo.tb_user.Tu_roleid = dbo.Tb_role.Tr_roleid INNER JOIN dbo.Tb_position ON dbo.tb_user.Tu_position = dbo.Tb_position.Tp_zhiweiid WHERE (dbo.tb_user.username = @username) and (dbo.tb_user.password = @pwd)";
Session["susername"] = "";
SqlCommand cmd = new SqlCommand(strSQL, connection);
cmd.Parameters.AddWithValue("@username", username);
cmd.Parameters.AddWithValue("@pwd", pwd);
connection.Open();
SqlDataReader myReader = cmd.ExecuteReader();
if (myReader.Read())
{
Session["suserid"] = myReader["userid"].ToString();
Session["struename"] = myReader["truename"].ToString();
Session["szhiweiname"] = myReader["Tp_zhiweiname"].ToString();
Session["spositionid"] = myReader["Tp_zhiweiid"].ToString();
Session["srolename"] = myReader["Tr_rolename"].ToString();
Session["sdepname"] = myReader["departmentname"].ToString();
Session["sdepcode"] = myReader["departmentcode"].ToString();
Session["spagename"] = "回到首页";
Session["susername"] = username;
}
myReader.Close();
cmd.Dispose();
connection.Close();
if (Session["susername"].ToString() != "")
{
Response.Write("<script>function window.onload(){mainfram.location.href='default.aspx';}</script>");
}
else
{
Response.Write("<script>function window.onload(){mainfram.location.href='login.aspx';}</script>");
}
}
,在ie6和ie7中是可以取得用户名和密码进入default.aspx页面的,而在ie8中运行winfrom程序,第一次是可以进入的,但是第一次之后就不能进入'default.aspx'了,而是进入'login.aspx'页面。有谁知道为什么呀,谢谢了。。。<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />