Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var updateLocationContact = Request.QueryString["updateLocationContact"];
                var updateFaxPhoneContact = Request.QueryString["updateFaxPhoneContact"];
                var account_id            = Request.QueryString["account_id"];

                // GetContactByIds
                if (!string.IsNullOrEmpty(updateLocationContact))
                {
                    locationContactList = new ContactBLL().GetContactByIds(updateLocationContact);
                }
                if (!string.IsNullOrEmpty(updateFaxPhoneContact))
                {
                    faxPhoneContactList = new ContactBLL().GetContactByIds(updateFaxPhoneContact);
                }

                account         = new CompanyBLL().GetCompany(Convert.ToInt64(account_id));
                defaultLocation = new LocationBLL().GetLocationByAccountId(Convert.ToInt64(account_id));
                if (account != null)
                {
                    Phone.Text = account.phone;
                    Fax.Text   = account.fax;
                }
                else
                {
                    Response.End();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)

        {
            location_id = Request.QueryString["id"];  // 传id进来代表修改,未传代表新增
            account_id  = Request.QueryString["account_id"];
            if (!string.IsNullOrEmpty(location_id))   // 修改时
            {
                location = new LocationBLL().GetLocation(Convert.ToInt64(location_id));
                if (location != null)
                {
                    // is_default.Checked = location.is_default == 1;
                    // AreaCountyInit.Value = location.country_id.ToString();
                    province_idInit.Value   = location.province_id.ToString();
                    city_idInit.Value       = location.city_id.ToString();
                    district_idInit.Value   = location.district_id.ToString();
                    address.Text            = location.address;
                    additional_address.Text = location.additional_address;
                    postal_code.Text        = location.postal_code;
                    location_label.Text     = location.location_label;
                    if (!IsPostBack)
                    {
                        isDefault.Checked = location.is_default == 1;
                        isDefault.Enabled = false;
                    }
                }
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var accountId = Request.QueryString["accountId"];

            if (!string.IsNullOrEmpty(accountId))
            {
                account = comBll.GetCompany(long.Parse(accountId));
            }
            if (account == null)
            {
                Response.Write("<script>alert('为获取到客户信息');window.close();</script>");
                return;
            }
            accLocation = new crm_location_dal().GetLocationByAccountId(account.id);
            if (accLocation != null)
            {
                var disDal = new d_district_dal();
                if (accLocation.country_id != null)
                {
                    var country = new DAL.d_country_dal().FindById((long)accLocation.country_id);
                    countryName = country != null?country.country_name_display:"";
                }
                var province = disDal.FindById((long)accLocation.province_id);
                provinceName = province != null ? province.name : "";
                var city = disDal.FindById((long)accLocation.city_id);
                cityName = city != null ? city.name : "";
                var district = disDal.FindById((long)accLocation.district_id);
                districtName = district != null ? district.name : "";
            }
            subAccountList      = new crm_account_dal().GetSubsidiariesById(account.id);
            contactList         = new crm_contact_dal().GetContactByAccountId(account.id);
            oppoList            = new crm_opportunity_dal().FindOpHistoryByAccountId(account.id);
            companyUdfList      = udfBLL.GetUdf(DicEnum.UDF_CATE.COMPANY);
            companyUdfValueList = udfBLL.GetUdfValue(DicEnum.UDF_CATE.COMPANY, account.id, companyUdfList);
            insProList          = new crm_installed_product_dal().GetInsProAccoByProName(account.id);
            todoList            = new com_activity_dal().GetNoCompleteTodo(account.id);
            noteList            = new com_activity_dal().GetNoteByAccount(account.id);
            oppoUdfList         = udfBLL.GetUdf(DicEnum.UDF_CATE.OPPORTUNITY);


            //var arr = new string[][] { new string[] { "上海", "张耀", "1" }, new string[] { "北京", "张耀", "1" }, new string[] { "上海", "朱飞", "1" } };
            //var test = from i in Enumerable.Range(0, (int)arr.GetLongLength(0))
            //           from j in Enumerable.Range(0, (int)arr.GetLongLength(1))
            //           from k in Enumerable.Range(0, (int)arr.GetLongLength(2))
            //           select arr[i,j,k];
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var accountId = Request.QueryString["accountId"];

            if (!string.IsNullOrEmpty(accountId))
            {
                account = comBll.GetCompany(long.Parse(accountId));
            }
            if (account == null)
            {
                Response.Write("<script>alert('未获取到客户信息');window.close();</script>");
                return;
            }
            accLocation = new DAL.crm_location_dal().GetLocationByAccountId(account.id);
            if (accLocation != null)
            {
                var disDal = new DAL.d_district_dal();
                if (accLocation.country_id != null)
                {
                    var country = new DAL.d_country_dal().FindById((long)accLocation.country_id);
                    countryName = country != null ? country.country_name_display : "";
                }
                var province = disDal.FindById((long)accLocation.province_id);
                provinceName = province != null ? province.name : "";
                var city = disDal.FindById((long)accLocation.city_id);
                cityName = city != null ? city.name : "";
                var district = disDal.FindById((long)accLocation.district_id);
                districtName = district != null ? district.name : "";
            }
            if (account.resource_id != null)
            {
                accMan = new DAL.sys_resource_dal().FindNoDeleteById((long)account.resource_id);
            }
            startDate = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM") + "-01");
            endDate   = startDate.AddMonths(1).AddDays(-1);

            contractMoney = new DAL.crm_account_deduction_dal().GetContractSum(account.id, startDate, endDate);
            projectMoney  = new DAL.crm_account_deduction_dal().GetProjectSum(account.id, startDate, endDate);
            if (account.classification_id != null)
            {
                accClass = new DAL.d_account_classification_dal().FindNoDeleteById((long)account.classification_id);
            }
        }
Пример #5
0
        /// <summary>
        /// 更改地址
        /// </summary>
        /// <param name="new_location"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public bool Update(crm_location new_location, long user_id)
        {
            crm_location old_location = new crm_location_dal().GetLocationById(new_location.id);  // 根据客户id去获取到客户的地址,然后判断地址是否修改

            new_location.oid            = old_location.oid;
            new_location.create_user_id = old_location.create_user_id;
            new_location.create_time    = old_location.create_time;
            new_location.update_user_id = old_location.update_user_id;
            new_location.update_time    = old_location.update_time;
            if (!old_location.Equals(new_location))   // 代表用户更改了地址
            {
                var user = UserInfoBLL.GetUserInfo(user_id);
                new_location.update_user_id     = user.id;
                new_location.update_time        = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                new_location.additional_address = string.IsNullOrEmpty(new_location.additional_address) ? "" : new_location.additional_address;
                // 修改客户显示默认地址,默认地址不能主动移除
                if (new_location.is_default == 1 && old_location.is_default != 1)                      //  默认地址不进行修改的时候,忽略不计
                {
                    new crm_location_dal().UpdateDefaultLocation((long)new_location.account_id, user); // 首先将原来的默认地址取消  操作日志在方法内插入
                }

                new crm_location_dal().Update(new_location);             // 更改地址信息
                new sys_oper_log_dal().Insert(new sys_oper_log()
                {
                    user_cate           = "用户",
                    user_id             = user.id,
                    name                = user.name,
                    phone               = user.mobile == null ? "" : user.mobile,
                    oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                    oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CUSTOMER,
                    oper_object_id      = new_location.id,
                    oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                    oper_description    = _dal.CompareValue(old_location, new_location),
                    remark              = "修改客户地址",
                });    // 插入更改日志
            }

            return(true);
        }
Пример #6
0
        /// <summary>
        /// 插入地址
        /// </summary>
        /// <param name="location"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public bool Insert(crm_location location, long user_id)
        {
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (location.id == 0)
            {
                location.id = _dal.GetNextIdCom();
            }
            location.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            location.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            location.create_user_id = user.id;
            location.update_user_id = user.id;
            // 修改客户显示默认地址,默认地址不能主动移除
            var default_location = _dal.GetLocationByAccountId((long)location.account_id);

            if (location.is_default == 1 && default_location != null)
            {
                new crm_location_dal().UpdateDefaultLocation((long)location.account_id, user); // 首先将原来的默认地址取消  操作日志在方法内插入
            }


            new crm_location_dal().Insert(location);
            new sys_oper_log_dal().Insert(new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = "",
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CUSTOMER,
                oper_object_id      = location.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = _dal.AddValue(location),
                remark              = "保存地址信息"
            });       // 插入日志
            return(true);
        }
