/**
* 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 DeliverPlanWentiAdd : BasePage
{
public int Orderid = 0;
public int printNum = 0;
OA_CarManageBll _OA_CarManageBll = null;
OA_DeliverPlanPaicheBLL oA_DeliverPlanBLL = null;
OA_StaffBLL _OA_StaffBLL = null;
//初始化
public DeliverPlanWentiAdd()
{
_OA_CarManageBll = new OA_CarManageBll();
oA_DeliverPlanBLL = new OA_DeliverPlanPaicheBLL();
_OA_StaffBLL = new OA_StaffBLL();
}
///
/// 页面加载事件
///
///
///
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();
}
///
/// 默认执行方法
///
private void Page_Load_Default()
{
if (!IsPostBack && !IsCallback)
{
Sys_DictionaryBLL _sys_DictionaryBLL = new Sys_DictionaryBLL();//字典业务逻辑操作类对象
SysInquiry_PrintingTypeBLL _sysInquiry_PrintingTypeBLL = new SysInquiry_PrintingTypeBLL();//印刷业务类型业务逻辑操作类对象
OA_CorporateClientsBLL _oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
IList corporateClients = _oA_CorporateClientsBLL.SelectListByFirmId(CurrentUser.MemberId) as IList;
if (null != corporateClients)
{
corporateClients.Where(cc => CurrentUser.MemberId.Equals(cc.MemberId) && corporateClients.Remove(cc));
}
this.selBuyerId.DataSource = corporateClients;
this.selBuyerId.DataBind();
this.selBuyerId.Items.Insert(0, new ListItem("请选择", ""));
var oA_Staffs = _OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId,false,false);
this.selFankuiren.DataSource = oA_Staffs;
this.selFankuiren.DataTextField = "Name";
this.selFankuiren.DataValueField = "Keyid";
this.selFankuiren.DataBind();
this.selFankuiren.Items.Insert(0, new ListItem("请选择", ""));
this.selFankuiren.Value = CurrentUser.StaffId.Value.ToString();
}
}
///
/// 保存点击事件
///
///
///
protected void btnSave_ServerClick(object sender, EventArgs e)
{
if (SaveOrder())
{
//操作成功
JavaScript.MessageBox("操作成功", this, true,true);
}
else
{
//操作失败
JavaScript.MessageBox("操作失败", this);
}
}
///
/// 加载客户联系方式
///
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));
}
///
/// 保存订单
///
private bool SaveOrder()
{
bool isWin = false;
try
{
var keyid = Request["keyid"];
EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
OA_CorporateClientsBLL _oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
string SellerOrderId = "";
OA_DeliverPlan oA_DeliverPlan = new OA_DeliverPlan();
oA_DeliverPlan.Lianxiren = "";
oA_DeliverPlan.Keyid = Guid.NewGuid();
oA_DeliverPlan.FirmId = CurrentUser.MemberId;
oA_DeliverPlan.DeliverTime = DateTime.Now;
oA_DeliverPlan.DeliveredTime = oA_DeliverPlan.DeliverTime;
if (string.IsNullOrWhiteSpace(this.selBuyerId.Value))
{
oA_DeliverPlan.BuyerId = Guid.Empty;
oA_DeliverPlan.BusinessManagerId = 0;
oA_DeliverPlan.Biddingcompany = 0;
}
else
{
oA_DeliverPlan.BuyerId = this.selBuyerId.Value.ToGuid2();
OA_CorporateClients oA_CorporateClients = _oA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, this.selBuyerId.Value.ToGuid2());
oA_DeliverPlan.BusinessManagerId = oA_CorporateClients.BusinessManagerId ?? 0;
oA_DeliverPlan.Biddingcompany = oA_CorporateClients.Biddingcompany ?? 0;
}
//oA_DeliverPlan.DeliveredTime = null;
oA_DeliverPlan.Zhuyishixiang = "";
oA_DeliverPlan.Gongzuokaoping = "";
oA_DeliverPlan.CarId = 0;
oA_DeliverPlan.DriverId = this.selFankuiren.Value.ToInt32();
oA_DeliverPlan.Transferstatus = 1;
oA_DeliverPlan.TransfersTime = null;
oA_DeliverPlan.Sort = 1;
oA_DeliverPlan.Creater = CurrentUser.TrueMemberId;
oA_DeliverPlan.CreateTime = DateTime.Now;
oA_DeliverPlan.Updater = CurrentUser.TrueMemberId;
oA_DeliverPlan.LastUpdateTime = DateTime.Now;
oA_DeliverPlan.SellerOrderId = SellerOrderId;
oA_DeliverPlan.Dianhua = "";
oA_DeliverPlan.Dizhi = "";
oA_DeliverPlan.wentifankui = this.txtRemark.Value;
oA_DeliverPlan.Remark = "";
oA_DeliverPlan.shifouDelivery = 0;
oA_DeliverPlan.CompanyName = this.txtCompanyName.Value;
isWin = oA_DeliverPlanBLL.InsertModel(oA_DeliverPlan);
}
catch (Exception ex)
{
isWin = false;
}
return isWin;
}
///
/// 重新加载客户列表
///
///
private string ReLoadClients()
{
try
{
string res = "";
OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
IList m_OA_CorporateClientsList = bll_OA_CorporateClientsBLL.SelectListByFirmId(CurrentUser.MemberId) as IList;
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 + ("");
}
}
}
return res;
}
catch (Exception ex)
{
PAGEHandleException(ex);
return "";
}
}
}
}