/// <summary> /// 展示新闻界面 /// </summary> public NewsView(NewsViewModel viewModel, ViewState state) : this() { viewModel.LoadDetails(); GoToState(state); LoadImage(viewModel.NEWSID, state); if (state == ViewState.ADD) { txtDeptId.Text = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; txtDeptName.Text = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentName; viewModel.PUTDEPTID = txtDeptId.Text; viewModel.PUTDEPTNAME = txtDeptName.Text; ViewModel = viewModel; return; } viewModel.OnLoadDetailsCompleted += (obj, args) => { ViewModel = viewModel; }; viewModel.OnAddCompleted += (obj, args) => { loading.Stop(); }; viewModel.OnLoadDetailsCompleted += (obj, args) => { loading.Stop(); }; viewModel.OnDataChangedCompleted += (obj, args) => { loading.Stop(); }; // LoadImage(viewModel.NEWSID, state); }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { NewsViewModel wm = new NewsViewModel() { NEWSID = Guid.NewGuid().ToString(), ParentVM = viewModel }; NewsView addView = new NewsView(wm, ViewState.ADD); SMT.SAAS.Controls.Toolkit.Windows.Window host = ProgramManager.ShowProgram("新建新闻", "", AddFormID, addView, true, true, null); addView.Reset += (obj, arg) => { host.Close(); }; host.Closed += (obj, arg) => { // viewModel.Refresh(); }; }
private NewsViewModel ConventToViewModel(NewsModel model) { int state = model.NEWSSTATE.IsNotNull() ? int.Parse(model.NEWSSTATE) : 0; int type = model.NEWSTYPEID.IsNotNull() ? int.Parse(model.NEWSTYPEID) : 0; var vmodel = new NewsViewModel() { NEWSTITEL = model.NEWSTITEL, NEWSID = model.NEWSID, UPDATEDATE = model.UPDATEDATE }; vmodel.NEWSSTATE = vmodel.NEWSSTATELIST[state]; vmodel.NEWSTYPE = vmodel.NEWSTYPELIST[type]; return(vmodel); }
void _Services_OnGetNewsListCompleted(object sender, GetEntityListEventArgs <NewsModel> e) { if (_items == null) { _items = new ObservableCollection <NewsViewModel>(); } ObservableCollection <NewsViewModel> list = new ObservableCollection <NewsViewModel>(); foreach (var item in e.Result) { list.Add(ConventToViewModel(item)); } this.Items = list; this.PageCount = e.PageCount; if (this._currentEntity.IsNull() && list.Count > 0) { this._currentEntity = list[0]; } }
/// <summary> /// 清空当前View 数据 /// </summary> private void ClearValue() { _resetModel = this.DataContext as NewsViewModel; this.DataContext = new NewsViewModel(); }
private NewsViewModel ConventToViewModel(NewsModel model) { int state = model.NEWSSTATE.IsNotNull() ? int.Parse(model.NEWSSTATE) : 0; int type = model.NEWSTYPEID.IsNotNull() ? int.Parse(model.NEWSTYPEID) : 0; var vmodel = new NewsViewModel() { NEWSTITEL = model.NEWSTITEL, NEWSID = model.NEWSID, UPDATEDATE = model.UPDATEDATE, IsAdd = false }; vmodel.NEWSSTATE = vmodel.NEWSSTATELIST[state]; vmodel.NEWSTYPE = vmodel.NEWSTYPELIST[type]; return vmodel; }
private NewsViewModel ConventToViewModel(NewsModel model) { int state = model.NEWSSTATE.IsNotNull() ? int.Parse(model.NEWSSTATE) : 0; int type = model.NEWSTYPEID.IsNotNull() ? int.Parse(model.NEWSTYPEID) : 0; ObservableCollection<DISTR> distrs = new ObservableCollection<DISTR>(); foreach (var item in model.VIEWER) { distrs.Add(new DISTR() { VIEWERS = item.VIEWERS, MODELNAMES = item.MODELNAMES }); } var vmodel = new NewsViewModel() { NEWSTITEL = model.NEWSTITEL, NEWSID = model.NEWSID, ISRELEASE = model.ISRELEASE, NEWSCONTENT = model.NEWSCONTENT, ISIMAGE = model.ISIMAGE, ISPOPUP=model.ISPOPUP, ENDDATE=model.ENDDATE, UPDATEDATE = model.UPDATEDATE, DISTRS = distrs }; vmodel.NEWSSTATE = vmodel.NEWSSTATELIST[state]; vmodel.NEWSTYPE = vmodel.NEWSTYPELIST[type]; return vmodel; }
private NewsModel ConventToModel(NewsViewModel viewModel) { ObservableCollection<Model.DISTR> viewer = new ObservableCollection<Model.DISTR>(); foreach (var item in viewModel.DISTRS) { viewer.Add(new Model.DISTR() { VIEWERS = item.VIEWERS, MODELNAMES = item.MODELNAMES }); } return new NewsModel() { NEWSID = viewModel.NEWSID, NEWSTITEL = viewModel.NEWSTITEL.Trim(), ISRELEASE = viewModel.ISRELEASE, NEWSCONTENT = viewModel.NEWSCONTENT, NEWSSTATE = viewModel.NEWSSTATE.ID.ToString(), NEWSTYPEID = viewModel.NEWSTYPE.ID.ToString(), ISIMAGE = viewModel.ISIMAGE, VIEWER = viewer, ISPOPUP = viewModel.ISPOPUP, ENDDATE = viewModel.ENDDATE, UPDATEDATE = viewModel.UPDATEDATE, PUTDEPTID=viewModel.PUTDEPTID, PUTDEPTNAME=viewModel.PUTDEPTNAME }; }