Files
tj-tzhg/JJMediSys/DaylyHistory.cs

271 lines
11 KiB
C#
Raw Normal View History

2025-11-26 17:20:53 +08:00
using JJMediSys.cs;
using JJServer;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static JJMediSys.AlertForm;
namespace JJMediSys
{
public partial class DaylyHistory: Form
{
public double[] tableset = new double[17] { 0.05, 0.08, 0.11, 0.12, 0.29, 0.19, 0.07, 0.07, 0.15,0.01, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07 };
public string[] tabletitle = new string[17] { "ID", "卡号", "姓名", "年龄", "性别", "条码", "试管", "项目名称", "项目数量" ,"项目类型", "执行科室", "开单科室", "开单时间", "打印时间", "状态", "项目明细", "操作员"};
private DataTable dt;
private SystemSet parent;
string Recp = "";
public DaylyHistory()
{
InitializeComponent();
parent = SystemSet.systemSet;
dt = parent.myServer.GetHistory();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.Close();
}
private void DaylyHistory_Load(object sender, EventArgs e)
{
Recp = ConfigFileReader.GetValue("/configuration/appSettings/add[@key='RecpFormat']");
gridView1.OptionsBehavior.Editable = false;
gridView1.OptionsView.ShowIndicator = false;// 显示最左边空白列
GetData();
}
private void BFresh_Click(object sender, EventArgs e)
{
GetData();
}
public void GetData()
{
dt = parent.FreshDBData();
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = dt;
gridControl1.DataSource = bindingSource;
gridControl1.RefreshDataSource();
gridView1.RefreshData();
LabNote.Text = $"共检索到: {gridView1.DataRowCount} 条记录";
}
private void RecpOnly_CheckedChanged(object sender, EventArgs e)
{
}
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);
}
}
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;
}
}
}
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_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_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
{
if (gridView1.SelectedRowsCount <= 0)
{
PanelAction.Visible = false;
}
else
{
PanelAction.Visible = true;
}
}
public bool CanDispense(string Tube)
{
if (SystemSet.mTubeLabelTool.canDispenseTubles.Contains(Tube))
return true;
else
return false;
}
private void button1_Click_1(object sender, EventArgs e)
{
List<PatientDatail> patientsOut = new List<PatientDatail>();
List<PatientDatail> patientsTotallist = new List<PatientDatail>();
int[] selectedRowHandles = gridView1.GetSelectedRows();
foreach (int rowHandle in selectedRowHandles)
{
//PatID, PatName ,PatAge, PatSex ,Barcode , Tuble, ItemName ,ItemCount,ItemType, DoDept,OprDept,OprTime,PrintTime,ItemStatus,ItemsDetails,PrinterDev
// 检查行是否有效
if (rowHandle >= 0 && rowHandle < gridView1.DataRowCount)
{
object dataRow = gridView1.GetDataRow(rowHandle);
string Barcode = gridView1.GetRowCellValue(rowHandle, "Barcode").ToString();
string Tuble = gridView1.GetRowCellValue(rowHandle, "Tuble").ToString();
string ItemName = gridView1.GetRowCellValue(rowHandle, "ItemName").ToString();
string ItemCount = gridView1.GetRowCellValue(rowHandle, "ItemCount").ToString();
string ItemType = gridView1.GetRowCellValue(rowHandle, "ItemType").ToString();
string DoDept = gridView1.GetRowCellValue(rowHandle, "DoDept").ToString();
string OprDept = gridView1.GetRowCellValue(rowHandle, "OprDept").ToString();
string OprTime = gridView1.GetRowCellValue(rowHandle, "OprTime").ToString();
string PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string ItemStatus = gridView1.GetRowCellValue(rowHandle, "ItemStatus").ToString(); ;
string ItemsDetails = gridView1.GetRowCellValue(rowHandle, "ItemsDetails").ToString();
string Source = "LOCAL";
PatientDatail temp = new PatientDatail();
temp.jyDatas = new List<jyData>();
temp.OrginDatas = new List<OrginData>();
Patient_Info patient_Info = new Patient_Info();
patient_Info.Name = gridView1.GetRowCellValue(rowHandle, "PatName").ToString();
patient_Info.CardNo = gridView1.GetRowCellValue(rowHandle, "PatID").ToString();
patient_Info.Sex = gridView1.GetRowCellValue(rowHandle, "PatSex").ToString();
patient_Info.Age = gridView1.GetRowCellValue(rowHandle, "PatAge").ToString();
patient_Info.BedNo = "";
temp.PatientInfo = patient_Info;
temp.ItemCount = 1;
jyData mjyData = new jyData();
mjyData.sgname = Tuble;
mjyData.Barcode = Barcode;
mjyData.itemInfo = ItemName;
var variables = new Dictionary<string, string>
{
{ "pictureBox1", Barcode },
{ "Barcode", Barcode },
{ "ItemInfo", ItemName },
{ "CardNo", patient_Info.CardNo },
{ "ItemType", ItemType },
{ "Age", patient_Info.Age },
{ "PrintTime", PrintTime },
{ "OprDept", OprDept },
{ "DoDept", DoDept },
{ "Tuble", Tuble },
{ "patSex", patient_Info.Sex },
{ "patName", patient_Info.Name }
};
string bqxx = Regex.Replace(Recp, @"\{(\w+)\}", match =>
{
string variableName = match.Groups[1].Value;
return variables.ContainsKey(variableName) ? variables[variableName] : match.Value;
});
// string bqxx ="B060010255050|" + mjyData.Barcode + "@TB18320020080040|L^" + Tuble + "@TB18110060220040|L^" + mjyData.Barcode + "@TB18032090400040|L^" + patient_Info.Name + " " + patient_Info.Sex + " " + OprDept + " " + DoDept + "@TB18032120400040|L^" + DateTime.Now.ToString("yyyy-MM-dd") + " " + ItemType + " " + patient_Info.CardNo + "@TB18032150400080|L^" + mjyData.itemInfo;
if (!RecpOnly.Checked)
{
mjyData.sgxx = bqxx;
if (CanDispense(mjyData.sgname))
{
mjyData.bqtype = 1;
}
else
{
mjyData.bqtype = 2;
}
}
else
{
mjyData.sgxx = bqxx;
mjyData.bqtype = 2;
}
temp.jyDatas.Add(mjyData);
OrginData orginData = new OrginData();
orginData.PatID = patient_Info.CardNo;
orginData.PatName = patient_Info.Name;
orginData.PatAge = patient_Info.Age;
orginData.PatSex = patient_Info.Sex;
orginData.Barcode = Barcode;
orginData.Tuble = Tuble;
orginData.ItemName = ItemName;
orginData.ItemCount = ItemCount;
orginData.ItemType = ItemType;
orginData.DoDept = DoDept;
orginData.OprDept = OprDept;
orginData.OprTime = OprTime;
orginData.PrintTime = PrintTime;
orginData.ItemStatus = "1";
orginData.ItemsDetails = ItemsDetails;
orginData.PrinterDev = Login.nurseDeskInfo.NurseName;
temp.OrginDatas.Add(orginData);
patientsTotallist.Add(temp);
}
}
foreach (PatientDatail patientDatail in patientsTotallist)
{
bool isexist = false;
for (int i = 0; i < patientsOut.Count; i++)
{
PatientDatail PerpatientDatail = patientsOut[i];
if (PerpatientDatail.PatientInfo.CardNo == patientDatail.PatientInfo.CardNo)
{
isexist = true;
patientsOut[i].jyDatas.Add(patientDatail.jyDatas[0]);
patientsOut[i].OrginDatas.Add(patientDatail.OrginDatas[0]);
patientsOut[i].ItemCount += patientDatail.ItemCount;
patientsOut[i].RecpCount += patientDatail.RecpCount;
}
}
if (!isexist)
{
patientDatail.ID = patientsOut.Count;
patientsOut.Add(patientDatail);
}
}
parent.MultiDispense(patientsOut);
}
}
}