/// <summary> /// 加载页面信息 /// </summary> private void BindShow() { // 附件信息 Session.Remove("ww"); this.File.FileSizeLimit = "3000"; this.File.FilesNname = "File"; this.File.FileSessionID = "ww"; this.File.FileType = "经销商资料"; string id = Request.QueryString["id"]; if (!string.IsNullOrEmpty(id)) { string products = string.Empty; Common_BLL bllComm = new Common_BLL(); Dealers_DealersInfoBLL bllDealers_DealersInfo = new Dealers_DealersInfoBLL(); Business_DealersProductBLL bllBusiness_DealersProduct = new Business_DealersProductBLL(); Business_DealersBrandBLL bllDealersBrand = new Business_DealersBrandBLL(); Product_ProductDefinitionBLL bllProduct = new Product_ProductDefinitionBLL(); List <Product_ProductDefinition> ProductDefinition = bllProduct.FindWhere(p => p.ProductDefinition_Deleted == false && p.ProductDefinition_ExpirationDate > DateTime.Now); //根据经销商编号获取经销商信息 Dealers_DealersInfo model = bllDealers_DealersInfo.Find(p => p.DealersInfoID == id); //获取经销商关联的产品 List <Business_DealersProduct> DealersProduct = bllBusiness_DealersProduct.FindWhere(p => p.DealersProduct_DealersID == id); if (DealersProduct.Count != 0) { foreach (Business_DealersProduct Product in DealersProduct) { for (int i = 0; i < ProductDefinition.Count; i++) { if (ProductDefinition[i].ProductDefinition_ID == Product.DealersProduct_ProductID) { products += Product.DealersProduct_ProductID + ","; } } } if (!products.IsNullOrEmpty()) { products = products.Substring(0, products.Length - 1); } } if (model == null) { MessageBox.ShowAndRedirect(this, "该数据不存在!", "DealersDealersInfoList.aspx"); } else { FormModel.SetForm <Dealers_DealersInfo>(this, model, "txt"); FormModel.SetForm <Dealers_DealersInfo>(this, model, "ddl"); txtDealersInfo_CLDate.Text = model.DealersInfo_CLDate == null ? "" : Convert.ToDateTime(model.DealersInfo_CLDate).ToString("yyyy年MM月dd日"); txtDealersInfo_ValidityPeriod.Text = model.DealersInfo_ValidityPeriod == null ? "" : Convert.ToDateTime(model.DealersInfo_ValidityPeriod).ToString("yyyy年MM月dd日"); txtDealersInfo_CooperativeValidity.Text = model.DealersInfo_CooperativeValidity == null ? "" : Convert.ToDateTime(model.DealersInfo_CooperativeValidity).ToString("yyyy年MM月dd日"); hidProductID_New.Value = products; hidProductID_Old.Value = products; string[] area = null; if (!string.IsNullOrEmpty(model.DealersInfo_Area)) { area = model.DealersInfo_Area.Split(','); //所属区域1 ddlDealersInfo_Area1.SelectedValue = area[0]; //所属区域2 DataTable listDealersInfo_Area2 = bllComm.GetDataBySQL("SELECT B.AreaId,B.Area_Name FROM dbo.Business_AreaDistribution A LEFT JOIN dbo.Business_Area B ON A.AreaDistribution_AreaID=B.AreaId WHERE A.AreaDistribution_ID='" + area[0] + "' AND B.Area_Depth=1"); this.ddlDealersInfo_Area2.DataSource = listDealersInfo_Area2; this.ddlDealersInfo_Area2.DataTextField = "Area_Name"; this.ddlDealersInfo_Area2.DataValueField = "AreaId"; this.ddlDealersInfo_Area2.DataBind(); ddlDealersInfo_Area2.SelectedValue = area[1]; //所属区域3 DataTable listDealersInfo_Area3 = bllComm.GetDataBySQL("SELECT CONVERT(varchar(50),AreaId) as AreaIds,Area_Name FROM dbo.Business_Area WHERE Area_ParentId=(SELECT Area_ID FROM dbo.Business_Area WHERE AreaId='" + area[1] + "')"); this.ddlDealersInfo_Area3.DataSource = listDealersInfo_Area3; this.ddlDealersInfo_Area3.DataTextField = "Area_Name"; this.ddlDealersInfo_Area3.DataValueField = "AreaIds"; this.ddlDealersInfo_Area3.DataBind(); ddlDealersInfo_Area3.SelectedValue = area[2]; } //获取经销商管理的车辆品牌 List <Business_DealersBrand> dtBrand = bllDealersBrand.FindWhere(p => p.DealersBrand_DealersID == id).OrderBy(p => p.DealersBrand_BrandCNName).ToList(); if (dtBrand.Count > 0) { string str = string.Empty; string brandID = string.Empty; string brandName = string.Empty; string brandNameLength = "0"; for (int i = 0; i < dtBrand.Count; i++) { brandID = dtBrand[i].DealersBrand_BrandID; brandName = dtBrand[i].DealersBrand_BrandCNName; brandNameLength = (brandName.Length * 12 + 10).ToString(); str = "<div id='" + brandID + "' class='div_Brand' style='width:" + brandNameLength + "px;'><span>" + brandName + "</span><img id='img_" + brandID + "' title='删除' onclick='RemoveBrand(\"" + brandID + "\",\"" + brandName + "\")' src='../../Images/buttons/btn_delete.gif'></img></div>"; hidBrandID.Value += brandID + ","; hidBrandName.Value += brandName + ","; hidBrandInfo.Value += str; } } } this.File.FileOperationID = id; } else { this.File.FileOperationID = Guid.NewGuid().ToString(); } }
/// <summary> /// 保存按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, ImageClickEventArgs e) { string id = Request.QueryString["id"]; string msg = string.Empty; string products = string.Empty; if (!string.IsNullOrEmpty(id)) { if (string.IsNullOrEmpty(hidProductID_Old.Value)) { products = hidProductID_New.Value; } else { // 获取更新后产品编号 products = GetProductID(id); if (products == "0") { return; } } Dealers_DealersInfoBLL bllDealers_DealersInfo = new Dealers_DealersInfoBLL(); //获取经销商详细信息 Dealers_DealersInfo Dealers_DealersInfo = bllDealers_DealersInfo.Find(p => p.DealersInfoID == id); FormModel.GetForm <Dealers_DealersInfo>(this, Dealers_DealersInfo, "txt"); FormModel.GetForm <Dealers_DealersInfo>(this, Dealers_DealersInfo, "ddl"); Dealers_DealersInfo.DealersInfo_Area = ddlDealersInfo_Area1.SelectedValue + "," + ddlDealersInfo_Area2.SelectedValue + "," + ddlDealersInfo_Area3.SelectedValue; Dealers_DealersInfo.DealersInfo_UpdateTime = DateTime.Now; Dealers_DealersInfo.DealersInfo_UpdateUserID = base.CurrUserInfo().UserID; List <Business_DealersProduct> listDealersProduct = new List <Business_DealersProduct>(); string[] product_ID = products.Split(','); for (int i = 0; i < product_ID.Length; i++) { //获取经销商所管理的产品 Business_DealersProduct Business_DealersProduct = new Business_DealersProduct(); Business_DealersProduct.DealersProduct_ID = Guid.NewGuid().ToString(); Business_DealersProduct.DealersProduct_DealersID = id; Business_DealersProduct.DealersProduct_ProductID = product_ID[i]; Business_DealersProduct.DealersProduct_UpdateTime = DateTime.Now; Business_DealersProduct.DealersProduct_UpdateUserID = base.CurrUserInfo().UserID; listDealersProduct.Add(Business_DealersProduct); } List <Business_DealersBrand> listDealersBrand = new List <Business_DealersBrand>(); if (!string.IsNullOrEmpty(hidBrandID.Value)) { string[] brand_ID = hidBrandID.Value.Substring(0, hidBrandID.Value.Length - 1).Split(','); string[] brand_Name = hidBrandName.Value.Substring(0, hidBrandName.Value.Length - 1).Split(','); for (int i = 0; i < brand_ID.Length; i++) { //获取经销商所管理的品牌 Business_DealersBrand Business_DealersBrand = new Business_DealersBrand(); Business_DealersBrand.DealersBrand_ID = Guid.NewGuid().ToString(); Business_DealersBrand.DealersBrand_DealersID = id; Business_DealersBrand.DealersBrand_BrandID = brand_ID[i]; Business_DealersBrand.DealersBrand_BrandCNName = brand_Name[i]; Business_DealersBrand.DealersBrand_UpdateTime = DateTime.Now; Business_DealersBrand.DealersBrand_UpdateUserID = base.CurrUserInfo().UserID; listDealersBrand.Add(Business_DealersBrand); } } //更新经销商 bool bol = bllDealers_DealersInfo.Update(Dealers_DealersInfo, listDealersProduct, listDealersBrand); if (bol) { new Sys_ModelFileBLL().AddList(Session["ww"] as List <Sys_ModelFile>, out msg); MessageBox.ShowAndRedirect(this, "保存成功!", "DealersDealersInfoList.aspx"); } else { MessageBox.Show(this, "保存失败!"); } } else { MessageBox.Show(this, msg); } }