using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.OA;
using CY.Infrastructure.Common;
using System.Data;
namespace CY.WebForm.Pages.procurement
{
public partial class CommoditySpeciAssociateManager : BasePage
{
OA_CommodityBLL _OA_CommodityBLL = null;
OA_SpecificationBLL _OA_SpecificationBLL = null;
OA_CommoditySpeciAssociateBLL _OA_CommoditySpeciAssociateBLL = null;
DataTable ds = null;
public CommoditySpeciAssociateManager()
{
_OA_CommodityBLL = new OA_CommodityBLL();
_OA_SpecificationBLL = new OA_SpecificationBLL();
_OA_CommoditySpeciAssociateBLL = new OA_CommoditySpeciAssociateBLL();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindList();
}
}
///
///绑定下拉列表和checkboxlist里面的原始数据
///
protected void BindList()
{
ds=_OA_CommoditySpeciAssociateBLL.SelectModelPage(Request["Keyid"].ToString2());
CBSpecification.DataSource = _OA_SpecificationBLL.getAllSpecification(CurrentUser.MemberId);
CBSpecification.DataTextField = "Name";
CBSpecification.DataValueField = "Keyid";
CBSpecification.DataBind();
for (int i = 0; i < ds.Rows.Count; i++)
{
for (int j = 0; j < CBSpecification.Items.Count; j++)
{
if (CBSpecification.Items[j].Value == ds.Rows[i]["SpecificationId"].ToString2())
{
CBSpecification.Items[j].Selected = true;
}
}
}
}
protected void btn_config_Click(object sender, EventArgs e)
{
ds = _OA_CommoditySpeciAssociateBLL.SelectModelPage(Request["Keyid"].ToString2());
List SpecificationListAfter = new List();
List SpecificationListBefore = new List();
for (int i = 0; i < CBSpecification.Items.Count; i++)
{
if (CBSpecification.Items[i].Selected)
SpecificationListAfter.Add(CBSpecification.Items[i].Value);
}
for (int i = 0; i < ds.Rows.Count; i++)
{
SpecificationListBefore.Add(ds.Rows[i]["SpecificationId"].ToString2());
}
_OA_CommoditySpeciAssociateBLL.DeleteModel(SpecificationListBefore.ToArray(),Request["Keyid"].ToString2() );
_OA_CommoditySpeciAssociateBLL.InsertModel(SpecificationListAfter.ToArray(),Request["Keyid"].ToString2());
}
}
}