Пример #7
0
        /// <summary>
        /// 对页面上的地址相关信息的处理
        /// </summary>
        /// <param name="sale"></param>
        /// <returns></returns>
        private crm_sales_order LocationDeal(crm_sales_order sale)
        {
            var location_id = Request.Form["location_id"];
            var location    = new LocationBLL().GetLocation(long.Parse(location_id));

            if (location == null)
            {
                return(sale);
            }

            if (billTo_use_account_address.Checked)
            {
                sale.bill_to_location_id         = location.id;
                sale.bill_to_use_account_address = 1;
            }
            else
            {
                sale.bill_to_use_account_address = 0;
                var bill_id = Request.Params["billLocationId"];
                if (bill_id == location_id)
                {
                    bill_id = "";
                }
                var bill_location = new crm_location()
                {
                    account_id         = opportunity.account_id,
                    additional_address = Request.Params["bill_address2"],
                    address            = Request.Params["bill_address"],
                    city_id            = string.IsNullOrEmpty(Request.Params["bill_city_id"]) ? 0 : int.Parse(Request.Params["bill_city_id"]),
                    country_id         = 1,
                    district_id        = string.IsNullOrEmpty(Request.Params["bill_district_id"]) ? 0 : int.Parse(Request.Params["bill_district_id"]),
                    is_default         = 0,
                    province_id        = string.IsNullOrEmpty(Request.Params["bill_province_id"]) ? 0 : int.Parse(Request.Params["bill_province_id"]),
                    postal_code        = Request.Params["bill_postcode"],
                };
                if (bill_location.country_id != 0 && bill_location.province_id != 0 && bill_location.city_id != 0 && bill_location.district_id != 0 && (!string.IsNullOrEmpty(bill_location.address)))
                {
                    if (!string.IsNullOrEmpty(bill_id)) // 修改
                    {
                        bill_location.id = long.Parse(bill_id);
                        new LocationBLL().Update(bill_location, GetLoginUserId());
                    }
                    else         // 新增
                    {
                        bill_location.id = new crm_location_dal().GetNextIdCom();
                        new LocationBLL().Insert(bill_location, GetLoginUserId());
                    }
                    sale.bill_to_location_id = bill_location.id;
                }
                else
                {
                    sale.bill_to_location_id = this.sale_order.bill_to_location_id;
                }
            }


            if (shipTo_use_account_address.Checked)
            {
                sale.ship_to_location_id         = location.id;
                sale.ship_to_use_account_address = 1;
            }
            else
            {
                sale.ship_to_use_account_address = 0;
                var ship_id = Request.Params["shipLocationId"];
                if (ship_id == location_id)
                {
                    ship_id = "";
                }
                var ship_location = new crm_location()
                {
                    account_id         = opportunity.account_id,
                    additional_address = Request.Params["ship_address2"],
                    address            = Request.Params["ship_address"],
                    city_id            = string.IsNullOrEmpty(Request.Params["ship_city_id"]) ? 0 : int.Parse(Request.Params["ship_city_id"]),
                    country_id         = 1,
                    district_id        = string.IsNullOrEmpty(Request.Params["ship_district_id"]) ? 0 : int.Parse(Request.Params["ship_district_id"]),
                    is_default         = 0,
                    province_id        = string.IsNullOrEmpty(Request.Params["ship_province_id"]) ? 0 : int.Parse(Request.Params["ship_province_id"]),
                    postal_code        = Request.Params["ship_postcode"],
                };
                if (ship_location.country_id != 0 && ship_location.province_id != 0 && ship_location.city_id != 0 && ship_location.district_id != 0 && (!string.IsNullOrEmpty(ship_location.address)))
                {
                    if (!string.IsNullOrEmpty(ship_id))
                    {
                        ship_location.id = long.Parse(ship_id);
                        new LocationBLL().Update(ship_location, GetLoginUserId());
                    }
                    else
                    {
                        ship_location.id = new crm_location_dal().GetNextIdCom();
                        new LocationBLL().Insert(ship_location, GetLoginUserId());
                    }
                    sale.ship_to_location_id = ship_location.id;
                }
                else
                {
                    sale.ship_to_location_id = this.sale_order.ship_to_location_id;
                }
            }

            if (shipTo_use_bill_to_address.Checked)
            {
                sale.ship_to_location_id         = sale.bill_to_location_id;
                sale.ship_to_use_bill_to_address = 1;
            }
            else
            {
                sale.ship_to_use_bill_to_address = 0;
            }
            return(sale);
        }
