/// <summary> /// 修改公司信息 /// </summary> protected void btnSave_Click(object sender, EventArgs e) { int ProvinceId = EyouSoft.Common.Utils.GetInt(Request.Form["dropProvinceId"]); //省份编号 int CityId = EyouSoft.Common.Utils.GetInt(Request.Form["dropCityId"]); //城市编号 #region 客户类型 //客户类型 List <CustomerTypeInfo> CustomerList = new List <CustomerTypeInfo>(); CustomerTypeInfo CustomerModel = null; for (int i = 0; i < chbCustomerType.Items.Count; i++) { if (chbCustomerType.Items[i].Selected) { CustomerModel = new CustomerTypeInfo(); CustomerModel = EyouSoft.BLL.PoolStructure.CustomerType.CreateInstance().GetCustomerType(Utils.GetInt(chbCustomerType.Items[i].Value)); CustomerList.Add(CustomerModel); } } #endregion string txtCompanyName = Utils.InputText(this.txtCompanyName.Value.Trim()); //公司名称 string txtCompanyStar = Utils.InputText(this.txtCompanyStar.Value.Trim()); //企业星级 #region 公司联系人 //公司联系人 string[] Name = Utils.GetFormValues("txt_Name"); string[] Birthday = Utils.GetFormValues("txt_Birthday"); string[] MemorialDay = Utils.GetFormValues("txt_MemorialDay"); string[] Duties = Utils.GetFormValues("txt_Duties"); string[] Mobile = Utils.GetFormValues("txt_Mobile"); string[] Email = Utils.GetFormValues("txt_Email"); string[] QQ = Utils.GetFormValues("txt_QQ"); string[] Character = Utils.GetFormValues("txt_Character"); string[] Hobby = Utils.GetFormValues("txt_Hobby"); string[] Remarks = Utils.GetFormValues("txt_Remarks"); List <ContacterInfo> ContacterList = new List <ContacterInfo>(); if (Name != null) { EyouSoft.Model.PoolStructure.ContacterInfo ContacterModel = null; for (int index = 0; index < Name.Length; index++) { if (!string.IsNullOrEmpty(Name[index].Trim()) || !string.IsNullOrEmpty(Birthday[index].Trim()) || !string.IsNullOrEmpty(MemorialDay[index].Trim()) || !string.IsNullOrEmpty(Duties[index].Trim()) || !string.IsNullOrEmpty(Mobile[index].Trim()) || !string.IsNullOrEmpty(Email[index].Trim()) || !string.IsNullOrEmpty(QQ[index].Trim()) || !string.IsNullOrEmpty(Character[index].Trim()) || !string.IsNullOrEmpty(Hobby[index].Trim()) || !string.IsNullOrEmpty(Remarks[index].Trim())) { ContacterModel = new EyouSoft.Model.PoolStructure.ContacterInfo(); ContacterModel.Fullname = Name[index]; ContacterModel.Birthday = Utils.GetDateTime((Birthday[index]), DateTime.Now); ContacterModel.RememberDay = Utils.GetDateTime(MemorialDay[index], DateTime.Now); ContacterModel.JobTitle = Duties[index]; ContacterModel.Mobile = Mobile[index]; ContacterModel.Email = Email[index]; ContacterModel.QQ = QQ[index]; ContacterModel.Character = Character[index]; ContacterModel.Interest = Hobby[index]; ContacterModel.Remark = Remarks[index]; ContacterList.Add(ContacterModel); ContacterModel = null; } } } #endregion string txtAddress = Utils.InputText(this.txtAddress.Value.Trim()); //企业地址 string txtCompanyRemark = Utils.InputText(this.txtCompanyRemark.Value.Trim()); //备注 #region 适用产品 List <SuitProductInfo> SuitProductList = new List <SuitProductInfo>(); SuitProductInfo SuitProductModel = null; for (int i = 0; i < chbSuitProduct.Items.Count; i++) { if (chbSuitProduct.Items[i].Selected) { SuitProductModel = new SuitProductInfo(); SuitProductModel = EyouSoft.BLL.PoolStructure.SuitProduct.CreateInstance().GetSuitProduct(Utils.GetInt(chbSuitProduct.Items[i].Value)); SuitProductList.Add(SuitProductModel); } } #endregion #region 保存客户信息 EyouSoft.Model.PoolStructure.CompanyInfo CompanyModel = new EyouSoft.Model.PoolStructure.CompanyInfo(); CompanyModel.ProvinceId = ProvinceId; CompanyModel.CityId = CityId; CompanyModel.CustomerTypeConfig = CustomerList; CompanyModel.CompanyName = txtCompanyName; CompanyModel.Star = txtCompanyStar; CompanyModel.Contacters = ContacterList; CompanyModel.Address = txtAddress; CompanyModel.Remark = txtCompanyRemark; CompanyModel.SuitProductConfig = SuitProductList; if (!string.IsNullOrEmpty(EditId)) { CompanyModel.CompanyId = EditId; bool result = EyouSoft.BLL.PoolStructure.Company.CreateInstance().Update(CompanyModel); if (result) { MessageBox.ShowAndRedirect(this, "修改成功", "Default.aspx"); } } else { bool result = EyouSoft.BLL.PoolStructure.Company.CreateInstance().Create(CompanyModel); if (result) { MessageBox.ShowAndRedirect(this, "添加成功", "Default.aspx"); } } CompanyModel = null; CustomerList = null; ContacterList = null; SuitProductList = null; #endregion }
/// <summary> /// 初始化公司信息 /// </summary> protected void GetCompanyInfo() { EyouSoft.Model.PoolStructure.CompanyInfo Model = EyouSoft.BLL.PoolStructure.Company.CreateInstance().GetCompanyInfo(EditId); if (Model != null) { BindProvince(); BindCity(); InitQueryDropDownList(); //绑定省份 城市 if (Model.ProvinceId > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "SetProvince('" + Model.ProvinceId + "');ChangeList('" + this.dropCityId.ClientID + "','" + Model.ProvinceId + "');", true); if (Model.CityId > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "SetCity('" + Model.CityId + "');", true); } } #region 绑定客户类型 适用产品 //绑定客户类型 适用产品 IList <CustomerTypeInfo> list = Model.CustomerTypeConfig; IList <SuitProductInfo> SuitList = Model.SuitProductConfig; for (int i = 0; i < list.Count; i++) { for (int j = 0; j < chbCustomerType.Items.Count; j++) { if (list[i].TypeId == Utils.GetInt(chbCustomerType.Items[j].Value)) { chbCustomerType.Items[j].Selected = true; } } } for (int i = 0; i < SuitList.Count; i++) { for (int j = 0; j < chbSuitProduct.Items.Count; j++) { if (SuitList[i].ProuctId == Utils.GetInt(chbSuitProduct.Items[j].Value)) { chbSuitProduct.Items[j].Selected = true; } } } #endregion this.txtCompanyName.Value = Model.CompanyName; //公司名称 this.txtCompanyStar.Value = Model.Star; //企业星级 this.rptContacters.DataSource = Model.Contacters; //公司联系人 this.rptContacters.DataBind(); this.txtAddress.Value = Model.Address; //公司地址 this.txtCompanyRemark.Value = Model.Remark; //公司备注 } else { EyouSoft.Common.Function.MessageBox.Show(this.Page, "未找到该客户信息!"); return; } Model = null; }