Ejemplo n.º 1
0
 /// <summary>
 /// 把用户类和前台
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Button1_Click(object sender, EventArgs e)
 {
     YF.Model.User user = new YF.Model.User();
     user.Username = this.username.Text;
     user.Password = this.password.Text;
     user.Name     = this.name.Text;
     user.Address  = this.address.Text;
     user.Sex      = int.Parse(this.sex.Text);
     user.Mobile   = this.mobile.Text;
     user.Email    = this.email.Text;
     user.Qq       = this.qq.Text;
     user.Adddate  = DateTime.Now;
     user.Role     = this.role.Text;
     // when username already exists
     if (YF.BLL.User.usernameSearch(this.username.Text) == false)
     {
         YF.JsHelper.AlertAndRedirect("warning!username is already used!please change username and register again!", "register.aspx");
     }
     else
     {
         if (YF.BLL.User.add(user) == true)
         {
             YF.JsHelper.AlertAndRedirect("Congratulation!register successfully!", "login.aspx");
         }
         else
         {
             YF.JsHelper.AlertAndRedirect("warning!fail to register!", "register.aspx");
         }
     }
 }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        YF.Model.User myuser = new YF.Model.User();

        myuser = (YF.Model.User)YF.SessionHelper.GetSesstion("user"); // 读取我们在login.aspx.cs刚刚保存的值

        if (myuser != null)
        {
            this.username.Text = myuser.Username;
        }
        else
        {
            YF.JsHelper.AlertAndRedirect("no member!please login in", "/myweb/login.aspx");
        }
        // 判断会员登陆的话,直接跳转到会员中心,否则跳转到登陆界面
    }
Ejemplo n.º 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string username = this.username.Text, password = this.password.Text, role = this.role.Text;

        if (YF.BLL.User.loginSearch(username, password, role) == true)
        {
            YF.Model.User user = YF.BLL.User.GetUserbyname(username); //通过username 查询 返回一个实体对象user
            YF.SessionHelper.SetSession("user", user);                //记住对象,保存当前用户登录身份信息
            YF.JsHelper.AlertAndRedirect("login successfully!!!", "user/member.aspx");
            //YF.JsHelper.AlertAndRedirect("login successfully!!!", "user/member.aspx");
        }
        else
        {
            YF.JsHelper.AlertAndRedirect("warning!!!fail to login!", "login.aspx");
        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        YF.Model.User myuser = new YF.Model.User();

        myuser = (YF.Model.User)YF.SessionHelper.GetSesstion("user"); // 读取我们在login.aspx.cs刚刚保存的值

        // 判断商家登陆的话,直接跳转到管理界面,否则跳转到书店主业
        if (myuser.Role == "shop")
        {
            YF.JsHelper.Alert("Permissions enough!");
        }
        else
        {
            YF.JsHelper.AlertAndRedirect("Insufficient permissions!", "/myweb/bookShop.aspx");
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //向后台数据库加入记录,点击购买,购物车加
        YF.Model.User myuser = new YF.Model.User();
        myuser = (YF.Model.User)YF.SessionHelper.GetSesstion("user");//读取当前用户信息  //强制转为用户实体类型
        if (myuser != null)
        {
            YF.Model.Cart cart = new YF.Model.Cart(); // 声明空的购物车对象,然后要对购物车对象进行赋值
            // 通过id来查询
            int id = int.Parse(Request.QueryString["id"].ToString());

            YF.Model.Books books = YF.BLL.Books.GetBooks(id); // 通过我们传过来的商品id,找到商品实体

            cart.Books   = books;
            cart.User    = myuser;
            cart.Num     = 1;
            cart.State   = 0; // 0 代表还没有下单,只是加购物车
            cart.Adddate = DateTime.Now;

            // 当图书数量为0时,退出,重新选购
            if (books.Num <= 0)
            {
                YF.JsHelper.AlertAndRedirect("fail to add cart! Connect with shop!", "/myweb/bookshop.aspx");//库存为0,添加失败返回图书详情页面
            }

            if (YF.BLL.Cart.list(books.Id, myuser.Id, 0).Count > 0)                                // 当不是第一次插入的时候,只是更新数量就可以
            {
                YF.BLL.Cart.updatenum(books.Id, myuser.Id, 0);                                     //修改数量
                YF.JsHelper.AlertAndRedirect("add cart successfully!!!", "/myweb/user/cart.aspx"); //3,添加成功返回购物车页面
            }
            else // 第一次插入
            {
                if (YF.BLL.Cart.addbooks(cart))
                {
                    YF.JsHelper.AlertAndRedirect("add cart successfully!!!", "/myweb/user/cart.aspx");
                }
                else
                {
                    YF.JsHelper.AlertAndRedirect("fail to add cart successfully!!!", "/myweb/books.aspx");
                }
            }
        }
        else
        {
            YF.JsHelper.AlertAndRedirect("no member!please login in!!!", "/myweb/login.aspx");
        }
    }
Ejemplo n.º 6
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //订单信息保存到后台
        //正式下单

        // 通过用户id,查询此用户购物车信息
        YF.Model.User myuser = new YF.Model.User();
        myuser = (YF.Model.User)YF.SessionHelper.GetSesstion("user");

        // 生成订单编号,通过时间
        string orderid = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();

        // 声明空的订单对象
        YF.Model.Order myorder = new YF.Model.Order();

        //给订单对象赋值
        myorder.Id      = orderid;                      //赋值订单编号
        myorder.User    = myuser;                       //赋值当前用户信息
        myorder.Amount  = float.Parse(this.total.Text); //赋值总价
        myorder.State   = 1;                            //订单状态,0表示未付款
        myorder.Adddate = DateTime.Now;                 //订单时间

        // 更新库存
        List <YF.Model.Cart> list = YF.BLL.Cart.list(myuser.Id); //用户id/通过用户id,查询购物车信息,算出总价

        if (YF.BLL.Order.add(myorder))                           //把订单对象,调用业务层,插入数据
        {
            //遍历更新库存
            for (int i = 0; i < list.Count; i++)
            {
                YF.BLL.Books.update(list[i].Books.Id); //
            }

            //更新 清空 购物车
            YF.BLL.Order.update(orderid, myuser.Id, 0);


            YF.JsHelper.AlertAndRedirect("下单成功", "/myweb/user/order.aspx");
        }
        else
        {
            YF.JsHelper.AlertAndRedirect("下单失败", "/myweb/user/Order_add.aspx");
        }
    }
