using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
namespace runzemall.BackManagement
{
public partial class storemanagement : 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 son_bll = new Maticsoft.BLL.SonType();
Maticsoft.Model.SonType son_model = new Maticsoft.Model.SonType();
Maticsoft.BLL.Orderform order_bll = new Maticsoft.BLL.Orderform();
Maticsoft.Model.Orderform order_model = new Maticsoft.Model.Orderform();
static string sqlstring;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session[“sqlselect”]="";
RadDropDownList1.DataSource = father_bll.GetList("");
RadDropDownList1.DataTextField = “FatherName”;
RadDropDownList1.DataValueField = “FatherId”;
RadDropDownList1.DataBind();
RadDropDownList1.Items.Add(new DropDownListItem(“请选择”, “”));
RadDropDownList1.SelectedText = “请选择”;
RadDropDownList2.Items.Add(new DropDownListItem(“请选择”, “”));
RadDropDownList2.SelectedText = “请选择”;
}
}
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
sqlstring = Session["sqlselect"].ToString();
RadGrid1.DataSource = store_bll.GetList(0, " Store.SonId=SonType.SonId and SonType.FatherId=FatherType.FatherId "+ sqlstring, "AddTime desc");
}
protected void RadButton2_Click(object sender, EventArgs e)
{
Response.Redirect("add1.aspx");
}
protected void RadButton3_Click(object sender, EventArgs e)
{
if (RadGrid1.SelectedValue == null)
{
RadAjaxManager1.Alert("请选择一条数据");
}
else
{
var sel = RadGrid1.SelectedItems[0];
string id = RadGrid1.MasterTableView.DataKeyValues[sel.ItemIndex]["ProductId"].ToString();
Response.Redirect("alter.aspx?ID=" + id + "");
}
}
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
string id = e.CommandArgument.ToString();
if (e.CommandName == "Deletes")
{
if (store_bll.GetRecordCount(" OrderId ='" + id + "' ") != 0 && order_bll.GetRecordCount(" OrderId ='" + id + "' ") != 0)
{
RadAjaxManager1.Alert("存在订单,不能删除");
}
else
{
store_bll.Delete(e.CommandArgument.ToString());//删除
RadGrid1.Rebind();//重新绑定
}
}
}
protected void RadButton1_Click(object sender, EventArgs e)
{
if (RadTextBox1.Text == "" && RadDropDownList3.SelectedText == "全部" && RadDropDownList1.SelectedText == "请选择" && RadDropDownList2.SelectedText == "请选择")//0000
{
Session["sqlselect"] = "";
}
else if (RadTextBox1.Text != "" && RadDropDownList3.SelectedText == "全部" && RadDropDownList1.SelectedText != "请选择" && RadDropDownList2.SelectedText == "请选择")//1010
{
Session["sqlselect"] = "and ProductName like '%" + RadTextBox1.Text + "%' and FatherName like '%" + RadDropDownList2.SelectedText + "%' ";
}
else if (RadTextBox1.Text != "" && RadDropDownList3.SelectedText == "全部" && RadDropDownList1.SelectedText == "请选择" && RadDropDownList2.SelectedText == "请选择")//1000
{
Session["sqlselect"] = "and ProductName like '%" + RadTextBox1.Text + "%' ";
}
else if (RadTextBox1.Text != "" && RadDropDownList3.SelectedText != "全部" && RadDropDownList1.SelectedText == "请选择" && RadDropDownList2.SelectedText == "请选择")//1100
{
Session["sqlselect"] = "and ProductName like '%" + RadTextBox1.Text + "%' and recommend like '%" + RadDropDownList3.SelectedText + "%' ";
}
else if (RadTextBox1.Text != "" && RadDropDownList3.SelectedText != "全部" && RadDropDownList1.SelectedText != "请选择" && RadDropDownList2.SelectedText == "请选择")//1110
{
Session["sqlselect"] = "and ProductName like '%" + RadTextBox1.Text + "%' and recommend like '%" + RadDropDownList3.SelectedText + "%' and FatherName like '%" + RadDropDownList1.SelectedText + "%'";
}
else if (RadTextBox1.Text != "" && RadDropDownList3.SelectedText != "全部" && RadDropDownList1.SelectedText != "请选择" && RadDropDownList2.SelectedText != "请选择")//1111
{
Session["sqlselect"] = "and ProductName like '%" + RadTextBox1.Text + "%' and recommend like '%" + RadDropDownList3.SelectedText + "%' and FatherName like '%" + RadDropDownList1.SelectedText + "%' and SonName like '%" + RadDropDownList2.SelectedText + "%'";
}
else if (RadTextBox1.Text == "" && RadDropDownList3.SelectedText != "全部" && RadDropDownList1.SelectedText == "请选择" && RadDropDownList2.SelectedText == "请选择")//0100
{
Session["sqlselect"] = "and recommend like '%" + RadDropDownList3.SelectedText + "%' ";
}
else if (RadTextBox1.Text == "" && RadDropDownList3.SelectedText != "全部" && RadDropDownList1.SelectedText != "请选择" && RadDropDownList2.SelectedText == "请选择")//0110
{
Session["sqlselect"] = "and recommend like '%" + RadDropDownList3.SelectedText + "%' and FatherName like '%" + RadDropDownList1.SelectedText + "%' ";
}
else if (RadTextBox1.Text == "" && RadDropDownList3.SelectedText != "全部" && RadDropDownList1.SelectedText != "请选择" && RadDropDownList2.SelectedText != "请选择")//0111
{
Session["sqlselect"] = "and recommend like '%" + RadDropDownList3.SelectedText + "%' and FatherName like '%" + RadDropDownList1.SelectedText + "%' and SonName like '%" + RadDropDownList2.SelectedText + "%' ";
}
else if (RadTextBox1.Text == "" && RadDropDownList3.SelectedText == "全部" && RadDropDownList1.SelectedText != "请选择" && RadDropDownList2.SelectedText == "请选择")//0010
{
Session["sqlselect"] = "and FatherName like '%" + RadDropDownList1.SelectedText + "%' ";
}
else if (RadTextBox1.Text == "" && RadDropDownList3.SelectedText == "全部" && RadDropDownList1.SelectedText != "请选择" && RadDropDownList2.SelectedText != "请选择")//0011
{
Session["sqlselect"] = "and ProductName like '%" + RadTextBox1.Text + "%' and FatherName like '%" + RadDropDownList1.SelectedText + "%'and SonName like '%" + RadDropDownList2.SelectedText + "%' ";
}
RadGrid1.Rebind();
}
protected void RadDropDownList1_SelectedIndexChanged(object sender, DropDownListEventArgs e)
{
RadDropDownList2.ClearSelection();
RadDropDownList2.DataSource = son_bll.GetList("FatherId ='" + RadDropDownList1.SelectedValue + "' ");
RadDropDownList2.DataTextField = "SonName";
RadDropDownList2.DataValueField = "SonId";
RadDropDownList2.DataBind();
RadDropDownList2.Items.Add(new DropDownListItem("请选择", ""));
RadDropDownList2.SelectedText = "请选择";
}
}
}