shopdetail behind

using NavigationPlatformWeb.util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace runzemall.ForeManagement
{

public partial class shopdetail : System.Web.UI.Page
{
    Maticsoft.BLL.Store store_bll = new Maticsoft.BLL.Store();
    Maticsoft.Model.Store store_model = new Maticsoft.Model.Store();
    Maticsoft.BLL.FatherType father_bll = new Maticsoft.BLL.FatherType();
    Maticsoft.Model.FatherType father_model = new Maticsoft.Model.FatherType();
    Maticsoft.BLL.SonType son1_bll = new Maticsoft.BLL.SonType();
    Maticsoft.Model.SonType son_model = new Maticsoft.Model.SonType();
    Maticsoft.BLL.CartId Car_bll = new Maticsoft.BLL.CartId();
    Maticsoft.Model.CartId Car_model = new Maticsoft.Model.CartId();
    Maticsoft.BLL.ShoppingCar ShoppingCar_bll = new Maticsoft.BLL.ShoppingCar();
    Maticsoft.Model.ShoppingCar ShoppingCar_model = new Maticsoft.Model.ShoppingCar();
    Maticsoft.BLL.OrderDetail OrderDetail_bll = new Maticsoft.BLL.OrderDetail();
    Maticsoft.Model.OrderDetail OrderDetail_model = new Maticsoft.Model.OrderDetail();
    public int num;
    public static bool A = true;
    protected void Page_Load(object sender, EventArgs e)
    {
        //Label12.Text = store_bll.avg(" ProductId ='" + Request.QueryString["ID"] + "' ").Tables[0].Rows[0][0].ToString();

        if (!IsPostBack)
        {
            num = 1;
            RadNumericTextBox1.Text = num.ToString();

            if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
            {
                string id = Request["ID"];
                store_model = store_bll.GetModel(id);
                Image3.ImageUrl = store_model.ProductImage;
                Label7.Text = store_model.ProductName;
                Label2.Text = store_model.marketPrize.ToString();
                Label3.Text = store_model.VipPrize.ToString();
                Label4.Text = store_model.NumberSold.ToString();
                Label5.Text = store_model.ProductNum.ToString();
                Label6.Text = store_model.GoodState;
                Label12.Text = OrderDetail_bll.GetAvgList(" ProductId ='" + Request.QueryString["ID"] + "' ").Tables[0].Rows[0][0].ToString();

                if (Car_bll.GetRecordCount(" ProductId='" + Request.QueryString["ID"] + "' and UserId='" + UsersInfo.UserID + "' ") > 0)
                {

                    ImageButton1.ImageUrl = "../images/商品详细页_11.png";
                }
                else
                {

                    ImageButton1.ImageUrl = "../images/灰色收藏.png";
                }

                RadButton4.Enabled = true;


                RadNumericTextBox1.MaxValue = Convert.ToInt32(store_model.ProductNum);
            }
            if (ShoppingCar_bll.GetRecordCount("ProductId='" + Request.QueryString["ID"].ToString() + "' and UserId='" + UsersInfo.UserID + "' ") == 0)
            {
                RadButton5.Visible = false;
            }
        }
        if (UsersInfo.UserName != "")
        {
            Label9.Text = UsersInfo.UserName;
            Label10.Text = "";
        }

    }


    protected void RadButton2_Click(object sender, EventArgs e)
    {
        if (UsersInfo.UserName == "")
        {
            RadAjaxManager1.Alert("请先登录");
            RadAjaxManager1.Redirect("frontlogin.aspx");
        }
        else
        {
            ShoppingCar_model.CartId = DateTime.Now.ToString("yyyymmddss");
            ShoppingCar_model.ProductId = Request["ID"];
            ShoppingCar_model.UserId = UsersInfo.UserID;
            ShoppingCar_model.Number = Convert.ToDecimal(RadNumericTextBox1.Text);
            ShoppingCar_bll.Add(ShoppingCar_model);
            RadAjaxManager1.Alert("已加入购物车!");

        }

    }

    protected void RadButton1_Click(object sender, EventArgs e)
    {
        string search = RadTextBox1.Text;
        Response.Redirect("/ForeManagement/shoppinglist.aspx?search=" + search + "");

    }

    protected void RadButton3_Click(object sender, EventArgs e)
    {
        num = Convert.ToInt32(RadNumericTextBox1.Text);
        if (num <= 1)
        {
            num = 1;
        }
        else
        {
            num--;
        }
        RadNumericTextBox1.Text = num.ToString();

    }

    protected void RadButton4_Click(object sender, EventArgs e)
    {
        try
        {
            string id = Request["ID"];
            store_model = store_bll.GetModel(id);
            num = Convert.ToInt32(RadNumericTextBox1.Text);
            int number = Convert.ToInt32(store_model.ProductNum);
            if (num >= number)
            {
                RadNumericTextBox1.MaxValue = number;
            }

            num++;
            RadNumericTextBox1.Text = num.ToString();

        }
        catch (Exception)
        {
            RadNumericTextBox1.Text = "1";
        }
    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string id = Request["ID"];
        store_model = store_bll.GetModel(id);
        if (UsersInfo.UserName == "")
        {
            RadAjaxManager1.Alert("请先登录");
            RadAjaxManager1.Redirect("frontlogin.aspx");
        }
        else
        {
            Car_model.AddId = DateTime.Now.ToString("yyyyMMddHHmmssff");
            Car_model.UserId = UsersInfo.UserID;
            Car_model.ProductId = store_model.ProductId;

            if (Car_bll.GetRecordCount(" ProductId='" + Request.QueryString["ID"] + "' and UserId='" + UsersInfo.UserID + "' ") > 0)
            {
                Car_bll.Delete(Car_bll.GetList(" ProductId='" + Request.QueryString["ID"] + "' and UserId='" + UsersInfo.UserID + "' ").Tables[0].Rows[0]["AddId"].ToString());
                ImageButton1.ImageUrl = "../images/灰色收藏.png";
            }
            else
            {
                Car_bll.Add(Car_model);
                ImageButton1.ImageUrl = "../images/商品详细页_11.png";
            }

        }


    }

    protected void RadNumericTextBox1_TextChanged(object sender, EventArgs e)
    {

    }

    protected void RadButton5_Click(object sender, EventArgs e)
    {
        //if (UsersInfo.UserId == "")
        //{
        //    Response.Write("<script>alert('请登录账户!');window.location.href='../ForeManagement/frontlogin.aspx'</script>");
        //    return;
        //}
        //else
        //{
        //      store_model =  store_bll.GetModel(Request.QueryString["ID"].ToString());


        //    if (RadRating1.Value == 1)
        //    {
        //       store_model.Score = 20;
        //    }
        //    if (RadRating1.Value == 2)
        //    {
        //        store_model.Score = 40;
        //    }
        //    if (RadRating1.Value == 3)
        //    {
        //        store_model.Score = 60;
        //    }
        //    if (RadRating1.Value == 4)
        //    {
        //       store_model.Score = 80;
        //    }
        //    if (RadRating1.Value == 5)
        //    {
        //        store_model.Score = 100;
        //    }
        //    store_bll.Update(store_model);
        //    Response.Write("<script> alert('评分成功!')</script>");
        //}

      


        if (string.IsNullOrEmpty(UsersInfo.UserID))
        {
            Response.Write("<script>alert('请先登录')</script>");
        }
        else if (OrderDetail_bll.GetRecordCount("UserId='" + UsersInfo.UserID + "' and  ProductId='" + Request.QueryString["ID"] + "' ") == 0)
        {
            Response.Write("<script>alert('请先购买商品')</script>");
            return;
        }
        else if (OrderDetail_bll.GetRecordCount("UserId='" + UsersInfo.UserID + "' and  ProductId'" + Request.QueryString["ID"] + "'") > 0)
        {
            if (OrderDetail_bll.GetOrderList("Score =0") != 0 && OrderDetail_bll.GetOrderList("OrderStatus='已收货'") != 0 && OrderDetail_bll.GetRecordCount("UserId='" + UsersInfo.UserID + "' and  ProductId='" + Request.QueryString["ID"] + "'") > 0)
            {
                string OID = "";
                if (!String.IsNullOrEmpty(UsersInfo.UserID))//判断标题是否为空
                {
                    if (!String.IsNullOrEmpty(OID))//判断strwhere是否为空
                    {
                        OID += " and ";//不为空加and
                    }
                    OID += "UserId='" + UsersInfo.UserID + "' ";//加入条件
                }
                if (!String.IsNullOrEmpty(Request["ID"].ToString()))
                {
                    if (!String.IsNullOrEmpty(OID))//判断strwhere是否为空
                    {
                        OID += " and ";//不为空加and)
                    }
                    OID += " ProductId= '" + Request["ID"].ToString() + "'";//加入条件

                    if (!String.IsNullOrEmpty(OID))//判断strwhere是否为空
                    {
                        OID += " and ";//不为空加and)
                    }
                    OID += " Score =0";//加入条件
                }
                DataSet yh = OrderDetail_bll.GetDescList(1, OID, "OrderTime desc");
                string dd = yh.Tables[0].Rows[0]["OrderDetailId"].ToString();
                if (RadRating1.Value == 0)
                {
                    RadAjaxManager1.Alert("评分不可为零分");
                    return;
                }
                string id = Request["ID"];
                OrderDetail_model = OrderDetail_bll.GetModel(id);
                if (RadRating1.Value == 1)
                {
                    OrderDetail_model.Score = 40;

                }
                if (RadRating1.Value == 2)
                {
                    OrderDetail_model.Score = 60;
                }
                if (RadRating1.Value == 3)
                {
                    OrderDetail_model.Score = 80;

                }
                if (RadRating1.Value == 4)
                {
                    OrderDetail_model.Score = 100;
                }
                OrderDetail_bll.Update(OrderDetail_model);
                RadAjaxManager1.Alert("评价成功");
            }
            else if (OrderDetail_bll.GetOrderList("Score IS NULL") == 0 && OrderDetail_bll.GetRecordCount("UserId='" + UsersInfo.UserID + "' and  ProductId='" + Request.QueryString["ID"] + "'") > 0)
            {
                Response.Write("<script>alert('已评论过商品')</script>");
            }
            else if (OrderDetail_bll.GetOrderList("OrderStatus='已收货'") == 0 && OrderDetail_bll.GetRecordCount("UserId='" + UsersInfo.UserID + "' and  ProductId='" + Request.QueryString["ID"] + "'") > 0)
            {
                Response.Write("<script>alert('商品未收货')</script>");
            }






        }
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Response.Redirect("/BackManagement/index.aspx");
    }

}

}

猜你喜欢

转载自blog.csdn.net/qq_39593196/article/details/86501687