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 shoppinglist : 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.ShoppingCar ShoppingCar_bll = new Maticsoft.BLL.ShoppingCar();
Maticsoft.Model.ShoppingCar ShoppingCar_model = new Maticsoft.Model.ShoppingCar();
static string sql = “”;
string father , son ;
static string sqlselect = “”;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString[“search”]))
{
RadTextBox1.Text = Request.QueryString[“search”].ToString();
chaxun();
}
Session[“sql”] = “”;
if (Request.QueryString[“FatherType”] != null)
{
father = Request.QueryString[“FatherType”].ToString();
}
if (Request.QueryString[“SonType”] != null)
{
son = Request.QueryString[“SonType”].ToString();
}
DataLoad();
}
if (UsersInfo.UserName != "")
{
Label9.Text = UsersInfo.UserName;
Label10.Text = "";
}
}
void DataLoad()
{
if (father != null)
{
if (!string.IsNullOrEmpty(sql))
{
sql += " and ";
}
sql += " FatherId='" + father + "' ";
}
if (son != null)
{
if (!string.IsNullOrEmpty(sql))
{
sql += " and ";
}
sql += " SonId = '" + son + "' ";
}
if (store_bll.GetList(0, sql, " Addtime desc ").Tables[0].Rows.Count <= 15)
{
RadDataPager1.Visible = false;
}
else
{
RadDataPager1.Visible = true;
}
}
protected void chaxun()
{
sql = "";
if (!string.IsNullOrEmpty(RadTextBox1.Text))
{
if (!string.IsNullOrEmpty(sql))
{
sql += " and ";
}
sql += "ProductName like '%" + Request.QueryString["search"] + "%' ";
RadListView1.Rebind();
}
}
protected void RadListView1_NeedDataSource1(object sender, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e)
{
RadListView1.DataSource = store_bll.GetList(sql);
DataLoad();
}
protected void RadListView2_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
{
string id = e.Item.OwnerListView.DataKeyValues[e.Item.OwnerListView.DataKeyValues.Count - 1]["FatherId"].ToString();
Telerik.Web.UI.RadListView RadListView3 = e.Item.FindControl("RadListView3") as Telerik.Web.UI.RadListView;
if (RadListView3 != null)
{
RadListView3.DataSource = son1_bll.GetList(" FatherId ='" + id + "' ");
RadListView3.DataBind();
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("/BackManagement/index.aspx");
}
protected void RadButton1_Click(object sender, EventArgs e)
{
lyc();
}
public void lyc()
{
string strWhere = "";
if (!String.IsNullOrEmpty(RadTextBox1.Text))//判断RdtTitle.Text是否不为空
{
strWhere= "ProductName like '%" + RadTextBox1.Text + "%' ";
}
RadListView1.DataSource = store_bll.GetList(strWhere);
RadListView1.DataBind();
RadListView1.Rebind();
}
protected void RadListView2_NeedDataSource(object sender, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e)
{
RadListView2.DataSource = father_bll.GetList("");
}
protected void RadListView3_ItemCommand1(object sender, Telerik.Web.UI.RadListViewCommandEventArgs e)
{
RadListView1.DataSource = store_bll.GetList1(0, " SonName = '" + e.CommandArgument + "' and ProductNum!=0 ", " AddTime desc ");
}
protected void RadListView2_ItemCommand1(object sender, Telerik.Web.UI.RadListViewCommandEventArgs e)
{
RadListView1.DataSource = store_bll.GetList1(0, " FatherName = '" + e.CommandArgument + "' and ProductNum!=0 ", " AddTime desc ");
}
protected void RadListView1_ItemCommand(object sender, Telerik.Web.UI.RadListViewCommandEventArgs e)
{
if (UsersInfo.UserName == "")
{
RadAjaxManager1.Alert("请先登录");
RadAjaxManager1.Redirect("frontlogin.aspx");
}
else
{
ShoppingCar_model.CartId = DateTime.Now.ToString("yyyymmddss");
ShoppingCar_model.ProductId = e.CommandArgument.ToString();
ShoppingCar_model.Number = 1;
ShoppingCar_model.UserId = UsersInfo.UserID;
ShoppingCar_bll.Add(ShoppingCar_model);
Response.Write("<script>alert('已加入购物车!')</script>");
}
}
}
}