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;
|
using CY.Infrastructure.Common;
|
using System.Data;
|
using CY.BLL.Sys;
|
using System.Text;
|
|
namespace CY.WebForm.Pages.InfoManage
|
{
|
//吴辉
|
//添加/修改广告
|
public partial class AdEdit : BasePage
|
{
|
Info_AdBLL bll_Info_AdBLL = null;
|
Info_AdLoctionBLL bll_Info_AdLoctionBLL = null;
|
Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
|
EC_MemberBasicBLL bll_EC_MemberBasicBLL = null;
|
EC_PaymentRecordBLL bll_EC_PaymentRecordBLL = null;
|
|
//初始化
|
public AdEdit()
|
{
|
bll_Info_AdBLL = new Info_AdBLL();
|
bll_Info_AdLoctionBLL = new Info_AdLoctionBLL();
|
bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
|
bll_EC_MemberBasicBLL = new EC_MemberBasicBLL();
|
bll_EC_PaymentRecordBLL = new EC_PaymentRecordBLL();
|
}
|
|
//页面加载
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
try
|
{
|
|
switch (Request["datatype"].ToString2())
|
{
|
case "check":
|
if (Request["companyName"] != null && Request["datatype"].ToString2() == "check")
|
Response.Write(BindCompanyList(Request["companyName"].ToString2().Trim()));
|
break;
|
default:
|
if (!IsPostBack)
|
{
|
InitData();
|
}
|
return;
|
}
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
Response.Clear();
|
Response.Write("-1");
|
}
|
Response.End();
|
}
|
|
//页面加载
|
public void InitData()
|
{
|
try
|
{
|
this.selRemark.DataSource = bll_Sys_DictionaryBLL.GetDataByType("网站广告位置版块");
|
this.selRemark.DataValueField = "MeanValue";
|
this.selRemark.DataTextField = "Name";
|
this.selRemark.DataBind();
|
|
Info_Ad m_Info_Ad = new Info_Ad();
|
if (Request["Keyid"] != null && Request["Keyid"].ToInt32() > 0)
|
{
|
m_Info_Ad = bll_Info_AdBLL.SelectModelByKeyId(Request["Keyid"].ToInt32());
|
EC_MemberBasic m_EC_MemberBasic = bll_EC_MemberBasicBLL.GetMemberByMemberId(m_Info_Ad.A_MemberId);
|
this.txtCompanyName.Text = m_EC_MemberBasic.Name;
|
this.selTimeChange.SelectedValue = ((m_Info_Ad.A_EndTime.Value.Year - m_Info_Ad.A_StartTime.Value.Year) * 12 + (m_Info_Ad.A_EndTime.Value.Month - m_Info_Ad.A_StartTime.Value.Month)).ToString2();
|
this.spanStartTime.InnerText = m_Info_Ad.A_StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
this.spanEndTime.InnerText = m_Info_Ad.A_EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
this.txtAP_Title.Value = m_Info_Ad.A_Title.ToString2();
|
if (m_Info_Ad.A_Pic.ToString2() == "" || m_Info_Ad.A_Pic.ToString2() == "xx")
|
{
|
this.afileAP_DefaultImg.Visible = false;
|
}
|
else
|
{
|
this.afileAP_DefaultImg.HRef = m_Info_Ad.A_Pic.ToString2();
|
}
|
this.txtA_Url.Value = m_Info_Ad.A_Url.ToString2();
|
this.selA_IsTarget.Value = m_Info_Ad.A_IsTarget.ToString2();
|
this.txtHideMemberId.Value = m_Info_Ad.A_MemberId.ToString2();
|
|
|
Info_AdLoction m_Info_AdLoctionM = bll_Info_AdLoctionBLL.SelectModelByKeyId(m_Info_Ad.AdLocationId);
|
|
switch (this.selTimeChange.SelectedValue)
|
{
|
case "1":
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Month ?? 0).ToString("0.00");
|
break;
|
case "3":
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Season ?? 0).ToString("0.00");
|
break;
|
case "6":
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Half ?? 0).ToString("0.00");
|
break;
|
case "12":
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Year ?? 0).ToString("0.00");
|
break;
|
default:
|
break;
|
}
|
|
|
List<Info_AdLoction> m_Info_AdLoctionList = bll_Info_AdLoctionBLL.SelectListByMeanValue(m_Info_AdLoctionM.Remark.ToInt32()) as List<Info_AdLoction>;
|
this.selAdLocation.Items.Add(new ListItem("请选择", ""));
|
if (m_Info_AdLoctionList != null && m_Info_AdLoctionList.Count > 0)
|
{
|
foreach (var m_Info_AdLoction in m_Info_AdLoctionList)
|
{
|
this.selAdLocation.Items.Add(new ListItem(m_Info_AdLoction.AP_Title + "[W:" + m_Info_AdLoction.AP_WidePixels + ",H:" + m_Info_AdLoction.AP_HighPixels + "]", m_Info_AdLoction.Keyid.ToString2()));
|
}
|
}
|
this.selAdLocation.SelectedValue = m_Info_Ad.AdLocationId.ToString2();
|
|
this.selRemark.Enabled = false;
|
this.selAdLocation.Enabled = false;
|
this.txtCompanyName.Enabled = false;
|
this.txtReset.Visible = false;
|
}
|
else
|
{
|
this.afileAP_DefaultImg.Visible = false;
|
this.selAdLocation.Items.Add(new ListItem("请选择", ""));
|
}
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
JavaScript.MessageBox("加载失败", this);
|
}
|
}
|
|
//提交事件
|
protected void btn_Submit_form(object sender, EventArgs e)
|
{
|
Info_Ad m_Info_Ad = new Info_Ad();
|
if (Request["Keyid"] != null && Request["Keyid"].ToInt32() > 0)
|
m_Info_Ad = bll_Info_AdBLL.SelectModelByKeyId(Request["Keyid"].ToInt32());
|
|
m_Info_Ad.A_Title = this.txtAP_Title.Value.ToString2();
|
|
//图片上传
|
CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult2 = CY.WebForm.cs.UploadCS.Upload("fileAP_DefaultImg", m_Info_Ad.A_Pic);
|
m_Info_Ad.A_Pic = m_Info_Ad.A_Pic ?? "";
|
if (_UpFileResult2.returnerror.Count == 0)
|
{
|
if (_UpFileResult2.returnfilename.Count > 0)
|
m_Info_Ad.A_Pic = _UpFileResult2.returnfilename[0].ToString2();
|
}
|
else
|
{
|
JavaScript.MessageBox(string.Join("<br/>", (string[])_UpFileResult2.returnerror.ToArray(typeof(string))), this);
|
return;
|
}
|
|
m_Info_Ad.A_Url = this.txtA_Url.Value.ToString2();
|
m_Info_Ad.AdLocationId = this.selAdLocation.SelectedValue.ToInt32();
|
m_Info_Ad.A_IsTarget = this.selA_IsTarget.Value.ToBoolean2();
|
m_Info_Ad.A_StartTime = this.spanStartTime.InnerText.ToDateTime2();
|
m_Info_Ad.A_EndTime = this.spanEndTime.InnerText.ToDateTime2();
|
m_Info_Ad.A_MemberId = this.txtHideMemberId.Value.ToGuid2();
|
m_Info_Ad.A_Remarks = m_Info_Ad.A_Remarks ?? "";
|
m_Info_Ad.LastUpdateTime = DateTime.Now;
|
m_Info_Ad.Operator = CurrentUser.ShortName;
|
|
Info_AdLoction m_Info_AdLoction = bll_Info_AdLoctionBLL.SelectModelByKeyId(this.selAdLocation.SelectedValue.ToInt32());
|
EC_MemberBasic m_EC_MemberBasic = bll_EC_MemberBasicBLL.GetMemberByMemberId(this.txtHideMemberId.Value.ToGuid2());
|
EC_MemberExtend m_EC_MemberExtend = bll_EC_MemberBasicBLL.GetMemberExtendByMemberId(this.txtHideMemberId.Value.ToGuid2());
|
m_Info_Ad.Remark = m_Info_AdLoction.AP_Title + " [宽:" + m_Info_AdLoction.AP_WidePixels + ",高:" + m_Info_AdLoction.AP_HighPixels + "]";
|
|
bool result = false;
|
if (Request["Keyid"] != null && Request["Keyid"].ToInt32() > 0)
|
{
|
result = bll_Info_AdBLL.UpdateModel(m_Info_Ad);
|
if (result)
|
{
|
JavaScript.MessageBox("更新成功", this, true, true);
|
}
|
else
|
JavaScript.MessageBox("更新失败", this);
|
}
|
else
|
{
|
result = bll_Info_AdBLL.InsertModel(m_Info_Ad);
|
if (result)
|
JavaScript.MessageBox("添加成功", this, true, true);
|
else
|
JavaScript.MessageBox("添加失败", this);
|
}
|
if (result && Request["type"] == "no" && !string.IsNullOrEmpty(m_Info_Ad.A_Pic) && m_Info_Ad.A_Pic != "xx")
|
{
|
EC_PaymentRecord m_EC_PaymentRecord = new EC_PaymentRecord();
|
m_EC_PaymentRecord.BusinessManagerId = 0;
|
m_EC_PaymentRecord.AccountManagerId = 0;
|
m_EC_PaymentRecord.PayStartTime = this.spanStartTime.InnerText.ToDateTime2();
|
m_EC_PaymentRecord.PayEndTime = this.spanEndTime.InnerText.ToDateTime2();
|
m_EC_PaymentRecord.LastUpdateTime = DateTime.Now;
|
m_EC_PaymentRecord.AdForum = this.selRemark.SelectedItem.Text;
|
m_EC_PaymentRecord.AdImg = "<a target=\"_blank\" href=\"/Pages/InfoManage/AdDetail.aspx?Keyid=" + m_Info_Ad.Keyid + "\">点击查看</a>";
|
m_EC_PaymentRecord.AdInstallments = "";
|
m_EC_PaymentRecord.AdLocation = m_Info_AdLoction.AP_Title;
|
m_EC_PaymentRecord.AdSize = m_Info_AdLoction.AP_WidePixels + " * " + m_Info_AdLoction.AP_HighPixels;
|
m_EC_PaymentRecord.CompanyPhone = m_EC_MemberExtend.PhoneNum;
|
m_EC_PaymentRecord.Contact = m_EC_MemberExtend.BusinessContacts;
|
m_EC_PaymentRecord.Email = m_EC_MemberExtend.Email;
|
m_EC_PaymentRecord.MemberId = this.txtHideMemberId.Value.ToGuid2();
|
m_EC_PaymentRecord.MemberName = this.txtCompanyName.Text;
|
m_EC_PaymentRecord.Operator = CurrentUser.ShortName;
|
m_EC_PaymentRecord.PayAllMoney = this.txtPrice.Text.ToDecimal2();
|
m_EC_PaymentRecord.PayMoney = this.txtPrice.Text.ToDecimal2();
|
m_EC_PaymentRecord.PayRole = m_EC_MemberBasic.MemberType;
|
m_EC_PaymentRecord.PayType = "网站广告费";
|
m_EC_PaymentRecord.QQ = m_EC_MemberExtend.QQ;
|
m_EC_PaymentRecord.Remark = bll_EC_PaymentRecordBLL.GetNewOrderId();
|
m_EC_PaymentRecord.SoftwarePermissions = "";
|
|
if (bll_EC_PaymentRecordBLL.InsertModel(m_EC_PaymentRecord))
|
{
|
Pay_PaymentAccountBLL _pay_PaymentAccountBLL = new Pay_PaymentAccountBLL();
|
_pay_PaymentAccountBLL.SendPoOrMoToMember(m_EC_MemberBasic.MemberId, 392, m_EC_PaymentRecord.PayMoney);
|
}
|
}
|
}
|
|
//切换版块获取位置
|
protected void changeRemarkGetLocation(object sender, EventArgs e)
|
{
|
this.selAdLocation.Items.Clear();
|
List<Info_AdLoction> m_Info_AdLoctionList = bll_Info_AdLoctionBLL.SelectListByMeanValue(this.selRemark.SelectedValue.ToInt32()) as List<Info_AdLoction>;
|
this.selAdLocation.Items.Add(new ListItem("请选择", ""));
|
if (m_Info_AdLoctionList != null && m_Info_AdLoctionList.Count > 0)
|
{
|
foreach (var m_Info_AdLoction in m_Info_AdLoctionList)
|
{
|
this.selAdLocation.Items.Add(new ListItem(m_Info_AdLoction.AP_Title + "[W:" + m_Info_AdLoction.AP_WidePixels + ",H:" + m_Info_AdLoction.AP_HighPixels + "]", m_Info_AdLoction.Keyid.ToString2()));
|
}
|
}
|
}
|
|
//切换位置获取开始时间和结束时间
|
protected void changeLoctionGetTimeAndMoney(object sender, EventArgs e)
|
{
|
DateTime? LastedTime = DateTime.Now;
|
Info_Ad m_Info_Ad = new Info_Ad();
|
if (Request["Keyid"] != null && Request["Keyid"].ToInt32() > 0)
|
{
|
m_Info_Ad = bll_Info_AdBLL.SelectModelByKeyId(Request["Keyid"].ToInt32());
|
if (m_Info_Ad != null)
|
LastedTime = m_Info_Ad.A_StartTime;
|
}
|
else
|
{
|
m_Info_Ad = bll_Info_AdBLL.SelectListByAdLocationId(this.selAdLocation.SelectedValue.ToInt32());
|
if (m_Info_Ad != null)
|
LastedTime = m_Info_Ad.A_EndTime;
|
}
|
|
string startTimeString = LastedTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
string endTimeString = LastedTime.Value.AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss");
|
|
this.spanStartTime.InnerText = startTimeString;
|
this.spanEndTime.InnerText = endTimeString;
|
|
this.selTimeChange.Items.Clear();
|
this.selTimeChange.Items.Add(new ListItem("一个月", "1"));
|
this.selTimeChange.Items.Add(new ListItem("一季度", "3"));
|
this.selTimeChange.Items.Add(new ListItem("半年", "6"));
|
this.selTimeChange.Items.Add(new ListItem("一年", "12"));
|
Info_AdLoction m_Info_AdLoctionM = bll_Info_AdLoctionBLL.SelectModelByKeyId(this.selAdLocation.SelectedValue.ToInt32());
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Month ?? 0).ToString("0.00");
|
}
|
|
//切换时长更新
|
protected void changeTimeGetStartAndEnd(object sender, EventArgs e)
|
{
|
DateTime? LastedTime = DateTime.Now;
|
Info_Ad m_Info_Ad = new Info_Ad();
|
if (Request["Keyid"] != null && Request["Keyid"].ToInt32() > 0)
|
{
|
m_Info_Ad = bll_Info_AdBLL.SelectModelByKeyId(Request["Keyid"].ToInt32());
|
if (m_Info_Ad != null)
|
LastedTime = m_Info_Ad.A_StartTime;
|
}
|
else
|
{
|
m_Info_Ad = bll_Info_AdBLL.SelectListByAdLocationId(this.selAdLocation.SelectedValue.ToInt32());
|
if (m_Info_Ad != null)
|
LastedTime = m_Info_Ad.A_EndTime;
|
}
|
|
int nowTime = this.selTimeChange.SelectedValue.ToInt32() ?? 1;
|
string startTimeString = LastedTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
string endTimeString = LastedTime.Value.AddMonths(nowTime).ToString("yyyy-MM-dd HH:mm:ss");
|
|
this.spanStartTime.InnerText = startTimeString;
|
this.spanEndTime.InnerText = endTimeString;
|
|
Info_AdLoction m_Info_AdLoctionM = bll_Info_AdLoctionBLL.SelectModelByKeyId(this.selAdLocation.SelectedValue.ToInt32());
|
switch (this.selTimeChange.SelectedValue)
|
{
|
case "1":
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Month ?? 0).ToString("0.00");
|
break;
|
case "3":
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Season ?? 0).ToString("0.00");
|
break;
|
case "6":
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Half ?? 0).ToString("0.00");
|
break;
|
case "12":
|
this.txtPrice.Text = (m_Info_AdLoctionM.Price_Year ?? 0).ToString("0.00");
|
break;
|
default:
|
break;
|
}
|
}
|
|
//绑定关联会员列表
|
protected string BindCompanyList(string companyname)
|
{
|
List<EC_MemberExtend> m_EC_MemberExtendList = bll_EC_MemberBasicBLL.SelectExtendListByName(companyname) as List<EC_MemberExtend>;
|
|
string[] modelArry = new string[m_EC_MemberExtendList.Count];
|
int i = 0;
|
foreach (var item in m_EC_MemberExtendList)
|
{
|
string result = "";
|
StringBuilder sb_html = new StringBuilder();
|
|
sb_html.AppendFormat("CustormKeyId:'{0}',", item.Keyid);
|
sb_html.AppendFormat("CustormName:'{0}'", item.Name);
|
result = "{" + sb_html.ToString() + "}";
|
modelArry[i] = result;
|
i++;
|
}
|
return ("[" + string.Join(",", modelArry) + "]");
|
}
|
}
|
}
|