private void ReplaceKey(XWPFParagraph CurPara, Lib.MemberInfoEntity PMember) { if (CurPara.ParagraphText.Trim().Contains("[PrintCaption]")) { CurPara.ReplaceText("[PrintCaption]", _FixedDocVM.PrintCaption); return; } if (CurPara.ParagraphText.Trim().Contains("[PrintDate]")) { CurPara.ReplaceText("[PrintDate]", $"填表时间:{_FixedDocVM.PrintDate:yyyy年MM月dd日}"); return; } //以上是段落内容替换。下面代码是段内不同的“Run”内容部分替换。 //所谓“Run”是某段落内具有完全相关样式的内容。 //var runs = CurPara.Runs; //for (int i = 0; i < runs.Count; i++) //{ // var CurRun = runs[i]; // string text = CurRun.ToString(); // if (text.Contains("[XXX]")) // { // text = text.Replace("[XXX]", "YYY"); // } // CurRun.SetText(text, 0); //} }
/// <summary> /// 查询满足指定条件的计划信息 /// </summary> /// <param name="mSearchMember">查询条件类的实例</param> /// <returns></returns> public static async Task <Lib.MemberInfoEntity> ReadEntity(string EntityId) { Lib.MemberInfoEntity TheEntity = null; string urlParams = DataApiRepository.CreateUrlParams(EntityId); if (urlParams.Length > 0) { TheEntity = await DataApiRepository.GetApiUri <Lib.MemberInfoEntity>(_ApiUrlBase + "ReadEntity" + urlParams); } return(TheEntity); }
public CurPageViewModel(Lib.MemberInfoEntity PMember) { if (PMember == null) { isEditFlag = false; EntityMember = new Lib.MemberInfoEntity(); } else { isEditFlag = true; EntityMember = PMember; } UseHeadImage = new BitmapImage(); MSettings = AppSet.ServerSetting; }
public async System.Threading.Tasks.Task InitVMAsync(Lib.MemberInfoEntity PMember) { CurMember = PMember; if (PMember != null) { MemberPrizePunishSearch SearchCondition = new MemberPrizePunishSearch() { MemberId = PMember.Id, UserId = AppSet.LoginUser.Id }; IEnumerable <MemberPrizePunishDto> MemberPrizePunishss = await DataMemberPrizePunishRepository.GetRecords(SearchCondition); CurRecords.Clear(); MemberPrizePunishss?.ToList().ForEach(e => { CurRecords.Add(e); }); } }
/// <summary> /// 新增用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_AddPerson_ClickAnsyc(object sender, RoutedEventArgs e) { Lib.MemberInfoEntity NewMamber = new Lib.MemberInfoEntity(); PageMemberPayFastWin WinAddMember = new PageMemberPayFastWin(NewMamber); if (WinAddMember.ShowDialog().Value == false) { return; } JToken TempJtoken = _CurViewModel.SalaryJArray.Where(x => x["身份证号"].ToString().Equals(NewMamber.Id)).FirstOrDefault(); if (TempJtoken != null) { AppFuns.ShowMessage($"[{NewMamber.Name}]的已经存在。", "重复"); return; } JToken NewJtoken = _CurViewModel.SalaryJArray.First.DeepClone(); NewJtoken["身份证号"] = NewMamber.Id; NewJtoken["姓名"] = NewMamber.Name; _CurViewModel.SalaryJArray.Add(NewJtoken); DataGridResult.SelectedIndex = DataGridResult.Items.Count - 1; DataGridResult.ScrollIntoView(DataGridResult.SelectedItem); }
public async void initControlAsync(Lib.MemberInfoEntity PMember) { await _UCPrizePunishVM.InitVMAsync(PMember); this.DataContext = _UCPrizePunishVM; }
public async void initControlAsync(Lib.MemberInfoEntity PMember) { await _CurUcViewModel.InitVMAsync(PMember); this.DataContext = _CurUcViewModel; }
public async System.Threading.Tasks.Task InitVMAsync(Lib.MemberInfoEntity PMember) { CurMember = PMember; CurRecords.Clear(); await SearchRecords(); }
private void CreateFlowDoc(string SheetTemplet, string Caption, string DateStr, MemoryStream UserHeadStream, Lib.MemberInfoEntity data, double P_DocWidth, double P_DocHeight) { //1.导入流文件格式模板 App.Current.Dispatcher.Invoke(() => { m_doc = (FlowDocument)Application.LoadComponent(new Uri($"/Office.Work.Platform;component/Member/{SheetTemplet}", UriKind.RelativeOrAbsolute)); m_doc.PageWidth = P_DocWidth; m_doc.PageHeight = P_DocHeight; m_doc.ColumnWidth = P_DocWidth; m_doc.Background = System.Windows.Media.Brushes.Transparent; m_doc.PagePadding = new Thickness(60, 60, 60, 60); //设置页面与页面之间的边距宽度 //2填充模板内容 PrintMemberSheetFlowRender renderer = new PrintMemberSheetFlowRender(); if (m_doc == null || renderer == null) { return; } renderer.Render(m_doc, Caption, DateStr, UserHeadStream, data); }); //必须这样操作,否则m_doc中绑定的数据不显示,可能是未及时更新原因。 //也就是说,等上面的Render完成后再,再构造内存中的Xps Document Dispatcher.BeginInvoke(() => { LoadXps(m_doc); }, DispatcherPriority.ApplicationIdle); }
/// <summary> /// 删除一个实体 /// </summary> /// <param name="Entity"></param> /// <returns></returns> public static async Task <ExcuteResult> DeleteEntity(Lib.MemberInfoEntity Entity) { ExcuteResult JsonResult = await DataApiRepository.DeleteApiUri <ExcuteResult>(_ApiUrlBase + "DeleteEntity/?Id=" + Entity.Id).ConfigureAwait(false); return(JsonResult); }
/// <summary> /// 更新信息(采用PUT) /// </summary> /// <param name="Entity"></param> /// <returns></returns> public static async Task <ExcuteResult> UpdateEntity(Lib.MemberInfoEntity PEntity) { ExcuteResult JsonResult = await DataApiRepository.PutApiUriAsync(_ApiUrlBase + "UpdateEntity", PEntity).ConfigureAwait(false); return(JsonResult); }
public PageMemberPayFastWin(Lib.MemberInfoEntity PMember) { InitializeComponent(); this.Owner = App.Current.MainWindow; CurMember = PMember; }
public void Render(FlowDocument FlowDoc, string Caption, string DateStr, MemoryStream UserHeadStream, Lib.MemberInfoEntity PCurMember) { if (PCurMember == null) { return; } DocVM = new DocViewModel { CurMember = PCurMember }; //设置标题 if (string.IsNullOrWhiteSpace(Caption)) { DocVM.Caption = "事 业 编 制 人 员 基 本 情 况 表"; } else { DocVM.Caption = Caption; } DocVM.DateStr = DateStr; //设置员工头像 if (UserHeadStream != null) { //TableCell Cell_UserPhoto = FlowDoc.FindName("UserPhotoCell") as TableCell; //Paragraph TParagraph = new Paragraph //{ // TextAlignment = TextAlignment.Center //}; //ImageSourceConverter imageSourceConverter = new ImageSourceConverter(); //ImageBrush HeadImgBrush = new ImageBrush((ImageSource)imageSourceConverter.ConvertFrom(UserHeadStream)); //Border HeadImg = new Border //{ // Width = 120, // Height = 170, // Background = HeadImgBrush //}; //TParagraph.Inlines.Add(HeadImg); //Cell_UserPhoto.Blocks.Add(TParagraph); } //填充职工简历 var TempResumes = DataMemberResumeRepository.GetRecords(new Lib.MemberResumeSearch() { UserId = AppSet.LoginUser.Id, MemberId = DocVM.CurMember.Id }).Result; TableCell Cell_Resume = FlowDoc.FindName("Cell_Resume") as TableCell; if (TempResumes != null && TempResumes.Count() > 0) { List <Lib.MemberResume> MemberResumes = TempResumes.OrderBy(x => x.BeginDate).ToList(); for (int i = 0; i < MemberResumes.Count; i++) { Paragraph TParagraph = new Paragraph(); TParagraph.TextAlignment = TextAlignment.Left; TParagraph.Inlines.Add(new Run(MemberResumes[i].BeginDate.ToString("yyyy年MM月—"))); TParagraph.Inlines.Add(new Run(MemberResumes[i].EndDate.ToString("yyyy年MM月"))); TParagraph.Inlines.Add(new Run(MemberResumes[i].Content)); if (!string.IsNullOrWhiteSpace(MemberResumes[i].Remark)) { TParagraph.Inlines.Add(new Run($"({MemberResumes[i].Remark})")); } Cell_Resume.Blocks.Add(TParagraph); } } else { Paragraph TParagraph = new Paragraph(); TParagraph.TextAlignment = TextAlignment.Left; TParagraph.Inlines.Add(new TextBlock() { Height = 400 }); Cell_Resume.Blocks.Add(TParagraph); } //填充职工奖惩信息 var TempPrizePunish = DataMemberPrizePunishRepository.GetRecords(new Lib.MemberPrizePunishSearch() { UserId = AppSet.LoginUser.Id, MemberId = DocVM.CurMember.Id }).Result; if (TempPrizePunish != null && TempPrizePunish.Count() > 0) { TableCell Cell_PrizePunish = FlowDoc.FindName("Cell_PrizePunish") as TableCell; List <Lib.MemberPrizePunishEntity> MemberPrizePunishs = TempPrizePunish.OrderByDescending(x => x.PrizrOrPunishType).ToList(); for (int i = 0; i < MemberPrizePunishs.Count; i++) { Paragraph TParagraph = new Paragraph(); TParagraph.TextAlignment = TextAlignment.Left; TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].OccurDate.ToString("yyyy年MM月"))); TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].PrizrOrPunishName)); TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].PrizrOrPunishUnit)); if (!string.IsNullOrWhiteSpace(MemberPrizePunishs[i].Remark)) { TParagraph.Inlines.Add(new Run($"({MemberPrizePunishs[i].Remark})")); } Cell_PrizePunish.Blocks.Add(TParagraph); } } //填充职工年度考核信息 var TempAppraise = DataMemberAppraiseRepository.GetRecords(new Lib.MemberAppraiseSearch() { UserId = AppSet.LoginUser.Id, MemberId = DocVM.CurMember.Id }).Result; if (TempAppraise != null && TempAppraise.Count() > 0) { TableCell Cell_Appraise = FlowDoc.FindName("Cell_Appraise") as TableCell; List <Lib.MemberAppraise> MemberAppraises = TempAppraise.OrderByDescending(x => x.Year).ToList(); for (int i = 0; i < MemberAppraises.Count; i++) { Paragraph TParagraph = new Paragraph(); TParagraph.TextAlignment = TextAlignment.Left; TParagraph.Inlines.Add(new Run(MemberAppraises[i].Year)); TParagraph.Inlines.Add(new Run(MemberAppraises[i].Result)); if (!string.IsNullOrWhiteSpace(MemberAppraises[i].Remark)) { TParagraph.Inlines.Add(new Run($"({MemberAppraises[i].Remark})")); } Cell_Appraise.Blocks.Add(TParagraph); } } //填充职工社会关系 var TempRelations = DataMemberRelationsRepository.GetRecords(new Lib.MemberRelationsSearch() { UserId = AppSet.LoginUser.Id, MemberId = DocVM.CurMember.Id }).Result; if (TempRelations != null && TempRelations.Count() > 0) { TableCell Cell_Appraise = FlowDoc.FindName("Cell_Relations") as TableCell; List <Lib.MemberRelations> MemberRelationses = TempRelations.OrderBy(x => x.OrderIndex).ToList(); for (int i = 0; i < MemberRelationses.Count; i++) { Paragraph TParagraph = new Paragraph(); TParagraph.TextAlignment = TextAlignment.Left; TParagraph.Inlines.Add(new Run(MemberRelationses[i].Relation)); TParagraph.Inlines.Add(new Run(MemberRelationses[i].Name)); TParagraph.Inlines.Add(new Run(MemberRelationses[i].UnitName)); TParagraph.Inlines.Add(new Run(MemberRelationses[i].Role)); if (!string.IsNullOrWhiteSpace(MemberRelationses[i].Remark)) { TParagraph.Inlines.Add(new Run($"({MemberRelationses[i].Remark})")); } Cell_Appraise.Blocks.Add(TParagraph); } } FlowDoc.DataContext = DocVM; }
public FixedDocViewModel(Lib.MemberInfoEntity PMember) { CurMember = PMember; MemberAge = DateTime.Now.Year - CurMember.Birthday.Year; }
/// <summary> /// 表格中查找替换 /// </summary> /// <param name="CurCell"></param> /// <param name="PMember"></param> /// <param name="PResumes"></param> /// <param name="PRelations"></param> /// <param name="PPrizePunishs"></param> /// <param name="PAppraises"></param> private void ReplaceKeyInCell(XWPFDocument WDoc, XWPFTableCell CurCell, Lib.MemberInfoEntity PMember, List <MemberResume> PResumes, List <MemberRelations> PRelations, List <MemberPrizePunish> PPrizePunishs, List <MemberAppraise> PAppraises) { for (int i = 0; i < CurCell.Paragraphs.Count; i++) { XWPFParagraph CurPara = CurCell.Paragraphs[i]; //头像 if (CurPara.ParagraphText.Trim().Contains("[HeadImage]")) { while (CurPara.Runs.Count > 0) { CurPara.RemoveRun(0); } if (_FixedDocVM.HeadImage != null && _FixedDocVM.HeadImage.StreamSource != null) { XWPFRun imageCellRun = CurPara.CreateRun(); //必须将流位置指针设置到开始处,否则显示不出来。 _FixedDocVM.HeadImage.StreamSource.Position = 0; var picID = WDoc.AddPictureData(_FixedDocVM.HeadImage.StreamSource, (int)PictureType.PNG); CreatePictureInLine(imageCellRun, picID, 100, 140); // CreatePictureWithAnchor(imageCellRun, picID, 90, 120); } break; } //简历 if (CurPara.ParagraphText.Trim().Contains("[Resume]")) { if (PResumes != null && PResumes.Count > 0) { for (int pr = 0; pr < PResumes.Count; pr++) { string EndDateStr = PResumes[pr].EndDate.ToString("yyy.MM"); if (PResumes[pr].EndDate.Year == 1) { EndDateStr = "今"; } string tempValue = $"{PResumes[pr].BeginDate:yyyy.MM}--{EndDateStr} {PResumes[pr].Content}"; if (pr == 0) { CurPara.ReplaceText("[Resume]", tempValue); } else { XWPFParagraph NewParagraph = CurCell.AddParagraph(); XWPFRun NewRun = NewParagraph.CreateRun(); NewRun.FontFamily = CurPara.Runs[0].FontFamily; NewRun.FontSize = CurPara.Runs[0].FontSize; NewRun.SetText(tempValue); } } } else { while (CurPara.Runs.Count > 0) { CurPara.RemoveRun(0); } } break; } //奖情惩况 if (CurPara.ParagraphText.Trim().Contains("[PrizePunish]")) { if (PPrizePunishs != null && PPrizePunishs.Count > 0) { for (int pr = 0; pr < PPrizePunishs.Count; pr++) { string tempValue = $"{PPrizePunishs[pr].OccurDate:yyyy.MM} {PPrizePunishs[pr].PrizrOrPunishUnit} {PPrizePunishs[pr].PrizrOrPunishName}"; if (pr == 0) { CurPara.ReplaceText("[PrizePunish]", tempValue); } else { XWPFParagraph NewParagraph = CurCell.AddParagraph(); XWPFRun NewRun = NewParagraph.CreateRun(); NewRun.FontFamily = CurPara.Runs[0].FontFamily; NewRun.FontSize = CurPara.Runs[0].FontSize; NewRun.SetText(tempValue); } } } else { while (CurPara.Runs.Count > 0) { CurPara.RemoveRun(0); } } break; } //近三年考核情况 if (CurPara.ParagraphText.Trim().Contains("[Appraise]")) { if (PAppraises != null && PAppraises.Count > 0) { for (int pr = 0; pr < PAppraises.Count; pr++) { string tempValue = $"{PAppraises[pr].Year:yyyy} {PAppraises[pr].Result}"; if (pr == 0) { CurPara.ReplaceText("[Appraise]", tempValue); } else { XWPFParagraph NewParagraph = CurCell.AddParagraph(); XWPFRun NewRun = NewParagraph.CreateRun(); NewRun.FontFamily = CurPara.Runs[0].FontFamily; NewRun.FontSize = CurPara.Runs[0].FontSize; NewRun.SetText(tempValue); } } } else { while (CurPara.Runs.Count > 0) { CurPara.RemoveRun(0); } } break; } //主要社会关系 if (CurPara.ParagraphText.Trim().Contains("[Relations")) { string tempValue = ""; for (int p = 1; p <= 7; p++) { for (int k = 0; k <= 4; k++) { if (CurPara.ParagraphText.Trim().Equals($"[Relations{p}{k}]")) { if (PRelations != null && PRelations.Count >= p) { switch (k) { case 0: tempValue = $"{PRelations[p - 1].Relation}"; break; case 1: tempValue = $"{PRelations[p - 1].Name}"; break; case 2: tempValue = $"{PRelations[p - 1].Birthday:yyyy.MM}"; break; case 3: tempValue = $"{PRelations[p - 1].PoliticalStatus}"; break; case 4: tempValue = $"{PRelations[p - 1].UnitName} {PRelations[p - 1].Role} {PRelations[p - 1].Remark}"; break; } } CurPara.ReplaceText($"[Relations{p}{k}]", tempValue == null ? "" : tempValue.Trim()); break; } } } } //基本信息 { Type t = PMember.GetType(); PropertyInfo[] pi = t.GetProperties(); foreach (PropertyInfo p in pi) { if (CurPara.ParagraphText.Trim().Contains($"[{p.Name}]")) { string CurValue = p.GetValue(PMember)?.ToString(); if (string.IsNullOrWhiteSpace(CurValue)) { CurValue = ""; } else { DateTime tempDate; switch (p.Name) { case "Birthday": tempDate = DateTime.Parse(CurValue); CurValue = $"{tempDate:yyyy.MM}"; XWPFParagraph NewParagraph = CurCell.AddParagraph(); NewParagraph.Alignment = ParagraphAlignment.CENTER; XWPFRun NewRun = NewParagraph.CreateRun(); NewRun.FontFamily = CurPara.Runs[0].FontFamily; NewRun.FontSize = CurPara.Runs[0].FontSize; NewRun.SetText($"({DateTime.Now.Year - tempDate.Year}岁)"); break; case "JoinCPC": tempDate = DateTime.Parse(CurValue); CurValue = $"{tempDate:yyyy.MM}"; break; case "BeginWork": tempDate = DateTime.Parse(CurValue); CurValue = $"{tempDate:yyyy.MM}"; break; } } CurPara.ReplaceText("[" + p.Name + "]", CurValue); break; } } } } }
private async void BtnSelectFile_Click(object sender, RoutedEventArgs e) { Button CurBtn = sender as Button; int AddCount = 0; // 在WPF中, OpenFileDialog位于Microsoft.Win32名称空间 Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog { Filter = "Excel Files|*.xls;*.xlsx" }; if (dialog.ShowDialog() == true) { CurBtn.IsEnabled = false; try { System.IO.FileInfo theExcelFile = new System.IO.FileInfo(dialog.FileName); OperationMsg = $"正在从文件[{theExcelFile.FullName}]中导入人员信息,请稍候...."; await Task.Run(async() => { DataTable UserTable = NpoiExcel.ReadStreamToDataTable(theExcelFile.OpenRead(), null, true); if (UserTable != null && UserTable.Rows.Count > 0) { Lib.MemberInfoEntity tempMember = new Lib.MemberInfoEntity(); PropertyInfo[] Attri = tempMember.GetType().GetProperties(); for (int i = 0; i < UserTable.Rows.Count; i++) { tempMember = new Lib.MemberInfoEntity(); foreach (PropertyInfo item in Attri) { //获取该属性的描述特性值(比如:[Description("身份证号")]中的 "身份证号" ) object[] objs = item.GetCustomAttributes(typeof(DescriptionAttribute), true); string PropDescription = ((DescriptionAttribute)objs[0]).Description; if (UserTable.Columns.Contains(PropDescription) && UserTable.Rows[i][PropDescription] != null) { StringBuilder dateStr = new StringBuilder(UserTable.Rows[i][PropDescription].ToString()); switch (item.PropertyType.FullName) { case "System.DateTime": if (!DateTime.TryParse(dateStr.ToString(), out DateTime tempDateTime)) { //处理Excel中数据不规范情况。 dateStr = dateStr.Replace('.', '/'); dateStr = dateStr.Replace('-', '/'); dateStr = dateStr.Replace('—', '/'); dateStr = dateStr.Replace('。', '/'); if (dateStr.Length < 8) { dateStr.Append("/01"); } } if (DateTime.TryParse(dateStr.ToString(), out tempDateTime)) { item.SetValue(tempMember, tempDateTime); } break; case "System.Int32": if (int.TryParse(dateStr.ToString(), out int tempIntValue)) { item.SetValue(tempMember, tempIntValue); } break; case "System.String": item.SetValue(tempMember, UserTable.Rows[i][PropDescription].ToString()); break; default: continue; } } } if (!string.IsNullOrEmpty(tempMember.Id)) { tempMember.UserId = AppSet.LoginUser.Id; ExcuteResult excuteResult = await DataMemberRepository.AddOrUpdate(tempMember).ConfigureAwait(false); if (excuteResult.State == 0) { AddCount++; OperationMsg = $"正在从文件[{theExcelFile.FullName}]中导入人员信息,已导入[{AddCount}]条信息。"; } } } } });//Task Finish OperationMsg = $"人员信息导入成功,共导入[{AddCount}]条信息。"; CurBtn.IsEnabled = true; } catch (Exception VE) { AppFuns.ShowMessage("出现错误:" + VE.Message, Caption: "错误", isErr: true); CurBtn.IsEnabled = true; return; } } }