public static int u_id; //用户ID protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserCollect_Bll uc_b = new UserCollect_Bll(); Coures_Bll cb = new Coures_Bll(); Button1.Attributes.Add("onmouseout", "this.src='Images/index_btn.png'"); Button1.Attributes.Add("onmouseover", "this.src='Images/index_btn_hover.png'"); u_id = Convert.ToInt32(Session["ID"].ToString()); UserCollect uc = new UserCollect(); uc = uc_b.GetUserCollect(u_id); c_id = uc.C_ID; //Response.Write("<script>alert('" + c_id + "')</script>"); lab_view.Text = cb.GetCourse(c_id).C_NAME.ToString(); lab_view.DataBind(); //获取单词包名称 Bind(); //剩余天数 UserDownload ud = new UserDownload(); UserDownload_Bll ud_b = new UserDownload_Bll(); int count = ud_b.GetCount(Convert.ToInt32(Session["ID"]), c_id); lab_view_finish.Text = count.ToString(); lab_view_finish.DataBind();//完成单词数 lab_view_number.Text = cb.GetCourse(c_id).C_vocabulary.ToString(); lab_view_number.DataBind();//该单词包的总单词数 DateTime now = DateTime.Now.Date; DateTime ts = DateTime.Parse(uc_b.GetUserCollectUid(u_id).UC_StartDay.ToString()).Date; TimeSpan t1 = ts.Subtract(now); //计算开始时间到结束时间天数差 TimeSpan t2 = now.Subtract(now); //计算开始时间到结束时间天数差 lab_xinxue.Text = "0"; //if(t1!=t2) //{ // lab_xinxue.Text = "0"; //} //else //{ // lab_xinxue.Text = Convert.ToString(Session["xinxue"].ToString()); //} //获取今日新目标 lab_view_words.Text = uc_b.GetUserCollectUid(u_id).UC_EveWord.ToString(); lab_view_words.DataBind();//获取今日目标 Users_Bll ub = new Users_Bll(); Users u = new Users(); u = ub.GetUser(Convert.ToInt32(Session["ID"])); Lab_name.Text = u.U_NAME; } }
/// <summary> /// 登录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { try { Users u = new Users(); u.U_NAME = txt_Name.Text.Trim(); u.U_PASSWORD = txt_psd.Text.Trim(); //判断用户是否进行了输入 if (IfInput(u.U_NAME, u.U_PASSWORD)) { bool b = ub.ExistsUsers(u); if (b) { UserCollect_Bll uc_b = new UserCollect_Bll(); Response.Cookies["name"].Value = txt_Name.Text.Trim(); Session["ID"] = ub.QueryUserID(u).ToString(); u_id = Convert.ToInt32(Session["ID"].ToString()); Session["c_id"] = uc_b.GetUserCollectUid(u_id).C_ID.ToString();//与数据库中数据进行对比 Response.Write("<script>alert('登录成功');</script>"); if (Convert.ToInt32(Session["c_id"]) == 0) { Response.Redirect("Plan/Select.aspx", false); } else { Response.Redirect("Recite Words/start.aspx", false); } } else { Response.Write("<script>alert('登录失败');</script>"); } } } catch { } }