using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.Model; using CY.BLL.OA; using CY.Infrastructure.Common; using CY.Infrastructure.Query; using CY.BLL.Sys; using System.Data; using CY.BLL; namespace CY.WebForm.Pages.procurement { public partial class ProcurementList : BasePage { Sys_DictionaryBLL _Sys_DictionaryBLL = null; OA_SuppliersBLL _OA_SuppliersBLL = null; OA_CommodityBLL _OA_CommodityBLL = null; OA_GoodsInfoBLL _OA_GoodsInfoBLL = null; OA_ProcurementBLL _OA_ProcurementBLL = null; OA_Procurement Procuremet = null; OA_StaffBLL bll_OA_StaffBLL = null; public ProcurementList() { bll_OA_StaffBLL = new OA_StaffBLL(); Procuremet = new OA_Procurement(); _OA_CommodityBLL = new OA_CommodityBLL(); _Sys_DictionaryBLL = new Sys_DictionaryBLL(); _OA_SuppliersBLL = new OA_SuppliersBLL(); _OA_GoodsInfoBLL = new OA_GoodsInfoBLL(); _OA_ProcurementBLL = new OA_ProcurementBLL(); } protected void Page_Load(object sender, EventArgs e) { UCPager1.AspNetPager.PageChanged += AspNetPager1_PageChanged; if (!IsPostBack) { } if (!IsPostBack) { if (Request["Keyid"].ToInt32() > 0) //如果keyid>0 则删除对应对象 { Procuremet = _OA_ProcurementBLL.SelectSingleModel(Request["Keyid"].ToString2()); if (_OA_ProcurementBLL.DeleteModel(Procuremet)) { JavaScript.MessageBox("删除成功", this); InitialData(); BindList(); } else { JavaScript.MessageBox("删除失败", this); InitialData(); BindList(); } } else { InitialData(); BindList(); } } } protected void BindList() { Pagination pa = new Pagination(); pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex; pa.PageSize = UCPager1.AspNetPager.PageSize; ReProcurentList.DataSource = _OA_ProcurementBLL.getModelList(pa, CurrentUser.MemberId, this.selOpretor.Value, this.selPurchaseStatus.Value, this.selClearingStatus.Value, this.selSuppliers.Value, this.selGoodsName.Value, this.dwCommity.SelectedValue, this.txtRegTimeStart.Value.ToDateTime2(), this.txtRegTimeEnd.Value.ToDateTime2(), this.txtBrandName.Value, this.txtPaperWeight.Value); ReProcurentList.DataBind(); UCPager1.AspNetPager.RecordCount = pa.RecordCount; } protected void InitialData() { //采购状态 this.selPurchaseStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("采购状态"); this.selPurchaseStatus.DataBind(); this.selPurchaseStatus.Items.Insert(0, new ListItem("全部", "")); this.selPurchaseStatus.Value = "200"; //结账状态 this.selClearingStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("结账状态"); this.selClearingStatus.DataBind(); this.selClearingStatus.Items.Insert(0, new ListItem("全部", "")); //供应商 this.selSuppliers.DataSource = _OA_SuppliersBLL.getSupplierTable(CurrentUser.MemberId); this.selSuppliers.DataBind(); this.selSuppliers.Items.Insert(0, new ListItem("全部", "")); //产品类别 DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId, "", "true"); GetDataByLevel(this.dwCommity, ds, 0, 0); this.dwCommity.Items.Insert(0, new ListItem("全部", "")); } public static void GetDataByLevel(System.Web.UI.WebControls.DropDownList dwCommity, DataTable data, int parentId, int level) { DataRow[] result = data.Select(string.Format("ParentId={0}", parentId)); int i = -1; while (++i < result.Length) { dwCommity.Items.Add(new ListItem(GetSplitChar(level) + result[i]["CommodityName"].ToString2(), result[i]["Keyid"].ToString2())); GetDataByLevel(dwCommity, data, result[i]["Keyid"].ToInt32().Value, level + 1); } } public static string GetSplitChar(int level) { string splitchar = ""; int i = -1; while (++i < level) { splitchar += "."; } return splitchar; } protected void AspNetPager1_PageChanged(object src, EventArgs e) { BindList(); } protected void btn_Register_Click(object sender, EventArgs e) { BindList(); } protected void dwCommity_SelectedIndexChanged(object sender, EventArgs e) { //货品名称 DataTable ds = _OA_GoodsInfoBLL.SlectModleByCommity(dwCommity.SelectedValue.ToString(), CurrentUser.MemberId); if (ds.Rows.Count > 0) { this.selGoodsName.Items.Clear(); this.selGoodsName.DataSource = ds; this.selGoodsName.DataTextField = "GoodsName"; this.selGoodsName.DataValueField = "Keyid"; this.selGoodsName.DataBind(); this.selGoodsName.Items.Insert(0, new ListItem("全部", "")); } else { this.selGoodsName.Items.Clear(); this.selGoodsName.Items.Insert(0, new ListItem("全部", "")); } BindList(); } } }