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 CY.BLL;
using System.Data;
namespace CY.WebForm.Pages.procurement
{
//吴辉
//选择账户明细打印
public partial class InventoryPrintTable : BasePage
{
OA_WarehouseInfoBLL _OA_WarehouseInfoBLL = null;
OA_InventoryBLL _OA_InventoryBLL = null;
OA_SpecificationBLL _OA_SpecificationBLL = null;
OA_GoodsInfoBLL _OA_GoodsInfoBLL = null;
OA_PaperWeightBLL _OA_PaperWeightBLL = null;
OA_BrandBLL _OA_BrandBLL = null;
OA_CommodityBLL _OA_CommodityBLL = null;
OA_StaffBLL bll_OA_StaffBLL = null;
public InventoryPrintTable()
{
bll_OA_StaffBLL = new OA_StaffBLL();
_OA_CommodityBLL = new OA_CommodityBLL();
_OA_GoodsInfoBLL = new OA_GoodsInfoBLL();
_OA_SpecificationBLL = new OA_SpecificationBLL();
_OA_WarehouseInfoBLL = new OA_WarehouseInfoBLL();
_OA_InventoryBLL = new OA_InventoryBLL();
_OA_BrandBLL = new OA_BrandBLL();
_OA_PaperWeightBLL = new OA_PaperWeightBLL();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindList();
InitialData();
}
}
protected void InitialData()
{
//仓库
this.selWarehouseId.DataSource = _OA_WarehouseInfoBLL.getAllWarehouseInfo(CurrentUser.MemberId);
this.selWarehouseId.DataTextField = "WarehouseName";
this.selWarehouseId.DataValueField = "Keyid";
this.selWarehouseId.DataBind();
this.selWarehouseId.Items.Insert(0, new ListItem("全部", ""));
//货品类别
dwCommity.Items.Insert(0, new ListItem("全部", ""));
DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId, "", "true");
GetDataByLevel(dwCommity, ds, 0, 0);
dwBrand.Items.Insert(0, new ListItem("全部", ""));
dwGoodsList.Items.Insert(0, new ListItem("全部", ""));
dwPaperWeight.Items.Insert(0, new ListItem("全部", ""));
dwSpecification.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 dwCommity_SelectedIndexChanged(object sender, EventArgs e)
{
DataTable ds = _OA_GoodsInfoBLL.SlectModleByCommity(dwCommity.SelectedValue, CurrentUser.MemberId);
if (ds.Rows.Count > 0)
{
dwGoodsList.DataSource = ds;
dwGoodsList.DataTextField = "GoodsName";
dwGoodsList.DataValueField = "Keyid";
dwGoodsList.DataBind();
dwGoodsList.Items.Insert(0, new ListItem("全部", ""));
}
else
{
dwGoodsList.Items.Clear();
dwGoodsList.Items.Insert(0, new ListItem("全部", ""));
}
BindList();
//indecChage();
}
///
/// 根据产品名初始化数据
///
///
///
protected void dwGoodsList_SelectedIndexChanged(object sender, EventArgs e)
{
indecChage();
BindList();
}
///
/// 根据货品类别和货品名称选择规格和品牌
///
protected void indecChage()
{
///品牌
DataTable dt_brand = _OA_BrandBLL.getAllBrand(CurrentUser.MemberId, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue);
if (dt_brand.Rows.Count > 0)
{
dwBrand.DataSource = dt_brand;
dwBrand.DataTextField = "Name";
dwBrand.DataValueField = "Keyid";
dwBrand.DataBind();
dwBrand.Items.Insert(0, new ListItem("全部", ""));
}
else
{
dwBrand.Items.Clear();
dwBrand.Items.Insert(0, new ListItem("全部", ""));
}
DataTable dt_Specefiction = _OA_SpecificationBLL.getAllSpecification(CurrentUser.MemberId, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue);
///规格
if (dt_Specefiction.Rows.Count > 0)
{
dwSpecification.DataSource = dt_Specefiction;
dwSpecification.DataTextField = "Name";
dwSpecification.DataValueField = "Keyid";
dwSpecification.DataBind();
dwSpecification.Items.Insert(0, new ListItem("全部", ""));
}
else
{
dwSpecification.Items.Clear();
dwSpecification.Items.Insert(0, new ListItem("全部", ""));
}
DataTable dt_PaperWeight = _OA_PaperWeightBLL.getPaperWeight(CurrentUser.MemberId, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue);
///克重
if (dt_PaperWeight.Rows.Count > 0)
{
dwPaperWeight.DataSource = dt_PaperWeight;
dwPaperWeight.DataTextField = "Name";
dwPaperWeight.DataValueField = "Keyid";
dwPaperWeight.DataBind();
dwPaperWeight.Items.Insert(0, new ListItem("全部", ""));
}
}
protected void BindList()
{
Pagination pa = new Pagination();
pa.PageIndex = 1;
pa.PageSize = int.MaxValue;
List OA_InventoryList = _OA_InventoryBLL.SelectModelList(pa, CurrentUser.MemberId, this.dwPaperWeight.SelectedValue, this.selWarehouseId.Value, this.dwSpecification.SelectedValue, this.dwBrand.SelectedValue, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue, this.selOpretor.Value, this.txtRegTimeStart.Value.ToDateTime2(), this.txtRegTimeEnd.Value.ToDateTime2()).ToList();
List NEW_OA_InventoryList = new List();
foreach (var item in OA_InventoryList)
{
if (item.IsPaper == 1)
{
if (item.SpeceicationName.IndexOf("*") > 0)
{
int wNum = 0;
int hNum = 0;
try
{
wNum = item.SpeceicationName.Split('*')[0].ToInt32() ?? 0;
hNum = item.SpeceicationName.Split('*')[1].ToInt32() ?? 0;
}
catch (Exception ex)
{
PAGEHandleException(ex);
}
try
{
//item.TotalPrice = (item.UnitPrice * item.InventoryCount);
}
catch (Exception ex)
{
PAGEHandleException(ex);
}
try
{
item.LingShu = item.InventoryCount.ToDouble2() / 500.ToDouble2();
item.DunShu = item.InventoryCount.ToDouble2() * (wNum.ToDouble2() * hNum.ToDouble2() / (1000 * 1000).ToDouble2()) * (item.PaperWeightName.ToInt32().ToDouble2() / (1000 * 1000).ToDouble2());
}
catch (Exception ex)
{
PAGEHandleException(ex);
}
}
}
NEW_OA_InventoryList.Add(item);
}
ReInventoryList.DataSource = NEW_OA_InventoryList;
ReInventoryList.DataBind();
this.AllMoney.InnerText = _OA_InventoryBLL.SelectModelListTotalPrice(pa, CurrentUser.MemberId, this.dwPaperWeight.SelectedValue, this.selWarehouseId.Value, this.dwSpecification.SelectedValue, this.dwBrand.SelectedValue, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue, this.selOpretor.Value, this.txtRegTimeStart.Value.ToDateTime2(), this.txtRegTimeEnd.Value.ToDateTime2()).ToString("0.00") + "元";
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
BindList();
}
///
/// 批量入库
///
///
///
protected void btn_Bulkstorage_Click(object sender, EventArgs e)
{
Response.Redirect("/Pages/procurement/StorageVolume.aspx");
}
///
/// 查询
///
///
///
protected void btn_Register_Click(object sender, EventArgs e)
{
BindList();
}
}
}