using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WpfApp2;
namespace WpfApp2
{
///
/// Interaction logic for Window1.xaml
///
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
}
public class BillsViewModel2 : ViewModelBase
{
public BillsViewModel2() { ResetYear(); }
private CultureInfo culture = new CultureInfo("en-IN");
public object AdjBills { get; set; }
private ICollectionView _allBills;
public ICollectionView AllBills { get; set; }
private ObservableCollection _allBillss;
public ObservableCollection AllBillss
{
get
{
if (this._allBillss == null) this._allBillss = DatabaseLayer.GetAllBillsFromDB();
return _allBillss;
}
}
public object CityName { get; set; }
public object Cnt { get; set; }
public object Cnt2 { get; set; }
private ObservableCollection _comboItems;
public ObservableCollection ComboItems
{
get {
if (_comboItems == null) this._comboItems = new ObservableCollection(AllBillss.Select(b => b.Party).Distinct().OrderBy(b => b).ToList());
return this._comboItems; }
}
public object ComboItems2 { get; set; }
public object DocxButtonClicked { get; set; }
public object FilteredBills { get; set; }
public object FilterString { get; set; }
public object myInfo { get; set; }
private ICollectionView _pendingBills;
public ICollectionView PendingBills
{
get
{
if (_pendingBills == null)
this._pendingBills = new ListCollectionView(AllBillss)
{
Filter = o => String.IsNullOrEmpty(((Bills)o).Remarks)
&& (DateTime.ParseExact(((Bills)o).DueDt, "yyyy-MM-dd", culture) >= DateTime.Today.AddDays(-10)
&& DateTime.ParseExact(((Bills)o).DueDt, "yyyy-MM-dd", culture) < DateTime.Today.AddDays(11)
)
};
return this._pendingBills;
}
}
public object SearchButtonClicked { get; set; }
public object SelectedButtonClicked { get; set; }
public object SelButtonClicked { get; set; }
public object SelecedItme { get; set; }
public object SelectedCBItem { get; set; }
public object SelectedCBItem2 { get; set; }
public object SelectedIndex { get; set; }
public object SelectedInv { get; set; }
public IList ListOfYears { get { return new List() { "2020", "2021", "2022" }; } }
private string _selectedYear = DateTime.Now.Year.ToString();
public string SelectedYear
{
get { return this._selectedYear; }
set
{
var selYear = value;
if (selYear != this._selectedYear)
{
this._selectedYear = selYear;
ResetYear();
}
}
}
private void ResetYear()
{
DatabaseLayer.dbloc = $"Data Source = {this._selectedYear}.db";
this._pendingBills = null;
this._allBillss = null;
this._comboItems = null;
OnPropertyChanged(string.Empty);
}
}
}