コード例 #1
0
        public string GetSelectedCities()
        {
            var areaInfo = AreaDao.GetAreaInfo(_areaId);

            if (string.IsNullOrEmpty(areaInfo.Cities))
            {
                return("[]");
            }
            var builder = new StringBuilder();

            foreach (var city in areaInfo.Cities.Split(','))
            {
                builder.Append($"'{city}',");
            }
            builder.Length--;
            return($"[{builder}]");
        }
コード例 #2
0
        private bool SaveDelivery()
        {
            var deliveryInfo = DeliveryDao.GetDeliveryInfo(_deliveryId);

            deliveryInfo.DeliveryName   = TbDeliveryName.Text;
            deliveryInfo.DeliveryType   = DdlDeliveryType.SelectedValue;
            deliveryInfo.StartStandards = Utils.ParseInt(TbStartStandards.Text);
            deliveryInfo.StartFees      = Utils.ParseDecimal(TbStartFees.Text);
            deliveryInfo.AddStandards   = Utils.ParseInt(TbAddStandards.Text);
            deliveryInfo.AddFees        = Utils.ParseDecimal(TbAddFees.Text);

            foreach (RepeaterItem repeaterItem in RptAreas.Items)
            {
                if (repeaterItem.ItemType != ListItemType.Item && repeaterItem.ItemType != ListItemType.AlternatingItem)
                {
                    continue;
                }

                var hfAreaId         = (HiddenField)repeaterItem.FindControl("hfAreaId");
                var tbStartStandards = (TextBox)repeaterItem.FindControl("tbStartStandards");
                var tbStartFees      = (TextBox)repeaterItem.FindControl("tbStartFees");
                var tbAddStandards   = (TextBox)repeaterItem.FindControl("tbAddStandards");
                var tbAddFees        = (TextBox)repeaterItem.FindControl("tbAddFees");

                var areaId   = Utils.ParseInt(hfAreaId.Value);
                var areaInfo = AreaDao.GetAreaInfo(areaId);

                areaInfo.StartStandards = Utils.ParseInt(tbStartStandards.Text);
                areaInfo.StartFees      = Utils.ParseDecimal(tbStartFees.Text);
                areaInfo.AddStandards   = Utils.ParseInt(tbAddStandards.Text);
                areaInfo.AddFees        = Utils.ParseDecimal(tbAddFees.Text);

                if (string.IsNullOrEmpty(areaInfo.Cities))
                {
                    return(false);
                }

                AreaDao.Update(areaInfo);
            }

            DeliveryDao.Update(deliveryInfo);

            return(true);
        }
コード例 #3
0
        public void Page_Load(object sender, EventArgs e)
        {
            var request = SiteServer.Plugin.Context.GetCurrentRequest();

            _siteId     = request.GetQueryInt("siteId");
            _deliveryId = request.GetQueryInt("deliveryId");
            _areaId     = request.GetQueryInt("areaId");

            if (!request.AdminPermissions.HasSitePermissions(_siteId, Main.PluginId))
            {
                Response.Write("<h1>未授权访问</h1>");
                Response.End();
                return;
            }

            if (!string.IsNullOrEmpty(Request.QueryString["delete"]) &&
                !string.IsNullOrEmpty(Request.QueryString["idCollection"]))
            {
                var array = Request.QueryString["idCollection"].Split(',');
                var list  = array.Select(s => Utils.ParseInt(s)).ToList();
                OrderDao.Delete(list);
                LtlMessage.Text = Utils.GetMessageHtml("删除成功!", true);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["addArea"]))
            {
                var areaInfo = new AreaInfo
                {
                    DeliveryId = _deliveryId
                };
                areaInfo.Id = AreaDao.Insert(areaInfo);
                Response.Redirect($@"{GetRedirectUrl(_siteId, _deliveryId)}");
                return;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["removeArea"]))
            {
                AreaDao.Delete(_areaId);
                Response.Redirect($@"{GetRedirectUrl(_siteId, _deliveryId)}");
                return;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["saveCities"]))
            {
                var areaInfo = AreaDao.GetAreaInfo(_areaId);
                areaInfo.Cities = Request.QueryString["selectedCities"];
                AreaDao.Update(areaInfo);
                Response.Redirect($@"{GetRedirectUrl(_siteId, _deliveryId)}");
                return;
            }

            if (IsPostBack)
            {
                return;
            }

            var deliveryInfo = DeliveryDao.GetDeliveryInfo(_deliveryId);

            TbDeliveryName.Text = deliveryInfo.DeliveryName;
            Utils.SelectListItems(DdlDeliveryType, deliveryInfo.DeliveryType);
            TbStartStandards.Text = deliveryInfo.StartStandards.ToString();
            TbStartFees.Text      = deliveryInfo.StartFees.ToString("N2");
            TbAddStandards.Text   = deliveryInfo.AddStandards.ToString();
            TbAddFees.Text        = deliveryInfo.AddFees.ToString("N2");

            RptAreas.DataSource     = AreaDao.GetAreaInfoList(_deliveryId);
            RptAreas.ItemDataBound += RptAreas_ItemDataBound;
            RptAreas.DataBind();

            BtnAreaAdd.Attributes.Add("onclick", $@"location.href = '{GetRedirectUrl(_siteId, _deliveryId)}&addArea={true}';return false;");

            if (!string.IsNullOrEmpty(Request.QueryString["areas"]) && !string.IsNullOrEmpty(Request.QueryString["areaId"]))
            {
                PhModalAreas.Visible = true;
                BtnAreas.Attributes.Add("onclick", $"location.href='{GetRedirectUrl(_siteId, _deliveryId)}&saveCities={true}&areaId={_areaId}&selectedCities=' + selectedCities.join(',');return false;");
            }
        }