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.Infrastructure.Query;
|
using CY.BLL.OA;
|
using CY.Infrastructure.Common;
|
using System.Data;
|
namespace CY.WebForm.Pages.procurement
|
{
|
public partial class OA_PaperWeightEdit : BasePage
|
{
|
OA_PaperWeightBLL _OA_PaperWeightBLL = null;
|
OA_PaperWeight paperWeight = null;
|
OA_CommodityBLL _OA_CommodityBLL = null;
|
OA_GoodsInfoBLL _OA_GoodsInfoBLL = null;
|
OA_BrandBLL _OA_BrandBLL = null;
|
|
public OA_PaperWeightEdit()
|
{
|
_OA_BrandBLL = new OA_BrandBLL();
|
_OA_GoodsInfoBLL = new OA_GoodsInfoBLL();
|
_OA_CommodityBLL = new OA_CommodityBLL();
|
paperWeight = new OA_PaperWeight();
|
_OA_PaperWeightBLL = new OA_PaperWeightBLL();
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
try
|
{
|
if (!string.IsNullOrEmpty(Request["PaperWeightName"].ToString2()))
|
{
|
int id = Request["id"].ToInt32() ?? 0;
|
int GoodsId = Request["Goodsid"].ToInt32() ?? 0;
|
bool result = _OA_PaperWeightBLL.isExistPaperWeightName(Request["PaperWeightName"].ToString2(), CurrentUser.MemberId, id, GoodsId);
|
Response.Write(result ? "1" : "0");
|
}
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
string ms = ex.Message;
|
Response.Clear();
|
Response.Write("-1");
|
}
|
if (!string.IsNullOrEmpty(Request["PaperWeightName"].ToString2()))
|
{
|
Response.End();
|
}
|
|
|
if (!IsPostBack)
|
{
|
string PaperCommodiyId = _OA_CommodityBLL.getCommodityId(CurrentUser.MemberId).Keyid.ToString2();
|
ChangeSelBrand(PaperCommodiyId);
|
if (Request["EditKeyid"].ToInt32() > 0)
|
|
InitialData();
|
}
|
}
|
|
protected void InitialSelData()
|
{
|
DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId, "true", "true");
|
var dic = new Dictionary<string, string>();
|
}
|
|
protected void InitialData()
|
{
|
paperWeight = _OA_PaperWeightBLL.getSingleBrand(Request["EditKeyid"].ToString2());
|
if (paperWeight != null)
|
{
|
this.txtBrandName.Value = paperWeight.Name;
|
//this.dwCommity.SelectedValue = paperWeight.CommodityId.ToString2();
|
ChangeSelBrand(paperWeight.CommodityId.ToString2());
|
this.selGoodName.Value = paperWeight.GoodsId.ToString2();
|
this.txtOrderNum.Value = paperWeight.OrderNum.ToString2();
|
}
|
else
|
{
|
this.txtBrandName.Value = "";
|
this.txtOrderNum.Value = _OA_BrandBLL.GetMaxOrderNum(CurrentUser.MemberId, "OA_PaperWeight");
|
}
|
}
|
|
protected void btn_Submit_Click(object sender, EventArgs e)
|
{
|
if (Request["EditKeyid"].ToInt32() > 0)
|
{
|
paperWeight = _OA_PaperWeightBLL.getSingleBrand(Request["EditKeyid"].ToString2());
|
}
|
|
paperWeight.FirmId = CurrentUser.MemberId;
|
paperWeight.LastUpdateTime = DateTime.Now;
|
paperWeight.Name = txtBrandName.Value;
|
paperWeight.Operator = CurrentUser.ShortName;
|
paperWeight.OrderNum = this.txtOrderNum.Value.ToInt32();
|
paperWeight.GoodsId = this.selGoodName.Value.ToInt32();
|
paperWeight.CommodityId = _OA_CommodityBLL.getCommodityId(CurrentUser.MemberId).Keyid;
|
if (Request["EditKeyid"].ToInt32() > 0)
|
{
|
if (_OA_PaperWeightBLL.UpdateModel(paperWeight))
|
JavaScript.MessageBoxCloseAndRefreshFirst("更新成功", this);
|
else
|
JavaScript.MessageBox("更新失败", this);
|
}
|
else
|
{
|
if (_OA_PaperWeightBLL.InsertModel(paperWeight))
|
{
|
//InitialData();
|
//JavaScript.MessageBox("添加成功", this, false, true);
|
JavaScript.MessageBoxCloseAndRefreshFirst("添加成功", this);
|
}
|
else
|
JavaScript.MessageBox("添加失败", this);
|
}
|
|
|
}
|
|
protected void dwCommity_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
string PaperCommodiyId = _OA_CommodityBLL.getCommodityId(CurrentUser.MemberId).ToString2();
|
this.selGoodName.DataValueField = "Keyid";
|
this.selGoodName.DataTextField = "GoodsName";
|
this.selGoodName.DataBind();
|
}
|
|
protected void ChangeSelBrand(string CommodityId)
|
{
|
this.txtOrderNum.Value = _OA_BrandBLL.GetMaxOrderNum(CurrentUser.MemberId, "OA_PaperWeight");
|
this.selGoodName.DataSource = _OA_GoodsInfoBLL.SlectModleByCommity(CommodityId, CurrentUser.MemberId);
|
this.selGoodName.DataValueField = "Keyid";
|
this.selGoodName.DataTextField = "GoodsName";
|
this.selGoodName.DataBind();
|
}
|
}
|
}
|