using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.Inquiry;
using CY.Infrastructure.Common;
using CY.Model;
using CY.Infrastructure.Query;
using CY.BLL.Sys;
namespace CY.WebForm.Pages.business
{
public partial class FollowRecord : BasePage
{
#region 变量
FollowRecordInfoBLL _followRecordInfoBLL = new FollowRecordInfoBLL();
Sys_DictionaryBLL _sys_DictionaryBLL = new Sys_DictionaryBLL();
RecordInfoBLL _recordInfoBLL = new RecordInfoBLL();
#endregion
#region 属性
#endregion
#region 方法
///
/// 初始化绑定页面
///
private void BindList()
{
int keyId = 0;
if (Request["keyId"] != null)
keyId = Request["keyId"].ToString().ToInt32().Value;
Inquiry_RecordInfo recordInfo = _recordInfoBLL.GetModel(keyId);
if (recordInfo.CustomerPrice.HasValue)
{
this.txtCustomerPrice.Value = recordInfo.CustomerPrice.Value.ToString("0.00");
}
this.hidInquiryId.Value = keyId.ToString();
Pagination pa = new Pagination();
pa.PageSize = UCPager1.AspNetPager.PageSize;
pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex;
IList recordList = _followRecordInfoBLL.GetModeList(keyId, pa);
this.RepRecordList.DataSource = recordList;
this.RepRecordList.DataBind();
UCPager1.AspNetPager.RecordCount = pa.RecordCount;
}
private void BindFollowType()
{
IEnumerable list = _sys_DictionaryBLL.GetDataByType("跟单方式");
this.ddlFollowType.DataSource = list;
this.ddlFollowType.DataTextField = "Name";
this.ddlFollowType.DataValueField = "MeanValue";
this.ddlFollowType.DataBind();
}
private void BindIntentType()
{
IEnumerable list = _sys_DictionaryBLL.GetDataByType("成交意向");
this.ddlIntentType.DataSource = list;
this.ddlIntentType.DataTextField = "Name";
this.ddlIntentType.DataValueField = "MeanValue";
this.ddlIntentType.DataBind();
}
#endregion
#region 事件
protected void Page_Load(object sender, EventArgs e)
{
this.UCPager1.AspNetPager.PageChanged += new EventHandler(AspNetPager1_PageChanged);
if (!IsPostBack)
{
BindFollowType();
BindIntentType();
BindList();
}
if (Request["deleteKeyIds"] != null)
{
List deleteKeyIdList = new List();
string deleteKeyIds = Request["deleteKeyIds"].ToString();
if (deleteKeyIds.Contains(","))
{
string[] keyIdArry = deleteKeyIds.Split(',');
foreach (string keyId in keyIdArry)
{
deleteKeyIdList.Add(Convert.ToInt32(keyId));
}
}
else
{
deleteKeyIdList.Add(Convert.ToInt32(deleteKeyIds));
}
bool isSuccess = _followRecordInfoBLL.DeleteModelList(deleteKeyIdList);
if (isSuccess)
{
JavaScript.MessageBox("删除成功", this);
}
else
{
JavaScript.MessageBox("删除失败", this);
}
BindList();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
bool isSuccess = false;
Inquiry_FollowRecordInfo _recordInfo = new Inquiry_FollowRecordInfo();
int keyId = -1;
if (!string.IsNullOrEmpty(this.hidKeyId.Value))
{
keyId = this.hidKeyId.Value.ToInt32().Value;
}
//新增
if (keyId == -1)
{
_recordInfo.RecordId = Request["keyId"].ToString().ToInt32().Value;
if (this.txtCustomerPrice.Value.Trim() == "")
{
_recordInfo.CustomerPrice = null;
}
else
{
_recordInfo.CustomerPrice = this.txtCustomerPrice.Value.ToDecimal2().Value;
}
_recordInfo.FollowTypeId = this.ddlFollowType.SelectedValue.ToString().ToInt32().Value;
_recordInfo.IntentTypeId = this.ddlIntentType.SelectedValue.ToString().ToInt32().Value;
_recordInfo.FollowRecord = this.txtFollowRecord.Text.ToString();
_recordInfo.FollowPerson = CurrentUser.ShortName;
_recordInfo.FollowTime = DateTime.Now;
_recordInfo.ResultStatus = ddlResultStatus.SelectedValue.ToInt32().Value;
isSuccess = _followRecordInfoBLL.InsertModel(_recordInfo);
}
else //修改
{
_recordInfo.KeyId = keyId;
_recordInfo.RecordId = Request["keyId"].ToString().ToInt32().Value;
if (this.txtCustomerPrice.Value.Trim() == "")
{
_recordInfo.CustomerPrice = null;
}
else
{
_recordInfo.CustomerPrice = this.txtCustomerPrice.Value.ToDecimal2().Value;
}
_recordInfo.FollowTypeId = this.ddlFollowType.SelectedValue.ToString().ToInt32().Value;
_recordInfo.IntentTypeId = this.ddlIntentType.SelectedValue.ToString().ToInt32().Value;
_recordInfo.FollowRecord = this.txtFollowRecord.Text.ToString();
_recordInfo.FollowPerson = CurrentUser.ShortName;
_recordInfo.FollowTime = DateTime.Now;
_recordInfo.ResultStatus = ddlResultStatus.SelectedValue.ToInt32().Value;
isSuccess = _followRecordInfoBLL.UpdateModel(_recordInfo);
}
if (isSuccess)
{
JavaScript.RefreshDIVOpener(this);
}
else
{
JavaScript.MessageBox("保存失败", this);
}
txtCustomerPrice.Value = string.Empty;
txtFollowRecord.Text = string.Empty;
this.ddlFollowType.SelectedIndex = 0;
this.ddlIntentType.SelectedIndex = 0;
this.hidKeyId.Value = string.Empty;
BindList();
}
///
/// 分页事件
///
///
///
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
BindList();
}
#endregion
}
}