protected override void CreateChildControls() { this.Controls.Clear(); if (!this.dataLoaded) { if (!string.IsNullOrEmpty(this.Context.Request.Form[RegionSelector.IDPrev + "regionSelectorValue"])) { this.currentRegionId = int.Parse(this.Context.Request.Form[RegionSelector.IDPrev + "regionSelectorValue"]); } this.dataLoaded = true; } if (this.currentRegionId.HasValue) { Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(this.currentRegionId.Value, true); if (region != null) { if (region.Depth == 4) { this.streetId = this.currentRegionId; this.countyId = region.ParentRegionId; this.cityId = RegionHelper.GetCityId(region.ParentRegionId); this.provinceId = RegionHelper.GetTopRegionId(region.ParentRegionId, true); } if (region.Depth == 3) { this.countyId = this.currentRegionId.Value; this.cityId = region.ParentRegionId; this.provinceId = RegionHelper.GetTopRegionId(region.ParentRegionId, true); } else if (region.Depth == 2) { this.cityId = this.currentRegionId.Value; this.provinceId = region.ParentRegionId; } else if (region.Depth == 1) { this.provinceId = this.currentRegionId.Value; } } } this.Controls.Add(RegionSelector.CreateTag("<div class=\"address_wap\"><div class=\"dp_border\"></div><div class=\"dp_address\">")); this.ddlProvinces = this.CreateHypLink("province_top", "provincename", this.provinceId, this.ProvinceTitle, this.ProvinceWidth, out this.proviceSpan); this.FillHypLink(this.proviceSpan, "province", (Dictionary <int, string>)RegionHelper.GetAllProvinces(false), this.provinceId, (int?)0, out this.proviceDiv); this.ddlCitys = this.CreateHypLink("city_top", "cityname", this.cityId, this.CityTitle, this.CityWidth, out this.citySpan); Dictionary <int, string> regions = new Dictionary <int, string>(); if (this.provinceId.HasValue) { regions = RegionHelper.GetCitys(this.provinceId.Value, false); } this.FillHypLink(this.citySpan, "city", regions, this.cityId, this.provinceId, out this.cityDiv); this.ddlCountys = this.CreateHypLink("area_top", "areaname", this.countyId, this.CountyTitle, this.CountyWidth, out this.areaSpan); Dictionary <int, string> regions2 = new Dictionary <int, string>(); if (this.cityId.HasValue) { regions2 = RegionHelper.GetCountys(this.cityId.Value, false); } this.FillHypLink(this.areaSpan, "area", regions2, this.countyId, this.cityId, out this.areaDiv); if (this.DisplayStreet) { this.ddlStreets = this.CreateHypLink("street_top", "streetname", this.streetId, this.StreetTitle, this.StreetWidth, out this.streetSpan); Dictionary <int, string> regions3 = new Dictionary <int, string>(); if (this.countyId.HasValue) { regions3 = RegionHelper.GetStreets(this.countyId.Value, false); } this.FillHypLink(this.streetSpan, "street", regions3, this.streetId, this.countyId, out this.streetDiv); } this.Controls.Add(this.ddlProvinces); this.Controls.Add(this.ddlCitys); this.Controls.Add(this.ddlCountys); if (this.DisplayStreet) { this.Controls.Add(this.ddlStreets); } this.Controls.Add(RegionSelector.CreateTag("</div>")); this.Controls.Add(this.proviceDiv); this.Controls.Add(this.cityDiv); this.Controls.Add(this.areaDiv); if (this.DisplayStreet) { this.Controls.Add(this.streetDiv); } this.Controls.Add(RegionSelector.CreateTag("</div>")); if (!this.CustomerCss) { Literal literal = new Literal(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<style type=\"text/css\">"); stringBuilder.AppendLine(".dropdown_button {" + string.Format("background: url('{0}') no-repeat;", "/Admin/images/combo_arrow.jpg") + "}"); stringBuilder.AppendLine(".dp_address a:hover .dropdown_button {" + string.Format("background: url('{0}') no-repeat;", "/Admin/images/combo_arrow1.jpg") + "}"); stringBuilder.AppendLine("</style>"); literal.Text = stringBuilder.ToString(); this.Controls.Add(literal); WebControl webControl = new WebControl(HtmlTextWriterTag.Link); webControl.Attributes.Add("rel", "stylesheet"); webControl.Attributes.Add("href", "/Admin/css/region.css"); webControl.Attributes.Add("type", "text/css"); webControl.Attributes.Add("media", "screen"); webControl.ID = "regionStyle"; this.Controls.Add(webControl); } }
private void UpdateStores() { StoresInfo storeById = StoresHelper.GetStoreById(this.storeId); ManagerInfo managerInfo = ManagerHelper.FindManagerByStoreId(this.storeId, SystemRoles.StoreAdmin); if (storeById == null) { base.Response.Redirect("StoresList.aspx"); } double num = 0.0; int num2 = 0; int num3 = 0; decimal num4 = default(decimal); string text = ""; string text2 = ""; string Address = ""; string text3 = Globals.StripAllTags(this.txtStoresName.Text.Trim()); Address = Globals.StripAllTags(this.txtAddress.Text); string text4 = Globals.StripAllTags(this.txtRegionScop.Value.Trim()); string text5 = Globals.StripAllTags(this.txtRegionScopName.Value.Trim()); text = this.txtTel.Text; text2 = this.txtContactMan.Text; string[] array = text4.Split(','); string[] array2 = text5.Split(','); IDictionary <int, DeliveryScopeInfo> dictionary = new Dictionary <int, DeliveryScopeInfo>(); for (int i = 0; i < array.Length; i++) { int num5 = 0; if (int.TryParse(array[i], out num5) && array2.Length >= i && dictionary != null && !dictionary.ContainsKey(num5)) { DeliveryScopeInfo deliveryScopeInfo = new DeliveryScopeInfo(); deliveryScopeInfo.RegionId = num5; deliveryScopeInfo.RegionName = array2[i]; deliveryScopeInfo.FullRegionPath = RegionHelper.GetFullPath(num5, true); dictionary.Add(num5, deliveryScopeInfo); } } if (storeById.StoreName != text3 && StoresHelper.ExistStoreName(text3)) { this.ResetForm(storeById.StoreId); this.ShowMsg("门店名称已经存在,请重新输入!", false); } else if (string.Compare(this.txtUserPwd.Text, this.txtUserRePwd.Text) != 0) { this.ResetForm(storeById.StoreId); this.ShowMsg("请确保两次输入的密码相同", false); } else if (!this.dropRegion.GetSelectedRegionId().HasValue) { this.ResetForm(storeById.StoreId); this.ShowMsg("请选择店铺所在区域!", false); } else if (text2.Length > 8 || text2.Length < 2) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入联系人,联系人长度必须是2-8位!", false); } else if (string.IsNullOrEmpty(this.hfLatitude.Value) || string.IsNullOrEmpty(this.hfLongitude.Value)) { this.ResetForm(storeById.StoreId); this.ShowMsg("请给门店标注定位!", false); } else if (text == "" || !DataHelper.IsTel(text)) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的联系电话(手机或者固定电话)!", false); } else { if (!string.IsNullOrEmpty(this.txtUserPwd.Text)) { if (this.txtUserPwd.Text.Length < 6 || this.txtUserPwd.Text.Length > 20) { this.ResetForm(storeById.StoreId); this.ShowMsg("密码长度必须在6到20个字符之间!", false); return; } managerInfo.Password = Users.EncodePassword(this.txtUserPwd.Text, managerInfo.PasswordSalt); } if (!this.chkIsSupportExpress.Checked && !this.chkIsAboveSelf.Checked && !this.chkIsStoreDelive.Checked) { this.ResetForm(storeById.StoreId); this.ShowMsg("请选择一种配送方式!", false); } else { if (this.chkIsStoreDelive.Checked) { if (!double.TryParse(this.txtServeRadius.Text.Trim(), out num) || num > 10000.0 || num <= 0.0) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的配送半径,为大于0至10000之间的数字!", false); return; } if (!int.TryParse(this.txtStoreFreight.Text.Trim(), out num2) || num2 > 99999999 || num2 < 0) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的配送费", false); return; } if (!int.TryParse(this.txtMinOrderPrice.Text.Trim(), out num3) || num3 > 99999999 || num3 < 0) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的起送价", false); return; } } if (!decimal.TryParse(this.txtCommissionRate.Text.Trim(), out num4) || num4 > 100m || num4 < decimal.Zero) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的平台抽佣比例", false); } else if (!this.chkOfflinePay.Checked && !this.chkOnlinePay.Checked && !this.chkCashOnDelivery.Checked) { this.ResetForm(storeById.StoreId); this.ShowMsg("支付方式请至少选择一种", false); } else { storeById.IsOfflinePay = this.chkOfflinePay.Checked; storeById.IsOnlinePay = this.chkOnlinePay.Checked; storeById.IsCashOnDelivery = this.chkCashOnDelivery.Checked; if (string.IsNullOrEmpty(this.txtStoreOpenTimeStartH.Text) || this.txtStoreOpenTimeStartH.Text.ToInt(0) < 0 || this.txtStoreOpenTimeStartH.Text.ToInt(0) >= 24) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的营业起始小时", false); } else if (string.IsNullOrEmpty(this.txtStoreOpenTimeStartM.Text) || this.txtStoreOpenTimeStartM.Text.ToInt(0) < 0 || this.txtStoreOpenTimeStartM.Text.ToInt(0) >= 60) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的营业起始分钟", false); } else if (string.IsNullOrEmpty(this.txtStoreOpenTimeEndH.Text) || this.txtStoreOpenTimeEndH.Text.ToInt(0) < 0 || this.txtStoreOpenTimeEndH.Text.ToInt(0) >= 24) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的营业结束小时", false); } else if (string.IsNullOrEmpty(this.txtStoreOpenTimeEndM.Text) || this.txtStoreOpenTimeEndM.Text.ToInt(0) < 0 || this.txtStoreOpenTimeEndM.Text.ToInt(0) >= 60) { this.ResetForm(storeById.StoreId); this.ShowMsg("请输入正确的营业结束分钟", false); } else { string empty = string.Empty; DateTime dateTime = DateTime.Now; string text6 = dateTime.ToString("yyyy-MM-dd"); DateTime?nullable = (text6 + " " + this.txtStoreOpenTimeStartH.Text.ToInt(0) + ":" + this.txtStoreOpenTimeStartM.Text.ToInt(0)).ToDateTime(); DateTime?nullable2 = (text6 + " " + this.txtStoreOpenTimeEndH.Text.ToInt(0) + ":" + this.txtStoreOpenTimeEndM.Text.ToInt(0)).ToDateTime(); dateTime = nullable.Value; string str = dateTime.ToString("HH:mm"); dateTime = nullable2.Value; string text7 = dateTime.ToString("HH:mm"); if (text7 == "00:00") { nullable2 = (text6 + " 23:59").ToDateTime(); text7 = "23:59"; } empty = (storeById.StoreOpenTime = str + "-" + text7); storeById.OpenStartDate = nullable.Value; storeById.OpenEndDate = nullable2.Value; storeById.IsSupportExpress = (this.chkIsSupportExpress.Checked && true); storeById.IsAboveSelf = (this.chkIsAboveSelf.Checked && true); storeById.IsStoreDelive = (this.chkIsStoreDelive.Checked && true); storeById.Introduce = this.editDescription.Text; if (this.chkIsStoreDelive.Checked) { storeById.ServeRadius = num; storeById.MinOrderPrice = num3; storeById.StoreFreight = num2; } else { storeById.ServeRadius = 0.0; storeById.MinOrderPrice = null; storeById.StoreFreight = null; } storeById.CommissionRate = num4; List <string> list = RegionHelper.GetFullRegion(this.dropRegion.GetSelectedRegionId().Value, ",", true, 0).Split(',').Take(3) .ToList(); list.ForEach(delegate(string c) { Address = Address.Replace(c, string.Empty); }); IList <string> list2 = new List <string>(); string text9 = this.hidUploadImages.Value.Trim(); string[] array3 = text9.Split(','); for (int j = 0; j < array3.Length; j++) { if (!string.IsNullOrEmpty(array3[j])) { string text10 = Globals.SaveFile("depot", array3[j], "/Storage/master/", true, false, ""); string text11 = base.Request.MapPath(text10); string virtualPath = HiContext.Current.GetStoragePath() + "/depot/thum_" + text10.Substring(text10.LastIndexOf("/") + 1); if (!File.Exists(text11)) { this.ShowMsg("缩略图文件夹未创建,请联系管理员", false); return; } ResourcesHelper.CreateThumbnail(text11, base.Request.MapPath(virtualPath), 160, 160); list2.Add(text10); } } if (list2.Count == 0) { this.ResetForm(storeById.StoreId); this.ShowMsg("logo已失效或未上传,请上传门店logo", false); } else if (ManagerHelper.Update(managerInfo)) { int value = this.dropRegion.GetSelectedRegionId().Value; storeById.StoreName = text3; storeById.RegionId = value; storeById.TopRegionId = RegionHelper.GetCityId(value); storeById.Tel = text; storeById.Address = Address; storeById.ContactMan = text2; storeById.StoreImages = ((list2.Count == 0) ? string.Empty : string.Join(",", list2.ToArray())); storeById.Longitude = Math.Round(double.Parse(string.IsNullOrEmpty(this.hfLongitude.Value) ? "0" : this.hfLongitude.Value), 6); storeById.Latitude = Math.Round(double.Parse(string.IsNullOrEmpty(this.hfLatitude.Value) ? "0" : this.hfLatitude.Value), 6); storeById.FullRegionPath = RegionHelper.GetFullPath(value, true); StoresHelper.UpdateStore(storeById); HiCache.Remove("DataCache-StoreInfoDataKey"); if (dictionary.Count > 0 && this.chkIsStoreDelive.Checked) { StoresHelper.AddDeliveryScope(this.storeId, dictionary); } else { StoresHelper.DeleteDevlieryScope(this.storeId); } if (!string.IsNullOrEmpty(this.txtStoreTag.Text.Trim())) { IList <int> list3 = new List <int>(); string text12 = this.txtStoreTag.Text.Trim(); string[] array4 = null; array4 = ((!text12.Contains(",")) ? new string[1] { text12 } : text12.Split(',')); string[] array5 = array4; foreach (string value2 in array5) { list3.Add(Convert.ToInt32(value2)); } StoresHelper.DeleteStoreTags(this.storeId); StoresHelper.BindStoreTags(this.storeId, list3); } else { StoresHelper.DeleteStoreTags(this.storeId); } HiCache.Remove($"DataCache-StoreStateCacheKey-{storeById.StoreId}"); SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (masterSettings.OpenDadaLogistics) { DataTable dataTable = DepotHelper.SynchroDadaStoreList(this.storeId); if (dataTable != null && dataTable.Rows.Count > 0) { for (int l = 0; l < dataTable.Rows.Count; l++) { string station_name = dataTable.Rows[l]["StoreName"].ToNullString(); int business = 5; string city_name = dataTable.Rows[l]["CityName"].ToNullString().Replace("市", ""); string area_name = dataTable.Rows[l]["RegionName"].ToNullString(); string station_address = dataTable.Rows[l]["Address"].ToNullString(); double lng = dataTable.Rows[l]["Longitude"].ToDouble(0); double lat = dataTable.Rows[l]["Latitude"].ToDouble(0); string contact_name = dataTable.Rows[l]["ContactMan"].ToNullString(); string phone = dataTable.Rows[l]["Tel"].ToNullString(); string text13 = dataTable.Rows[l]["StoreId"].ToNullString(); string text14 = DadaHelper.shopUpdate(masterSettings.DadaSourceID, this.storeId.ToString(), "", station_name, business, city_name, area_name, station_address, lng, lat, contact_name, phone, -1); } } } } } } } } }
private void btnAdd_Click(object sender, EventArgs e) { bool flag = false; string text = ""; string text2 = ""; string text3 = ""; string text4 = DataHelper.CleanSearchString(this.txtUserName.Text.Trim()); string text5 = Globals.StripAllTags(this.txtStoresName.Text.Trim()); text3 = Globals.StripAllTags(this.txtAddress.Text); string text6 = Globals.StripAllTags(this.txtRegionScop.Value.Trim()); string text7 = Globals.StripAllTags(this.txtRegionScopName.Value.Trim()); text = this.txtTel.Text; text2 = this.txtContactMan.Text; string[] array = text6.Split(','); string[] array2 = text7.Split(','); IDictionary <int, DeliveryScopeInfo> dictionary = new Dictionary <int, DeliveryScopeInfo>(); for (int i = 0; i < array.Length; i++) { int num = 0; if (int.TryParse(array[i], out num) && array2.Length >= i && dictionary != null && !dictionary.ContainsKey(num)) { DeliveryScopeInfo deliveryScopeInfo = new DeliveryScopeInfo(); deliveryScopeInfo.RegionId = num; deliveryScopeInfo.RegionName = array2[i]; deliveryScopeInfo.FullRegionPath = RegionHelper.GetFullPath(num, true); dictionary.Add(num, deliveryScopeInfo); } } ManagerInfo manager = HiContext.Current.Manager; StoresInfo storeById = StoresHelper.GetStoreById(manager.StoreId); if (storeById.StoreName != text5 && StoresHelper.ExistStoreName(text5)) { this.ShowMsg("门店名称已经存在,请重新输入!", false); } else if (string.Compare(this.txtUserPwd.Text, this.txtUserRePwd.Text) != 0) { this.ShowMsg("请确保两次输入的密码相同", false); } else if (!this.dropRegion.GetSelectedRegionId().HasValue) { this.ShowMsg("请选择店铺所在区域!", false); } else if (text2.Length > 8 || text2.Length < 2) { this.ShowMsg("请输入联系人,联系人长度必须是2-8位!", false); } else if (text == "" || !DataHelper.IsTel(text)) { this.ShowMsg("请输入正确的联系电话(手机或者固定电话)!", false); } else { manager.UserName = this.txtUserName.Text.Trim(); if (!string.IsNullOrEmpty(this.txtUserPwd.Text)) { if (this.txtUserPwd.Text.Length < 6 || this.txtUserPwd.Text.Length > 20) { this.ShowMsg("密码长度必须在6到20个字符之间!", false); return; } manager.Password = Users.EncodePassword(this.txtUserPwd.Text, manager.PasswordSalt); } if (ManagerHelper.Update(manager)) { storeById.StoreName = text5; storeById.RegionId = this.dropRegion.GetSelectedRegionId().Value; storeById.TopRegionId = RegionHelper.GetCityId(storeById.RegionId); storeById.Tel = text; storeById.Address = text3; storeById.ContactMan = text2; storeById.WxOpenId = Globals.StripAllTags(this.txtWxOpenId.Text); storeById.FullRegionPath = RegionHelper.GetFullPath(storeById.RegionId, true); storeById.Introduce = this.editDescription.Text; StoresHelper.UpdateStore(storeById); HiCache.Remove("DataCache-StoreInfoDataKey"); if (dictionary.Count > 0) { StoresHelper.AddDeliveryScope(storeById.StoreId, dictionary); } } this.ShowMsg("保存成功", true); } }