本文整理汇总了C#中System.Windows.Forms.Document.ImportNode方法的典型用法代码示例。如果您正苦于以下问题:C# Document.ImportNode方法的具体用法?C# Document.ImportNode怎么用?C# Document.ImportNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Document
的用法示例。
在下文中一共展示了Document.ImportNode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnRun_Click
private void btnRun_Click(object sender, EventArgs e)
{
string SelectedSchoolYear = "" + cmbSchoolYear.SelectedItem;
List<string> SelectedStudentIDs = K12.Presentation.NLDPanels.Student.SelectedSource;
if (K12.Data.Utility.Utility.IsNullOrEmpty(SelectedStudentIDs))
{
MessageBox.Show("請選取學生!");
return;
}
if (!string.IsNullOrEmpty(SelectedSchoolYear))
{
this.btnPrint.Enabled = false;
Task<Document> task = Task<Document>.Factory.StartNew(() =>
{
MemoryStream template = new MemoryStream(this.template);
Document doc = new Document();
doc.Sections.Clear();
List<string> keys = new List<string>();
List<object> values = new List<object>();
Dictionary<string, object> mergeKeyValue = new Dictionary<string,object>();
List<Student> Students = new List<Student>();
if (this.title.Contains("9"))
Students = DataAccess.GetGrade(SelectedSchoolYear, SelectedStudentIDs, false);
else
Students = DataAccess.GetGrade(SelectedSchoolYear, SelectedStudentIDs, true);
foreach (Student vStudent in Students)
{
Document dataDoc = new Document(template, "", LoadFormat.Doc, "");
dataDoc.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
dataDoc.MailMerge.RemoveEmptyParagraphs = true;
mergeKeyValue = vStudent.OutputValue();
dataDoc.MailMerge.Execute(mergeKeyValue.Keys.ToArray(), mergeKeyValue.Values.ToArray());
doc.Sections.Add(doc.ImportNode(dataDoc.Sections[0], true));
}
return doc;
});
task.ContinueWith((x) =>
{
this.btnPrint.Enabled = true;
if (x.Exception != null)
MessageBox.Show(x.Exception.InnerException.Message);
else
Completed(this.TitleText, x.Result);
}, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
}
}
示例2: btnPrint_Click
private void btnPrint_Click(object sender, EventArgs e)
{
string survey_year = this.nudSchoolYear.Value + "";
this.btnPrint.Enabled = false;
this.circularProgress.Visible = true;
this.circularProgress.IsRunning = true;
Task<Document> task = Task<Document>.Factory.StartNew(() =>
{
MemoryStream template = new MemoryStream(this.template);
Document doc = new Document();
Document dataDoc = new Document(template, "", LoadFormat.Doc, "");
dataDoc.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
dataDoc.MailMerge.RemoveEmptyParagraphs = true;
doc.Sections.Clear();
List<string> keys = new List<string>();
List<object> values = new List<object>();
Dictionary<string, object> mergeKeyValue = ApproachStatisticsCalculator
.Calculate(survey_year);
foreach (string key in mergeKeyValue.Keys)
{
keys.Add(key);
values.Add(mergeKeyValue[key]);
}
dataDoc.MailMerge.Execute(keys.ToArray(), values.ToArray());
doc.Sections.Add(doc.ImportNode(dataDoc.Sections[0], true));
return doc;
});
task.ContinueWith((x) =>
{
this.btnPrint.Enabled = true;
this.circularProgress.Visible = false;
this.circularProgress.IsRunning = false;
if (x.Exception != null)
MessageBox.Show(x.Exception.InnerException.Message);
else
Completed(this.TitleText, x.Result);
}, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
}
示例3: btnPrint_Click
private void btnPrint_Click(object sender, EventArgs e)
{
string survey_year = this.nudSchoolYear.Value + "";
this.btnPrint.Enabled = false;
this.circularProgress.Visible = true;
this.circularProgress.IsRunning = true;
Task<Dictionary<string, object>> task = Accessor.ApproachStatistics.Execute(int.Parse(survey_year));
task.ContinueWith((x) =>
{
this.btnPrint.Enabled = true;
this.circularProgress.Visible = false;
this.circularProgress.IsRunning = false;
if (x.Exception != null)
MessageBox.Show(x.Exception.InnerException.Message);
else
{
MemoryStream template = Accessor.ApproachReportTemplate.Execute(int.Parse(survey_year));
Document doc = new Document();
Document dataDoc = new Document(template, "", LoadFormat.Doc, "");
dataDoc.MailMerge.RemoveEmptyParagraphs = true;
doc.Sections.Clear();
List<string> keys = new List<string>();
List<object> values = new List<object>();
Dictionary<string, object> mergeKeyValue = x.Result;
foreach (string key in mergeKeyValue.Keys)
{
keys.Add(key);
values.Add(mergeKeyValue[key]);
}
dataDoc.MailMerge.Execute(keys.ToArray(), values.ToArray());
dataDoc.MailMerge.DeleteFields();
doc.Sections.Add(doc.ImportNode(dataDoc.Sections[0], true));
Completed(survey_year + "學年度國中畢業學生進路調查填報表格", doc);
}
}, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
}
示例4: btnSubjectSemesterScoreStatistics_Click
//.........这里部分代码省略.........
mergeKeyValue["修業歷程之學期_" + idx + "_" + SubjectSemesterScore.Semester.Value] = EMBACore.DataItems.SemesterItem.GetSemesterByCode(SubjectSemesterScore.Semester + "").Name;
if (string.IsNullOrEmpty(SubjectSemesterScore.OffsetCourse) && !SubjectSemesterScore.IsPass)
continue;
if (mergeKeyValue.ContainsKey("修業歷程之實得學分_" + idx + "_" + SubjectSemesterScore.Semester))
mergeKeyValue["修業歷程之實得學分_" + idx + "_" + SubjectSemesterScore.Semester] = int.Parse(mergeKeyValue["修業歷程之實得學分_" + idx + "_" + SubjectSemesterScore.Semester] + "") + SubjectSemesterScore.Credit;
if (mergeKeyValue.ContainsKey("畢業修業歷程之實得學分_" + idx + "_" + SubjectSemesterScore.Semester))
mergeKeyValue["畢業修業歷程之實得學分_" + idx + "_" + SubjectSemesterScore.Semester] = int.Parse(mergeKeyValue["畢業修業歷程之實得學分_" + idx + "_" + SubjectSemesterScore.Semester] + "") + SubjectSemesterScore.Credit;
credit_total += SubjectSemesterScore.Credit;
if (!dicSchoolYearMappings.ContainsKey(school_year))
dicSchoolYearMappings.Add(school_year, idx);
}
mergeKeyValue.Add("實得總學分", credit_total + SubjectSemesterScores.Where(x => !string.IsNullOrWhiteSpace(x.OffsetCourse)).Sum(x => x.Credit));
mergeKeyValue.Add("畢業實得總學分", credit_total + SubjectSemesterScores.Where(x => !string.IsNullOrWhiteSpace(x.OffsetCourse)).Sum(x => x.Credit));
mergeKeyValue.Add("應修最低畢業學分數", string.Empty);
if (this.dicStudentBrief2.ContainsKey(Student.ID))
{
if (this.dicGraduationRequirements.ContainsKey(this.dicStudentBrief2[Student.ID].GraduationRequirementID + ""))
mergeKeyValue["應修最低畢業學分數"] = this.dicGraduationRequirements[this.dicStudentBrief2[Student.ID].GraduationRequirementID + ""].RequiredCredit;
}
DateTime print_date;
if (!DateTime.TryParse(this.dtDueDate.Text, out print_date))
print_date = DateTime.Today;
mergeKeyValue.Add("列印日期_年", print_date.Year - 1911);
mergeKeyValue.Add("列印日期_月", print_date.Month.ToString("00"));
mergeKeyValue.Add("列印日期_日", print_date.Day.ToString("00"));
// 重覆修課
int total_credit_reduce = 0;
foreach (int SubjectID in dicDuplicateSubjectSemesterScores.Keys)
{
if (dicDuplicateSubjectSemesterScores[SubjectID].Count < 2)
continue;
List<UDT.SubjectSemesterScore> DuplicateSubjectSemesterScores = dicDuplicateSubjectSemesterScores[SubjectID];
bool init = false;
foreach (UDT.SubjectSemesterScore SubjectSemesterScore in DuplicateSubjectSemesterScores.OrderBy(x=>(x.SchoolYear.HasValue ? x.SchoolYear.Value : 0)).ThenBy(x=>(x.Semester.HasValue ? x.Semester.Value : 0)))
{
if (init)
{
if (dicSchoolYearMappings.ContainsKey((SubjectSemesterScore.SchoolYear.HasValue ? SubjectSemesterScore.SchoolYear.Value : 0)))
{
mergeKeyValue["不計入畢業學分_" + dicSchoolYearMappings[(SubjectSemesterScore.SchoolYear.HasValue ? SubjectSemesterScore.SchoolYear.Value : 0)] + "_" + (SubjectSemesterScore.Semester.HasValue ? SubjectSemesterScore.Semester.Value : 0)] = SubjectSemesterScore.Credit;
total_credit_reduce += SubjectSemesterScore.Credit;
int oCredit = int.Parse(mergeKeyValue["畢業修業歷程之實得學分_" + dicSchoolYearMappings[(SubjectSemesterScore.SchoolYear.HasValue ? SubjectSemesterScore.SchoolYear.Value : 0)] + "_" + (SubjectSemesterScore.Semester.HasValue ? SubjectSemesterScore.Semester.Value : 0)] + "");
mergeKeyValue["畢業修業歷程之實得學分_" + dicSchoolYearMappings[(SubjectSemesterScore.SchoolYear.HasValue ? SubjectSemesterScore.SchoolYear.Value : 0)] + "_" + (SubjectSemesterScore.Semester.HasValue ? SubjectSemesterScore.Semester.Value : 0)] = oCredit - SubjectSemesterScore.Credit;
}
}
init = true;
}
}
mergeKeyValue.Add("不計入畢業總學分", total_credit_reduce);
mergeKeyValue["畢業實得總學分"] = int.Parse(mergeKeyValue["畢業實得總學分"] + "") - total_credit_reduce;
int lowest_credit = 0;
int.TryParse(mergeKeyValue["應修最低畢業學分數"] + "", out lowest_credit);
int credit_differ = lowest_credit - int.Parse(mergeKeyValue["畢業實得總學分"] + "");
if (credit_differ > 0)
mergeKeyValue["本學期選修總學分"] = credit_differ - credit_current; // credit_is_not_requred_total;
else
mergeKeyValue["本學期選修總學分"] = 0;
eachStudentDoc.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
eachStudentDoc.MailMerge.RemoveEmptyParagraphs = true;
List<string> keys = new List<string>();
List<object> values = new List<object>();
foreach (string key in mergeKeyValue.Keys)
{
keys.Add(key);
values.Add(mergeKeyValue[key]);
}
eachStudentDoc.MailMerge.Execute(keys.ToArray(), values.ToArray());
doc.Sections.Add(doc.ImportNode(eachStudentDoc.Sections[0], true));
}
return doc;
});
task.ContinueWith((x) =>
{
this.circularProgress.Visible = false;
this.circularProgress.IsRunning = false;
this.btnPrint.Enabled = true;
if (x.Exception != null)
MessageBox.Show(x.Exception.InnerException.Message);
else
Completed("畢業生成績審核表", x.Result);
}, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
}
示例5: _bgWorker_DoWork
//.........这里部分代码省略.........
// 檢查料是否超過可合併欄位
ChechMapFieldName("測驗名稱", i);
ChechMapFieldName("測驗日期", i);
ChechMapFieldName("測驗結果", i);
row["測驗名稱" + i] = "";
if (_QuizDefDict.ContainsKey(data.QuizID))
row["測驗名稱" + i] = _QuizDefDict[data.QuizID].QuizName;
if (data.ImplementationDate.HasValue)
row["測驗日期" + i] = data.ImplementationDate.Value.ToShortDateString();
else
row["測驗日期" + i] = "";
row["測驗結果" + i] = Utility.CounselStudQuizXmlParse1(data.Content);
i++;
}
}
// 晤談紀錄
if (_CounselStudentInterviewRecordDict.ContainsKey(StudID))
{
int i1 = 1;
List<UDT_CounselStudentInterviewRecordDef> dataList = (from da in _CounselStudentInterviewRecordDict[StudID] orderby da.InterviewDate select da).ToList();
foreach (UDT_CounselStudentInterviewRecordDef data in dataList)
{
// 檢查料是否超過可合併欄位
ChechMapFieldName("晤談紀錄日期", i1);
ChechMapFieldName("晤談紀錄對象", i1);
ChechMapFieldName("晤談紀錄方式", i1);
ChechMapFieldName("晤談紀錄內容要點", i1);
ChechMapFieldName("晤談紀錄記錄者姓名", i1);
row["晤談紀錄日期"+i1]=data.InterviewDate.Value.ToShortDateString();
row["晤談紀錄對象" + i1] = data.IntervieweeType;
row["晤談紀錄方式" + i1] = data.InterviewType;
row["晤談紀錄內容要點" + i1] = data.ContentDigest;
row["晤談紀錄記錄者姓名" + i1] = data.AuthorName;
i1++;
}
}
// 個案會議
if (_CounselCaseMeetingRecordDict.ContainsKey(StudID))
{
int i2 = 1;
List<UDT_CounselCaseMeetingRecordDef> dataList = (from da in _CounselCaseMeetingRecordDict[StudID] orderby da.MeetingDate select da).ToList();
foreach (UDT_CounselCaseMeetingRecordDef data in dataList)
{
// 檢查料是否超過可合併欄位
ChechMapFieldName("個案會議會議日期", i2);
ChechMapFieldName("個案會議會議事由", i2);
ChechMapFieldName("個案會議內容要點", i2);
ChechMapFieldName("個案會議記錄者姓名", i2);
row["個案會議會議日期" + i2] = data.MeetingDate.Value.ToShortDateString();
row["個案會議會議事由" + i2] = data.MeetingCause;
row["個案會議內容要點" + 2] = data.ContentDigest;
row["個案會議記錄者姓名" + i2] = data.AuthorName;
i2++;
}
}
// 優先關懷
if (_CounselCareRecordDict.ContainsKey(StudID))
{
int i3 = 1;
List<UDT_CounselCareRecordDef> dataList = (from da in _CounselCareRecordDict[StudID] orderby da.FileDate select da).ToList();
foreach (UDT_CounselCareRecordDef data in dataList)
{
// 檢查料是否超過可合併欄位
ChechMapFieldName("優先關懷立案日期", i3);
ChechMapFieldName("優先關懷個案類別", i3);
ChechMapFieldName("優先關懷個案來源", i3);
ChechMapFieldName("優先關懷記錄者姓名", i3);
row["優先關懷立案日期" + i3] = data.FileDate.Value.ToShortDateString();
row["優先關懷個案類別" + i3] = data.CaseCategory;
row["優先關懷個案來源" + i3] = data.CaseOrigin;
row["優先關懷記錄者姓名" + i3] = data.AuthorName;
i3++;
}
}
_dtTable.Rows.Add(row);
}
Document document = new Document();
document = docTemplae;
doc.Sections.Add(doc.ImportNode(document.Sections[0], true));
doc.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
doc.MailMerge.Execute(_dtTable);
doc.MailMerge.RemoveEmptyParagraphs = true;
doc.MailMerge.DeleteFields();
_bgWorker.ReportProgress(95);
e.Result = doc;
}
示例6: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//未輸入電子報表名稱的檢查
if (textBox1.Text.Trim() != "")
{
//主要的Word文件
Document doc = new Document();
doc.Sections.Clear();
if (radioButton2.Checked)
{
#region 班級電子報表
//建立一個班級電子報表
//傳入參數 : 報表名稱,學年度,學期,類型(學生/班級/教師/課程)
paperForClass = new SmartSchool.ePaper.ElectronicPaper(textBox1.Text, School.DefaultSchoolYear, School.DefaultSemester, SmartSchool.ePaper.ViewerType.Class);
MemoryStream stream = new MemoryStream();
Document each_page = new Document(template, "", LoadFormat.Doc, "");
each_page.Save(stream, SaveFormat.Doc);
//取得所選擇的班級ID
List<string> ClassID = K12.Presentation.NLDPanels.Class.SelectedSource;
foreach (string each in ClassID)
{
//傳參數給PaperItem
//格式 / 內容 / 對象的系統編號
paperForClass.Append(new PaperItem(PaperFormat.Office2003Doc, stream, each));
}
//開始上傳
SmartSchool.ePaper.DispatcherProvider.Dispatch(paperForClass);
#endregion
}
else
{
#region 班級學生的電子報表
//建立一個學生電子報表
//傳入參數 : 報表名稱,學年度,學期,類型(學生/班級/教師/課程)
paperForStudent = new SmartSchool.ePaper.ElectronicPaper(textBox1.Text, School.DefaultSchoolYear, School.DefaultSemester, SmartSchool.ePaper.ViewerType.Student);
//學生個人的文件
Document each_page = new Document(template, "", LoadFormat.Doc, "");
MemoryStream stream = new MemoryStream();
each_page.Save(stream, SaveFormat.Doc);
doc.Sections.Add(doc.ImportNode(each_page.Sections[0], true)); //合併至doc
List<string> ClassID = K12.Presentation.NLDPanels.Class.SelectedSource; //取得畫面上所選班級的ID清單
List<StudentRecord> srList = Student.SelectByClassIDs(ClassID); //依據班級ID,取得學生物件
foreach (StudentRecord sr in srList)
{
//傳參數給PaperItem
//格式 / 內容 / 對象的系統編號
paperForStudent.Append(new PaperItem(PaperFormat.Office2003Doc, stream, sr.ID));
}
//開始上傳
SmartSchool.ePaper.DispatcherProvider.Dispatch(paperForStudent);
#endregion
}
}
else
{
MessageBox.Show("請輸入電子報表名稱!!");
}
}
示例7: _bgWork_DoWork
//.........这里部分代码省略.........
{
Global._CousreAttendList.Add(data);
SumCount++;
}
}
// 計算學生缺曠統計
dr["小計" + coIdx] = SumCount;
// 扣考
if (Global._StudentNotExamDict.ContainsKey(studID))
{
if (Global._StudentNotExamDict[studID].Contains(cid))
dr["扣考" + coIdx] = "扣考";
}
string ssid = cid.ToString();
if (!Global._CourseStudentAttendanceIdxDict.ContainsKey(ssid))
Global._CourseStudentAttendanceIdxDict.Add(ssid, coIdx);
drTT["缺曠紀錄" + coIdx] = ssid;
coIdx++;
}
}
dr["學年度"] = string.Join(",", syL.ToArray());
dr["學期"] = string.Join(",", ssL.ToArray());
dr["梯次"] = string.Join(",", smL.ToArray());
dt.Rows.Add(dr);
dtAtt.Rows.Add(drTT);
// 處理動態處理(缺曠)
Document docAtt = new Document();
docAtt.Sections.Clear();
docAtt.Sections.Add(docAtt.ImportNode(docTemplate.Sections[0], true));
_builder = new DocumentBuilder(docAtt);
docAtt.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
docAtt.MailMerge.Execute(dtAtt);
int cot = 1;
Document doc1 = new Document();
doc1.Sections.Clear();
doc1.Sections.Add(doc1.ImportNode(docAtt.Sections[0], true));
doc1.MailMerge.Execute(dt);
doc1.MailMerge.RemoveEmptyParagraphs = true;
doc1.MailMerge.DeleteFields();
//// 清除多餘欄位
//int TabRowCount = doc1.Sections[0].Body.Tables[0].Rows.Count - 1;
//for (int idx = TabRowCount; idx >= cot; idx--)
//{
// doc1.Sections[0].Body.Tables[0].Rows.RemoveAt(idx);
//}
docList.Add(doc1);
}
doc.Sections.Clear();
foreach (Document doc2 in docList)
doc.Sections.Add(doc.ImportNode(doc2.Sections[0], true));
string reportNameW = "重補修缺課通知單";
if(_SelectChkNotExam)
reportNameW = "重補修缺課扣考通知單";
else
reportNameW = "重補修缺課通知單";
pathW = Path.Combine(System.Windows.Forms.Application.StartupPath + "\\Reports", "");
if (!Directory.Exists(pathW))
示例8: btnPrint_Click
//.........这里部分代码省略.........
mergeKeyValue.Add("G2/A2", A2_sum > 0 ? Math.Round(G2_sum * 100 / A2_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("H2/A2", A2_sum > 0 ? Math.Round(H2_sum * 100 / A2_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("I2/A2", A2_sum > 0 ? Math.Round(I2_sum * 100 / A2_sum, 2, MidpointRounding.AwayFromZero) : 0);
#endregion
#region 學制別
A3_sum = B3_sum + C3_sum + D3_sum + E3_sum + F3_sum + G3_sum + H3_sum + I3_sum + J3_sum;
mergeKeyValue.Add("A3", A3_sum);
mergeKeyValue.Add("B3", B3_sum);
mergeKeyValue.Add("C3", C3_sum);
mergeKeyValue.Add("D3", D3_sum);
mergeKeyValue.Add("E3", E3_sum);
mergeKeyValue.Add("F3", F3_sum);
mergeKeyValue.Add("G3", G3_sum);
mergeKeyValue.Add("H3", H3_sum);
mergeKeyValue.Add("I3", I3_sum);
mergeKeyValue.Add("J3", J3_sum);
mergeKeyValue.Add("B3/A3", A3_sum > 0 ? Math.Round(B4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("C3/A3", A3_sum > 0 ? Math.Round(C4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("D3/A3", A3_sum > 0 ? Math.Round(D4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("E3/A3", A3_sum > 0 ? Math.Round(E4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("F3/A3", A3_sum > 0 ? Math.Round(F4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("G3/A3", A3_sum > 0 ? Math.Round(G4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("H3/A3", A3_sum > 0 ? Math.Round(H4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("I3/A3", A3_sum > 0 ? Math.Round(I4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("J3/A3", A3_sum > 0 ? Math.Round(J4_sum * 100 / A3_sum, 2, MidpointRounding.AwayFromZero) : 0);
#endregion
#region 入學方式
A4_sum = B4_sum + C4_sum + D4_sum + E4_sum + F4_sum + G4_sum + H4_sum + I4_sum + J4_sum +
K4_sum + L4_sum + M4_sum + N4_sum + O4_sum + P4_sum + Q4_sum + R4_sum + S4_sum;
mergeKeyValue.Add("A4", A4_sum);
mergeKeyValue.Add("B4", B4_sum);
mergeKeyValue.Add("C4", C4_sum);
mergeKeyValue.Add("D4", D4_sum);
mergeKeyValue.Add("E4", E4_sum);
mergeKeyValue.Add("F4", F4_sum);
mergeKeyValue.Add("G4", G4_sum);
mergeKeyValue.Add("H4", H4_sum);
mergeKeyValue.Add("I4", I4_sum);
mergeKeyValue.Add("J4", J4_sum);
mergeKeyValue.Add("K4", K4_sum);
mergeKeyValue.Add("L4", L4_sum);
mergeKeyValue.Add("M4", M4_sum);
mergeKeyValue.Add("N4", N4_sum);
mergeKeyValue.Add("O4", O4_sum);
mergeKeyValue.Add("P4", P4_sum);
mergeKeyValue.Add("Q4", Q4_sum);
mergeKeyValue.Add("R4", R4_sum);
mergeKeyValue.Add("S4", S4_sum);
mergeKeyValue.Add("B4/A4", A4_sum > 0 ? Math.Round(B4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("C4/A4", A4_sum > 0 ? Math.Round(C4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("D4/A4", A4_sum > 0 ? Math.Round(D4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("E4/A4", A4_sum > 0 ? Math.Round(E4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("F4/A4", A4_sum > 0 ? Math.Round(F4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("G4/A4", A4_sum > 0 ? Math.Round(G4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("H4/A4", A4_sum > 0 ? Math.Round(H4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("I4/A4", A4_sum > 0 ? Math.Round(I4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("J4/A4", A4_sum > 0 ? Math.Round(J4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("K4/A4", A4_sum > 0 ? Math.Round(K4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("L4/A4", A4_sum > 0 ? Math.Round(L4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("M4/A4", A4_sum > 0 ? Math.Round(M4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("N4/A4", A4_sum > 0 ? Math.Round(N4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("O4/A4", A4_sum > 0 ? Math.Round(O4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("P4/A4", A4_sum > 0 ? Math.Round(P4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("Q4/A4", A4_sum > 0 ? Math.Round(Q4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("R4/A4", A4_sum > 0 ? Math.Round(R4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
mergeKeyValue.Add("S4/A4", A4_sum > 0 ? Math.Round(S4_sum * 100 / A4_sum, 2, MidpointRounding.AwayFromZero) : 0);
#endregion
// 學校代碼及名稱
mergeKeyValue.Add("學校代碼", K12.Data.School.Code);
mergeKeyValue.Add("填報學校", K12.Data.School.ChineseName);
foreach (string key in mergeKeyValue.Keys)
{
keys.Add(key);
values.Add(mergeKeyValue[key]);
}
dataDoc.MailMerge.Execute(keys.ToArray(), values.ToArray());
doc.Sections.Add(doc.ImportNode(dataDoc.Sections[0], true));
return doc;
});
task.ContinueWith((x) =>
{
this.btnPrint.Enabled = true;
this.circularProgress.Visible = false;
this.circularProgress.IsRunning = false;
if (x.Exception != null)
MessageBox.Show(x.Exception.InnerException.Message);
else
Completed("國中畢業學生進路調查填報表格", x.Result);
}, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
}
示例9: _bgPrintData_DoWork
void _bgPrintData_DoWork(object sender, DoWorkEventArgs e)
{
_bgPrintData.ReportProgress(1);
AddTableColumn();
Document doc = new Document();
doc.Sections.Clear();
// 取得缺曠資料
_SelectAttendanceList = UDTTransfer.UDTAttendanceSelectByCourseIDList(_SelectCourseIDList);
// 取得課程修課
_SelectSCList = UDTTransfer.UDTSCSelectByCourseIDList(_SelectCourseIDList);
Dictionary<string, List<string>> _SCStudernDict = new Dictionary<string, List<string>>();
foreach (UDTScselectDef data in _SelectSCList)
{
string cid=data.CourseID.ToString();
if (!_SCStudernDict.ContainsKey(cid))
_SCStudernDict.Add(cid, new List<string>());
_SCStudernDict[cid].Add(data.StudentID.ToString());
}
_StudentIDList.Clear();
_StudentDict.Clear();
_AddressDict.Clear();
_ParentDict.Clear();
// 取得有缺曠學生id
foreach (UDTAttendanceDef data in _SelectAttendanceList)
{
string sid = data.StudentID.ToString();
if (!_StudentIDList.Contains(sid))
_StudentIDList.Add(sid);
}
// 取得學生資料
foreach (StudentRecord rec in Student.SelectByIDs(_StudentIDList))
_StudentDict.Add(rec.ID, rec);
// 地址資料
foreach (AddressRecord rec in Address.SelectByStudentIDs(_StudentIDList))
{
if (!_AddressDict.ContainsKey(rec.RefStudentID))
_AddressDict.Add(rec.RefStudentID, rec);
}
// 家長資料
foreach (ParentRecord rec in K12.Data.Parent.SelectByStudentIDs(_StudentIDList))
{
if (!_ParentDict.ContainsKey(rec.RefStudentID))
_ParentDict.Add(rec.RefStudentID, rec);
}
// 教師姓名
_TeacherNameDict.Clear();
foreach (TeacherRecord rec in Teacher.SelectAll())
{
if (rec.Status == TeacherRecord.TeacherStatus.刪除)
continue;
string name = rec.Name;
if(!string.IsNullOrWhiteSpace(rec.Nickname))
name="("+rec.Nickname+")";
_TeacherNameDict.Add(rec.ID, name);
}
// 班級名稱
_ClassNameDict.Clear();
foreach (ClassRecord cr in Class.SelectAll())
_ClassNameDict.Add(cr.ID, cr.Name);
string SchoolName = School.ChineseName;
string SchoolAddress = School.Address;
string SchoolTel = School.Telephone;
_bgPrintData.ReportProgress(20);
// 整理資料並過濾畫面上已修課學生
// 學校名稱、學校地址、學校電話、收件人、收件地址、學年度、學期、梯次、班級、座號、學號、
// 學生姓名、教師、課程名稱、缺曠統計、缺曠資料。
int idx = 1;
foreach (string StudID in _StudentIDList)
{
_dtTable.Clear();
DataRow row = _dtTable.NewRow();
// 處理 Word 資料合併
Document document = new Document();
document.Sections[0].PageSetup.PaperSize = PaperSize.A4;
NodeCollection doctables = _WordTemplate.GetChildNodes(NodeType.Table, true);
Node docdstNode = document.ImportNode(doctables[0], true, ImportFormatMode.KeepSourceFormatting);
document.LastSection.Body.AppendChild(docdstNode);
// 學校名稱
row["學校名稱"] = SchoolName;
// 學校地址
row["學校地址"] = SchoolAddress;
// 學校電話
row["學校電話"] = SchoolTel;
if (_StudentDict.ContainsKey(StudID))
//.........这里部分代码省略.........
示例10: _bgWorker_DoWork
//.........这里部分代码省略.........
foreach (int ssid in sortStudIDList)
{
foreach (UDT_CounselStudentInterviewRecordDef data in dataTT.Where(x => x.StudentID == ssid))
dataT.Add(data);
}
foreach (UDT_CounselStudentInterviewRecordDef data in dataT)
{
string studName = "";
string StudNumber = "";
string ClassName = "";
string StudSeatNo = "";
if (InterviewRecorStudDict.ContainsKey(data.StudentID))
{
studName = InterviewRecorStudDict[data.StudentID].Name;
StudNumber = InterviewRecorStudDict[data.StudentID].StudentNumber;
if (InterviewRecorStudDict[data.StudentID].Class != null)
ClassName = InterviewRecorStudDict[data.StudentID].Class.Name;
if (InterviewRecorStudDict[data.StudentID].SeatNo.HasValue)
StudSeatNo = InterviewRecorStudDict[data.StudentID].SeatNo.Value.ToString();
}
Dictionary<string, string> mapDict = new Dictionary<string, string>();
mapDict.Add("校名", SchoolName);
mapDict.Add("學生姓名", studName);
mapDict.Add("學號", StudNumber);
mapDict.Add("班級", ClassName);
if (intTeacherNameDict.ContainsKey(data.TeacherID))
mapDict.Add("晤談老師", intTeacherNameDict[data.TeacherID]);
mapDict.Add("晤談編號", data.InterviewNo);
mapDict.Add("座號", StudSeatNo);
mapDict.Add("晤談對象", data.IntervieweeType);
mapDict.Add("晤談方式", data.InterviewType);
if (data.InterviewDate.HasValue)
mapDict.Add("晤談日期", data.InterviewDate.Value.ToShortDateString());
mapDict.Add("時間", data.InterviewTime);
mapDict.Add("地點", data.Place);
mapDict.Add("參與人員", ParseUDTXML1(data.Attendees));
mapDict.Add("晤談事由", data.Cause);
mapDict.Add("輔導方式", ParseUDTXML1(data.CounselType));
mapDict.Add("輔導歸類", ParseUDTXML1(data.CounselTypeKind));
mapDict.Add("內容要點", data.ContentDigest);
mapDict.Add("記錄者姓名", data.AuthorName);
_dataDictList.Add(mapDict);
}
}
}
// word 資料合併
Document doc = new Document();
doc.Sections.Clear();
// 比對欄位名稱放值
List<string> mapFieldName = new List<string>();
mapFieldName.Add("校名");
mapFieldName.Add("學生姓名");
mapFieldName.Add("學號");
mapFieldName.Add("班級");
mapFieldName.Add("晤談老師");
mapFieldName.Add("晤談編號");
mapFieldName.Add("座號");
mapFieldName.Add("晤談對象");
mapFieldName.Add("晤談方式");
mapFieldName.Add("晤談日期");
mapFieldName.Add("時間");
mapFieldName.Add("地點");
mapFieldName.Add("參與人員");
mapFieldName.Add("晤談事由");
mapFieldName.Add("輔導方式");
mapFieldName.Add("輔導歸類");
mapFieldName.Add("內容要點");
mapFieldName.Add("記錄者姓名");
foreach (Dictionary<string, string> data in _dataDictList)
{
DataTable dt = new DataTable();
// 建立欄位名稱
foreach (string name in mapFieldName)
dt.Columns.Add(name, typeof(string));
DataRow dr = dt.NewRow();
foreach (string name in mapFieldName)
{
if (data.ContainsKey(name))
dr[name] = data[name];
}
dt.Rows.Add(dr);
Document docTemplate = new Document(new MemoryStream(_DocTemplate));
DocumentBuilder _builder = new DocumentBuilder(docTemplate);
docTemplate.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
docTemplate.MailMerge.RemoveEmptyParagraphs = true;
docTemplate.MailMerge.Execute(dt);
docTemplate.MailMerge.DeleteFields();
doc.Sections.Add(doc.ImportNode(docTemplate.Sections[0], true));
}
e.Result = doc;
}
示例11: _bgWorker_DoWork
//.........这里部分代码省略.........
row["生日"] = dtb.Year + "/" + dtb.Month + "/" + dtb.Day;
row["生日2"] = (dtb.Year - 1911) + "/" + dtb.Month + "/" + dtb.Day;
}
else
{
row["生日"] = "";
row["生日2"] = "";
}
}
if (_PhotoPDict.ContainsKey(StudID))
{
row["照片"] = _PhotoPDict[StudID];
row["照片2"] = _PhotoPDict[StudID];
}
if (_PhotoGDict.ContainsKey(StudID))
{
row["畢業照片"] = _PhotoGDict[StudID];
row["畢業照片2"] = _PhotoGDict[StudID];
}
if (_PhoneRecDict.ContainsKey(StudID))
{
row["戶籍電話"] = _PhoneRecDict[StudID].Permanent;
row["聯絡電話"] = _PhoneRecDict[StudID].Contact;
}
if (_ParentRecDict.ContainsKey(StudID))
{
row["監護人電話"] = _ParentRecDict[StudID].CustodianPhone;
row["父親電話"] = _ParentRecDict[StudID].FatherPhone;
row["母親電話"] = _ParentRecDict[StudID].MotherPhone;
//新加
if (radiobtnCustodianName.Checked)
{
row["監護人姓名"] = _ParentRecDict[StudID].CustodianName;
}
else if (radiobtnFatherName.Checked)
{
row["父親姓名"] = _ParentRecDict[StudID].FatherName;
}
else
{
row["母親姓名"] = _ParentRecDict[StudID].MotherName;
}
}
if (_AddressRecDict.ContainsKey(StudID))
{
//新加
if (radiobtnPermanentAddress.Checked)
{
row["戶籍地址"] = _AddressRecDict[StudID].PermanentAddress;
}
else if (radiobtnMailingAddress.Checked)
{
row["聯絡地址"] = _AddressRecDict[StudID].MailingAddress;
}
else
{
row["其它地址"] = _AddressRecDict[StudID].Address1;//新加
}
}
_DataTable.Rows.Add(row);
}
_bgWorker.ReportProgress(70);
int page = 1;
count = 0;
List<string> mapNameList = _Config.Template.ToDocument().MailMerge.GetFieldNames().ToList();
foreach (string str in mapNameList)
if (str == "姓名")
count++;
for (int i = 1; i <= _StudentIDList.Count; i++)
if (i % count == 0 && i >= count)
page++;
// 當人數與一頁個數相同,只有一頁
if (count == _StudentIDList.Count)
page = 1;
for (int i = 1; i <= page; i++)
{
Document document = new Document();
document = _Config.Template.ToDocument();
doc.Sections.Add(doc.ImportNode(document.Sections[0], true));
}
doc.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
doc.MailMerge.Execute(_DataTable);
doc.MailMerge.RemoveEmptyParagraphs = true;
doc.MailMerge.DeleteFields();
//doc.Sections.Add(doc.ImportNode(document.Sections[0], true));
_bgWorker.ReportProgress(95);
e.Result = doc;
}
示例12: _bgWork_DoWork
void _bgWork_DoWork(object sender, DoWorkEventArgs e)
{
Document doc = new Document();
doc.Sections.Clear();
// 比對欄位名稱放值
foreach (Dictionary<string, string> data in _DocDataList)
{
DataTable dt = new DataTable();
// 建立欄位名稱
foreach (string name in _MergeNameList)
dt.Columns.Add(name, typeof(string));
DataRow dr = dt.NewRow();
foreach (string name in _MergeNameList)
{
if (data.ContainsKey(name))
dr[name] = data[name];
}
dt.Rows.Add(dr);
docTemplate = new Document(new MemoryStream(_DocTemplate));
_builder = new DocumentBuilder(docTemplate);
docTemplate.MailMerge.MergeField += new Aspose.Words.Reporting.MergeFieldEventHandler(MailMerge_MergeField);
docTemplate.MailMerge.RemoveEmptyParagraphs = true;
docTemplate.MailMerge.Execute(dt);
docTemplate.MailMerge.DeleteFields();
doc.Sections.Add(doc.ImportNode(docTemplate.Sections[0], true));
}
e.Result = doc;
}