Ejemplo n.º 1
0
        public override void OnPageLoad(object sender, EventArgs e)
        {
            base.OnPageLoad(sender, e);
            List <KeyValuePair <AreaStatus?, string> > statusList = EnumConverter.GetKeyValuePairs <AreaStatus>();

            statusList.Insert(0, new KeyValuePair <AreaStatus?, string>(null, ResCommonEnum.Enum_Select));
            lisStatus.ItemsSource = statusList;
            List <KeyValuePair <AreaIsLocal?, string> > isLocalList = EnumConverter.GetKeyValuePairs <AreaIsLocal>();

            isLocalList.Insert(0, new KeyValuePair <AreaIsLocal?, string>(null, ResCommonEnum.Enum_Select));
            lisIsLocal.ItemsSource = isLocalList;
            _areaInfoViewModel     = new AreaInfoVM();
            Area_Feild.DataContext = _areaInfoViewModel;
            _areaFace = new AreaFacade(this);
            if (this.Request.QueryString.ContainsKey("operation"))
            {
                _op = this.Request.QueryString["operation"];
            }
            if (this.Request.QueryString.ContainsKey("sysno"))
            {
                _sysNo = int.Parse(this.Request.QueryString["sysno"]);
                _areaFace.Load(_sysNo, (s, args) =>
                {
                    _areaInfoViewModel     = args.Result;
                    Area_Feild.DataContext = _areaInfoViewModel;
                });
            }
            InitControl(_sysNo);
        }
Ejemplo n.º 2
0
        public void Load(int?sysNo, EventHandler <RestClientEventArgs <AreaInfoVM> > callback)
        {
            string relativeUrl = "/CommonService/Area/Load/" + sysNo;

            if (sysNo.HasValue)
            {
                restClient.Query <AreaInfo>(relativeUrl, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }

                    AreaInfo entity       = args.Result;
                    AreaInfoVM _viewModel = null;
                    if (entity == null)
                    {
                        _viewModel = new AreaInfoVM();
                    }
                    else
                    {
                        _viewModel = entity.Convert <AreaInfo, AreaInfoVM>();
                    }

                    callback(obj, new RestClientEventArgs <AreaInfoVM>(_viewModel, restClient.Page));
                });
            }
            else
            {
                callback(new Object(), new RestClientEventArgs <AreaInfoVM>(new AreaInfoVM(), restClient.Page));
            }
        }
Ejemplo n.º 3
0
        public void Create(AreaInfoVM infoVM, EventHandler <RestClientEventArgs <AreaInfoVM> > callback)
        {
            string relativeUrl = "/CommonService/Area/Create";
            var    msg         = infoVM.ConvertVM <AreaInfoVM, AreaInfo>((s, t) =>
            {
                if (!s.provinceSysNo.HasValue)
                {
                    t.ProvinceName = s.AreaName;
                }
                else if (!s.CitySysNo.HasValue && s.provinceSysNo.HasValue)
                {
                    t.CityName = s.AreaName;
                }
                //else if (!string.IsNullOrEmpty(s.DistrictName)) t.DistrictName = s.AreaName;
                else if (s.CitySysNo.HasValue)
                {
                    t.DistrictName = s.AreaName;
                }
            });

            restClient.Create <AreaInfoVM>(relativeUrl, msg, (s, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }
                infoVM = args.Result;
                callback(s, new RestClientEventArgs <AreaInfoVM>(infoVM, restClient.Page));
            });
        }
Ejemplo n.º 4
0
        public void Update(AreaInfoVM _viewMode, EventHandler <RestClientEventArgs <AreaInfoVM> > callback)
        {
            string relativeUrl = "/CommonService/Area/Update";
            var    msg         = _viewMode.ConvertVM <AreaInfoVM, AreaInfo>((s, t) =>
            {
                if (string.IsNullOrEmpty(s.DistrictName) && string.IsNullOrEmpty(s.CityName))
                {
                    t.ProvinceName = s.AreaName; t.ProvinceSysNo = null;
                }
                else if (string.IsNullOrEmpty(s.DistrictName) && !string.IsNullOrEmpty(s.CityName))
                {
                    t.CityName = s.AreaName; t.CitySysNo = null;
                }
                else if (!string.IsNullOrEmpty(s.DistrictName))
                {
                    t.DistrictName = s.AreaName;
                }
            });

            restClient.Update(relativeUrl, msg, callback);
        }
Ejemplo n.º 5
0
        private void Save_New_Click(object sender, RoutedEventArgs e)
        {
            ValidationManager.Validate(Area_Feild);
            if (_areaInfoViewModel.HasValidationErrors)
            {
                return;
            }
            if (!string.IsNullOrEmpty(_op) && !string.IsNullOrEmpty(_sysNo.ToString()))
            {
                _areaInfoViewModel.SysNo = _sysNo;
                _areaFace.Update(_areaInfoViewModel, (s, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }

                    this.Window.Alert("更新地区成功!");
                    _areaInfoViewModel = args.Result;
                    InitControl(_sysNo);
                    Area_Feild.DataContext = _areaInfoViewModel;
                });
            }
            else
            {
                _areaFace.Create(_areaInfoViewModel, (s, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    _areaInfoViewModel     = args.Result;
                    this._op               = "edit";
                    this._sysNo            = args.Result.SysNo;
                    Area_Feild.DataContext = _areaInfoViewModel;
                    this.Window.Alert("添加地区成功");
                    InitControl(_sysNo);
                });
            }
        }
Ejemplo n.º 6
0
 public VendorServiceInfoVM()
 {
     areaInfo = new AreaInfoVM();
 }