using Restaurant.Model;
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 Restaurant.WEB
{
public partial class FoodManage : System.Web.UI.Page
{
Restaurant.BLL.FoodManage manage = new BLL.FoodManage();
FoodModel model = new FoodModel();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sql = "select FoodID,CategoryName,FoodName,FoodPrice,FoodDes,FoodImg from [Restaurant].[dbo].[Food],[Restaurant].[dbo].[Category] where Category.CategoryId=Food.CategoryId";
PartPages2.Sql = sql;
}
}
protected void Button_search_Click(object sender, EventArgs e)
{
string sql = "";
try
{
string foodn = FoodN.Text.ToString().Trim();
string foodc = FoodC.Text.ToString().Trim();
sql = "select FoodID,CategoryName,FoodName,FoodPrice,FoodDes,FoodImg from [Restaurant].[dbo].[Food],[Restaurant].[dbo].[Category] where Category.CategoryId=Food.CategoryId";
if (foodn != "")
{
sql += " and FoodName like '%{0}%' ";
sql = string.Format(sql,foodn);
}
if (foodc != "")
{
sql += " and CategoryName like '%{0}%' ";
sql = string.Format(sql, foodc);
}
PartPages2.Sql = sql;
}
catch (Exception ty)
{
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>confirm('" + ty.Message + "');</script>");
}
}
protected void linkOper_Click(object sender, EventArgs e)//
{
try
{
object id = Request.Form["hidId"];
string linkId = (sender as LinkButton).ID;
string aid = Request.QueryString["content"];
if (linkId == "linkEdit" && !string.IsNullOrWhiteSpace((string)id))
Response.Redirect("AddOrEdit.aspx?type=0&FoodID=" + id+"&AdminId="+aid);
if (linkId == "LinkAdd")
Response.Redirect("AddOrEdit.aspx?type=1&AdminId=" + aid);
if (linkId == "linkDelete" && !string.IsNullOrWhiteSpace((string)id))
{
manage.Delete(Convert.ToInt32(id));
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('删除成功');</script>");
}
}
catch (Exception eq)
{
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>confirm('" + eq.Message + "');</script>");
}
}
}
}