/**
|
* OrderEdit.aspx.cs
|
*
|
* 功 能: 订单列表
|
* 类 名: OrderEdit
|
*
|
* Ver 变更日期 负责人 变更内容
|
* ───────────────────────────────────
|
* V0.01 2013-5-8 13:55 吴崎均 初版
|
* V0.02 2013-5-8 15:47 吴崎均 实现下拉数据绑定与数据级联
|
* V0.03 2013-5-8 18:00 吴崎均 初步完成新增线下订单(未调试)
|
*
|
*/
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.UI;
|
using System.Web.UI.WebControls;
|
using CY.BLL.Sys;
|
using CY.BLL;
|
using CY.Model;
|
using CY.Infrastructure.Common;
|
using CY.WebForm.Pages.common;
|
using CY.BLL.EC;
|
using CY.Model.Inquiry;
|
|
namespace CY.WebForm.Pages.business
|
{
|
public partial class DeliverPlanYijiao : BasePage
|
{
|
|
OA_DeliverPlanPaicheBLL _OA_DeliverPlanBLL = null;
|
OA_StaffBLL bll_OA_StaffBLL = null;
|
OA_CarManageBll _OA_CarManageBll = null;
|
|
|
//初始化
|
public DeliverPlanYijiao()
|
{
|
|
_OA_DeliverPlanBLL = new OA_DeliverPlanPaicheBLL();
|
bll_OA_StaffBLL = new OA_StaffBLL();
|
_OA_CarManageBll = new OA_CarManageBll();
|
|
}
|
|
/// <summary>
|
/// 页面加载事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
try
|
{
|
switch (Request["Target"])
|
{
|
case "GetCommunication":
|
LoadCommunication();
|
break;
|
case "ReBindClients":
|
Response.Write(ReLoadClients());
|
break;
|
|
default:
|
Page_Load_Default();
|
return;
|
}
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
Response.Clear();
|
//Response.Write("-1");
|
Response.Write(ex.Message);
|
}
|
Response.End();
|
}
|
|
|
|
/// <summary>
|
/// 默认执行方法
|
/// </summary>
|
private void Page_Load_Default()
|
{
|
|
|
|
if (!IsPostBack && !IsCallback)
|
{
|
|
|
|
|
|
|
|
|
|
|
string ids = Request["ids"];
|
var deliverPlan = _OA_DeliverPlanBLL.GetModelByKeyid(ids.ToGuid2(), null, null);
|
if (deliverPlan.Transferstatus.HasValue && deliverPlan.Transferstatus != 0)
|
{
|
if(deliverPlan.TransferType.HasValue && deliverPlan.TransferType.Value == 1)
|
{
|
this.IsBusinessManager.Items.Add(new ListItem(deliverPlan.TransferName, "1"));
|
this.IsBusinessManager.Items.Add(new ListItem("工厂物流部", "2"));
|
this.IsBusinessManager.SelectedValue = deliverPlan.TransferType.Value.ToString();
|
}
|
else if (deliverPlan.TransferType.HasValue && deliverPlan.TransferType.Value == 2)
|
{
|
this.IsBusinessManager.Items.Add(new ListItem("业务经理", "1"));
|
this.IsBusinessManager.Items.Add(new ListItem("工厂物流部", "2"));
|
this.IsBusinessManager.SelectedValue = deliverPlan.TransferType.Value.ToString();
|
}
|
else
|
{
|
this.IsBusinessManager.Items.Add(new ListItem("业务经理", "1"));
|
this.IsBusinessManager.Items.Add(new ListItem("工厂物流部", "2"));
|
this.IsBusinessManager.SelectedValue = "1";
|
}
|
|
|
}
|
else
|
{
|
this.IsBusinessManager.Items.Add(new ListItem("业务经理", "1"));
|
this.IsBusinessManager.Items.Add(new ListItem("工厂物流部", "2"));
|
this.IsBusinessManager.SelectedValue = "1";
|
}
|
|
|
|
|
|
}
|
}
|
|
/// <summary>
|
/// 保存点击事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
protected void btnSave_ServerClick(object sender, EventArgs e)
|
{
|
|
if (SaveOrder())
|
{
|
//操作成功
|
JavaScript.MessageBox("操作成功", this, true,true);
|
}
|
else
|
{
|
//操作失败
|
JavaScript.MessageBox("操作失败", this);
|
}
|
}
|
|
|
|
|
|
/// <summary>
|
/// 加载客户联系方式
|
/// </summary>
|
private void LoadCommunication()
|
{
|
Response.Clear();
|
string id = Request["id"];
|
if (string.IsNullOrEmpty(id))
|
{
|
Response.Write("-2");
|
return;
|
}
|
|
OA_CorporateClientsBLL _oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
|
OA_CorporateClients m_OA_CorporateClients = _oA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, id.ToGuid2());
|
OA_CustomerCommunications _oA_CustomerCommunications = _oA_CorporateClientsBLL.GetModel_CustomerCommunications(m_OA_CorporateClients.Keyid);
|
_oA_CustomerCommunications.DegreeImportanId = m_OA_CorporateClients.DegreeImportanId;
|
_oA_CustomerCommunications.AccountManagerId = m_OA_CorporateClients.AccountManagerId;
|
_oA_CustomerCommunications.BusinessManagerId = m_OA_CorporateClients.BusinessManagerId;
|
_oA_CustomerCommunications.CompanyName = m_OA_CorporateClients.CompanyName;
|
Response.Write(null == _oA_CustomerCommunications ? "" : JsonHelper.GetJsonStringByObject(_oA_CustomerCommunications));
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
/// 保存订单
|
/// </summary>
|
private bool SaveOrder()
|
{
|
|
|
bool isWin = false;
|
try
|
{
|
|
var ids = Request["ids"].ToString().Trim(',').Split(',');
|
|
|
|
foreach (var keyid in ids)
|
{
|
var deliverPlan = _OA_DeliverPlanBLL.GetModelByKeyid(keyid.ToGuid2(), null, null);
|
|
deliverPlan.TransferType = this.IsBusinessManager.SelectedValue.ToInt32();
|
if(this.IsBusinessManager.SelectedValue == "2")
|
{
|
deliverPlan.TransferName = "工厂物流部";
|
}
|
else
|
{
|
if(deliverPlan.BusinessManagerId.HasValue && deliverPlan.BusinessManagerId.Value > 0)
|
{
|
var oA_Staff = bll_OA_StaffBLL.GetModelByKeyid(deliverPlan.BusinessManagerId.Value);
|
if (oA_Staff != null)
|
{
|
deliverPlan.TransferName = oA_Staff.Name;
|
}
|
else
|
{
|
deliverPlan.TransferName = "业务经理";
|
}
|
}
|
else
|
{
|
deliverPlan.TransferName = "业务经理";
|
}
|
|
|
}
|
|
|
//var carManage = _OA_CarManageBll.SelectListByFirmId(CurrentUser.MemberId).Where(x => x.StaffID == deliverPlan.DriverId).FirstOrDefault();
|
//if (carManage != null)
|
//{
|
// deliverPlan.CarId = carManage.Keyid ?? 0;
|
//}
|
isWin = _OA_DeliverPlanBLL.UpdateModel(deliverPlan);
|
}
|
|
|
|
}
|
catch (Exception ex)
|
{
|
isWin = false;
|
}
|
|
|
|
|
|
return isWin;
|
}
|
|
|
|
/// <summary>
|
/// 重新加载客户列表
|
/// </summary>
|
/// <returns></returns>
|
private string ReLoadClients()
|
{
|
try
|
{
|
string res = "<option value=''>请选择</option>";
|
OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
|
IList<OA_CorporateClients> m_OA_CorporateClientsList = bll_OA_CorporateClientsBLL.SelectListByFirmId(CurrentUser.MemberId) as IList<OA_CorporateClients>;
|
if (null != m_OA_CorporateClientsList)
|
{
|
m_OA_CorporateClientsList.Where(cc => CurrentUser.MemberId.Equals(cc.MemberId) && m_OA_CorporateClientsList.Remove(cc));
|
if (m_OA_CorporateClientsList.Count > 0)
|
{
|
foreach (var m_OA_CorporateClients in m_OA_CorporateClientsList)
|
{
|
res = res + ("<option value='" + m_OA_CorporateClients.MemberId + "'>" + m_OA_CorporateClients.CompanyName + "</option>");
|
}
|
}
|
}
|
return res;
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
return "";
|
}
|
}
|
}
|
}
|