Exemple #1
0
        protected void btnReg_Click(object sender, EventArgs e)
        {
            #region 数据操作类

            string        strsql = string.Format("select * from [dbo].[user] where userName = '******'", txtAccount.Text);
            SqlDataReader myread = DbManger.ExceRead(strsql);
            if (myread.Read())
            {
                Response.Write("<script>alert('该用户已存在!')</script>");
            }
            else
            {
                #region 数据库连接数据库
                string username = txtAccount.Text;
                string pwd      = txtPassword.Text;
                string address  = txtAddress.Text;
                string tel      = txtTel.Text;
                string zip      = txtPostCode.Text;
                string email    = txtEmail.Text;
                string regDate  = DateTime.Now.ToShortDateString();
                strsql = string.Format("insert into [dbo].[user] values ('{0}' ,'{1}','{2}' ,'{3}' ,'{4}' ,'{5}','','{6}')", username, pwd, tel, email, address, zip, regDate);

                //执行命令对象,返回数据阅读器
                if (DbManger.ExceSQL(strsql))
                {
                    RegisterClientScriptBlock("01", "<script>alert('注册成功')</script>");
                    //Response.Write("<script>alert('注册成功')</script>");
                    Response.Redirect("Login.aspx");
                }
                #endregion
            }
            #endregion
        }
Exemple #2
0
 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
 {
     //
     if (Session["userid"] != null || Session["userid"].ToString() != "")
     {
         //
         string    strsql = string.Format("select * from cart where userid={0} and comid={1}", Session["userid"], Request.QueryString["c_id"]);
         DataSet   ds     = DbManger.GetDataSet(strsql, "cart");
         DataTable dt     = ds.Tables["cart"];
         if (dt.Rows.Count > 0)
         {
             //
             int num = Int32.Parse(dt.Rows[0]["amout"].ToString()) + Int32.Parse(txt_Num.Text);
             strsql = string.Format("update cart set amout={0} where userid={1} and comid={2}", num, Session["userid"], Request.QueryString["c_id"]);
             if (DbManger.ExceSQL(strsql))
             {
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('更新数量成功!')</script>", true);
             }
         }
         else
         {
             float price = float.Parse(DetailsView1.Rows[8].Cells[1].Text.Substring(6));
             strsql = string.Format("insert into cart values({0},{1},{2},{3})", Session["userid"], Request.QueryString["c_id"], Int32.Parse(txt_Num.Text), price);
             if (DbManger.ExceSQL(strsql))
             {
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加商品成功!')</script>", true);
             }
         }
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
Exemple #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //更新订单表
            Random rnd     = new Random();
            int    num     = rnd.Next(100, 1000);
            string orderid = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute + num.ToString();
            //获取联系地址编号
            int contactid = Int32.Parse(RadioButtonList1.SelectedValue);
            //.下单时间
            string orderdate = DateTime.Now.ToString();

            //订单总价
            float total = float.Parse(lblTotal.Text);

            //配置SQL
            string strsql = string.Format("insert into orders values('{0}',{1},{2},{3},0,'{4}','','','')", orderid, Session["userid"].ToString(), contactid, total, orderdate);

            //更新orders表
            if (DbManger.ExceSQL(strsql))
            {
                //更新订单详情表
                for (int i = 0; i < Repeater1.Items.Count; i++)
                {
                    int   merid  = Int32.Parse((Repeater1.Items[i].FindControl("lblId") as Label).Text);
                    float price  = float.Parse((Repeater1.Items[i].FindControl("lblPrice") as Label).Text.Substring(1));
                    int   amount = Int32.Parse((Repeater1.Items[i].FindControl("lblAmount") as Label).Text);
                    strsql = string.Format("insert into detailsOrder values('{0}',{1},{2},{3})", orderid, merid, price, amount);
                    DbManger.ExceSQL(strsql);
                }
                Response.Write("<script>alert('订单生成');window.location.href='admin/myallorder.aspx'</script>");
            }
        }
Exemple #4
0
        protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e)
        {
            string strsql = string.Format("delete from cart where CartId{0}", DataList1.DataKeys[e.Item.ItemIndex].ToString());

            if (DbManger.ExceSQL(strsql))
            {
                Response.Write("<script>alert('删除成功!')</script>");
                DataList1.DataBind();
            }
        }
Exemple #5
0
 protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
 {
     if (e.CommandName == "operNum")
     {
         TextBox txtNum = e.Item.FindControl("txt_num") as TextBox;
         int     num    = Int32.Parse(txtNum.Text);
         int     cartid = Int32.Parse(DataList1.DataKeys[e.Item.ItemIndex].ToString());
         string  strsql = string.Format("update cart set amout={0} where CartId={1}", num, cartid);
         if (DbManger.ExceSQL(strsql))
         {
             Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!')</script>", true);
             DataList1.DataBind();
         }
     }
 }
Exemple #6
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            #region 用户登录处理
            string check = Request.Cookies["checkcode"].Value.ToString();
            if (check == txtCheckcode.Text)
            {
                #region 使用数据访问类来完成登陆
                string        strsql = string.Format("select *  FROM [dbo].[user] where userName='******' and userPwd='{1}'", txtAccount.Text, txtPassword.Text);
                SqlDataReader dr     = DbManger.ExceRead(strsql);;
                if (dr.Read())
                {
                    int userid = Int32.Parse(dr["id"].ToString());
                    Session.Timeout   = 20;
                    Session["userid"] = userid;

                    Session["username"] = txtAccount.Text;
                    Response.Write("<script>alert('" + Session["username"].ToString() + "用户登录成功!')</script>");

                    string sql = string.Format("update [dbo].[user] set LoginTimes=LoginTimes+1 where id={0}", userid);

                    if (DbManger.ExceSQL(sql))
                    {
                        Response.Write("<script>alert('更新成功!')</script>");
                        //Response.Redirect("myhome/UpdatePic.aspx");
                        Response.Redirect("index.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('不成功!')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('用户名密码不正确!')</script>");
                }

                dr.Close();
                #endregion
            }
            else
            {
                Response.Write("<script>alert('验证码不正确')</script>");
            }


            #endregion
        }