台州海关TD3600上线版本
This commit is contained in:
145
JJMediSys/Report.cs
Normal file
145
JJMediSys/Report.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using DevExpress.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JJMediSys
|
||||
{
|
||||
public partial class Report : Form
|
||||
{
|
||||
List<STATS.PersonInfo> Persons;
|
||||
List<STATSRules.Rule> Rules;
|
||||
public Report(List<STATS.PersonInfo> inPersons, List<STATSRules.Rule> inRules)
|
||||
{
|
||||
InitializeComponent();
|
||||
Persons = inPersons;
|
||||
Rules = inRules;
|
||||
}
|
||||
|
||||
private void Report_Load(object sender, EventArgs e)
|
||||
{
|
||||
int x = (Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2;
|
||||
int y = (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2;
|
||||
this.Location = new Point(x, y);
|
||||
listView1.Columns.Add("序号", 20);
|
||||
listView1.Columns.Add("卡号", 150);
|
||||
listView1.Columns.Add("姓名", 150);
|
||||
listView1.Columns.Add("采血管总数", 100);
|
||||
listView1.Columns.Add("送检验科", 100);
|
||||
foreach(STATSRules.Rule rule in Rules)
|
||||
{
|
||||
listView1.Columns.Add(rule.Name, 100);
|
||||
}
|
||||
listView1.Columns.Add("试管明细", 100);
|
||||
int i = 0;
|
||||
foreach(STATS.PersonInfo personInfo in Persons)
|
||||
{
|
||||
i++;
|
||||
List<string> Arr = new List<string>();
|
||||
Arr.Add( i.ToString());
|
||||
Arr.Add(personInfo.CardNo);
|
||||
Arr.Add(personInfo.Name);
|
||||
Arr.Add(personInfo.items.Count.ToString());
|
||||
Arr.Add(personInfo.Counts[personInfo.Counts.Count - 1].ToString());
|
||||
for(int j=0;j < personInfo.Counts.Count - 1;j++)
|
||||
{
|
||||
Arr.Add(personInfo.Counts[j].ToString());
|
||||
}
|
||||
Arr.Add(string.Join(";", personInfo.items.Select(item => item.ItemName)));
|
||||
listView1.Items.Add(new ListViewItem(Arr.ToArray()));
|
||||
}
|
||||
BindListViewDataToGrid();
|
||||
}
|
||||
|
||||
|
||||
private void BindListViewDataToGrid()
|
||||
{
|
||||
// 创建 DataTable
|
||||
DataTable dataTable = new DataTable();
|
||||
foreach (ColumnHeader column in listView1.Columns)
|
||||
{
|
||||
dataTable.Columns.Add(column.Text);
|
||||
}
|
||||
// 填充 DataTable
|
||||
foreach (ListViewItem item in listView1.Items)
|
||||
{
|
||||
DataRow row = dataTable.NewRow();
|
||||
for (int i = 0; i < item.SubItems.Count; i++)
|
||||
{
|
||||
row[i] = item.SubItems[i].Text;
|
||||
}
|
||||
dataTable.Rows.Add(row);
|
||||
}
|
||||
// 绑定 DataTable 到 GridControl
|
||||
gridControl1.DataSource = null;
|
||||
gridControl1.DataSource = dataTable;
|
||||
gridControl1.RefreshDataSource();
|
||||
gridView1.RefreshData();
|
||||
LabNote.Text = $"共: {gridView1.DataRowCount} 条记录";
|
||||
gridView1.OptionsView.ShowFooter = true;
|
||||
gridView1.Appearance.FooterPanel.Options.UseTextOptions = true;
|
||||
gridView1.Appearance.FooterPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
|
||||
gridView1.Appearance.FooterPanel.BackColor = System.Drawing.Color.Transparent; // 设置背景颜色为透明
|
||||
gridView1.Appearance.FooterPanel.BorderColor = System.Drawing.Color.Transparent;
|
||||
|
||||
gridView1.Columns["采血管总数"].SummaryItem.SummaryType = SummaryItemType.Sum;
|
||||
gridView1.Columns["采血管总数"].SummaryItem.DisplayFormat = "总管数: {0} 管";
|
||||
gridView1.Columns["姓名"].SummaryItem.SummaryType = SummaryItemType.Count;
|
||||
gridView1.Columns["姓名"].SummaryItem.DisplayFormat = "总人数: {0} 人";
|
||||
gridView1.Columns["送检验科"].SummaryItem.SummaryType = SummaryItemType.Sum;
|
||||
gridView1.Columns["送检验科"].SummaryItem.DisplayFormat = "送检验科: {0} 管";
|
||||
foreach (STATSRules.Rule rule in Rules)
|
||||
{
|
||||
gridView1.Columns[rule.Name].SummaryItem.SummaryType = SummaryItemType.Sum;
|
||||
gridView1.Columns[rule.Name].SummaryItem.DisplayFormat = rule.Name+ ": {0} 管";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||||
{
|
||||
if (e.Column != null && e.Column.FieldName == "试管明细")
|
||||
{
|
||||
string detailes = gridView1.GetRowCellValue(e.RowHandle, "试管明细").ToString();
|
||||
ItemsShowBox itemsShowBox = new ItemsShowBox(detailes);
|
||||
itemsShowBox.Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void BExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "Excel 文件 (*.xlsx)|*.xlsx",
|
||||
FileName = $"统计数据{DateTime.Now.ToString("yyyy-MM-dd")}.xlsx"
|
||||
};
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// 导出为 Excel (XLSX)
|
||||
gridView1.ExportToXlsx(saveFileDialog.FileName);
|
||||
|
||||
// 提示用户导出完成
|
||||
MessageBox.Show("导出成功!");
|
||||
}
|
||||
}
|
||||
|
||||
private void gridView1_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
if (gridView1.RowCount > 0 && gridView1.FocusedColumn != null && gridView1.FocusedRowHandle >= 0)
|
||||
{
|
||||
string data = gridView1.GetFocusedRowCellDisplayText(gridView1.FocusedColumn);
|
||||
if (!String.IsNullOrEmpty(data))
|
||||
Clipboard.SetText(data, TextDataFormat.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user