Commit 0ba8b484 by 施晓雨

更新模板

parent e79cd512
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.OfficeSample.Entities
{
public class Task:EntityWithMetadata
{
#region 任务基本信息
/// <summary>
/// 任务大项名称
/// </summary>
public string Title { get; set; }
/// <summary>
/// 大项名称和部位
/// </summary>
[Ignore]
public string TitleWithPart
{
get
{
if (Tag == null) return "";
return Tag.ToString();
}
set
{
Tag = value;
}
}
/// <summary>
/// 大项名称和部位(因为省局和监督是将单位单独列出来显示的,所以在此需要特殊处理,大项后不需要带单位)
/// </summary>
[Ignore]
public string TitleWithPartEx { get; set; }
/// <summary>
/// 小项名称和单位
/// </summary>
[Ignore]
public string TitleExWithUnit
{
get
{
if (ParentKvid == Guid.Empty) return "";//如果是大项,肯定不会生成小项
if (string.IsNullOrEmpty(Unit)) return TitleEx;//如果大项单位不为空,把小项名称设为空
return TitleEx + "(" + Unit + ")";
}
}
/// <summary>
/// 小项名称
/// </summary>
public string TitleEx { get; set; }
/// <summary>
/// 单位
/// </summary>
public string Unit { get; set; }
/// <summary>
/// 色号信息
/// </summary>
public string Color { get; set; }
/// <summary>
/// 色号的排序号
/// </summary>
public int ColorSortId { get; set; }
/// <summary>
/// 检验部位
/// </summary>
public string TitlePart { get; set; }
/// <summary>
/// 参考值
/// </summary>
public string ReferenceValue { get; set; }
/// <summary>
/// 实测值
/// </summary>
public string MeasuredValue { get; set; }
/// <summary>
/// 合格、不合格、/、""=>四种判定结果
/// </summary>
public string IsQualified { get; set; }
/// <summary>
/// 是否完成
/// </summary>
public bool? IsFinished { get; set; }
#endregion
#region 费用信息
/// <summary>
/// 理论收费
/// </summary>
public decimal Fee { get; set; }
/// <summary>
/// 实收费用
/// </summary>
public decimal RealFee { get; set; }
#endregion
#region 检测组及相关录入人信息
/// <summary>
/// 检验小组
/// </summary>
public string TaskGroup { get; set; }
/// <summary>
/// 录入人
/// </summary>
public string Recorder { get; set; }
/// <summary>
/// 录入人的Kvid
/// </summary>
public Guid RecordKvid { get; set; }
#endregion
#region 所属协议及父项Kvid、排序号
/// <summary>
/// 所属协议?是否要拆分出任务单
/// </summary>
[IgnoreUpdate]
public Guid ContractKvid { get; set; }
/// <summary>
/// 父项Kvid
/// </summary>
[IgnoreUpdate]
public Guid ParentKvid { get; set; }
/// <summary>
/// 排序号,尾两位为子项排序号,百位为检测部位排序号,千位及以上为大项排序号
/// </summary>
public int SortId { get; set; }
#endregion
#region 任务状态
/// <summary>
/// 和委托协议同步
/// </summary>
public int Flow { get; set; }
/// <summary>
///是否打印,Status=1表示正常状态,Status==2表示被拆分的检验项目,不需打印
/// </summary>
[Ignore]
public bool IsPrint
{
get
{
return Status == 1;
}
set
{
Status = value ? 1 : 2;
}
}
#endregion
#region 关联标准和项目信息
/// <summary>
/// 标准排序号,18401为-1,其它的为递增值
/// </summary>
public int StandardSortId { get; set; }
/// <summary>
/// 标准名称
/// </summary>
public string StandardName { get; set; }
/// <summary>
/// 标准的代号
/// </summary>
public string StandardCode { get; set; }
/// <summary>
/// 所属方法标准代号
/// </summary>
public string TestCode { get; set; }
/// <summary>
/// 检验方法,从检验项目中取出StandardCode
/// </summary>
public string TestMethod { get; set; }
/// <summary>
/// 检验项目Kvid,以便对应到标准值
/// </summary>
[IgnoreUpdate]
public Guid DetectionKvid { get; set; }
#endregion
public string OriginalFile { set; get; }
public string CheckerName { set; get; }
public Guid CheckerKvid { set; get; }
}
[Route("/Restful/Jst.Lims.Entities.Task/Query")]
internal class TaskQuery : RestfulQuery<Task>, IReturn<RestfulQueryResponse<Task>>
{
public Guid ContractKvid { get; set; }
public string OrderBy { get; set; }
}
}
......@@ -41,8 +41,17 @@
this.pgResult = new System.Windows.Forms.PropertyGrid();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lblSpendTime = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.dgTasks = new System.Windows.Forms.DataGridView();
this.Title = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.panel2.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgTasks)).BeginInit();
this.SuspendLayout();
//
// btnGetReport
......@@ -70,6 +79,7 @@
this.tbxReportId.Name = "tbxReportId";
this.tbxReportId.Size = new System.Drawing.Size(162, 21);
this.tbxReportId.TabIndex = 2;
this.tbxReportId.Text = "JST-AW201900090";
//
// label2
//
......@@ -90,9 +100,9 @@
//
// btnGenerateXlsx
//
this.btnGenerateXlsx.Location = new System.Drawing.Point(539, 72);
this.btnGenerateXlsx.Location = new System.Drawing.Point(507, 25);
this.btnGenerateXlsx.Name = "btnGenerateXlsx";
this.btnGenerateXlsx.Size = new System.Drawing.Size(112, 23);
this.btnGenerateXlsx.Size = new System.Drawing.Size(65, 50);
this.btnGenerateXlsx.TabIndex = 0;
this.btnGenerateXlsx.Text = "生成Xlsx文件";
this.btnGenerateXlsx.UseVisualStyleBackColor = true;
......@@ -101,7 +111,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(363, 31);
this.label3.Location = new System.Drawing.Point(15, 23);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 1;
......@@ -109,14 +119,14 @@
//
// tbxTemplateFileName
//
this.tbxTemplateFileName.Location = new System.Drawing.Point(433, 28);
this.tbxTemplateFileName.Location = new System.Drawing.Point(85, 20);
this.tbxTemplateFileName.Name = "tbxTemplateFileName";
this.tbxTemplateFileName.Size = new System.Drawing.Size(162, 21);
this.tbxTemplateFileName.TabIndex = 2;
//
// btnSelectTemplateFile
//
this.btnSelectTemplateFile.Location = new System.Drawing.Point(601, 26);
this.btnSelectTemplateFile.Location = new System.Drawing.Point(253, 18);
this.btnSelectTemplateFile.Name = "btnSelectTemplateFile";
this.btnSelectTemplateFile.Size = new System.Drawing.Size(50, 23);
this.btnSelectTemplateFile.TabIndex = 0;
......@@ -160,30 +170,90 @@
// lblSpendTime
//
this.lblSpendTime.AutoSize = true;
this.lblSpendTime.Location = new System.Drawing.Point(375, 83);
this.lblSpendTime.Location = new System.Drawing.Point(15, 57);
this.lblSpendTime.Name = "lblSpendTime";
this.lblSpendTime.Size = new System.Drawing.Size(65, 12);
this.lblSpendTime.TabIndex = 1;
this.lblSpendTime.Text = "生成时间:";
//
// panel2
//
this.panel2.Controls.Add(this.dgTasks);
this.panel2.Controls.Add(this.groupBox2);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(339, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(601, 736);
this.panel2.TabIndex = 5;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.tbxTemplateFileName);
this.groupBox2.Controls.Add(this.btnGenerateXlsx);
this.groupBox2.Controls.Add(this.btnSelectTemplateFile);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.lblSpendTime);
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox2.Location = new System.Drawing.Point(0, 0);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(601, 95);
this.groupBox2.TabIndex = 0;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "groupBox2";
//
// dgTasks
//
this.dgTasks.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgTasks.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Title,
this.Column1,
this.Column2});
this.dgTasks.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgTasks.Location = new System.Drawing.Point(0, 95);
this.dgTasks.Name = "dgTasks";
this.dgTasks.RowTemplate.Height = 23;
this.dgTasks.Size = new System.Drawing.Size(601, 641);
this.dgTasks.TabIndex = 1;
//
// Title
//
this.Title.DataPropertyName = "Title";
this.Title.HeaderText = "项目名称";
this.Title.Name = "Title";
this.Title.ReadOnly = true;
//
// Column1
//
this.Column1.DataPropertyName = "TitleEx";
this.Column1.HeaderText = "小项名称";
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
//
// Column2
//
this.Column2.DataPropertyName = "IsQualified";
this.Column2.HeaderText = "检测结果";
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(940, 736);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.tbxTemplateFileName);
this.Controls.Add(this.label3);
this.Controls.Add(this.lblSpendTime);
this.Controls.Add(this.btnSelectTemplateFile);
this.Controls.Add(this.btnGenerateXlsx);
this.Name = "FrmMain";
this.Text = "Office测试";
this.Load += new System.EventHandler(this.FrmMain_Load);
this.panel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.panel2.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgTasks)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
......@@ -202,6 +272,12 @@
private System.Windows.Forms.PropertyGrid pgResult;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label lblSpendTime;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.DataGridView dgTasks;
private System.Windows.Forms.DataGridViewTextBoxColumn Title;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
}
}
......@@ -2,6 +2,7 @@
using Kivii.Office.OpenXml.Excel.Templates;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace Kivii.Client.OfficeSample
......@@ -9,11 +10,16 @@ namespace Kivii.Client.OfficeSample
public partial class FrmMain : Form
{
private Contract _contract = null;
private RestfulQueryResponse<Task> _tasks = null;
public FrmMain()
{
InitializeComponent();
}
private void FrmMain_Load(object sender, EventArgs e)
{
tbxTemplateFileName.Text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "附页模板.xlsx");
dgTasks.AutoGenerateColumns = false;
}
private void btnGetReport_Click(object sender, EventArgs e)
{
JsonServiceClient client = new JsonServiceClient(tbxServiceUrl.Text);
......@@ -28,6 +34,12 @@ namespace Kivii.Client.OfficeSample
_contract = results.Results[0];
//显示各个属性值
pgResult.SelectedObject = _contract;
var taskQuery = new TaskQuery();
taskQuery.ContractKvid = _contract.Kvid;
taskQuery.OrderBy = "StandardSortId,SortId";
_tasks = client.Get(taskQuery);
dgTasks.DataSource = _tasks.Results;
}
private void btnSelectTemplateFile_Click(object sender, EventArgs e)
......@@ -54,12 +66,14 @@ namespace Kivii.Client.OfficeSample
template.Open(tbxTemplateFileName.Text);//打开模板文件
template.Bind("contract", _contract);//将数据绑定到模板中,注意contract在模板中这是这个变量名了
var rtns=template.Fill();//填充模板
template.Bind("task", _tasks);
var rtns =template.Fill();//填充模板
template.SaveAs(saveFileName);//最后另存当前的文件
watch.Stop();
lblSpendTime.Text = $"共花费{watch.ElapsedMilliseconds}毫秒,共填充了{rtns.Count}个项目";
}
}
}
......@@ -117,4 +117,22 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Title.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Title.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
\ No newline at end of file
......@@ -53,6 +53,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Entitis\Contract.cs" />
<Compile Include="Entitis\Task.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
......@@ -83,6 +84,12 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="附页模板.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="首页模板.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment