public override void OnPageLoad(object sender, EventArgs e) { base.OnPageLoad(sender, e); List <KeyValuePair <CurrencyStatus?, string> > statusList = EnumConverter.GetKeyValuePairs <CurrencyStatus>(); statusList.Insert(0, new KeyValuePair <CurrencyStatus?, string>(null, ResCommonEnum.Enum_Select)); lisStatus.ItemsSource = statusList; List <KeyValuePair <bool?, string> > isLocalList = new List <KeyValuePair <bool?, string> >(); isLocalList.Insert(0, new KeyValuePair <bool?, string>(true, "是")); isLocalList.Insert(1, new KeyValuePair <bool?, string>(false, "否")); lisIsLocal.ItemsSource = isLocalList; _currencyInfoVm = new CurrencyInfoVM(); _currencyFacade = new CurrencyFacade(this); Currency_Feild.DataContext = _currencyInfoVm; if (this.Request.QueryString.ContainsKey("operation")) { _op = this.Request.QueryString["operation"]; } if (this.Request.QueryString.ContainsKey("sysno")) { _sysNo = int.Parse(this.Request.QueryString["sysno"]); _currencyFacade.Load(_sysNo, (s, args) => { _currencyInfoVm = args.Result; Currency_Feild.DataContext = _currencyInfoVm; }); } }
public void Update(CurrencyInfoVM _viewMode, EventHandler <RestClientEventArgs <CurrencyInfoVM> > callback) { string relativeUrl = "/CommonService/Currency/UpdateCurrency"; var msg = _viewMode.ConvertVM <CurrencyInfoVM, CurrencyInfo>((s, t) => { if (string.IsNullOrEmpty(s.CurrencyName)) { t.CurrencyName = s.CurrencyName; } if (string.IsNullOrEmpty(s.CurrencySymbol)) { t.CurrencySymbol = s.CurrencySymbol; } if (s.ExchangeRate.HasValue) { t.ExchangeRate = s.ExchangeRate; } if (s.IsLocal.HasValue) { t.IsLocal = s.IsLocal; } if (s.Status.HasValue) { t.Status = s.Status == CurrencyStatus.Active ? 0 : -1; } if (s.ListOrder.HasValue) { t.ListOrder = s.ListOrder; } }); restClient.Update(relativeUrl, msg, callback); }
public void Load(int?sysNo, EventHandler <RestClientEventArgs <CurrencyInfoVM> > callback) { string relativeUrl = "/CommonService/Currency/LoadCurrency/" + sysNo; if (sysNo.HasValue) { restClient.Query <CurrencyInfo>(relativeUrl, (obj, args) => { if (args.FaultsHandle()) { return; } CurrencyInfo entity = args.Result; CurrencyInfoVM _viewModel = null; if (entity == null) { _viewModel = new CurrencyInfoVM(); } else { _viewModel = entity.Convert <CurrencyInfo, CurrencyInfoVM>(); } callback(obj, new RestClientEventArgs <CurrencyInfoVM>(_viewModel, restClient.Page)); }); } else { callback(new Object(), new RestClientEventArgs <CurrencyInfoVM>(new CurrencyInfoVM(), restClient.Page)); } }
private void Save_New_Click(object sender, RoutedEventArgs e) { ValidationManager.Validate(Currency_Feild); if (_currencyInfoVm.HasValidationErrors) { return; } if (!string.IsNullOrEmpty(_op) && !string.IsNullOrEmpty(_sysNo.ToString())) { _currencyInfoVm.SysNo = _sysNo; _currencyFacade.Update(_currencyInfoVm, (s, args) => { if (args.FaultsHandle()) { return; } this.Window.Alert("更新币种成功!"); _currencyInfoVm = args.Result; //InitControl(_sysNo); Currency_Feild.DataContext = _currencyInfoVm; }); } else { _currencyFacade.Create(_currencyInfoVm, (s, args) => { if (args.FaultsHandle()) { return; } _currencyInfoVm = args.Result; this._op = "edit"; this._sysNo = args.Result.SysNo; Currency_Feild.DataContext = _currencyInfoVm; this.Window.Alert("添加币种成功"); //InitControl(_sysNo); }); } }
public List <CurrencyInfoVM> ConvertCurrencyInfoEntityToCurrencyInfoVm(List <CurrencyInfo> data) { var list = new List <CurrencyInfoVM>(); data.ForEach(area => { var vm = new CurrencyInfoVM(); if (area.SysNo.HasValue) { vm.SysNo = area.SysNo.Value; vm.CurrencyID = area.CurrencyID; vm.CurrencyName = area.CurrencyName; vm.CurrencySymbol = area.CurrencySymbol; vm.ExchangeRate = area.ExchangeRate; vm.ListOrder = area.ListOrder; vm.IsLocal = area.IsLocal; vm.Status = area.Status == 0 ? CurrencyStatus.Active : CurrencyStatus.Deactive; } list.Add(vm); }); return(list); }
public void Create(CurrencyInfoVM infoVM, EventHandler <RestClientEventArgs <CurrencyInfoVM> > callback) { string relativeUrl = "/CommonService/Currency/CreateCurrency"; var msg = infoVM.ConvertVM <CurrencyInfoVM, CurrencyInfo>((s, t) => { t.CurrencyName = s.CurrencyName; t.CurrencySymbol = s.CurrencySymbol; t.ExchangeRate = s.exchangeRate; t.ListOrder = s.ListOrder; t.IsLocal = s.IsLocal; t.Status = s.Status == CurrencyStatus.Active ? 0 : -1; }); restClient.Create <CurrencyInfoVM>(relativeUrl, msg, (s, args) => { if (args.FaultsHandle()) { return; } infoVM = args.Result; callback(s, new RestClientEventArgs <CurrencyInfoVM>(infoVM, restClient.Page)); }); }