private async void Page_LoadedAsync(object sender, System.Windows.RoutedEventArgs e)
        {
            IEnumerable <Lib.MemberPayItem> MemberPayItems = await DataMemberPayItemRepository.GetRecords(new Lib.MemberPayItemSearch()
            {
                PayUnitName = AppSet.LoginUser.UnitName,
                UserId      = AppSet.LoginUser.Id
            }).ConfigureAwait(false);

            if (MemberPayItems != null)
            {
                MemberPayItems = MemberPayItems.OrderBy(x => x.OrderIndex);
                MemberPayItems.ToList().ForEach(e =>
                {
                    cvm.PayItems.Add(e);
                });
            }
            App.Current.Dispatcher.Invoke(() => { this.DataContext = cvm; });
        }
Example #2
0
        /// <summary>
        /// 查询待发放信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Btn_Search_ClickAsync(object sender, RoutedEventArgs e)
        {
            //获取所有可发放的待遇项目

            IEnumerable <MemberPayItem> CollectPayItem = await DataMemberPayItemRepository.GetRecords(new MemberPayItemSearch()
            {
                PayUnitName = AppSet.LoginUser.UnitName, UserId = AppSet.LoginUser.Id
            }).ConfigureAwait(false);

            _CurViewModel.PayItems = CollectPayItem?.ToList();
            //1.查询所有可发放的待遇项目信息
            _CurViewModel.SearchCondition.PayYear  = _CurViewModel.PayYearMonth.Year;
            _CurViewModel.SearchCondition.PayMonth = _CurViewModel.PayYearMonth.Month;
            _CurViewModel.SalaryJArray.Clear();
            IEnumerable <MemberSalarySearchResult> SalaryList = await DataMemberSalaryRepository.GetRecords(_CurViewModel.SearchCondition).ConfigureAwait(false);

            if (SalaryList != null && SalaryList.Count() > 0)
            {
                foreach (MemberSalarySearchResult item in SalaryList)
                {
                    float YingFaDaiYu  = 0f;
                    float GeRenJiaoNa  = 0f;
                    float DanWeiJiaoNa = 0f;

                    JObject        TempJobj = new JObject();
                    PropertyInfo[] Props    = item.GetType().GetProperties();
                    for (int i = 0; i < Props.Length; i++)
                    {
                        if (_CurViewModel.NoPrintItemNames.Contains(Props[i].Name))
                        {
                            continue;
                        }
                        var CurValue = Props[i].GetValue(item);
                        if (CurValue != null)
                        {
                            if (Props[i].Name == "SalaryItems")
                            {
                                _CurViewModel.SalaryItems = CurValue as List <SalaryItem>;

                                //在 _CurViewModel.SalaryItems 中添加相应的汇总项
                                switch (item.TableType)
                                {
                                case "月度工资表":
                                    int k = 0;
                                    for (k = 0; k < _CurViewModel.SalaryItems.Count; k++)
                                    {
                                        MemberPayItem CurPayItem = _CurViewModel.PayItems.Where(x => x.Name.Equals(_CurViewModel.SalaryItems[k].Name)).FirstOrDefault();
                                        if (CurPayItem != null && CurPayItem.PayType.Equals("个人交纳"))
                                        {
                                            break;
                                        }
                                    }
                                    _CurViewModel.SalaryItems.Insert(k, new SalaryItem()
                                    {
                                        Name = "应发合计", Amount = 0
                                    });
                                    _CurViewModel.SalaryItems.Add(new SalaryItem()
                                    {
                                        Name = "实发合计", Amount = 0
                                    });
                                    break;

                                case "月度补贴表":
                                    _CurViewModel.SalaryItems.Add(new SalaryItem()
                                    {
                                        Name = "补贴合计", Amount = 0
                                    });
                                    break;

                                case "其他待遇表":
                                    _CurViewModel.SalaryItems.Add(new SalaryItem()
                                    {
                                        Name = "发放合计", Amount = 0
                                    });
                                    break;
                                }
                                for (int ik = 0; ik < _CurViewModel.SalaryItems.Count; ik++)
                                {
                                    TempJobj[_CurViewModel.SalaryItems[ik].Name] = _CurViewModel.SalaryItems[ik].Amount;
                                    MemberPayItem CurPayItem = _CurViewModel.PayItems.Where(x => x.Name.Equals(_CurViewModel.SalaryItems[ik].Name)).FirstOrDefault();

                                    if (CurPayItem != null)
                                    {
                                        if (CurPayItem.PayType.Equals("应发待遇"))
                                        {
                                            YingFaDaiYu += _CurViewModel.SalaryItems[ik].Amount;
                                        }
                                        else if (CurPayItem.PayType.Equals("个人交纳"))
                                        {
                                            GeRenJiaoNa += _CurViewModel.SalaryItems[ik].Amount;
                                        }
                                        else if (CurPayItem.PayType.Equals("单位交纳"))
                                        {
                                            DanWeiJiaoNa += _CurViewModel.SalaryItems[ik].Amount;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (Props[i].Name.Equals("UpDateTime"))
                                {
                                    DateTime upDate = DateTime.MinValue;
                                    DateTime.TryParse(CurValue.ToString(), out upDate);

                                    if (upDate == DateTime.MinValue)
                                    {
                                        upDate = DateTime.Now;
                                    }

                                    TempJobj[_CurViewModel.NamesEnCn[Props[i].Name]] = upDate.ToString("yyyy-MM-dd");
                                }
                                else
                                {
                                    TempJobj[_CurViewModel.NamesEnCn[Props[i].Name]] = CurValue.ToString();
                                }
                            }
                        }
                        else
                        {
                            TempJobj[_CurViewModel.NamesEnCn[Props[i].Name]] = "";
                            continue;
                        }
                    }
                    switch (item.TableType)
                    {
                    case "月度工资表":
                        TempJobj["应发合计"] = YingFaDaiYu.ToString("0.00");
                        TempJobj["实发合计"] = (YingFaDaiYu - GeRenJiaoNa).ToString("0.00");
                        break;

                    case "月度补贴表":
                        TempJobj["补贴合计"] = YingFaDaiYu.ToString("0.00");
                        break;

                    case "其他待遇表":
                        TempJobj["发放合计"] = YingFaDaiYu.ToString("0.00");
                        break;
                    }
                    _CurViewModel.SalaryJArray.Add(TempJobj);
                }
            }
            else
            {
                _CurViewModel.SalaryJArray.Clear();
                AppFuns.ShowMessage("未发现指定的待遇发放记录!");
                return;
            }
            App.Current.Dispatcher.Invoke(() =>
            {
                AppFuns.SetStateBarText($"共查询到:{_CurViewModel.SalaryJArray.Count} 条数据。");
                string Caption = $"{AppSet.LoginUser.UnitShortName}{_CurViewModel.SearchCondition.MemberType}人员{_CurViewModel.SearchCondition.TableType}";
                string DateStr = $"发放月份:({_CurViewModel.SearchCondition.PayYear}年{_CurViewModel.SearchCondition.PayMonth}月)";
                if (!_CurViewModel.SearchCondition.TableType.Contains("月"))
                {
                    DateStr = $"发放时间:{_CurViewModel.PayYearMonth.Year}年{_CurViewModel.PayYearMonth.Month}月{_CurViewModel.PayYearMonth.Day}日";
                }
                CreateFlowDoc("PrintMemberPaySheetDot.xaml", Caption, DateStr, _CurViewModel.SalaryJArray, P_DocWidth: 1122, P_DocHeight: 793);
            });
        }