Beispiel #1
0
        private void B_ADD_Click(object sender, EventArgs e)
        {
            if (isValidInputData())
            {
                ModelArea model = new ModelArea();
                model.id           = this.id;
                model.area_station = Convert.ToInt16(area_station.SelectedValue);
                model.area_lounge  = Convert.ToInt16(area_lounge.SelectedValue);
                model.area_name    = area_name.Text;

                Boolean result = false;
                switch (B_ADD.Text)
                {
                case "บันทึก":
                    //Check Exist
                    List <ModelArea> stationLists = areaDao.Select(" Where area_name='" + model.area_name + "'");
                    if (stationLists.Count > 0)
                    {
                        MessageBox.Show("มีข้อมูล " + model.area_name + " ในระบบแล้ว");
                        area_name.Text = "";
                    }
                    else
                    {
                        result = areaDao.Insert(model);
                        if (result)
                        {
                            MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว");
                        }
                    }
                    break;

                case "แก้ไข":
                    result = areaDao.Update(model);
                    if (result)
                    {
                        MessageBox.Show("แก้ไขข้อมูลเรียบร้อยแล้ว");
                    }
                    break;
                }
                if (result)
                {
                    refresh();
                }
            }
        }
        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;");
            }
        }
Beispiel #3
0
 public long Insert(AreaDTO entity)
 {
     return(organizationDAO.Insert(new AreaBO(entity)));
 }
Beispiel #4
0
        public int Insert(Area obj)
        {
            AreaBO areaBO = new AreaBO(obj);

            return(areaDao.Insert(areaBO));
        }