예제 #1
0
        protected void btnOK_Click(object sender, System.EventArgs e)
        {
            string strID = ViewState["ID"].ToString();
            string strName = txtName.Text.Trim();
            string strEmail = txtEmail.Text.Trim();
            string strPhone = txtPhone.Text.Trim();
            string strNum = ddlNum.SelectedValue;

            if (strName == String.Empty || strEmail == String.Empty || strPhone == String.Empty)
            {
                Response.Write("<script>");
                Response.Write("alert('请把必填项添上!!!');");
                Response.Write("</script>");
                return;
            }
         //   if (Session["CheckCode"] == null)
           // {
           //     Response.Redirect("index.aspx");
            //    return;
           // }
            if (Session["CheckCode"].ToString() != txtCheck.Text.Trim())
            {
                Response.Write("<script>");
                Response.Write("alert('输入的验证码有误!请重新输入!')");
                Response.Write("</script>");
                return;
            }

            //检查库存
            DBConn myDB = new DBConn();
            string mySql = "select PStock from Products where PID=" + strID;
            SqlDataReader mydr = myDB.getDataReader(mySql);
            if (mydr.Read())
            {
                int iPStock = Int32.Parse(mydr["PStock"].ToString());
                if (iPStock < int.Parse(strNum))
                {
                    Response.Write("<script>");
                    Response.Write("alert('库存不足!!!现在库存还有[ " + iPStock.ToString() + " ]');");
                    Response.Write("</script>");
                    return;
                }

            }
            else
            {
                Response.Write("<script>");
                Response.Write("alert('没有这个二手书!!!');");
                Response.Write("</script>");
                mydr.Close();
                myDB.Close();
                Response.Redirect("index.aspx");
                return;
            }
            mydr.Close();
            myDB.Close();

            Order myOrder = new Order();
            
            myOrder.PID = strID;
            myOrder.PName = lblPName.Text;
            myOrder.PNum = strNum.ToString();
            myOrder.PPrice = lblPNPrice.Text;
            myOrder.TotalPrice = lblTotalPric.Text;
            myOrder.TName = CleanString.htmlInputText(strName);
            myOrder.Email = strEmail;
            myOrder.Phone = CleanString.htmlInputText(strPhone);
            if (ViewState["PCPrice"] != null)
            {
                myOrder.PCPrice = ViewState["PCPrice"].ToString();
            }


            Session["myOrder"] = myOrder;

            if (Session["SubmitCheck"] != null)
            {
                DateTime myDTime = (DateTime)Session["SubmitCheck"];
                if (myDTime.AddMilliseconds(30000) > DateTime.Now)
                {
                    Response.Write("<script>");
                    TimeSpan myTime = DateTime.Now - (DateTime)Session["SubmitCheck"];
                    Response.Write("alert('不能频繁提交,请在" + (30 - myTime.Seconds) + "秒后继续!!!');");
                    Response.Write("</script>");
                    return;
                }
            }
            Session["SubmitCheck"] = DateTime.Now;

            Response.Redirect("orderinfo.aspx?key=" + Server.UrlEncode("makeOrder.aspx?id=" + ViewState["ID"].ToString()));

        }
예제 #2
0
        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>

        #endregion


        protected void btnOK_Click(object sender, System.EventArgs e)
        {
 
            string strName = txtName.Text.Trim();
            string strEmail = txtEmail.Text.Trim();
            string strPhone = txtPhone.Text.Trim();


            if (strName == String.Empty || strEmail == String.Empty || strPhone == String.Empty)
            {
                Response.Write("<script>");
                Response.Write("alert('请把必填项添上!!!');");
                Response.Write("</script>");
                return;
            }


            if (lblTotalPric.Text == String.Empty || lblTotalPric.Text == "0")
            {
               
                Response.Write("<script>");
                Response.Write("alert('购物车空,没办法生成订单!!!');");
                Response.Write("</script>");
                return;
            }
 
         
            if (Session["CheckCode"].ToString() != txtCheck.Text.Trim())
            {
                Response.Write("<script>");
                Response.Write("alert('输入的验证码有误!请重新输入!')");
                Response.Write("</script>");
                return;
            }

            Order myOrder = new Order();
            myOrder.PID = "0"; //特定批量购物的标识
            myOrder.TotalPrice = lblTotalPric.Text;
            myOrder.TName = CleanString.htmlInputText(strName);
            myOrder.Email = strEmail;
            myOrder.Phone = CleanString.htmlInputText(strPhone);

          Session["myOrder"]=  myOrder;
            Response.Redirect("orderinfo.aspx?key=" + Server.UrlEncode("makeOrder.aspx?id=" ));

        }