Пример #8
0
        protected crm_quote LocationDeal(crm_quote quote)
        {
            try
            {
                // 账单地址和配送地址新增删除处理
                // 首先要整理称谓地址对象  与默认地址的相同更改校验
                // 校验地址必填信息
                // 然后判断新增还是修改进行操作
                var sold_location_id = Request.Params["sold_to_location_id"];

                var old_sold_location = new LocationBLL().GetLocation(long.Parse(sold_location_id));
                if (old_sold_location == null)
                {
                    return(quote);
                }
                var sold_location = new crm_location()
                {
                    id                 = old_sold_location.id,
                    account_id         = old_sold_location.account_id,
                    cate_id            = old_sold_location.cate_id,
                    create_time        = old_sold_location.create_time,
                    create_user_id     = old_sold_location.create_user_id,
                    delete_time        = old_sold_location.delete_time,
                    delete_user_id     = old_sold_location.delete_user_id,
                    is_default         = old_sold_location.is_default,
                    location_label     = old_sold_location.location_label,
                    oid                = old_sold_location.is_default,
                    additional_address = Request.Params["address2"],
                    address            = Request.Params["address"],
                    city_id            = string.IsNullOrEmpty(Request.Params["city_id"]) ? 0 : int.Parse(Request.Params["city_id"]),
                    country_id         = old_sold_location.country_id,
                    district_id        = string.IsNullOrEmpty(Request.Params["district_id"]) ? 0 : int.Parse(Request.Params["district_id"]),
                    postal_code        = Request.Params["postal_code"],
                    province_id        = string.IsNullOrEmpty(Request.Params["province_id"]) ? 0 : int.Parse(Request.Params["province_id"]),
                    town_id            = old_sold_location.town_id,
                };
                if (sold_location.country_id != 0 && sold_location.province_id != 0 && sold_location.city_id != 0 && sold_location.district_id != 0 && (!string.IsNullOrEmpty(sold_location.address)))
                {
                    sold_location.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    sold_location.update_user_id = GetLoginUserId();
                    new LocationBLL().Update(sold_location, GetLoginUserId());
                }

                if (BillLocation.Checked)
                {
                    quote.bill_to_location_id = quote.sold_to_location_id;
                }
                else
                {
                    var bill_id       = Request.Params["bill_to_location_id"];
                    var bill_location = new crm_location()
                    {
                        //id = long.Parse(bill_id),
                        account_id         = quote.account_id,
                        additional_address = Request.Params["bill_address2"],
                        address            = Request.Params["bill_address"],
                        city_id            = string.IsNullOrEmpty(Request.Params["bill_city_id"]) ? 0 : int.Parse(Request.Params["bill_city_id"]),
                        country_id         = 1,
                        district_id        = string.IsNullOrEmpty(Request.Params["bill_district_id"]) ? 0 : int.Parse(Request.Params["bill_district_id"]),
                        is_default         = 0,
                        province_id        = string.IsNullOrEmpty(Request.Params["bill_province_id"]) ? 0 : int.Parse(Request.Params["bill_province_id"]),
                        postal_code        = Request.Params["bill_postcode"],
                    };
                    // 地址必填项未填写暂时不处理???
                    if (bill_location.country_id != 0 && bill_location.province_id != 0 && bill_location.city_id != 0 && bill_location.district_id != 0 && (!string.IsNullOrEmpty(bill_location.address)))
                    {
                        if (!string.IsNullOrEmpty(bill_id))  // 用户界面上存在账单地址 此时代表和客户默认地址相同或者是在更改地址
                        {
                            if (bill_id == sold_location_id)
                            {
                                if (bill_location.city_id != sold_location.city_id || bill_location.city_id != sold_location.city_id || bill_location.district_id != sold_location.district_id || bill_location.address != sold_location.address || bill_location.additional_address != sold_location.additional_address || bill_location.postal_code != sold_location.postal_code)
                                {
                                    bill_location.id = new crm_location_dal().GetNextIdCom();
                                    if (new LocationBLL().Insert(bill_location, GetLoginUserId()))
                                    {
                                        quote.bill_to_location_id = bill_location.id;
                                    }
                                }
                            }
                            else
                            {
                                bill_location.id = long.Parse(bill_id);
                                new LocationBLL().Update(bill_location, GetLoginUserId());
                            }
                        }
                        else
                        {
                            bill_location.id = new crm_location_dal().GetNextIdCom();
                            if (new LocationBLL().Insert(bill_location, GetLoginUserId()))
                            {
                                quote.bill_to_location_id = bill_location.id;
                            }
                        }
                    }
                }

                if (ShipLocation.Checked)
                {
                    quote.ship_to_location_id = quote.sold_to_location_id;
                }
                else
                {
                    var ship_id       = Request.Params["ship_to_location_id"];
                    var ship_location = new crm_location()
                    {
                        //id = long.Parse(bill_id),
                        account_id         = quote.account_id,
                        additional_address = Request.Params["ship_address2"],
                        address            = Request.Params["ship_address"],
                        city_id            = string.IsNullOrEmpty(Request.Params["ship_city_id"]) ? 0 : int.Parse(Request.Params["ship_city_id"]),
                        country_id         = 1,
                        district_id        = string.IsNullOrEmpty(Request.Params["ship_district_id"]) ? 0 : int.Parse(Request.Params["ship_district_id"]),
                        is_default         = 0,
                        province_id        = string.IsNullOrEmpty(Request.Params["ship_province_id"]) ? 0 : int.Parse(Request.Params["ship_province_id"]),
                        postal_code        = Request.Params["ship_postcode"],
                    };
                    // 地址必填项未填写暂时不处理???
                    if (ship_location.country_id != 0 && ship_location.province_id != 0 && ship_location.city_id != 0 && ship_location.district_id != 0 && (!string.IsNullOrEmpty(ship_location.address)))
                    {
                        if (!string.IsNullOrEmpty(ship_id))  // 用户界面上存在账单地址 此时代表和客户默认地址相同或者是在更改地址
                        {
                            if (ship_id == sold_location_id)
                            {
                                if (ship_location.city_id != sold_location.city_id || ship_location.city_id != sold_location.city_id || ship_location.district_id != sold_location.district_id || ship_location.address != sold_location.address || ship_location.additional_address != sold_location.additional_address || ship_location.postal_code != sold_location.postal_code)
                                {
                                    ship_location.id = new crm_location_dal().GetNextIdCom();
                                    if (new LocationBLL().Insert(ship_location, GetLoginUserId()))
                                    {
                                        quote.ship_to_location_id = ship_location.id;
                                    }
                                }
                            }
                            else
                            {
                                ship_location.id = long.Parse(ship_id);
                                new LocationBLL().Update(ship_location, GetLoginUserId());
                            }
                        }
                        else
                        {
                            ship_location.id = new crm_location_dal().GetNextIdCom();
                            if (new LocationBLL().Insert(ship_location, GetLoginUserId()))
                            {
                                quote.ship_to_location_id = ship_location.id;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            return(quote);
        }
Пример #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId);
            var company_id = Convert.ToInt64(Request.QueryString["id"]);

            if (AuthBLL.GetUserCompanyAuth(LoginUserId, LoginUser.security_Level_id, company_id).CanEdit == false)  // 权限验证
            {
                Response.End();
                return;
            }
            try
            {
                company_udfList      = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.COMPANY);
                company_udfValueList = new UserDefinedFieldsBLL().GetUdfValue(DicEnum.UDF_CATE.COMPANY, company_id, company_udfList);
                site_udfList         = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.SITE);
                site_udfValueList    = new UserDefinedFieldsBLL().GetUdfValue(DicEnum.UDF_CATE.SITE, company_id, site_udfList);
                account       = new CompanyBLL().GetCompany(company_id);
                location_list = new LocationBLL().GetLocationByCompany(company_id);
                // defaultLocation = new LocationBLL().GetLocationByAccountId(company_id);
                //if (!IsPostBack)
                //{
                // var company_id = Convert.ToInt64(Request.QueryString["id"]);

                if (account != null)
                {
                    subCompanyList = new crm_account_dal().GetMyCompany(account.id);
                    //searchCompany = new crm_account_dal().GetSubCompanys();
                    #region 为下拉框获取数据源
                    dic = new CompanyBLL().GetField();

                    // 分类类别
                    classification.DataTextField  = "show";
                    classification.DataValueField = "val";
                    classification.DataSource     = dic.FirstOrDefault(_ => _.Key == "classification").Value;
                    classification.DataBind();
                    classification.Items.Insert(0, new ListItem()
                    {
                        Value = "0", Text = "   ", Selected = true
                    });
                    // 公司类型
                    CompanyType.DataTextField  = "show";
                    CompanyType.DataValueField = "val";
                    CompanyType.DataSource     = dic.FirstOrDefault(_ => _.Key == "company_type").Value;
                    CompanyType.DataBind();
                    CompanyType.Items.Insert(0, new ListItem()
                    {
                        Value = "0", Text = "   ", Selected = true
                    });

                    // 市场领域
                    MarketSegment.DataTextField  = "show";
                    MarketSegment.DataValueField = "val";
                    MarketSegment.DataSource     = dic.FirstOrDefault(_ => _.Key == "market_segment").Value;
                    MarketSegment.DataBind();
                    MarketSegment.Items.Insert(0, new ListItem()
                    {
                        Value = "0", Text = "   ", Selected = true
                    });
                    // 销售区域
                    TerritoryName.DataTextField  = "show";
                    TerritoryName.DataValueField = "val";
                    TerritoryName.DataSource     = dic.FirstOrDefault(_ => _.Key == "territory").Value;
                    TerritoryName.DataBind();
                    TerritoryName.Items.Insert(0, new ListItem()
                    {
                        Value = "0", Text = "   ", Selected = true
                    });
                    // 客户经理
                    AccountManger.DataTextField  = "show";
                    AccountManger.DataValueField = "val";
                    AccountManger.DataSource     = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value;
                    AccountManger.DataBind();
                    AccountManger.Items.Insert(0, new ListItem()
                    {
                        Value = "0", Text = "   ", Selected = true
                    });
                    // 税区
                    TaxRegion.DataTextField  = "show";
                    TaxRegion.DataValueField = "val";
                    TaxRegion.DataSource     = dic.FirstOrDefault(_ => _.Key == "taxRegion").Value;
                    TaxRegion.DataBind();
                    TaxRegion.Items.Insert(0, new ListItem()
                    {
                        Value = "0", Text = "   ", Selected = true
                    });
                    // 竞争对手
                    Competitor.DataTextField  = "show";
                    Competitor.DataValueField = "val";
                    Competitor.DataSource     = dic.FirstOrDefault(_ => _.Key == "competition").Value;
                    Competitor.DataBind();
                    Competitor.Items.Insert(0, new ListItem()
                    {
                        Value = "0", Text = "   ", Selected = true
                    });
                    #endregion

                    company_name.Text = account.name;
                    //isactive.Checked = account.is_active == 1;

                    CompanyNumber.Text          = account.no;
                    Phone.Text                  = account.phone;
                    AlternatePhone1.Text        = account.alternate_phone1;
                    AlternatePhone2.Text        = account.alternate_phone2;
                    Fax.Text                    = account.fax;
                    WebSite.Text                = account.web_site;
                    is_optoutSurvey.Checked     = account.is_optout_survey == 1;
                    mileage.Text                = account.mileage == null ? "" : account.mileage.ToString();// todo decmail? 保留两位小数点??
                    stock_symbol.Text           = account.stock_symbol;
                    sic_code.Text               = account.sic_code;
                    stock_market.Text           = account.stock_market;
                    weibo_url.Text              = account.weibo_url;
                    wechat_mp_service.Text      = account.wechat_mp_service;
                    wechat_mp_subscription.Text = account.wechat_mp_subscription;

                    CompanyType.SelectedValue    = account.type_id == null ? "0" : account.type_id.ToString();
                    AccountManger.SelectedValue  = account.resource_id == null ? "0" : account.resource_id.ToString();
                    TerritoryName.SelectedValue  = account.territory_id == null ? "0" : account.territory_id.ToString();
                    MarketSegment.SelectedValue  = account.market_segment_id == null ? "0" : account.market_segment_id.ToString();
                    Competitor.SelectedValue     = account.competitor_id == null ? "0" : account.competitor_id.ToString();
                    Tax_Exempt.Checked           = account.is_tax_exempt == 1;
                    TaxRegion.SelectedValue      = account.tax_region_id == null ? "0" : account.tax_region_id.ToString();
                    classification.SelectedValue = account.classification_id == null ? "0" : account.classification_id.ToString();

                    if (Tax_Exempt.Checked)
                    {
                        TaxRegion.Enabled = true;
                    }
                    TaxId.Text = account.tax_identification;
                    if (account.parent_id != null)
                    {
                        var parCompany = new CompanyBLL().GetCompany((long)this.account.parent_id);
                        ParentComoanyName.Text = parCompany == null ? "" : parCompany.name;  //父客户
                    }
                    asset_value.Text = account.asset_value.ToString();

                    location = new LocationBLL().GetLocationByAccountId(account.id);
                    if (location != null)        // 如果该客户的地址是默认地址,不可更改为非默认,只能通过添加别的地址设置为默认这种方式去更改默认地址
                    {
                        country_idInit.Value   = location.country_id.ToString();
                        province_idInit.Value  = location.province_id.ToString();
                        city_idInit.Value      = location.city_id.ToString();
                        district_idInit.Value  = location.district_id.ToString();
                        address.Text           = location.address;
                        AdditionalAddress.Text = location.additional_address;
                    }

                    var company_detail_alert = new EMT.DoneNOW.DAL.crm_account_alert_dal().FindAlert(account.id, EMT.DoneNOW.DTO.DicEnum.ACCOUNT_ALERT_TYPE.COMPANY_DETAIL_ALERT);
                    var new_ticket_alert     = new EMT.DoneNOW.DAL.crm_account_alert_dal().FindAlert(account.id, EMT.DoneNOW.DTO.DicEnum.ACCOUNT_ALERT_TYPE.NEW_TICKET_ALERT);
                    var ticket_detail_alert  = new EMT.DoneNOW.DAL.crm_account_alert_dal().FindAlert(account.id, EMT.DoneNOW.DTO.DicEnum.ACCOUNT_ALERT_TYPE.TICKET_DETAIL_ALERT);

                    if (company_detail_alert != null)
                    {
                        Company_Detail_Alert.Text = company_detail_alert.alert_text;
                    }
                    if (new_ticket_alert != null)
                    {
                        New_Ticket_Alert.Text = new_ticket_alert.alert_text;
                    }
                    if (ticket_detail_alert != null)
                    {
                        Ticket_Detail_Alert.Text = ticket_detail_alert.alert_text;
                    }
                }
                else
                {
                    Response.End();
                }
                //}
            }
            catch (Exception)
            {
                Response.End();
            }
        }