using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.BLL; using CY.Model; using CY.Infrastructure.Query; using CY.Infrastructure.Common; using CY.BLL.Sys; using System.Text; using CY.BLL.OA; namespace CY.WebForm.Pages.adminclient { //吴辉 //新增/修改合作客户资料 public partial class AddCorporateClients : BasePage { OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null; Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;//字典业务逻辑操作类对象 EC_MemberBasicBLL bll_EC_MemberBasicBLL = null; OA_IntentionCustomerBLL bll_OA_IntentionCustomerBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; public string Province = ""; //接收值 Request["selectProvince"].ToString2(); public string City = "";//接收值 Request["selectCity"].ToString2(); public string County = "";//接收值 Request["selectCounty"].ToString2(); public string Targetid = ""; //收货方式目标值 //初始化 public AddCorporateClients() { bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL(); bll_Sys_DictionaryBLL = new Sys_DictionaryBLL(); bll_EC_MemberBasicBLL = new EC_MemberBasicBLL(); bll_OA_IntentionCustomerBLL = new OA_IntentionCustomerBLL(); bll_OA_StaffBLL = new OA_StaffBLL(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { try { Targetid = Request["Keyid"].ToString2(); 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) { Province = CurrentUser.Province; City = CurrentUser.City; //County = CurrentUser.County; BindData(); } return; } } catch (Exception ex) { PAGEHandleException(ex); Response.Clear(); Response.Write("-1"); } Response.End(); } //绑定数据 protected void BindData() { #region 初始字典表数据 this.selSourcesInfoId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("软件客户来源"); this.selSourcesInfoId.DataValueField = "Keyid"; this.selSourcesInfoId.DataTextField = "Name"; this.selSourcesInfoId.DataBind(); this.selCustomerIndustriesId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("软件所属行业"); this.selCustomerIndustriesId.DataValueField = "Keyid"; this.selCustomerIndustriesId.DataTextField = "Name"; this.selCustomerIndustriesId.DataBind(); this.selCustomerIndustriesId.Value = "435"; this.selCustomerTypeId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("软件客户类型"); this.selCustomerTypeId.DataValueField = "Keyid"; this.selCustomerTypeId.DataTextField = "Name"; this.selCustomerTypeId.DataBind(); this.selBusinessManagerId.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, true, false); this.selBusinessManagerId.DataTextField = "Name"; this.selBusinessManagerId.DataValueField = "Keyid"; this.selBusinessManagerId.DataBind(); this.selBusinessManagerId.Items.Insert(0, new ListItem("请选择", "")); this.selAccountManagerId.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, true); this.selAccountManagerId.DataTextField = "Name"; this.selAccountManagerId.DataValueField = "Keyid"; this.selAccountManagerId.DataBind(); this.selAccountManagerId.Items.Insert(0, new ListItem("请选择", "")); this.selCreditId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户信誉"); this.selCreditId.DataValueField = "Keyid"; this.selCreditId.DataTextField = "Name"; this.selCreditId.DataBind(); this.selCreditId.Value = "76"; this.selDegreeImportanId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户重要程度"); this.selDegreeImportanId.DataValueField = "Keyid"; this.selDegreeImportanId.DataTextField = "Name"; this.selDegreeImportanId.DataBind(); this.selBusinessAnalysisId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户业务分析量"); this.selBusinessAnalysisId.DataValueField = "Keyid"; this.selBusinessAnalysisId.DataTextField = "Name"; this.selBusinessAnalysisId.DataBind(); this.selBusinessAnalysisId.Value = "83"; #endregion if (Request["Keyid"] != null) { OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2()); OA_CustomerCommunications m_OA_CustomerCommunications = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(Request["Keyid"].ToGuid2()); EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers = bll_OA_CorporateClientsBLL.GetModel_AcceptWayByCustomers(Request["Keyid"].ToGuid2()); #region 页面初始合作客户基础信息 this.selSourcesInfoId.Value = m_OA_CorporateClients.SourcesInfoId.ToString2(); this.selCustomerIndustriesId.Value = m_OA_CorporateClients.CustomerIndustriesId.ToString2(); this.selCustomerTypeId.Value = m_OA_CorporateClients.CustomerTypeId.ToString2(); this.selBusinessManagerId.Value = m_OA_CorporateClients.BusinessManagerId.ToString2(); this.selAccountManagerId.Value = m_OA_CorporateClients.AccountManagerId.ToString2(); this.selDegreeImportanId.Value = m_OA_CorporateClients.DegreeImportanId.ToString2(); this.selBusinessAnalysisId.Value = m_OA_CorporateClients.BusinessAnalysisId.ToString2(); //this.selIsLoginCorporateWeb.Value = m_OA_CorporateClients.IsLoginCorporateWeb.ToString2(); this.selCreditId.Value = m_OA_CorporateClients.CreditId.ToString2(); this.txtCompanyName.Value = m_OA_CorporateClients.CompanyName.ToString2(); //this.txtCorporateWebsite.Value = m_OA_CorporateClients.CorporateWebsite.ToString2(); //this.txtCredit.Value = m_OA_CorporateClients.Credit.ToString2().ToDecimal2Yen(); //this.txtLoginPhone.Value = m_OA_CorporateClients.LoginPhone.ToString2(); this.txtBank.Value = m_OA_CorporateClients.Bank.ToString2(); this.txtTaxID.Value = m_OA_CorporateClients.TaxID.ToString2(); this.txtAccountID.Value = m_OA_CorporateClients.AccountID.ToString2(); this.txtRemark.InnerText = m_OA_CorporateClients.Remark.ToString2(); // this.txtPassWord.Value = m_OA_CorporateClients.LoginPwd.ToString2(); #endregion #region 页面初始合作客户通讯信息 this.txtDetailedAddress.Value = m_OA_CustomerCommunications.DetailedAddress.ToString2(); this.txtCompanyPhone.Value = m_OA_CustomerCommunications.CompanyPhone.ToString2(); this.txtPostcode.Value = m_OA_CustomerCommunications.Postcode.ToString2(); this.txtMobile.Value = m_OA_CustomerCommunications.Mobile.ToString2(); this.txtFax.Value = m_OA_CustomerCommunications.Fax.ToString2(); this.txtEmail.Value = m_OA_CustomerCommunications.Email.ToString2(); this.txtQQ.Value = m_OA_CustomerCommunications.QQ.ToString2(); this.txtLegalRepresentative.Value = m_OA_CustomerCommunications.LegalRepresentative.ToString2(); this.txtLegalMobile.Value = m_OA_CustomerCommunications.LegalMobile.ToString2(); this.txtLegalQQ.Value = m_OA_CustomerCommunications.LegalQQ.ToString2(); this.txtBusinessManagers.Value = m_OA_CustomerCommunications.BusinessManagers.ToString2(); this.txtManagersMobile.Value = m_OA_CustomerCommunications.ManagersMobile.ToString2(); this.txtManagersQQ.Value = m_OA_CustomerCommunications.ManagersQQ.ToString2(); this.txtFinancialOfficers.Value = m_OA_CustomerCommunications.FinancialOfficers.ToString2(); this.txtOfficersMobile.Value = m_OA_CustomerCommunications.OfficersMobile.ToString2(); this.txtOfficersQQ.Value = m_OA_CustomerCommunications.OfficersQQ.ToString2(); Province = m_OA_CustomerCommunications.Province.ToString2(); City = m_OA_CustomerCommunications.City.ToString2(); County = m_OA_CustomerCommunications.County.ToString2(); #endregion } else { #region 页面初始合作客户基础信息 this.txtCompanyName.Value = ""; this.txtBank.Value = ""; this.txtTaxID.Value = ""; this.txtAccountID.Value = ""; this.txtRemark.InnerText = ""; #endregion #region 页面初始合作客户通讯信息 this.txtDetailedAddress.Value = ""; this.txtCompanyPhone.Value = ""; this.txtPostcode.Value = ""; this.txtMobile.Value = ""; this.txtFax.Value = ""; this.txtEmail.Value = ""; this.txtQQ.Value = ""; this.txtLegalRepresentative.Value = ""; this.txtLegalMobile.Value = ""; this.txtLegalQQ.Value = ""; this.txtBusinessManagers.Value = ""; this.txtManagersMobile.Value = ""; this.txtManagersQQ.Value = ""; this.txtFinancialOfficers.Value = ""; this.txtOfficersMobile.Value = ""; this.txtOfficersQQ.Value = ""; #endregion } } //绑定关联会员列表以及意向客户列表 protected string BindCompanyList(string companyname) { Guid Keyid = Request["Keyid"].ToGuid2(); bool isExit = bll_OA_CorporateClientsBLL.isExistCompanyName(companyname, CurrentUser.MemberId, Keyid); if (isExit) return "0"; if (Request["xs"].ToString2() == "blur") { bool resultxs = bll_OA_IntentionCustomerBLL.isExistCompanyName(Request["companyname"].ToString2(), CurrentUser.MemberId, 0); if (resultxs) return "1"; else return "2"; } else { List m_OA_IntentionCustomerList = bll_OA_IntentionCustomerBLL.SelectListByName(companyname, CurrentUser.MemberId) as List; string[] modelArry = new string[m_OA_IntentionCustomerList.Count]; int i = 0; foreach (var item in m_OA_IntentionCustomerList) { string result = ""; StringBuilder sb_html = new StringBuilder(); sb_html.AppendFormat("CustormType:'{0}',", "意向客户"); sb_html.AppendFormat("CustormKeyId:'{0}',", item.Keyid); sb_html.AppendFormat("CustormName:'{0}',", item.CompanyName); sb_html.AppendFormat("CustormAddress:'{0}',", item.DetailedAddress); sb_html.AppendFormat("CustormPhone:'{0}',", item.PhoneNum); sb_html.AppendFormat("CustormMobile:'{0}',", item.MobileNum); sb_html.AppendFormat("CustormFax:'{0}',", ""); sb_html.AppendFormat("CustormQQ:'{0}',", item.QQ); sb_html.AppendFormat("CustormEmail:'{0}',", item.Email); sb_html.AppendFormat("CustormPostCode:'{0}',", item.Postcode); sb_html.AppendFormat("CustormWeb:'{0}'", ""); result = "{" + sb_html.ToString() + "}"; modelArry[i] = result; i++; } return ("[" + string.Join(",", modelArry) + "]"); } } //提交事件 protected void btn_Submit_Config(object sender, EventArgs e) { OA_CorporateClients m_OA_CorporateClients = new OA_CorporateClients(); OA_CustomerCommunications m_OA_CustomerCommunications = new OA_CustomerCommunications(); EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers = new EC_AcceptWayByCustomers(); try { Guid Keyid = Request["Keyid"].ToGuid2(); bool isExit = bll_OA_CorporateClientsBLL.isExistCompanyName(this.txtCompanyName.Value.ToString2(), CurrentUser.MemberId, Keyid); if (!isExit) { bool resultxs = bll_OA_IntentionCustomerBLL.isExistCompanyName(this.txtCompanyName.Value.ToString2(), CurrentUser.MemberId, 0); if (resultxs) { JavaScript.MessageBox("此客户已存在于意向客户中,请勿重复添加", this); } else { if (Request["Keyid"] != null) { m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2()); m_OA_CustomerCommunications = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(Request["Keyid"].ToGuid2()); m_EC_AcceptWayByCustomers = bll_OA_CorporateClientsBLL.GetModel_AcceptWayByCustomers(Request["Keyid"].ToGuid2()); if (m_EC_AcceptWayByCustomers == null) { m_EC_AcceptWayByCustomers = new EC_AcceptWayByCustomers(); } } #region 初始合作客户基础信息 m_OA_CorporateClients.CompanyName = this.txtCompanyName.Value.ToString2(); m_OA_CorporateClients.CustomerIndustriesId = this.selCustomerIndustriesId.Value.ToInt32() ?? 0; m_OA_CorporateClients.CustomerTypeId = this.selCustomerTypeId.Value.ToInt32() ?? 0; m_OA_CorporateClients.SourcesInfoId = this.selSourcesInfoId.Value.ToInt32() ?? 0; m_OA_CorporateClients.DegreeImportanId = this.selDegreeImportanId.Value.ToInt32() ?? 0; m_OA_CorporateClients.AccountManagerId = this.selAccountManagerId.Value.ToInt32() ?? 0; m_OA_CorporateClients.BusinessManagerId = this.selBusinessManagerId.Value.ToInt32() ?? 0; m_OA_CorporateClients.CreditId = this.selCreditId.Value.ToInt32() ?? 0; m_OA_CorporateClients.LoginPhone = ""; m_OA_CorporateClients.LoginPwd = ""; m_OA_CorporateClients.CorporateWebsite = ""; m_OA_CorporateClients.BusinessAnalysisId = this.selBusinessAnalysisId.Value.ToInt32() ?? 0; m_OA_CorporateClients.IsLoginCorporateWeb = false; m_OA_CorporateClients.Credit =0; m_OA_CorporateClients.Bank = this.txtBank.Value.ToString2(); m_OA_CorporateClients.TaxID = this.txtTaxID.Value.ToString2(); m_OA_CorporateClients.AccountID = this.txtAccountID.Value.ToString2(); m_OA_CorporateClients.OutVendorName = CurrentUser.Name; m_OA_CorporateClients.LastUpdateTime = DateTime.Now; m_OA_CorporateClients.Operator = CurrentUser.ShortName; m_OA_CorporateClients.Remark = this.txtRemark.InnerText.ToString2(); m_OA_CorporateClients.OutRate =1; #endregion #region 初始合作客户通讯信息 m_OA_CustomerCommunications.Province = Request["selectProvince"].ToString2(); m_OA_CustomerCommunications.City = Request["selectCity"].ToString2(); m_OA_CustomerCommunications.County = Request["selectCounty"].ToString2(); m_OA_CustomerCommunications.DetailedAddress = this.txtDetailedAddress.Value.ToString2(); m_OA_CustomerCommunications.CompanyPhone = this.txtCompanyPhone.Value.ToString2(); m_OA_CustomerCommunications.Postcode = this.txtPostcode.Value.ToString2(); m_OA_CustomerCommunications.Mobile = this.txtMobile.Value.ToString2(); m_OA_CustomerCommunications.Fax = this.txtFax.Value.ToString2(); m_OA_CustomerCommunications.Email = this.txtEmail.Value.ToString2(); m_OA_CustomerCommunications.QQ = this.txtQQ.Value.ToString2(); m_OA_CustomerCommunications.LegalRepresentative = this.txtLegalRepresentative.Value.ToString2(); m_OA_CustomerCommunications.LegalMobile = this.txtLegalMobile.Value.ToString2(); m_OA_CustomerCommunications.LegalQQ = this.txtLegalQQ.Value.ToString2(); m_OA_CustomerCommunications.BusinessManagers = this.txtBusinessManagers.Value.ToString2(); m_OA_CustomerCommunications.ManagersMobile = this.txtManagersMobile.Value.ToString2(); m_OA_CustomerCommunications.ManagersQQ = this.txtManagersQQ.Value.ToString2(); m_OA_CustomerCommunications.FinancialOfficers = this.txtFinancialOfficers.Value.ToString2(); m_OA_CustomerCommunications.OfficersMobile = this.txtOfficersMobile.Value.ToString2(); m_OA_CustomerCommunications.OfficersQQ = this.txtOfficersQQ.Value.ToString2(); m_OA_CustomerCommunications.Remark = ""; m_OA_CustomerCommunications.LastUpdateTime = DateTime.Now; m_OA_CustomerCommunications.Operator = CurrentUser.ShortName; #endregion #region 初始合作客户收货地址 m_EC_AcceptWayByCustomers.AcceptTypeId = Request["AcceptTypeId"].ToInt32() ?? 0; m_EC_AcceptWayByCustomers.InvoiceDemand = Request["InvoiceId"].ToString2(); m_EC_AcceptWayByCustomers.Remark = Request["Remark"].ToString2(); m_EC_AcceptWayByCustomers.LastUpdateTime = DateTime.Now; m_EC_AcceptWayByCustomers.Operator = CurrentUser.ShortName; m_EC_AcceptWayByCustomers.City = ""; m_EC_AcceptWayByCustomers.Accepter = ""; m_EC_AcceptWayByCustomers.AccepterPhone = ""; m_EC_AcceptWayByCustomers.AppointCourierCompany = ""; m_EC_AcceptWayByCustomers.AccepterAddress = ""; m_EC_AcceptWayByCustomers.AccepterPhoneNum = ""; m_EC_AcceptWayByCustomers.AcceptContacts = ""; m_EC_AcceptWayByCustomers.FetchAddress = ""; m_EC_AcceptWayByCustomers.FetchPhoneNum = ""; m_EC_AcceptWayByCustomers.FetchContacts = ""; m_EC_AcceptWayByCustomers.AppointCourierCompany = ""; #endregion #region 添加或编辑 if (Request["Keyid"] != null) { bool result = bll_OA_CorporateClientsBLL.UpdateModel(m_OA_CorporateClients, m_OA_CustomerCommunications, m_EC_AcceptWayByCustomers);//更新信息 if (result) JavaScript.MessageBox("更新成功", this, true, true); else JavaScript.MessageBox("更新失败", this); } else { m_OA_CorporateClients.OrderCount = 0; m_OA_CorporateClients.OrderMoney = 0; m_OA_CorporateClients.Prepayments = 0; m_OA_CorporateClients.IsOutsourcing = false; m_OA_CorporateClients.IsPriority = false; m_OA_CorporateClients.CumulativePrepayments = 0; m_OA_CorporateClients.Keyid = Guid.NewGuid(); m_OA_CorporateClients.CreateTime = DateTime.Now; m_OA_CorporateClients.CustomerId = bll_OA_CorporateClientsBLL.GetLastIdByFirmId(CurrentUser.MemberId) + 1; m_OA_CorporateClients.FirmId = CurrentUser.MemberId; m_OA_CorporateClients.InquiryId = CurrentUser.InquiryId; if (this.txtHideMemberType.Value == "网站会员") { m_OA_CorporateClients.MemberId = this.txtHideMemberId.Value.ToGuid2(); } else { m_OA_CorporateClients.MemberId = m_OA_CorporateClients.Keyid; } m_OA_CustomerCommunications.Keyid = m_OA_CorporateClients.Keyid; m_EC_AcceptWayByCustomers.TargetId = m_OA_CorporateClients.Keyid; bool result = bll_OA_CorporateClientsBLL.InsertModel(m_OA_CorporateClients, m_OA_CustomerCommunications, m_EC_AcceptWayByCustomers);//添加信息 if (result) { Province = CurrentUser.Province; City = CurrentUser.City; County = CurrentUser.County; JavaScript.MessageBox("添加成功", this,false,true); BindData(); } else JavaScript.MessageBox("添加失败", this); } #endregion } } else { JavaScript.MessageBox("此客户已存在,请勿重复添加", this); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("操作失败", this); } } } }