You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
4.1 KiB

using GummingBusiness;
using GummingCommon;
using GummingEntity;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows;
namespace Gumming
{
public class CPSetViewModule : ViewModelBase
{
#region base parameters
private int rows = 20;
private int pagenumber = 1;
public CPSetView View { get; set; }
private bool IsConfirm;
private bool isLoading;
private AppEnum.PathType _CurrentPathType;
public AppEnum.PathType CurrentPathType
{
get
{
return _CurrentPathType;
}
set
{
_CurrentPathType = value;
OnPropertyChanged("CurrentPathType");
}
}
#endregion
#region constructor
public CPSetViewModule()
{
View = new CPSetView();
View.DataContext = this;
InitializeCommands();
InitializeParameters();
}
private void InitializeCommands()
{
ConfirmCommand = new DelegateCommand(OnConfirmCommand);
}
public override void InitializeParameters(object content = null)
{
IsConfirm = false;
WindowTitle = "";
}
~CPSetViewModule()
{
}
public void LoadDefaultValue()
{
CPSets = new ObservableCollection<SysSettingEntity>();
var record = SysSettingDA.Load(new PagerEntity() { PageIndex = pagenumber, Rows = rows, Conditions = " and IsActive = 1 and SettingGroup in ('CP') " });
List<SysSettingEntity> settings = (List<SysSettingEntity>)record.rows;
View.Dispatcher.Invoke((Action)(() =>
{
foreach (var s in settings)
{
s.Status = s.SettingStatus == 1;
s.StatusVisible = Visibility.Visible;
s.InputVisible = Visibility.Visible;
s.Copy = (SysSettingEntity)s.Clone();
CPSets.Add(s);
}
OnPropertyChanged("CPSets");
}));
}
#endregion
#region Binding Properties
public string WindowTitle { get; private set; }
private string _TotalRecords;
public string TotalRecords
{
get
{
return _TotalRecords;
}
set
{
_TotalRecords = value;
OnPropertyChanged("TotalRecords");
}
}
private ObservableCollection<SysSettingEntity> _CPSets;
public ObservableCollection<SysSettingEntity> CPSets
{
get
{
return _CPSets;
}
set
{
_CPSets = value;
OnPropertyChanged("CPSets");
}
}
private SysSettingEntity _SelectedSetting;
public SysSettingEntity SelectedSetting
{
get
{
return _SelectedSetting;
}
set
{
_SelectedSetting = value;
OnPropertyChanged("SelectedSetting");
}
}
#endregion
#region Binding Commands
private ICommand _ConfirmCommand;
public ICommand ConfirmCommand
{
get
{
return _ConfirmCommand;
}
set
{
_ConfirmCommand = value;
OnPropertyChanged("ConfirmCommand");
}
}
#endregion
#region Private Methods
private void OnConfirmCommand(Object sender)
{
foreach (var e in CPSets)
{
e.SettingStatus = e.Status ? 1 : 0;
SysSettingDA.Update(e);
}
LoadDefaultValue();
DataSet.LoadSetting();
}
#endregion
}
}