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 StorageVolume : BasePage { OA_StaffBLL bll_OA_StaffBLL = null; 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; public StorageVolume() { 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); BindList(); } else { JavaScript.MessageBox("删除失败", this); BindList(); } } else { BindList(); InitialData(); } } } protected void BindList() { DateTime? beginTime = null; DateTime? endTime = null; string statusId = _Sys_DictionaryBLL.GetKeyIdByKeyid(1, "采购状态").ToString2(); 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, "200", selClearingStatus.Value, selSuppliers.Value, selGoodsName.Value, dwCommity.SelectedValue, string.IsNullOrEmpty(this.txtRegTimeStart.Value) ? beginTime : Convert.ToDateTime(this.txtRegTimeStart.Value), string.IsNullOrEmpty(this.txtRegTimeEnd.Value) ? endTime : MyConvert.GetDateTime(this.txtRegTimeEnd.Value), "", ""); ReProcurentList.DataBind(); UCPager1.AspNetPager.RecordCount = pa.RecordCount; } protected void InitialData() { ///采购状态 selPurchaseStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("采购状态"); selPurchaseStatus.DataBind(); selPurchaseStatus.Items.Insert(0, new ListItem("请选择", "")); ///结账状态 selClearingStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("结账状态"); selClearingStatus.DataBind(); selClearingStatus.Items.Insert(0, new ListItem("请选择", "")); ///供应商 selSuppliers.DataSource = _OA_SuppliersBLL.getSupplierTable(CurrentUser.MemberId); selSuppliers.DataBind(); selSuppliers.Items.Insert(0, new ListItem("请选择", "")); ///货品名称 selGoodsName.DataSource = _OA_GoodsInfoBLL.SelectTableList(CurrentUser.MemberId); selGoodsName.DataBind(); selGoodsName.Items.Insert(0, new ListItem("请选择", "")); ///产品类别 DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId, "", "true"); GetDataByLevel(dwCommity, ds, 0, 0); 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, CurrentUser.MemberId); if (ds.Rows.Count > 0) { 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("请选择", "")); } } } }