/// <summary>
        /// 查询用户。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnSearch_ClickAsync(object sender, RoutedEventArgs e)
        {
            List <Lib.MemberInfoEntity> MemberList = await DataMemberRepository.ReadMembers(new Lib.MemberSearch()
            {
                Id = InputMemberId
            }).ConfigureAwait(false);

            Dispatcher.Invoke(new Action(() =>
            {
                if (MemberList.Count == 1)
                {
                    Btn_Ok.IsEnabled            = true;
                    PropertyInfo[] TargetAttris = CurMember.GetType().GetProperties();
                    PropertyInfo[] SourceAttris = MemberList[0].GetType().GetProperties();
                    foreach (PropertyInfo item in SourceAttris)
                    {
                        var tempObj = TargetAttris.Where(x => x.Name.Equals(item.Name, StringComparison.Ordinal)).FirstOrDefault();
                        if (tempObj != null)
                        {
                            item.SetValue(CurMember, item.GetValue(MemberList[0]));
                        }
                        Btn_Ok.IsEnabled = true;
                    }
                }
                else
                {
                    AppFuns.ShowMessage("未找到该身份号码的职工信息!");
                }
            }));
        }
        /// <summary>
        /// 导出数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnExport_ClickAsync(object sender, RoutedEventArgs e)
        {
            Button CurBtn = sender as Button;
            List <Lib.MemberInfoEntity> MemberList = await DataMemberRepository.ReadMembers(new MemberSearch()
            {
            });

            if (MemberList == null)
            {
                return;
            }
            System.Windows.Forms.SaveFileDialog fileDialog = new System.Windows.Forms.SaveFileDialog();
            fileDialog.Filter = "Excel|*.xls";
            if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            try
            {
                CurBtn.IsEnabled = false;
                OperationMsg     = "正在导出人员信息,请稍候....";
                await Task.Run(() =>
                {
                    NpoiExcel.ExportExcels(fileDialog.FileName, "员工信息", MemberList);
                });

                OperationMsg     = $"人员信息导出....完成,文件为[{fileDialog.FileName}]。";
                CurBtn.IsEnabled = true;
            }
            catch (Exception Ex)
            {
                AppFuns.ShowMessage(Ex.Message, Caption: "失败");
                CurBtn.IsEnabled = true;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查询待发放信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnSearchClickAsync(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(mSearch.Id))
            {
                return;
            }
            List <Lib.MemberInfoEntity> Members = await DataMemberRepository.ReadMembers(mSearch);

            if (Members == null || Members.Count < 1)
            {
                return;
            }
            //读取用户头像信息
            MemoryStream             UserHeadStream = null;
            IEnumerable <MemberFile> UserPhotos     = await DataMemberFileRepository.ReadFiles(new MemberFileSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = Members[0].Id,
                Name     = Members[0].Id
            });

            UserPhotos = UserPhotos.OrderByDescending(x => x.UpDateTime);
            if (UserPhotos != null && UserPhotos.Count() > 0)
            {
                Stream TempStream = await DataMemberFileRepository.DownloadFileStream(UserPhotos.First().Id, null);

                System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(TempStream);
                UserHeadStream = new MemoryStream();
                bitmap.Save(UserHeadStream, System.Drawing.Imaging.ImageFormat.Png);
                TempStream.Dispose();

                //TempBitMap = new BitmapImage();
                //TempBitMap.BeginInit();
                //TempBitMap.CacheOption = BitmapCacheOption.OnLoad;
                //TempBitMap.StreamSource = UserHeadStream;
                //TempBitMap.EndInit();
                //TempBitMap.Freeze();
                //UserHeadStream.Dispose();
            }
            string DateStr = $"打印日期:{DateTime.Now:yyy-MM-dd}";

            CreateFlowDoc("PrintMemberSheetFlowDot.xaml", null, DateStr, UserHeadStream, Members[0], P_DocWidth: 793, P_DocHeight: 1122);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 查询指定条件的记录
        /// </summary>
        /// <returns></returns>
        private async System.Threading.Tasks.Task SearchMember()
        {
            List <Lib.MemberInfoEntity> MemberList = await DataMemberRepository.ReadMembers(_PageViewModel.mSearch);

            if (MemberList == null)
            {
                AppFuns.SetStateBarText("查询过程出现错误,请重试!");
                return;
            }
            if (MemberList.Count < 1)
            {
                _PageViewModel.EntityList.Clear();
            }
            else
            {
                MemberList.Sort((x, y) => x.OrderIndex - y.OrderIndex);

                _PageViewModel.EntityList.Clear();
                MemberList.ForEach(e => { _PageViewModel.EntityList.Add(e); });
            }
            AppFuns.SetStateBarText($"共查询到记录:{_PageViewModel.EntityList.Count}条");
        }
        /// <summary>
        /// 查询待发放信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnSearchClickAsync(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(_MemberSearch.Id))
            {
                return;
            }
            List <Lib.MemberInfoEntity> Members = await DataMemberRepository.ReadMembers(_MemberSearch);

            if (Members == null || Members.Count < 1)
            {
                AppFuns.ShowMessage("未找到此用户信息!");
                return;
            }
            AppFuns.SetStateBarText($"查看或打印[{Members[0].Name}]信息表。");

            _FixedDocVM = new FixedDocViewModel(Members[0]);
            await _FixedDocVM.InitPropsAsync();

            //设定打印标题
            _FixedDocVM.PrintCaption = $"事 业 编 制 人 员 基 本 情 况 表";
            if (_FixedDocVM.CurMember.MemberType.Equals("劳动合同制"))
            {
                _FixedDocVM.PrintCaption = $"劳 动 用 工 人 员 基 本 情 况 表";
            }
            if (_FixedDocVM.CurMember.MemberType.Equals("劳务派遣制"))
            {
                _FixedDocVM.PrintCaption = $"劳 务 用 工 人 员 基 本 情 况 表";
            }
            //设定打印日期
            _FixedDocVM.PrintDate = DateTime.Now;
            //导入格式模板
            string SheetTemplet = "PrintMemberSheetFixedDot.xaml";

            _FixedDoc = (FixedDocument)Application.LoadComponent(new Uri($"/Office.Work.Platform;component/Member/{SheetTemplet}", UriKind.RelativeOrAbsolute));
            _FixedDoc.AddPages();
            _FixedDoc.DataContext    = _FixedDocVM;
            docViewer.Document       = _FixedDoc;
            this.BtnExport.IsEnabled = true;
        }
            /// <summary>
            /// 查询数据
            /// </summary>
            /// <returns></returns>
            public async Task SearchRecords()
            {
                if (string.IsNullOrWhiteSpace(SearchCondition.MemberId))
                {
                    return;
                }
                //1.先查询用户信息
                List <Lib.MemberInfoEntity> TempMembers = await DataMemberRepository.ReadMembers(new MemberSearch()
                {
                    Id = SearchCondition.MemberId
                }).ConfigureAwait(false);

                if (TempMembers != null && TempMembers.Count > 0)
                {
                    CurMember = TempMembers[0];
                }
                if (CurMember == null)
                {
                    AppFuns.ShowMessage("未找到此用户信息!");
                    return;
                }
                if (SearchCondition != null)
                {
                    List <Lib.MemberScore> MemberScoreList = await DataMemberScoreRepository.GetRecords(SearchCondition);


                    App.Current.Dispatcher.Invoke(() =>
                    {
                        MemberScores.Clear();
                        MemberScoreList?.ToList().ForEach(e =>
                        {
                            e.Member = CurMember;
                            MemberScores.Add(e);
                        });
                    });
                }
            }