Esempio n. 1
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);
            });
        }
Esempio n. 2
0
        /// <summary>
        /// 获取上次数据,以便供编辑使用。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Btn_Last_ClickAnsyc(object sender, RoutedEventArgs e)
        {
            //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)
            {
                App.Current.Dispatcher.Invoke(() =>
                {
                    DataGridResult.ItemsSource = null;
                    foreach (MemberSalarySearchResult item in SalaryList)
                    {
                        JObject TempJobj     = new JObject();
                        PropertyInfo[] Props = item.GetType().GetProperties();
                        for (int i = 0; i < Props.Length; i++)
                        {
                            var CurValue = Props[i].GetValue(item);
                            if (CurValue != null)
                            {
                                if (Props[i].Name == "SalaryItems")
                                {
                                    _CurViewModel.SalaryItems = CurValue as List <SalaryItem>;
                                    for (int ik = 0; ik < _CurViewModel.SalaryItems.Count; ik++)
                                    {
                                        TempJobj[_CurViewModel.SalaryItems[ik].Name] = _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;
                            }
                        }
                        _CurViewModel.SalaryJArray.Add(TempJobj);
                    }
                    DataGridResult.ItemsSource = _CurViewModel.SalaryJArray;

                    foreach (DataGridColumn item in DataGridResult.Columns)
                    {
                        if (_CurViewModel.NamesEnCn.Values.Contains(item.Header.ToString()))
                        {
                            if (item.Header.ToString().Equals("备注"))
                            {
                                continue;
                            }
                            item.IsReadOnly = true;
                        }
                    }
                    //DataGridResult.Columns.Add(new DataGridCheckBoxColumn() { Header = "姓名", Binding = new Binding("MemberName") });
                });
                _CurViewModel.CanOperation = true;
            }
            else
            {
                _CurViewModel.CanOperation = false;
            }
        }
Esempio n. 3
0
        /// <summary>
        ///  获取上次数据,以便供编辑使用。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Btn_GetData_ClickAsync(object sender, RoutedEventArgs e)
        {
            string MemberId = null;

            if (string.IsNullOrWhiteSpace(_CurViewModel.SearchCondition.TableType) || string.IsNullOrWhiteSpace(_CurViewModel.SearchCondition.MemberId))
            {
                return;
            }
            //1.查询所有可发放的待遇项目信息
            _CurViewModel.SalaryJArray.Clear();
            IEnumerable <MemberSalarySearchResult> SalaryList = await DataMemberSalaryRepository.GetRecords(_CurViewModel.SearchCondition).ConfigureAwait(false);

            if (SalaryList != null && SalaryList.Count() > 0)
            {
                await App.Current.Dispatcher.BeginInvoke(new Action(async() =>
                {
                    MemberId = _CurViewModel.SearchCondition.MemberId.Clone().ToString();
                    foreach (MemberSalarySearchResult item in SalaryList)
                    {
                        JObject TempJobj = new JObject();
                        PropertyInfo[] Props = item.GetType().GetProperties();
                        for (int i = 0; i < Props.Length; i++)
                        {
                            var CurValue = Props[i].GetValue(item);
                            if (CurValue != null)
                            {
                                if (Props[i].Name == "SalaryItems")
                                {
                                    _CurViewModel.SalaryItems = CurValue as List <SalaryItem>;
                                    for (int ik = 0; ik < _CurViewModel.SalaryItems.Count; ik++)
                                    {
                                        TempJobj[_CurViewModel.SalaryItems[ik].Name] = _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;
                            }
                        }
                        _CurViewModel.SalaryJArray.Add(TempJobj);
                    }

                    DataGridResult.ItemsSource = null;
                    DataGridResult.ItemsSource = _CurViewModel.SalaryJArray;

                    foreach (DataGridColumn item in DataGridResult.Columns)
                    {
                        if (_CurViewModel.NamesEnCn.Values.Contains(item.Header.ToString()))
                        {
                            if (item.Header.ToString().Equals("备注"))
                            {
                                continue;
                            }
                            item.IsReadOnly = true;
                        }
                    }
                    _CurViewModel.CanOperation = true;
                    await UcMemberPayFile.InitFileDatasAsync(MemberId, "个人待遇", true);
                }), null);
            }
            else
            {
                _CurViewModel.CanOperation = false;
                AppFuns.ShowMessage("未查询到相关记录,请先使用快速发放!");
            }
        }