244 lines
9.2 KiB
C#
244 lines
9.2 KiB
C#
using DevExpress.Utils;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
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 STATS : Form
|
|
{
|
|
|
|
public DataSet dataSet;
|
|
public List<STATSRules.Rule> rules;
|
|
public List<STATSRules.Rule> Inrules;
|
|
public List<int> DefaultCount=new List<int>();
|
|
public STATS()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
|
|
|
|
private void groupBox1_Enter(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void STATS_Load(object sender, EventArgs e)
|
|
{
|
|
gridView1.OptionsBehavior.Editable = false;
|
|
gridView1.OptionsView.ShowIndicator = false;// 显示最左边空白列
|
|
dateStart.DateTime = DateTime.Now;
|
|
dateEnd.DateTime = DateTime.Now;
|
|
RadioZX.Checked = true;
|
|
}
|
|
|
|
|
|
|
|
private void BSearch_Click(object sender, EventArgs e)
|
|
{
|
|
DoSearch();
|
|
}
|
|
|
|
public void DoSearch()
|
|
{
|
|
try
|
|
{
|
|
string sql = "select * from trans_history where DBExcTime >'" + dateStart.DateTime.Date.ToString("yyyy-MM-dd") + "' and DBExcTime <='" + dateEnd.DateTime.Date.AddDays(1).ToString("yyyy-MM-dd") + "' and ItemStatus ='1'";
|
|
MainForm.logger.Info("Mysql sql=" + sql);
|
|
dataSet = DoDBMySql.Query(sql);
|
|
BindingSource bindingSource = new BindingSource();
|
|
bindingSource.DataSource = dataSet;
|
|
bindingSource.DataMember = "ds";
|
|
gridControl1.DataSource = bindingSource;
|
|
gridControl1.RefreshDataSource();
|
|
gridView1.RefreshData();
|
|
LabNote.Text = $"共检索到: {gridView1.DataRowCount} 条记录";
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
MessageBox.Show(e.Message);
|
|
}
|
|
|
|
}
|
|
|
|
private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
|
|
{
|
|
if (e.Column.Name == "Tuble")
|
|
{
|
|
var v = e.CellValue;
|
|
if (v != null)
|
|
{
|
|
e.Appearance.BackColor = Color.FromName(MZCY.GetColorInfo(v.ToString(), false));
|
|
}
|
|
}
|
|
if (e.Column.Name == "ItemDetails1")
|
|
{
|
|
var v = e.CellValue;
|
|
}
|
|
}
|
|
|
|
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
|
{
|
|
if (e.Column != null && e.Column.FieldName == "ItemName")
|
|
{
|
|
string detailes = gridView1.GetRowCellValue(e.RowHandle, "ItemsDetails").ToString();
|
|
ItemsShowBox itemsShowBox = new ItemsShowBox(detailes);
|
|
itemsShowBox.Show();
|
|
}
|
|
}
|
|
|
|
private void gridView1_CustomFilterDisplayText(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
|
{
|
|
if (e.Column.FieldName == "ItemStatus")
|
|
{
|
|
if (e.Value != null)
|
|
{
|
|
string zsStatus = MZCY.TransItemStatus(e.Value.ToString());
|
|
e.DisplayText = zsStatus;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct PersonInfo
|
|
{
|
|
public string CardNo { get; set; }
|
|
public string Name { get; set; }
|
|
public List<Item> items { get; set; } //
|
|
public List<int> Counts { get; set; } //各个统计项数量
|
|
}
|
|
|
|
public struct Item
|
|
{
|
|
public string BarCode { get; set; } //条码号
|
|
public string ItemName { get; set; } //项目名称
|
|
public string Tuble { get; set; } //项目名称
|
|
public List<string> ItemDetails { get; set; } //项目明细
|
|
}
|
|
|
|
public List<PersonInfo> personInfos;
|
|
private void BSTATS_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (dataSet==null||dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0)
|
|
{
|
|
MessageBox.Show("没有有效的数据");
|
|
return;
|
|
}
|
|
|
|
rules = STATSRules.LoadRule();
|
|
Inrules = new List<STATSRules.Rule>();
|
|
DefaultCount = new List<int>();
|
|
foreach (STATSRules.Rule rule in rules)
|
|
{
|
|
if (rule.INUSE == "1")
|
|
{
|
|
DefaultCount.Add(0);
|
|
Inrules.Add(rule);
|
|
}
|
|
}
|
|
DefaultCount.Add(0); //加一项送检验科统计
|
|
|
|
personInfos = new List<PersonInfo>();
|
|
foreach (DataRow dataRow in dataSet.Tables[0].Rows)
|
|
{
|
|
PersonInfo foundPerson = personInfos.FirstOrDefault(p => p.CardNo == dataRow["PatID"].ToString());
|
|
if (foundPerson.CardNo != null)
|
|
{
|
|
Item item = new Item();
|
|
item.Tuble = dataRow["Tuble"] == null ? "" : dataRow["Tuble"].ToString();
|
|
item.BarCode = dataRow["Barcode"] == null ? "" : dataRow["Barcode"].ToString();
|
|
item.ItemName = dataRow["ItemName"] == null ? "" : dataRow["ItemName"].ToString();
|
|
item.ItemDetails = dataRow["ItemsDetails"] == null ? null : dataRow["ItemsDetails"].ToString().Split(';').ToList().Where(item1 => !string.IsNullOrWhiteSpace(item1)).ToList();
|
|
foundPerson.items.Add(item);
|
|
}
|
|
else
|
|
{
|
|
PersonInfo personInfo = new PersonInfo();
|
|
personInfo.CardNo = dataRow["PatID"] == null ? "" : dataRow["PatID"].ToString();
|
|
personInfo.Name = dataRow["PatName"] == null ? "" : dataRow["PatName"].ToString();
|
|
List<Item> items = new List<Item>();
|
|
List<int> Counts = new List<int>(DefaultCount);
|
|
personInfo.items = items;
|
|
personInfo.Counts = Counts;
|
|
Item item = new Item();
|
|
item.Tuble = dataRow["Tuble"] == null ? "" : dataRow["Tuble"].ToString();
|
|
item.BarCode = dataRow["Barcode"] == null ? "" : dataRow["Barcode"].ToString();
|
|
item.ItemName = dataRow["ItemName"] == null ? "" : dataRow["ItemName"].ToString();
|
|
item.ItemDetails = dataRow["ItemsDetails"] == null ? null : dataRow["ItemsDetails"].ToString().Split(';').ToList().Where(item1 => !string.IsNullOrWhiteSpace(item1)).ToList();
|
|
personInfo.items.Add(item);
|
|
personInfos.Add(personInfo);
|
|
}
|
|
}
|
|
|
|
foreach(PersonInfo personInfo in personInfos)
|
|
{
|
|
foreach(Item item in personInfo.items)
|
|
{
|
|
int ruleindex = 0;
|
|
bool isSendtoJYK = true;//是否送检验科 如果是符合统计规则则不算在检验科里
|
|
foreach (STATSRules.Rule rule in Inrules)
|
|
{
|
|
if(rule.Type=="XM")
|
|
{
|
|
var intersection = item.ItemDetails.Intersect(rule.DetailItem).ToList();
|
|
if (intersection.Any())
|
|
{
|
|
personInfo.Counts[ruleindex]++;
|
|
if(!rule.SendKS.Equals("检验科"))
|
|
isSendtoJYK = false;
|
|
}
|
|
}
|
|
else //按试管排
|
|
{
|
|
var intersection = item.Tuble.Split('|').Intersect(rule.DetailItem).ToList();
|
|
if (intersection.Any())
|
|
{
|
|
personInfo.Counts[ruleindex]++;
|
|
}
|
|
}
|
|
|
|
ruleindex++;
|
|
}
|
|
if (isSendtoJYK)
|
|
{
|
|
personInfo.Counts[personInfo.Counts.Count-1]++;
|
|
}
|
|
}
|
|
|
|
}
|
|
Report report = new Report(personInfos, Inrules);
|
|
report.Show();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
STATSRules sTATSRules = new STATSRules();
|
|
sTATSRules.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);
|
|
}
|
|
}
|
|
}
|
|
}
|