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 CASetViewModule : ViewModelBase
{
#region base parameters
private int rows = 20;
private int pagenumber = 1;
public CASetView 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 CASetViewModule()
{
View = new CASetView();
View.DataContext = this;
InitializeCommands();
InitializeParameters();
}
private void InitializeCommands()
{
ConfirmCommand = new DelegateCommand(OnConfirmCommand);
}
public override void InitializeParameters(object content = null)
{
IsConfirm = false;
WindowTitle = "";
}
~CASetViewModule()
{
}
public void LoadDefaultValue()
{
CASets = new ObservableCollection<SysSettingEntity>();
var record = SysSettingDA.Load(new PagerEntity() { PageIndex = pagenumber, Rows = rows, Conditions = " and IsActive = 1 and SettingGroup in ('CA') " });
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();
CASets.Add(s);
}
OnPropertyChanged("CASets");
}));
}
#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> _CASets;
public ObservableCollection<SysSettingEntity> CASets
{
get
{
return _CASets;
}
set
{
_CASets = value;
OnPropertyChanged("CASets");
}
}
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 CASets)
{
e.SettingStatus = e.Status ? 1 : 0;
SysSettingDA.Update(e);
}
LoadDefaultValue();
DataSet.LoadSetting();
}
#endregion
}
}