using System;
using System.Web;
using System.Web.UI;
using System.Collections;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using SocoShop.Common;
using SocoShop.Business;
using SocoShop.Entity;
using SkyCES.EntLib;

namespace SocoShop.Web
{
	public partial class GroupBuy : System.Web.UI.Page
	{
		protected int adminID = 0;
		/// <summary>
		/// 页面加载方法
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				AdminBLL.CheckAdminPower(ShopConfig.ReadConfigInfo().PowerKey, "ReadGroupBuy", PowerCheckType.Single, ref adminID);
                int currentPage = RequestHelper.GetQueryString<int>("Page");
                if (currentPage < 1)
                {
                    currentPage = 1;
                }
                int pageSize = 20;
                int count = 0;
                List<GroupBuyInfo> groupBuyList = new List<GroupBuyInfo>();
                groupBuyList = GroupBuyBLL.ReadGroupBuyList(currentPage, pageSize, ref count);
                RecordList.DataSource = groupBuyList;
                RecordList.DataBind();
                MyPager.CurrentPage = currentPage;
                MyPager.PageSize = pageSize;
                MyPager.Count = count;
			}
		}
	
		/// <summary>
		/// 删除按钮点击方法
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void DeleteButton_Click(object sender, EventArgs e)
		{
			AdminBLL.CheckAdminPower(ShopConfig.ReadConfigInfo().PowerKey, "DeleteGroupBuy", PowerCheckType.Single, ref adminID);
			string deleteID = RequestHelper.GetIntsForm("SelectID");
			if(deleteID != string.Empty)
			{
				GroupBuyBLL.DeleteGroupBuy(deleteID);
				AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("DeleteRecord"), ShopLanguage.ReadLanguage("GroupBuy"), deleteID);
				ScriptHelper.Alert(ShopLanguage.ReadLanguage("DeleteOK"), RequestHelper.RawUrl);
			}
		}
	}
}