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.Sys;
using CY.BLL.Promotion;
using CY.Infrastructure;
using System.Data.SqlClient;
using System.Data;
using CY.Infrastructure.Common;
namespace CY.WebForm.Pages.sysglobal
{
public partial class AddPromotionRule : BasePage
{
Sys_DictionaryBLL _Sys_DictionaryBLL = null; //字典业务逻辑操作类对象
Promotion_IncomeRuleBLL _Promotion_IncomeRuleBLL = null; // 推广收益规则 业务逻辑操作对象
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitPageData();
if (Request["Keyid"].ToInt32() > 0)
{
ModifyData();
}
}
}
public AddPromotionRule()
{
_Sys_DictionaryBLL = new Sys_DictionaryBLL();
_Promotion_IncomeRuleBLL = new Promotion_IncomeRuleBLL();
}
///
/// 初始化页面数据
///
private void InitPageData()
{
lstSourceType.DataSource = _Sys_DictionaryBLL.GetDataByType("来源类型");
lstSourceType.DataBind();
}
protected void ModifyData()
{
string Keyid = Request["Keyid"];
Promotion_IncomeRule incomerule = _Promotion_IncomeRuleBLL.GetSingleModel(Keyid);
this.lstSourceType.Value = incomerule.SourceTypeId.ToString2();
this.txtPopularizeScore.Value = incomerule.PopularizeScore.ToString2();
this.txtPopularizeNoteMoney.Value = incomerule.PopularizeNoteMoney.ToString2();
this.txtSuperiorScore.Value = incomerule.SuperiorScore.ToString2();
this.txtSuperiorNoteMoney.Value = incomerule.SuperiorNoteMoney.ToString2();
this.lstIsRatio.Value = MyConvert.ConvertToString(incomerule.IsRatio);
this.txtDeputyCityRevenue.Value = incomerule.DeputyCityRevenue.ToString2();
this.txtDeputyDistrictRevenue.Value = incomerule.DeputyDistrictRevenue.ToString2();
this.txtRemark.Value = incomerule.Remark.ToString2();
}
///
/// 插入一条收益规则
///
///
///
protected void btn_Submit_Config(object sender, EventArgs e)
{
Promotion_IncomeRule model = new Promotion_IncomeRule();
model.DeputyDistrictRevenue = MyConvert.ConvertToDecimal(txtDeputyDistrictRevenue.Value);
model.DeputyCityRevenue = MyConvert.ConvertToDecimal(txtDeputyCityRevenue.Value);
model.SourceTypeId = MyConvert.ConvertToInt32(lstSourceType.Value);
model.SuperiorNoteMoney = this.txtSuperiorNoteMoney.Value.ToDecimal2();
model.SuperiorScore = this.txtSuperiorScore.Value.ToDecimal2();
model.PopularizeNoteMoney = this.txtPopularizeNoteMoney.Value.ToDecimal2();
model.PopularizeScore = this.txtPopularizeScore.Value.ToDecimal2();
model.IsRatio = this.lstIsRatio.Value.ToBoolean2();
model.Operator = CurrentUser.ShortName;
model.Remark = this.txtRemark.Value;
model.LastUpdateTime = DateTime.Now;
if (Request["Keyid"].ToInt32() > 0)
{
model.Keyid = Request["Keyid"].ToInt32();
if (_Promotion_IncomeRuleBLL.UpdateModel(model))
JavaScript.MessageBox("更新成功", this, true, true);
else
JavaScript.MessageBox("更新失败", this);
}
else
{
if (_Promotion_IncomeRuleBLL.InsertModel(model))
JavaScript.MessageBox("添加成功", this, true, true);
else
JavaScript.MessageBox("添加失败", this);
}
}
}
}