using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL;
using CY.Model;
using CY.Infrastructure.Query;
using CY.Infrastructure.Common;
using CY.BLL.EC;
namespace CY.WebForm.Pages.webmanage
{
public partial class PrizeInfoEdit :BasePage
{
public string Province = "";
public string City = "";
public string County = "";
EC_PrizeInfo prizeInfo = null;
EC_PrizeInfoBLL _EC_PrizeInfoBLL = null;
EC_PrizeReciveAddressBLL _EC_PrizeReciveAddressBLL = null;
public PrizeInfoEdit()
{
prizeInfo = new EC_PrizeInfo(); //实例化奖品实体类
_EC_PrizeInfoBLL = new EC_PrizeInfoBLL(); // 实例化奖品信息操作对象
_EC_PrizeReciveAddressBLL = new EC_PrizeReciveAddressBLL(); // 实例化奖品地址信息操作对象
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitialAddressData();
if (Request["Keyid"].ToInt32() > 0)
{
InitialModifyData();
}
}
}
public void InitialAddressData()
{
this.selPrizeAddress.DataSource = _EC_PrizeReciveAddressBLL.getAllPriceAddress();
this.selPrizeAddress.DataBind();
}
///
/// 如果是修改则显示原来数据的信息
///
public void InitialModifyData()
{
prizeInfo = _EC_PrizeInfoBLL.getOnePrizeInfo(Request["Keyid"].ToInt32());
this.trImg.Visible = string.IsNullOrEmpty(prizeInfo.FileId)? false:true;
this.imgFileId.Src = prizeInfo.FileId;
this.txtAllCount.Value = prizeInfo.AllCount.ToString2();
this.txtCommoditycode.Value = prizeInfo.Commoditycode.ToString2();
this.txtExchangedCount.Value = prizeInfo.ExchangedCount.ToString2();
this.txtNeedIntegral.Value = prizeInfo.NeedIntegral.ToString2();
this.txtOrderCode.Value = prizeInfo.OrderCode.ToString2();
this.txtPrizeName.Value = prizeInfo.PrizeName;
this.txtSingleExCount.Value = prizeInfo.SingleExCount.ToString2();
this.selPrizeAddress.Value = prizeInfo.ReceiveAddId.ToString2();
this.txtPrizeName.Value = prizeInfo.PrizeName;
this.selIsUsed.Value = prizeInfo.IsUsed.ToString2();
this.txtRemark.Value = prizeInfo.Remark;
}
protected void btn_Submit_Click(object sender, EventArgs e)
{
//上传奖品照片
CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult0 = CY.WebForm.cs.UploadCS.Upload("FileId", prizeInfo.FileId);
if (_UpFileResult0.returnerror.Count == 0)
{
if (_UpFileResult0.returnfilename.Count > 0)
{
prizeInfo.FileId = _UpFileResult0.returnfilename[0].ToString2();
}
else
{
prizeInfo.FileId = "";
}
}
else
{
prizeInfo.FileId = "";
JavaScript.MessageBox(string.Join("
", (string[])_UpFileResult0.returnerror.ToArray(typeof(string))), this);
return;
}
if (Request["Keyid"].ToInt32() > 0)
{
prizeInfo = _EC_PrizeInfoBLL.getOnePrizeInfo(Request["Keyid"].ToInt32());
if (!string.IsNullOrEmpty( this.FileId.Value) )
{
if (_UpFileResult0.returnerror.Count == 0)
{
if (_UpFileResult0.returnfilename.Count > 0)
{
prizeInfo.FileId = _UpFileResult0.returnfilename[0].ToString2();
}
else
{
prizeInfo.FileId = "";
}
}
else
{
prizeInfo.FileId = "";
JavaScript.MessageBox(string.Join("
", (string[])_UpFileResult0.returnerror.ToArray(typeof(string))), this);
return;
}
}
}
//更新或添加奖品信息
prizeInfo.ExchangedCount = this.txtExchangedCount.Value.ToInt32();
prizeInfo.AllCount = this.txtAllCount.Value.ToInt32();
prizeInfo.Commoditycode = this.txtCommoditycode.Value.ToString2();
prizeInfo.IsUsed = this.selIsUsed.Value.ToBoolean2();
prizeInfo.LastUpdateTime = DateTime.Now;
prizeInfo.NeedIntegral = this.txtNeedIntegral.Value.ToInt32();
prizeInfo.Operator = this.CurrentUser.ShortName;
prizeInfo.OrderCode = this.txtOrderCode.Value.ToString2();
prizeInfo.PrizeName = this.txtPrizeName.Value.ToString2();
prizeInfo.Remark = this.txtRemark.Value.ToString2();
prizeInfo.SingleExCount = this.txtSingleExCount.Value.ToInt32();
prizeInfo.ReceiveAddId = this.selPrizeAddress.Value.ToInt32();
if (Request["Keyid"].ToInt32() > 0)
{
if (_EC_PrizeInfoBLL.UpdateModel(prizeInfo))
{
JavaScript.RefreshDIVOpener(this);
}
else
{
JavaScript.MessageBox("更新失败", this);
}
}
else
{
if (_EC_PrizeInfoBLL.InsertModel(prizeInfo))
{
JavaScript.RefreshDIVOpener(this);
}
else
{
JavaScript.MessageBox("插入失败", this);
}
}
}
}
}