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.BLL;
using CY.Model;
using CY.Infrastructure.Common;
using CY.BLL.Sys;
using CY.Infrastructure.Query;
using System.Data;
namespace CY.WebForm.Pages.procurement
{
public partial class StockOutEdit : BasePage
{
OA_BrandBLL _OA_BrandBLL = null;
OA_CargoSpaceBLL _OA_CargoSpaceBLL = null;
OA_CommodityBLL _OA_CommodityBLL = null;
OA_WarehouseInfoBLL _OA_WarehouseInfoBLL = null;
OA_SpecificationBLL _OA_SpecificationBLL = null;
OA_InventoryBLL _OA_InventoryBLL = null;
OA_GoodsInfoBLL _OA_GoodsInfoBLL = null;
OA_PaperWeightBLL _OA_PaperWeightBLL = null;
OA_OutOfStorageBLL _OA_OutOfStorageBLL = null;
OA_CommoditySpeciAssociateBLL _OA_CommoditySpeciAssociateBLL = null;
public StockOutEdit()
{
_OA_PaperWeightBLL = new OA_PaperWeightBLL();
_OA_GoodsInfoBLL = new OA_GoodsInfoBLL();
_OA_CommoditySpeciAssociateBLL = new OA_CommoditySpeciAssociateBLL();
_OA_InventoryBLL = new OA_InventoryBLL();
_OA_WarehouseInfoBLL = new OA_WarehouseInfoBLL();
_OA_CargoSpaceBLL = new OA_CargoSpaceBLL();
_OA_BrandBLL = new OA_BrandBLL();
_OA_CommodityBLL = new OA_CommodityBLL();
_OA_SpecificationBLL = new OA_SpecificationBLL();
_OA_OutOfStorageBLL = new OA_OutOfStorageBLL();
}
string CommodityValue = null;
protected void Page_Load(object sender, EventArgs e)
{
UCPager1.AspNetPager.PageChanged += AspNetPager1_PageChanged;
if (!IsPostBack)
{
this.InitData();
BindList();
}
}
///
/// 初始化数据
///
private void InitData()
{
//填充仓库下拉框
this.selWarehouseId.DataSource = _OA_WarehouseInfoBLL.getAllWarehouseInfo(CurrentUser.MemberId);
this.selWarehouseId.DataValueField = "Keyid";
this.selWarehouseId.DataTextField = "WarehouseName";
this.selWarehouseId.DataBind();
this.selWarehouseId.Items.Insert(0, new ListItem("全部", ""));
//产品类别
DataTable dsCommity = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId, "", "true");
if (dsCommity.Rows.Count > 0)
{
this.dwCommity.Items.Clear();
this.dwCommity.DataSource = dsCommity;
this.dwCommity.DataTextField = "CommodityName";
this.dwCommity.DataValueField = "Keyid";
this.dwCommity.DataBind();
this.dwCommity.Items.Insert(0, new ListItem("全部", ""));
}
else
{
this.dwCommity.Items.Clear();
this.dwCommity.Items.Insert(0, new ListItem("全部", ""));
}
//初始化 货品名称,规格,品牌,克重
this.dwGoodsList.Items.Insert(0, new ListItem("全部", ""));
this.dwBrand.Items.Insert(0, new ListItem("全部", ""));
this.dwSpecification.Items.Insert(0, new ListItem("全部", ""));
this.dwPaperWeight.Items.Insert(0, new ListItem("全部", ""));
}
///
/// 根据产品名初始化数据
///
///
///
protected void dwGoodsList_SelectedIndexChanged(object sender, EventArgs e)
{
GetDataByGoods();
BindList();
}
///
/// 根据货品名称获取规格、品牌、克重
///
protected void GetDataByGoods()
{
///品牌
DataTable dt_brand = _OA_BrandBLL.getAllBrand(CurrentUser.MemberId, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue);
if (dt_brand.Rows.Count > 0)
{
this.dwBrand.Items.Clear();
this.dwBrand.DataSource = dt_brand;
this.dwBrand.DataTextField = "Name";
this.dwBrand.DataValueField = "Keyid";
this.dwBrand.DataBind();
this.dwBrand.Items.Insert(0, new ListItem("全部", ""));
}
else
{
this.dwBrand.Items.Clear();
this.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)
{
this.dwSpecification.Items.Clear();
this.dwSpecification.DataSource = dt_Specefiction;
this.dwSpecification.DataTextField = "Name";
this.dwSpecification.DataValueField = "Keyid";
this.dwSpecification.DataBind();
this.dwSpecification.Items.Insert(0, new ListItem("全部", ""));
}
else
{
this.dwSpecification.Items.Clear();
this.dwSpecification.Items.Insert(0, new ListItem("全部", ""));
}
DataTable dt_PaperWeight = _OA_PaperWeightBLL.getPaperWeight(CurrentUser.MemberId, this.CommodityValue, this.dwGoodsList.SelectedValue);
///克重
if (dt_PaperWeight.Rows.Count > 0)
{
this.dwPaperWeight.Items.Clear();
this.dwPaperWeight.DataSource = dt_PaperWeight;
this.dwPaperWeight.DataTextField = "Name";
this.dwPaperWeight.DataValueField = "Keyid";
this.dwPaperWeight.DataBind();
this.dwPaperWeight.Items.Insert(0, new ListItem("全部", ""));
}
else
{
this.dwPaperWeight.Items.Clear();
this.dwPaperWeight.Items.Insert(0, new ListItem("全部", ""));
}
}
protected void BindList()
{
Pagination pa = new Pagination();
pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex;
pa.PageSize = UCPager1.AspNetPager.PageSize;
ReInventoryList.DataSource = _OA_InventoryBLL.SelectModelList(pa, CurrentUser.MemberId, this.dwPaperWeight.SelectedValue, this.selWarehouseId.Value, this.dwSpecification.SelectedValue, this.dwBrand.SelectedValue, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue, "", DateTime.MinValue, DateTime.MaxValue);
ReInventoryList.DataBind();
UCPager1.AspNetPager.RecordCount = pa.RecordCount;
}
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.dwGoodsList.Items.Clear();
this.dwGoodsList.DataSource = ds;
this.dwGoodsList.DataTextField = "GoodsName";
this.dwGoodsList.DataValueField = "Keyid";
this.dwGoodsList.DataBind();
this.dwGoodsList.Items.Insert(0, new ListItem("全部", ""));
}
else
{
this.dwGoodsList.Items.Clear();
this.dwGoodsList.Items.Insert(0, new ListItem("全部", ""));
}
BindList();
}
protected void btn_Submit_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.InventoryCounttext.Value) || this.InventoryCounttext.Value.ToInt32() == null || this.InventoryCounttext.Value.ToInt32() <= 0 || this.InventoryCounttext.Value.ToInt32() == null)
{
JavaScript.MessageBox("请填写正确的出库数量", this);
return;
}
OA_Inventory Inventory = new OA_Inventory();
OA_OutOfStorage outOfStorage = new OA_OutOfStorage();
string keyid = txtKeyid.Value;
Inventory = _OA_InventoryBLL.GetModelByKeyid(Convert.ToInt32(keyid));
outOfStorage.FirmId = CurrentUser.MemberId;
outOfStorage.GoodsId = Inventory.GoodsId;
outOfStorage.CargoSpaceId = 0;
outOfStorage.LastUpdateTime = DateTime.Now;
outOfStorage.Operator = CurrentUser.ShortName;
outOfStorage.Remark = "";
outOfStorage.WarehouseId = Inventory.WarehouseId;
outOfStorage.SuppliersId = 0;
outOfStorage.AllMoney = 0;
outOfStorage.InfoType = "出库";
outOfStorage.Price = 0;
outOfStorage.Quantity = InventoryCounttext.Value.ToInt32();
outOfStorage.TanPrice = 0;
outOfStorage.SpecificationId = Inventory.SpecificationId;
outOfStorage.PaperWeightId = Inventory.PaperWeightId;
outOfStorage.BrandId = Inventory.BrandId;
if (InventoryCounttext.Value.ToInt32() > Inventory.InventoryCount)
{
JavaScript.MessageBox("库存不足!", this);
return;
}
if (_OA_OutOfStorageBLL.InsertModel(Inventory, outOfStorage))
{
JavaScript.MessageBoxAndFirstRefresh("出库成功", this, false);
}
else
{
JavaScript.MessageBox("操作失败", this);
}
}
}
}