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 System.Data;
|
using CY.Infrastructure.Common;
|
using CY.BLL.OA;
|
using CY.BLL.Sys;
|
namespace CY.WebForm.Pages.procurement
|
{
|
public partial class GoodsInfoEdit : BasePage
|
{
|
OA_CommoditySpeciAssociate A = new OA_CommoditySpeciAssociate();
|
OA_BrandBLL _OA_BrandBLL = null;
|
OA_CommodityBLL _OA_CommodityBLL = null;
|
OA_GoodsInfo goodInfo = null;
|
OA_GoodsInfoBLL _OA_GoodsInfoBLL = null;
|
OA_CommoditySpeciAssociateBLL _OA_CommoditySpeciAssociateBLL = null;
|
OA_SpecificationBLL _OA_SpecificationBLL = null;
|
Sys_DictionaryBLL _Sys_DictionaryBLL = null;
|
|
public GoodsInfoEdit()
|
{
|
_Sys_DictionaryBLL = new Sys_DictionaryBLL();
|
_OA_BrandBLL = new OA_BrandBLL();
|
_OA_CommodityBLL = new OA_CommodityBLL();
|
_OA_GoodsInfoBLL = new OA_GoodsInfoBLL();
|
goodInfo = new OA_GoodsInfo();
|
_OA_SpecificationBLL = new OA_SpecificationBLL();
|
_OA_CommoditySpeciAssociateBLL = new OA_CommoditySpeciAssociateBLL();
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
try
|
{
|
if (!string.IsNullOrEmpty(Request["GoodsName"].ToString2()))
|
{
|
int id = Request["id"].ToInt32() ?? 0;
|
bool result = _OA_GoodsInfoBLL.isExistGoodsName(Request["GoodsName"].ToString2(), CurrentUser.MemberId, id);
|
Response.Write(result ? "1" : "0");
|
}
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
string ms = ex.Message;
|
Response.Clear();
|
Response.Write("-1");
|
}
|
if (!string.IsNullOrEmpty(Request["GoodsName"].ToString2()))
|
{
|
Response.End();
|
}
|
if (!IsPostBack)
|
{
|
BindList();
|
if (Request["Keyid"].ToInt32() > 0)
|
{
|
BindModifyData();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 货品状态 货品类别的数据添加
|
/// </summary>
|
protected void BindList()
|
{
|
this.txtOrderNum.Value = _OA_BrandBLL.GetMaxOrderNum(CurrentUser.MemberId, " OA_GoodsInfo ");
|
this.selGoodsStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("货品状态");
|
this.selGoodsStatus.DataBind();
|
//this.selGoodsStatus.Items.Insert(0, new ListItem("请选择", ""));
|
//this.RBbrandList.DataSource = _OA_BrandBLL.getAllBrand(CurrentUser.MemberId);
|
//this.RBbrandList.DataTextField = "Name";
|
//this.RBbrandList.DataValueField = "Keyid";
|
//this.RBbrandList.DataBind();
|
DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId,"","true");
|
|
var dic = new Dictionary<string, string>();
|
GetDataByLevel(dwCommity, ds, 0, 0);
|
}
|
|
#region 上级父类数据初始化
|
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;
|
}
|
|
#endregion
|
|
/// <summary>
|
/// 取得不同类别下面的规格、是否纸张
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
//protected void dwCommity_SelectedIndexChanged(object sender, EventArgs e)
|
//{
|
// this.RBspecificationList.DataSource = _OA_CommoditySpeciAssociateBLL.SelectALLModel(dwCommity.SelectedValue);
|
// this.RBspecificationList.DataTextField = "OA_SpecificationName";
|
// this.RBspecificationList.DataValueField = "SpecificationId";
|
// this.RBspecificationList.DataBind();
|
|
// OA_Commodity Commodity = _OA_CommodityBLL.SelectSingleModel(dwCommity.SelectedValue);
|
// if (Commodity.IsPaper == true)
|
// {
|
// this.trWeight.Visible = true;
|
// }
|
//}
|
|
/// <summary>
|
/// 装载要更新的数据
|
/// </summary>
|
protected void BindModifyData()
|
{
|
if (Request["Keyid"].ToInt32() > 0)
|
{
|
goodInfo = _OA_GoodsInfoBLL.SelectSingleModel(Request["Keyid"].ToString2());
|
|
this.txtGoodsName.Value = goodInfo.GoodsName;
|
this.dwCommity.SelectedValue = goodInfo.GoodsTypeId;
|
this.txtOrderNum.Value = goodInfo.OrderNum.ToString2();
|
//this.RBspecificationList.DataSource = _OA_CommoditySpeciAssociateBLL.SelectALLModel(goodInfo.GoodsTypeId);
|
//this.RBspecificationList.DataTextField = "OA_SpecificationName";
|
//this.RBspecificationList.DataValueField = "SpecificationId";
|
//this.RBspecificationList.DataBind();
|
//this.RBbrandList.SelectedValue = goodInfo.BrandId.ToString2();
|
//this.RBspecificationList.SelectedValue = goodInfo.SpecificationId.ToString2();
|
//this.txtWeight.Value = goodInfo.Weight.ToString2();
|
//if (!string.IsNullOrEmpty(goodInfo.Weight.ToString2()))
|
//{
|
// this.trWeight.Visible = true;
|
//}
|
//this.txtWarningInventory.Value = goodInfo.WarningInventory.ToString2();
|
//this.txtGoodsHeight.Value = goodInfo.GoodsHeight.ToString2();
|
//this.txtGoodsLength.Value = goodInfo.GoodsLength.ToString2();
|
//this.txtGoodsWidth.Value = goodInfo.GoodsWidth.ToString2();
|
//this.txtPrice.Value = goodInfo.Price.ToString2();
|
//this.txtUnit.Value = goodInfo.Unit.ToString2();
|
|
this.selGoodsStatus.Value = goodInfo.StatusId.ToString2();
|
}
|
else
|
{
|
this.txtGoodsName.Value = "";
|
this.txtOrderNum.Value = goodInfo.OrderNum.ToString2();
|
}
|
}
|
|
protected void btn_config_Click(object sender, EventArgs e)
|
{
|
goodInfo.Price = 0;
|
goodInfo.WarningInventory = 0;
|
goodInfo.GoodsHeight =0;
|
goodInfo.GoodsLength =0;
|
goodInfo.GoodsWidth = 0;
|
goodInfo.GoodsName = this.txtGoodsName.Value;
|
goodInfo.GoodsTypeId = this.dwCommity.SelectedValue;
|
goodInfo.LastUpdateTime = DateTime.Now;
|
goodInfo.Operator = CurrentUser.ShortName;
|
goodInfo.Remark = " ";
|
goodInfo.SpecificationId = 0;
|
goodInfo.BrandId = 0;
|
goodInfo.Weight = 0;
|
goodInfo.OrderNum = this.txtOrderNum.Value.ToInt32();
|
goodInfo.StatusId = this.selGoodsStatus.Value.ToInt32();
|
goodInfo.Unit = " ";
|
|
goodInfo.FirmId = CurrentUser.MemberId;
|
if (Request["Keyid"].ToInt32() > 0)
|
{
|
goodInfo.Keyid = Request["Keyid"].ToInt32();
|
if (_OA_GoodsInfoBLL.UpdateModel(goodInfo))
|
JavaScript.MessageBox("更新成功", this, true, true);
|
else
|
JavaScript.MessageBox("更新失败", this);
|
}
|
else
|
{
|
if (_OA_GoodsInfoBLL.insertModel(goodInfo))
|
{
|
BindModifyData();
|
JavaScript.MessageBox("添加成功", this, false, true);
|
}
|
else
|
JavaScript.MessageBox("添加失败", this);
|
}
|
}
|
}
|
}
|