Ejemplo n.º 7
0
 /// <summary>
 /// when user click 'edit' button, the page will be loaded
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)//刷新页面
     {
         //保存了用户信息,将信息拿过来
         YF.Model.User myuser = new YF.Model.User();                   //声明空对象
         myuser = (YF.Model.User)YF.SessionHelper.GetSesstion("user"); //读取 强制转换类型
         //将信息赋值
         this.username.Text = myuser.Username;
         this.password.Text = myuser.Password;
         this.name.Text     = myuser.Name;
         this.address.Text  = myuser.Address;
         this.sex.Text      = myuser.Sex.ToString();
         this.mobile.Text   = myuser.Mobile;
         this.email.Text    = myuser.Email;
         this.qq.Text       = myuser.Qq;
         this.role.Text     = myuser.Role.ToString();
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// when user click 'edit' button, the page will be loaded
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     // IsPostBack 使得返回管理界面时数据已经刷新
     if (!IsPostBack)
     {
         string id = Request.QueryString["id"];
         // get user's all properties and data
         YF.Model.User user = YF.BLL.User.Getuser(int.Parse(id));
         this.username.Text = user.Username;
         this.password.Text = user.Password;
         this.name.Text     = user.Name;
         this.address.Text  = user.Address;
         this.sex.Text      = user.Sex.ToString();
         this.mobile.Text   = user.Mobile;
         this.email.Text    = user.Email;
         this.qq.Text       = user.Qq;
         this.id.Value      = user.Id.ToString();
         this.role.Text     = user.Role.ToString();
     }
 }
Ejemplo n.º 9
0
    /// <summary>
    /// 当跳转到此页面时
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        // 声明变量 总价
        float total = 0;

        // 获取当前未下单用户的信息(通过session对象)
        YF.Model.User myuser = new YF.Model.User();
        // 强制转换为User实体类型
        myuser = (YF.Model.User)YF.SessionHelper.GetSesstion("user");

        // 通过用户id,查询此用户购物车信息
        List <YF.Model.Cart> list = YF.BLL.Cart.list(myuser.Id);

        // 遍历求和 计算总价
        for (int i = 0; i < list.Count; i++)
        {
            total = total + list[i].Books.Price * list[i].Num; //i=i+1
        }

        // 把总价返回到前台显示出来
        this.total.Text = total.ToString();
    }
Ejemplo n.º 10
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     YF.Model.User user = new YF.Model.User();
     user.Username = this.username.Text;
     user.Password = this.password.Text;
     user.Name     = this.name.Text;
     user.Address  = this.address.Text;
     user.Sex      = int.Parse(this.sex.Text);
     user.Mobile   = this.mobile.Text;
     user.Email    = this.email.Text;
     user.Qq       = this.qq.Text;
     user.Id       = int.Parse(this.id.Value);
     user.Role     = this.role.Text;
     // when edit successfully
     if (YF.BLL.User.updateData(user) == true)
     {
         YF.JsHelper.AlertAndRedirect("edit successfully!", "index.aspx");
     }
     else
     {
         YF.JsHelper.AlertAndRedirect("fail to edit!", "index.aspx");
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 把数据传回数据库
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Button1_Click(object sender, EventArgs e)
 {
     //保存
     //当前登录对象
     YF.Model.User user = new YF.Model.User();
     user = (YF.Model.User)YF.SessionHelper.GetSesstion("user");//读取   //强制转
     //新的数据重新赋值赋值
     user.Password = this.password.Text;
     user.Name     = this.name.Text;
     user.Address  = this.address.Text;
     user.Sex      = int.Parse(this.sex.Text);
     user.Mobile   = this.mobile.Text;
     user.Email    = this.email.Text;
     user.Qq       = this.qq.Text;
     //调后台方法更新
     if (YF.BLL.User.updateData(user))
     {
         YF.JsHelper.AlertAndRedirect("用户信息修改成功", "/myweb/login.aspx");
     }
     else
     {
         YF.JsHelper.AlertAndRedirect("用户信息修改失败", "useredit.aspx");
     }
 }