private void IncomeLoaded(object sender, System.Windows.RoutedEventArgs e) { DataContext = new SpendViewModel { LoginViewModel = new LoginViewModel() { IsAdmin = ApplicationState.GetValue <bool>("IsAdmin") } }; txtDate.SelectedDate = null; vmSpendList = new ObservableCollection <VmSpend>(Mapper.Map <List <Spend>, List <VmSpend> >(_unitOfWork.Spends.GetAll().ToList())); SpendGridName.ItemsSource = vmSpendList; cmbSpendSource.ItemsSource = _unitOfWork.SpendSource.GetAll().ToList(); }
//public delegate void UpdateOrInsert(object sender, EventArgs s); //public List<string> PickerStrings { get; set; } //public string Methods { get; set; } public NewSpendPage(Tra_Spending viewdata = null) { InitializeComponent(); SpendViewModel spend = new SpendViewModel(); PickerListSpend = spend.Get_Picker_List().ToList(); this.MyPicker.Title = "選択してください"; if (viewdata == null) { Spends = new Tra_Spending(); Spends.Purchase_Date = DateTime.Today; Selected = 0; this.button.Clicked += Save_Clicked; } else { Spends = viewdata; Selected = viewdata.Spend_Id - 1; this.button.Clicked += Update_Clicked; } BindingContext = this; }
void Chenge_Month_Remove(object sender, EventArgs e) { BindingContext = viewModel = new SpendViewModel(-1); OnAppearing(); }
public SpendPage() { InitializeComponent(); BindingContext = viewModel = new SpendViewModel(); }
public ActionResult Index(int id) { try { var startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0); var endDate = new DateTime(startDate.Year, startDate.Month, startDate.AddMonths(1).AddDays(-1).Day, 0, 0, 0); var spendsList = this.SpendService.GetByConsortiumId(id, startDate, endDate); var spendTypes = this.SpendTypeService.GetAll(); var spendItems = this.SpendItemService.GetAll(); var spendTypesList = spendTypes.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Description }); var spendItemsList = spendItems.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Description }); var salaryDictionary = new Dictionary <int, IList <Spend> >(); var spendItemDetYSueldos = spendItemsList.Where(x => x.Text.ToLower().Equals("detalle de sueldo y cargas sociales")).FirstOrDefault(); var salarySpends = spendsList.Where(x => x.Type.Item.Id == int.Parse(spendItemDetYSueldos.Value)).ToList(); var spendsWithoutManager = new List <Spend>(); var managers = new List <Manager>(); var aportesYcontribucionesSpends = new Dictionary <string, decimal>(); salarySpends.ForEach(x => { if (x.Bill.Manager != null) { if (x.Description == "Suterh" || x.Description == "Fateryh" || x.Description == "Seracarh" || x.Description.ToLower().Contains("afip")) { if (!aportesYcontribucionesSpends.Keys.Contains(x.Description)) { aportesYcontribucionesSpends.Add(x.Description, x.Bill.Amount); } else { var actual = aportesYcontribucionesSpends[x.Description]; actual += x.Bill.Amount; aportesYcontribucionesSpends[x.Description] = actual; } } else { if (!salaryDictionary.Keys.Contains(x.Bill.Manager.Id)) { var list = new List <Spend>() { x }; salaryDictionary.Add(x.Bill.Manager.Id, list); managers.Add(x.Bill.Manager); } else { var list = salaryDictionary[x.Bill.Manager.Id]; list.Add(x); salaryDictionary[x.Bill.Manager.Id] = list; } } } else { spendsWithoutManager.Add(x); } }); var salaryDictionaryManager = new Dictionary <Manager, IList <Spend> >(); foreach (var key in salaryDictionary.Keys) { salaryDictionaryManager.Add(managers.Where(x => x.Id == key).FirstOrDefault(), salaryDictionary[key]); } var spendsViewModel = new SpendViewModel() { Id = id, Month = startDate.Month, Spends = spendsList, SpendItems = spendItemsList, SpendTypes = spendTypesList, ConsortiumId = id, SalarySpends = salaryDictionaryManager, AportesYContribucionesSpends = aportesYcontribucionesSpends, SalarySpendWithoutManager = spendsWithoutManager }; return(View("List", spendsViewModel)); } catch (Exception ex) { return(View("../Shared/Error")); } }
public ActionResult PastList(int id, int pastMonth) { try { //var startDate = DateTime.Now.AddMonths(-pastMonth); //startDate = startDate.AddDays(-startDate.Day); //var endDate = DateTime.Now.AddMonths(-pastMonth); //endDate = endDate.AddDays(30 - endDate.Day); var month = DateTime.Now.AddMonths(-pastMonth); var startDate = new DateTime(DateTime.Now.Year, month.Month, 1, 0, 0, 0); var endDate = new DateTime(startDate.Year, startDate.Month, startDate.AddMonths(1).AddDays(-1).Day, 0, 0, 0); var spendsList = this.SpendService.GetByConsortiumId(id, startDate, endDate); var spendTypes = this.SpendTypeService.GetAll(); var spendItems = this.SpendItemService.GetAll(); var spendTypesList = spendTypes.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Description }); var spendItemsList = spendItems.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Description }); var spendsWithoutManager = new List <Spend>(); var salaryDictionary = new Dictionary <int, IList <Spend> >(); var managers = new List <Manager>(); var spendItemDetYSueldos = spendItemsList.Where(x => x.Text.ToLower().Equals("detalle de sueldo y cargas sociales")).FirstOrDefault(); var salarySpends = spendsList.Where(x => x.Type.Item.Id == int.Parse(spendItemDetYSueldos.Value)).ToList(); salarySpends.ForEach(x => { if (x.Bill.Manager != null) { if (!salaryDictionary.Keys.Contains(x.Bill.Manager.Id)) { var list = new List <Spend>() { x }; salaryDictionary.Add(x.Bill.Manager.Id, list); managers.Add(x.Bill.Manager); } else { var list = salaryDictionary[x.Bill.Manager.Id]; list.Add(x); salaryDictionary[x.Bill.Manager.Id] = list; } } else { spendsWithoutManager.Add(x); } }); var salaryDictionaryManager = new Dictionary <Manager, IList <Spend> >(); foreach (var key in salaryDictionary.Keys) { salaryDictionaryManager.Add(managers.Where(x => x.Id == key).FirstOrDefault(), salaryDictionary[key]); } var spendsViewModel = new SpendViewModel() { Spends = spendsList, SpendItems = spendItemsList, SpendTypes = spendTypesList, ConsortiumId = id, SalarySpends = salaryDictionaryManager, SalarySpendWithoutManager = spendsWithoutManager, Id = id, Month = month.Month }; return(View("List", spendsViewModel)); } catch (Exception ex) { return(View("../Shared/Error")); } }