1686 lines
72 KiB
C#
1686 lines
72 KiB
C#
using AIMS.OperationAanesthesia;
|
||
using AIMSBLL;
|
||
using AIMSExtension;
|
||
using AIMSModel;
|
||
using AxNsoOfficeLib;
|
||
using DCSoftDotfuscate;
|
||
using DevComponents.DotNetBar;
|
||
using DocumentManagement;
|
||
using DrawGraph;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Windows.Forms;
|
||
|
||
namespace AIMS.PublicUI.UI
|
||
{
|
||
public partial class frmFeesRecord : OfficeForm
|
||
{
|
||
#region 公共成员
|
||
public string FeeType;
|
||
public OperationRecord _record;
|
||
int x = 0;
|
||
public List<FeesRecord> FeesRecordList;
|
||
public DataGridView _dataGridView;
|
||
private int _lineNumber;
|
||
private Person _worker;
|
||
|
||
public frmFeesRecord()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
public frmFeesRecord(OperationRecord record, string feeType)
|
||
{
|
||
InitializeComponent();
|
||
_record = record;
|
||
FeeType = feeType;
|
||
dgvYP.Visible = false;
|
||
dgvYP.AutoGenerateColumns = false;
|
||
}
|
||
private void frmFeesRecord_Load(object sender, EventArgs e)
|
||
{
|
||
_dataGridView = dgvDrugs;
|
||
SetDGVNotSort();
|
||
BindAnaesthesiaEvents();
|
||
FullALLDGV();
|
||
if (FeeType == "护士")
|
||
tabDrugs.SelectedTabIndex = 1;
|
||
}
|
||
#endregion
|
||
|
||
#region 初始化数据
|
||
private void FullALLDGV()
|
||
{
|
||
FeesRecordList = BFeesRecord.Select("FeeType='" + FeeType + "' and OperationRecordId=" + _record.Id, null, RecursiveType.None, 0);
|
||
SetDGVEvent(_dataGridView);
|
||
|
||
if (FeesRecordList.Count > 0)
|
||
{
|
||
FullDrugsData(FeesRecordList);
|
||
}
|
||
else
|
||
{
|
||
if (FeeType == "麻醉")
|
||
LoadRecordDrugs();
|
||
}
|
||
SetChargDrugPrice();
|
||
AddNewNullRows();
|
||
|
||
if (TxtOperatorName.Tag == null || TxtOperatorName.Text == "")
|
||
{
|
||
if (FeeType == "麻醉" && _record.AnesthesiaDoctor != null && _record.AnesthesiaDoctor.Trim() != "")
|
||
{
|
||
string AnesthesiaDoctor = _record.AnesthesiaDoctor;
|
||
if (AnesthesiaDoctor.Contains(',')) AnesthesiaDoctor = AnesthesiaDoctor.Split(',')[0];
|
||
_worker = BPerson.SelectSingle(" id in (" + AnesthesiaDoctor + ")", null, RecursiveType.Parent, 1);
|
||
TxtOperatorName.Text = _worker.Name;
|
||
TxtOperatorName.Tag = _worker.Id;
|
||
}
|
||
if (FeeType == "护士" && _record.OperationDoctor != null && _record.OperationDoctor.Trim() != "")
|
||
{
|
||
string OperationDoctor = _record.OperationDoctor;
|
||
if (OperationDoctor.Contains(',')) OperationDoctor = OperationDoctor.Split(',')[0];
|
||
_worker = BPerson.SelectSingle(" id in (" + OperationDoctor + ")", null, RecursiveType.Parent, 1);
|
||
TxtOperatorName.Text = _worker.Name;
|
||
TxtOperatorName.Tag = _worker.Id;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void FullDrugsData(List<FeesRecord> list)
|
||
{
|
||
_dataGridView.Rows.Clear();
|
||
foreach (FeesRecord item in list)
|
||
{
|
||
if (item.FeeIsDrug == "1")
|
||
{
|
||
int index = _dataGridView.Rows.Add();
|
||
_dataGridView.Rows[index].Tag = item;
|
||
_dataGridView.Rows[index].Cells[0].Value = item.Id;
|
||
//Drugs drug = BDrugs.SelectSingle(int.Parse(item.FeeId));
|
||
//_dataGridView.Rows[index].Cells[3].Tag = drug;
|
||
_dataGridView.Rows[index].Cells[1].Value = item.FeeTypeId;//药品编号
|
||
_dataGridView.Rows[index].Cells[2].Value = item.FeeCode;//药品编号
|
||
_dataGridView.Rows[index].Cells[3].Value = item.ChargName;//药品名称
|
||
_dataGridView.Rows[index].Cells[4].Value = item.ChargSpec;
|
||
_dataGridView.Rows[index].Cells[6].Value = item.Unit;
|
||
_dataGridView.Rows[index].Cells[5].Value = item.UnitPrice;
|
||
_dataGridView.Rows[index].Cells[7].Value = item.FeeNum;
|
||
_dataGridView.Rows[index].Cells[8].Value = item.ChargePrice;
|
||
|
||
_dataGridView.Rows[index].Cells[5].Tag = item.Extend3;
|
||
_dataGridView.Rows[index].Cells[6].Tag = item.Extend1;
|
||
_dataGridView.Rows[index].Cells[7].Tag = item.Extend2;
|
||
}
|
||
if (item.BillingWorkId != null && item.BillingWorkId != "")
|
||
{
|
||
_worker = BPerson.SelectSingle(int.Parse(item.BillingWorkId));
|
||
TxtOperatorName.Text = _worker.Name;
|
||
TxtOperatorName.Tag = _worker.Id;
|
||
}
|
||
}
|
||
dgvChargsRecord.Rows.Clear();
|
||
foreach (FeesRecord item in list)
|
||
{
|
||
if (item.FeeIsDrug != "1")
|
||
{
|
||
int index = dgvChargsRecord.Rows.Add();
|
||
dgvChargsRecord.Rows[index].Tag = item;
|
||
dgvChargsRecord.Rows[index].Cells[0].Value = item.Id;
|
||
//Charges drug = BCharges.SelectSingle(int.Parse(item.FeeId));
|
||
//dgvChargsRecord.Rows[index].Cells[3].Tag = drug;
|
||
dgvChargsRecord.Rows[index].Cells[1].Value = item.FeeTypeId;
|
||
dgvChargsRecord.Rows[index].Cells[2].Value = item.FeeCode;
|
||
dgvChargsRecord.Rows[index].Cells[3].Value = item.ChargName;
|
||
dgvChargsRecord.Rows[index].Cells[4].Value = item.ChargSpec;
|
||
dgvChargsRecord.Rows[index].Cells[6].Value = item.Unit;
|
||
dgvChargsRecord.Rows[index].Cells[5].Value = item.UnitPrice;
|
||
dgvChargsRecord.Rows[index].Cells[7].Value = item.FeeNum;
|
||
dgvChargsRecord.Rows[index].Cells[8].Value = item.ChargePrice;
|
||
|
||
//dgvChargsRecord.Rows[index].Cells[5].Tag = item.Extend3;
|
||
//dgvChargsRecord.Rows[index].Cells[6].Tag = item.Extend1;
|
||
//dgvChargsRecord.Rows[index].Cells[7].Tag = item.Extend2;
|
||
}
|
||
if (item.BillingWorkId != null && item.BillingWorkId != "")
|
||
{
|
||
_worker = BPerson.SelectSingle(int.Parse(item.BillingWorkId));
|
||
TxtOperatorName.Text = _worker.Name;
|
||
TxtOperatorName.Tag = _worker.Id;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void LoadRecordDrugs()
|
||
{
|
||
List<Drugs> dRUGDICTs = new List<Drugs>();
|
||
if (_record.FactDrugList == null || _record.FactDrugList.Count <= 0)
|
||
return;
|
||
foreach (var item in _record.FactDrugList)
|
||
{
|
||
bool IScON = false;
|
||
foreach (var item1 in dRUGDICTs)
|
||
{
|
||
if (item1.Id == item.DrugId)
|
||
IScON = true;
|
||
}
|
||
Drugs DrugsRef = BDrugs.SelectSingle(item.DrugId);
|
||
if (DrugsRef.Code != null && IScON == false)
|
||
{
|
||
dRUGDICTs.Add(DrugsRef);
|
||
}
|
||
}
|
||
foreach (var drug in dRUGDICTs)
|
||
{
|
||
DataGridViewRow dr = new DataGridViewRow();
|
||
dr.CreateCells(_dataGridView);
|
||
dr.Cells[1].Value = drug.DrugKind;
|
||
dr.Cells[2].Value = drug.Code;
|
||
dr.Cells[3].Tag = drug;
|
||
dr.Cells[3].Value = drug.Name;
|
||
dr.Cells[4].Value = drug.Stand;
|
||
dr.Cells[5].Value = drug.Price;
|
||
dr.Cells[6].Value = drug.Unit;
|
||
double doses = 0; string doseunit = ""; string rote = "";
|
||
dr.Cells[7].Value = GetDrugsNum(drug, ref doses, ref doseunit, ref rote);
|
||
|
||
dr.Cells[5].Tag = rote;
|
||
dr.Cells[6].Tag = doseunit;
|
||
dr.Cells[7].Tag = doses;
|
||
|
||
if (_dataGridView.Rows.Count != 0 && _dataGridView.Rows[_dataGridView.Rows.Count - 1].Cells[3].EditedFormattedValue.ToString() == "")
|
||
{
|
||
_dataGridView.Rows.Insert(_dataGridView.Rows.Count - 1, dr);
|
||
}
|
||
else
|
||
{
|
||
_dataGridView.Rows.Add(dr);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 计算药品数量
|
||
/// </summary>
|
||
/// <param name="drug"></param>
|
||
/// <returns></returns>
|
||
public decimal GetDrugsNum(Drugs drug, ref double doses, ref string doseunit, ref string rote)
|
||
{
|
||
decimal XMSL = 1;
|
||
List<FactDrug> drugsRecords = _record.FactDrugList.Where(a => a.DrugId == drug.Id).ToList();
|
||
|
||
if (drug.Name == "吸入用七氟烷")
|
||
{
|
||
decimal dose = 0;
|
||
foreach (var item in drugsRecords)
|
||
{
|
||
//4.手术消耗七氟烷体积=3.6×氧流量×吸入浓度×吸入时间 诱导期耗量≈8%浓度x6L/min氧流量x(2min/60min)x3.6=5.7ml
|
||
if (item.DrugName == "吸入用七氟烷" && item.Density > 0 && item.DensityUnit != null && item.DensityUnit != "")
|
||
{
|
||
TimeSpan timeSpan = item.DrugEndTime - item.DrugBeginTime;
|
||
string yndden = "";
|
||
decimal Velocity = 0;
|
||
_record.FactDrugList.ForEach(a => { if (a.DrugName == "氧气" && a.Velocity != "") yndden = a.Velocity; });
|
||
if (yndden != "")
|
||
{
|
||
try
|
||
{
|
||
Velocity = Convert.ToDecimal(yndden);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
Velocity = 0;
|
||
}
|
||
dose += ((decimal)3.6) * Velocity * item.Density * (decimal)Math.Round(timeSpan.TotalHours, 2) + (decimal)5.3;
|
||
}
|
||
}
|
||
}
|
||
XMSL = Math.Ceiling(dose);
|
||
rote = "吸入";
|
||
doseunit = "ml";
|
||
doses = double.Parse(dose.ToString());
|
||
}
|
||
else
|
||
{
|
||
//最小剂量
|
||
decimal DOSEPER = 0;
|
||
//最小单位
|
||
string DOSEPERUNIT = "";
|
||
decimal dose = 0;
|
||
foreach (var item in drugsRecords)
|
||
{
|
||
rote = item.DrugChannel;
|
||
if (drug.Dosage != null && drug.Dosage != "")
|
||
DOSEPER = decimal.Parse(drug.Dosage);
|
||
if (drug.DosageUnit != null && drug.DosageUnit != "")
|
||
DOSEPERUNIT = drug.DosageUnit;
|
||
//3.根据表达式划算 37.5mg/5ml
|
||
if (drug.Comment != null && drug.Comment != "")
|
||
{
|
||
List<string> strings = drug.Comment.Split('|').ToList();
|
||
foreach (var items in strings)
|
||
{
|
||
List<string> units = items.Split('=').ToList();
|
||
if (units[0] == item.DosageUnit.Trim() || units[0] + "/h" == item.VelocityUnit.Trim() || units[0] + "/min" == item.VelocityUnit.Trim())
|
||
{
|
||
DOSEPERUNIT = units[0];
|
||
DOSEPER = Convert.ToDecimal(units[1]);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
//2.速度 速度单位不为空 计算时间总量
|
||
decimal Velocity = 0;
|
||
try
|
||
{
|
||
Velocity = Convert.ToDecimal(item.Velocity);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
Velocity = 0;
|
||
}
|
||
//1.当使用单位等于规格单位 总量增加实际用量
|
||
if (item.Dosage > 0 && drug.DosageUnit != null && drug.DosageUnit != "")
|
||
dose += GetConvertedValue(item.Dosage, item.DosageUnit, DOSEPERUNIT);
|
||
else if (Velocity > 0 && item.VelocityUnit != null && item.VelocityUnit != "")
|
||
{
|
||
TimeSpan timeSpan = item.DrugEndTime - item.DrugBeginTime;
|
||
if (item.VelocityUnit.Contains("/h"))
|
||
{
|
||
dose += GetConvertedValue(Velocity, item.VelocityUnit, DOSEPERUNIT) * (decimal)Math.Round(timeSpan.TotalHours, 2);
|
||
}
|
||
else if (item.VelocityUnit.Contains("/min"))
|
||
{
|
||
dose += GetConvertedValue(Velocity, item.VelocityUnit, DOSEPERUNIT) * (decimal)Math.Round(timeSpan.TotalMinutes, 2);
|
||
}
|
||
}
|
||
}
|
||
//总剂量计算方式 根据规格单位得到换算完的总量 除以最小剂量
|
||
doses = double.Parse(dose.ToString());
|
||
doseunit = DOSEPERUNIT;
|
||
XMSL = Math.Ceiling(dose / DOSEPER);
|
||
if (XMSL < 1) XMSL = 1;
|
||
}
|
||
return XMSL;
|
||
}
|
||
|
||
decimal GetConvertedValue(decimal drugValue, string drugUnit, string ConUnit)
|
||
{
|
||
decimal value = 0;
|
||
if (drugUnit == ConUnit)
|
||
{
|
||
value = drugValue;
|
||
}
|
||
else if (drugUnit == "g" && ConUnit == "mg")
|
||
{
|
||
value = drugValue * 1000;
|
||
}
|
||
else if (drugUnit == "mg" && ConUnit == "g")
|
||
{
|
||
value = drugValue / 1000;
|
||
}
|
||
else if (drugUnit == "mg" && ConUnit == "ug")
|
||
{
|
||
value = drugValue * 1000;
|
||
}
|
||
else if (drugUnit == "ug" && ConUnit == "mg")
|
||
{
|
||
value = drugValue / 1000;
|
||
}
|
||
else if (drugUnit == "ml" && ConUnit == "l")
|
||
{
|
||
value = drugValue / 1000;
|
||
}
|
||
else if (drugUnit == "l" && ConUnit == "ml")
|
||
{
|
||
value = drugValue * 1000;
|
||
}
|
||
else if ((drugUnit == "g/h" || drugUnit == "g/min") && ConUnit == "g")
|
||
{
|
||
value = drugValue;
|
||
}
|
||
else if ((drugUnit == "mg/h" || drugUnit == "mg/min") && ConUnit == "mg")
|
||
{
|
||
value = drugValue;
|
||
}
|
||
else if ((drugUnit == "ug/h" || drugUnit == "ug/min") && ConUnit == "ug")
|
||
{
|
||
value = drugValue;
|
||
}
|
||
else if ((drugUnit == "ml/h" || drugUnit == "ml/min") && ConUnit == "ml")
|
||
{
|
||
value = drugValue;
|
||
}
|
||
|
||
else if ((drugUnit == "g/h" || drugUnit == "g/min") && ConUnit == "mg")
|
||
{
|
||
value = drugValue * 1000;
|
||
}
|
||
else if ((drugUnit == "mg/h" || drugUnit == "mg/min") && ConUnit == "g")
|
||
{
|
||
value = drugValue / 1000;
|
||
}
|
||
else if ((drugUnit == "mg/h" || drugUnit == "mg/min") && ConUnit == "ug")
|
||
{
|
||
value = drugValue * 1000;
|
||
}
|
||
else if ((drugUnit == "ug/h" || drugUnit == "ug/min") && ConUnit == "mg")
|
||
{
|
||
value = drugValue / 1000;
|
||
}
|
||
|
||
return value;
|
||
}
|
||
|
||
private void SetChargDrugPrice()
|
||
{
|
||
int chargCount = 0;
|
||
double chargValue = 0;
|
||
double chargValue2 = 0;
|
||
foreach (DataGridViewRow item in dgvDrugs.Rows)
|
||
{
|
||
if (item.Cells[3].EditedFormattedValue.ToString() != "" && item.Cells[5].EditedFormattedValue.ToString() != "" && item.Cells[7].EditedFormattedValue.ToString() != "")
|
||
{
|
||
double res = 0;
|
||
if (double.TryParse(item.Cells[7].EditedFormattedValue.ToString(), out res))
|
||
{
|
||
double price = double.Parse(item.Cells[5].Value.ToString());
|
||
chargCount++;
|
||
double rowprice = res * price;
|
||
item.Cells[8].Value = rowprice;
|
||
chargValue += rowprice;
|
||
}
|
||
}
|
||
}
|
||
foreach (DataGridViewRow item in dgvChargsRecord.Rows)
|
||
{
|
||
if (item.Cells[3].EditedFormattedValue.ToString() != "" && item.Cells[5].EditedFormattedValue.ToString() != "" && item.Cells[7].EditedFormattedValue.ToString() != "")
|
||
{
|
||
double res = 0;
|
||
if (double.TryParse(item.Cells[7].EditedFormattedValue.ToString(), out res))
|
||
{
|
||
double price = double.Parse(item.Cells[5].Value.ToString());
|
||
chargCount++;
|
||
double rowprice = res * price;
|
||
item.Cells[8].Value = rowprice;
|
||
chargValue2 += rowprice;
|
||
}
|
||
}
|
||
}
|
||
if (chargCount > 0)
|
||
{
|
||
if (FeeType != "护士")
|
||
{
|
||
lblDrugs.Text = string.Format(" 药品:{0}元 其他:{1}元 ", chargValue, chargValue2);
|
||
if (_record.InRoomTime != null && _record.OutRoomTime != null)
|
||
{
|
||
lblDrugs.Text += "在室时长:" + Math.Round(((TimeSpan)(_record.OutRoomTime - _record.InRoomTime)).TotalHours, 2) + " h ";
|
||
}
|
||
if (_record.AnesthesiaBeginTime != null && _record.AnesthesiaEndTime != null)
|
||
{
|
||
lblDrugs.Text += "麻醉时长:" + Math.Round(((TimeSpan)(_record.AnesthesiaEndTime - _record.AnesthesiaBeginTime)).TotalHours, 2) + " h";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (chargValue > 0)
|
||
lblDrugs.Text = string.Format(" 药品:{0}元 手术耗材:{1}元 ", chargValue, chargValue2);
|
||
else
|
||
lblDrugs.Text = string.Format(" 手术耗材:{0}元 ", chargValue2);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
lblDrugs.Text = "";
|
||
}
|
||
}
|
||
|
||
int page = 0;
|
||
int currpage = 0;
|
||
DataTable drugdt;
|
||
Panel panelleftsel;
|
||
private void FullCommonlyDrugs(DataTable dt, Panel panelleft)
|
||
{
|
||
if (panelleft.Controls != null) panelleft.Controls.Clear();
|
||
if (dt.Rows.Count == 18 || dt.Rows.Count == 36 || dt.Rows.Count == 54)
|
||
page = (dt.Rows.Count / 18);
|
||
else
|
||
page = (dt.Rows.Count / 18) + 1;
|
||
|
||
currpage = 1;
|
||
drugdt = dt;
|
||
int y = -28;
|
||
if (page > 1)
|
||
{
|
||
Panel paneltab = new Panel();
|
||
paneltab.AutoScroll = true;
|
||
paneltab.BackColor = Color.White;
|
||
paneltab.Dock = DockStyle.Top;
|
||
paneltab.Height = 36;
|
||
panelleft.Controls.Add(paneltab);
|
||
int x = -28;
|
||
y = 8;
|
||
for (int i = 1; i <= page; i++)
|
||
{
|
||
ButtonX lb = new ButtonX();
|
||
lb.Text = i.ToString().Trim();
|
||
lb.Size = new System.Drawing.Size(30, 30);
|
||
lb.Font = new System.Drawing.Font("微软雅黑", 11f, FontStyle.Bold);
|
||
lb.Parent = paneltab;
|
||
if (i == 1)
|
||
lb.TextColor = System.Drawing.Color.Black;
|
||
x += 34;
|
||
lb.Location = new Point(x, 3);
|
||
lb.Click += butten_Click;
|
||
paneltab.Controls.Add(lb);
|
||
}
|
||
}
|
||
|
||
Panel panel = new Panel();
|
||
panel.AutoScroll = true;
|
||
panel.BackColor = Color.White;
|
||
panel.Dock = DockStyle.Fill;
|
||
panelleft.Controls.Add(panel);
|
||
panelleftsel = panel;
|
||
LoadDrugsMethod(y);
|
||
}
|
||
|
||
private void butten_Click(object sender, EventArgs e)
|
||
{
|
||
ButtonX button = (ButtonX)sender;
|
||
currpage = int.Parse(button.Text);
|
||
foreach (Control item in button.Parent.Controls)
|
||
{
|
||
if (item is ButtonX)
|
||
{
|
||
if (((ButtonX)item).Text == currpage.ToString())
|
||
((ButtonX)item).TextColor = System.Drawing.Color.Black;
|
||
else
|
||
((ButtonX)item).TextColor = System.Drawing.Color.White;
|
||
}
|
||
}
|
||
panelleftsel.Controls.Clear();
|
||
int y = 8;
|
||
LoadDrugsMethod(y);
|
||
}
|
||
|
||
private void LoadDrugsMethod(int y)
|
||
{
|
||
int row = (currpage - 1) * 18;
|
||
for (int i = 0; i < 18; i++)
|
||
{
|
||
if (row + i >= drugdt.Rows.Count) break;
|
||
int usedose = 0;
|
||
ButtonX lb = new ButtonX();
|
||
string name = drugdt.Rows[row + i]["Name"].ToString().Trim() + " " + drugdt.Rows[row + i]["Stand"].ToString().Trim();
|
||
//if (name.Length > 30) name = name.Substring(0, 30);
|
||
if (name.Contains("\r\n"))
|
||
name = name.Replace("\r\n", "");
|
||
lb.Text = name + " " + drugdt.Rows[row + i]["Price"].ToString().Trim();
|
||
lb.Tag = drugdt.Rows[row + i]["Id"].ToString();
|
||
lb.Font = new System.Drawing.Font("微软雅黑", 9f, FontStyle.Bold);
|
||
lb.Tooltip = drugdt.Rows[row + i]["Name"].ToString().Trim() + " " + drugdt.Rows[row + i]["Stand"].ToString().Trim() + " " + drugdt.Rows[row + i]["Price"].ToString().Trim();
|
||
lb.Size = new System.Drawing.Size(panelleftsel.Width - (usedose * 43) - 8, 31);
|
||
lb.Cursor = Cursors.Hand;
|
||
lb.ColorTable = eButtonColor.Orange; ;
|
||
lb.BackColor = Color.SkyBlue;
|
||
lb.TextAlignment = eButtonTextAlignment.Left;
|
||
lb.Parent = panelleftsel;
|
||
lb.TextColor = System.Drawing.Color.Black;
|
||
y += 32;
|
||
lb.Location = new Point(4, y);
|
||
lb.Click += new EventHandler(lb_Click);
|
||
panelleftsel.Controls.Add(lb);
|
||
|
||
}
|
||
}
|
||
string SelectedTab = "";
|
||
|
||
void lb_Click(object sender, EventArgs e)
|
||
{
|
||
ButtonX send = sender as ButtonX;
|
||
DataGridViewRow dr = new DataGridViewRow();
|
||
dr.CreateCells(_dataGridView);
|
||
|
||
if (SelectedTab == "药品")
|
||
{
|
||
Drugs drug = BDrugs.SelectSingle(int.Parse(send.Tag.ToString()));
|
||
dr.Cells[1].Value = drug.DrugKind;
|
||
dr.Cells[2].Value = drug.Code;
|
||
dr.Cells[3].Tag = drug;
|
||
dr.Cells[3].Value = drug.Name;
|
||
dr.Cells[4].Value = drug.Stand;
|
||
dr.Cells[5].Value = drug.Price;
|
||
dr.Cells[6].Value = drug.Unit;
|
||
dr.Cells[7].Value = "1";
|
||
dr.Cells[8].Value = drug.Price;
|
||
}
|
||
else
|
||
{
|
||
Charges drug = BCharges.SelectSingle(int.Parse(send.Tag.ToString()));
|
||
dr.Cells[1].Value = drug.Class;
|
||
dr.Cells[2].Value = drug.Code;
|
||
dr.Cells[3].Tag = drug;
|
||
dr.Cells[3].Value = drug.Name;
|
||
dr.Cells[4].Value = drug.Bill;
|
||
dr.Cells[5].Value = drug.Price;
|
||
dr.Cells[6].Value = drug.Unit;
|
||
dr.Cells[7].Value = "1";
|
||
dr.Cells[8].Value = drug.Price;
|
||
}
|
||
|
||
|
||
if (_lineNumber > 0)
|
||
{
|
||
_dataGridView.Rows.RemoveAt(_lineNumber);
|
||
_dataGridView.Rows.Insert(_lineNumber, dr);
|
||
_lineNumber = 0;
|
||
}
|
||
else
|
||
{
|
||
if (_dataGridView.Rows.Count != 0 && _dataGridView.Rows[_dataGridView.Rows.Count - 1].Cells[3].EditedFormattedValue.ToString() == "")
|
||
{
|
||
_dataGridView.Rows.Insert(_dataGridView.Rows.Count - 1, dr);
|
||
}
|
||
else
|
||
{
|
||
_dataGridView.Rows.Add(dr);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 保存事件
|
||
private void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (TxtOperatorName.Text == "")
|
||
{
|
||
MessageBox.Show("请选择开单人!", "系统提示");
|
||
return;
|
||
}
|
||
btnSave.Focus();
|
||
Save(dgvDrugs, 1);
|
||
Save(dgvChargsRecord, 2);
|
||
SetChargDrugPrice();
|
||
|
||
new frmMessageBox().Show();
|
||
}
|
||
catch (Exception exp)
|
||
{
|
||
PublicMethod.WriteLog(exp);
|
||
}
|
||
}
|
||
private void Save(DataGridView _dataGridView, int index)
|
||
{
|
||
try
|
||
{
|
||
if (_dataGridView.Rows.Count < 1) return;
|
||
string drugEffect = string.Empty;
|
||
foreach (DataGridViewRow dr in _dataGridView.Rows)
|
||
{
|
||
if (dr.Cells[3].Value == null || dr.Cells[3].Value.ToString() == "")//药品名称
|
||
continue;
|
||
if (dr.Cells[7].Value == null || dr.Cells[7].Value.ToString() == "")//药品名称
|
||
continue;
|
||
//实例化FeesRecord对象
|
||
FeesRecord feesR = new FeesRecord();
|
||
if (dr.Tag != null)
|
||
{
|
||
feesR = dr.Tag as FeesRecord;
|
||
}
|
||
feesR.PatientId = _record.PatientId;
|
||
feesR.ApplyId = _record.OperationApplyId;
|
||
feesR.OperationRecordId = _record.Id;
|
||
feesR.ApplyOrderNo = "";
|
||
feesR.FeeIsDrug = index.ToString();
|
||
feesR.GroupID = index.ToString();
|
||
feesR.FeeType = FeeType;
|
||
feesR.FeeTypeId = dr.Cells[1].EditedFormattedValue.ToString();
|
||
if (index == 1)
|
||
{
|
||
Drugs drug = dr.Cells[3].Tag as Drugs;
|
||
if (drug != null)
|
||
{
|
||
feesR.FeeId = drug.Id.ToString();
|
||
feesR.DrugType = drug.DrugKind;
|
||
feesR.Extend1 = "";//剂量
|
||
feesR.Extend2 = "uv";//途径
|
||
feesR.Extend3 = "";//是否打印处方单
|
||
if (dr.Cells[6].Tag != null)
|
||
feesR.Extend1 = dr.Cells[6].Tag.ToString();//剂量
|
||
if (dr.Cells[7].Tag != null)
|
||
feesR.Extend2 = dr.Cells[7].Tag.ToString();//途径
|
||
if (dr.Cells[5].Tag != null)
|
||
feesR.Extend3 = dr.Cells[5].Tag.ToString();//是否打印处方单
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Charges drug = dr.Cells[3].Tag as Charges;
|
||
if (drug != null)
|
||
{
|
||
feesR.FeeId = drug.Id.ToString();
|
||
feesR.Extend1 = "";//剂量
|
||
feesR.Extend2 = "";//途径
|
||
feesR.Extend3 = "";//是否打印处方单
|
||
}
|
||
}
|
||
feesR.FeeCode = dr.Cells[2].EditedFormattedValue.ToString();
|
||
feesR.FeeSerial = dr.Cells[2].EditedFormattedValue.ToString();
|
||
feesR.ChargName = dr.Cells[3].EditedFormattedValue.ToString();
|
||
feesR.ChargSpec = dr.Cells[4].EditedFormattedValue.ToString();
|
||
if (feesR.ChargSpec.Contains("\r\n")) feesR.ChargSpec = feesR.ChargSpec.Replace("\r\n", "");
|
||
feesR.Unit = dr.Cells[6].EditedFormattedValue.ToString();
|
||
feesR.FeeNum = dr.Cells[7].EditedFormattedValue.ToString();
|
||
feesR.FeeClass = dr.Cells[1].EditedFormattedValue.ToString();
|
||
feesR.UnitPrice = dr.Cells[5].EditedFormattedValue.ToString();
|
||
feesR.ChargePrice = dr.Cells[8].EditedFormattedValue.ToString();
|
||
feesR.ActualPrice = dr.Cells[8].EditedFormattedValue.ToString();
|
||
feesR.ChargeFee = dr.Cells[8].EditedFormattedValue.ToString();
|
||
if (_worker != null)
|
||
{
|
||
Department dept = BDepartment.SelectSingle(_worker.DepId);
|
||
feesR.BillingDeptId = dept.Id.ToString();
|
||
feesR.BillingDept = dept.Name;
|
||
feesR.BillingWorkId = _worker.Id.ToString();
|
||
feesR.BillingWork = _worker.Name;
|
||
feesR.HappenTime = DateTime.Now;
|
||
feesR.EnrollTime = DateTime.Now;
|
||
feesR.ExecDeptId = dept.Id.ToString();
|
||
feesR.ExecDept = dept.Name;
|
||
feesR.ExecWorkId = _worker.Id.ToString();
|
||
feesR.ExecWork = _worker.Name;
|
||
feesR.ExecState = "";
|
||
}
|
||
feesR.ExecTime = DateTime.Now;
|
||
feesR.IsUpLoad = "0";
|
||
feesR.OperatorId = PublicMethod.OperatorId;
|
||
feesR.OperatorNo = PublicMethod.OperatorNo;
|
||
feesR.OperatorName = PublicMethod.OperatorName;
|
||
|
||
if (dr.Tag == null)
|
||
{
|
||
feesR.DrugSite = "";
|
||
feesR.FeeId2 = "";
|
||
feesR.BillCode = "";
|
||
feesR.GroupID = "";
|
||
feesR.Valuer = "";
|
||
feesR.Remark = "";
|
||
feesR.EmergencyFlag = "";
|
||
feesR.OrderNo = "";
|
||
feesR.OrderState = "";
|
||
feesR.Conclusion = "";
|
||
feesR.IsInsure = "";
|
||
feesR.InsureNO = "";
|
||
feesR.LimitDrug = "";
|
||
feesR.Extend4 = "";
|
||
feesR.Extend5 = "韩智慧";
|
||
|
||
|
||
feesR.Id = BFeesRecord.Insert(feesR);
|
||
dr.Tag = feesR;
|
||
dr.Cells[0].Value = feesR.Id;
|
||
FeesRecordList.Add(feesR);
|
||
}
|
||
else
|
||
{
|
||
feesR.Id = Convert.ToInt32(dr.Cells[0].Value);
|
||
//将修改的事件保存到集合
|
||
foreach (FeesRecord FeesRecord in FeesRecordList)
|
||
{
|
||
if (FeesRecord.Id == feesR.Id)
|
||
{
|
||
FeesRecordList.Remove(FeesRecord);
|
||
FeesRecordList.Add(feesR);
|
||
BFeesRecord.Update(feesR);
|
||
break;
|
||
}
|
||
}
|
||
dr.Tag = feesR;
|
||
dr.Cells[0].Value = feesR.Id;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception exp)
|
||
{
|
||
PublicMethod.WriteLog(exp);
|
||
}
|
||
}
|
||
private void btnDelete_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (_dataGridView.CurrentRow != null)
|
||
{
|
||
string objectName = _dataGridView.CurrentRow.Cells[3].EditedFormattedValue.ToString();
|
||
if (_dataGridView.CurrentRow.Tag != null)
|
||
{
|
||
FeesRecord record = _dataGridView.CurrentRow.Tag as FeesRecord;
|
||
|
||
if (tabDrugs.SelectedTab.Name != "P3")
|
||
{
|
||
string docname = "";
|
||
if (record.FeeTypeId == "精神II类")
|
||
{
|
||
docname = "第二类精神药品处方笺";
|
||
}
|
||
else if (record.FeeTypeId == "精神I类")
|
||
{
|
||
docname = "第一类精神药品处方笺";
|
||
}
|
||
else if (record.FeeTypeId == "麻醉药")
|
||
{
|
||
docname = "麻醉药品处方笺";
|
||
}
|
||
if (docname != "")
|
||
{
|
||
PrintDocument DModel = DocumentDAL.GetDocumentbyName(docname, _record.PatientId.Value, record.Id.Value);
|
||
if (DModel != null && DModel.Id > 0)
|
||
{
|
||
DialogResult dialogResult = MessageBox.Show("该药品已存在处方单 是否删除?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||
if (dialogResult == DialogResult.No) return;
|
||
else
|
||
DocumentDAL.DeletePrintDocument2(DModel);
|
||
}
|
||
}
|
||
}
|
||
BFeesRecord.Delete(record);
|
||
_dataGridView.Rows.Remove(_dataGridView.CurrentRow);
|
||
_lineNumber = 0;
|
||
|
||
//FullALLDGV();
|
||
//tabDrugs_SelectedTabChanged(null, null);
|
||
}
|
||
else
|
||
{
|
||
if (_dataGridView.CurrentRow.Cells[3].Value != null)//药品名称
|
||
{
|
||
_dataGridView.Rows.Remove(_dataGridView.CurrentRow);
|
||
_lineNumber = 0;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicMethod.WriteLog(ex);
|
||
}
|
||
}
|
||
|
||
private void AddNewNullRows()
|
||
{
|
||
if (_dataGridView.Rows.Count == 0)
|
||
{
|
||
DataGridViewRow row = new DataGridViewRow();
|
||
row.CreateCells(_dataGridView);
|
||
_dataGridView.Rows.Add(row);
|
||
}
|
||
else
|
||
{
|
||
if (_dataGridView.Rows[_dataGridView.Rows.Count - 1].Cells[3].EditedFormattedValue.ToString() != "")
|
||
{
|
||
DataGridViewRow row = new DataGridViewRow();
|
||
row.CreateCells(_dataGridView);
|
||
_dataGridView.Rows.Add(row);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region DataGridView事件
|
||
private void SetDGVNotSort()
|
||
{
|
||
for (int i = 0; i < dgvDrugs.Columns.Count; i++)
|
||
{
|
||
dgvDrugs.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
|
||
}
|
||
}
|
||
private void SetDGVEvent(DataGridView dgv)
|
||
{
|
||
dgv.CellClick -= new DataGridViewCellEventHandler(dgvDrugs_CellClick);
|
||
dgv.CellClick += new DataGridViewCellEventHandler(dgvDrugs_CellClick);
|
||
dgv.CellContentClick -= new DataGridViewCellEventHandler(dgvDrugs_CellContentClick);
|
||
dgv.CellValueChanged -= new DataGridViewCellEventHandler(dgvDrugs_CellValueChanged);
|
||
dgv.CurrentCellDirtyStateChanged -= new EventHandler(dgvDrugs_CurrentCellDirtyStateChanged);
|
||
dgv.EditingControlShowing -= new DataGridViewEditingControlShowingEventHandler(dgvDrugs_EditingControlShowing);
|
||
dgv.RowsAdded -= new DataGridViewRowsAddedEventHandler(dgvDrugs_RowsAdded);
|
||
dgv.CellContentClick += new DataGridViewCellEventHandler(dgvDrugs_CellContentClick);
|
||
dgv.CellValueChanged += new DataGridViewCellEventHandler(dgvDrugs_CellValueChanged);
|
||
dgv.CurrentCellDirtyStateChanged += new EventHandler(dgvDrugs_CurrentCellDirtyStateChanged);
|
||
dgv.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dgvDrugs_EditingControlShowing);
|
||
dgv.RowsAdded += new DataGridViewRowsAddedEventHandler(dgvDrugs_RowsAdded);
|
||
|
||
dgv.CellLeave -= new DataGridViewCellEventHandler(dgvDrugs_CellLeave);
|
||
dgv.CellLeave += new DataGridViewCellEventHandler(dgvDrugs_CellLeave);
|
||
dgv.KeyDown -= new System.Windows.Forms.KeyEventHandler(dgvDrugs_KeyDown);
|
||
dgv.KeyDown += new System.Windows.Forms.KeyEventHandler(dgvDrugs_KeyDown);
|
||
|
||
}
|
||
private void dgvDrugs_CellClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
//点击开始时间时显示时间
|
||
if (_dataGridView.CurrentCell != null)
|
||
{
|
||
_dataGridView.BeginEdit(true);
|
||
}
|
||
if (e.ColumnIndex != 3 && dgvYP.Visible == true)
|
||
{
|
||
dgvYP.Visible = false;
|
||
}
|
||
}
|
||
private void dgvDrugs_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
//if (e.ColumnIndex != 3 && dgvYP.Visible == true)
|
||
//{
|
||
// dgvYP.Visible = false;
|
||
//}
|
||
}
|
||
private void dgvDrugs_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
if (_dataGridView == null) return;
|
||
//判断如果事件名称列内容发生变化时(输入关键字),设置显示查询结果的控件的位置及内容
|
||
if (e.ColumnIndex == 3 || e.ColumnIndex == 7)
|
||
{
|
||
SetChargDrugPrice();
|
||
}
|
||
}
|
||
private void dgvDrugs_CurrentCellDirtyStateChanged(object sender, EventArgs e)
|
||
{
|
||
if (_dataGridView.IsCurrentCellDirty)
|
||
{
|
||
_dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
|
||
}
|
||
}
|
||
private void dgvDrugs_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
|
||
{
|
||
//DataGridViewComboBoxCell dUnitCell;
|
||
//if (e == null)
|
||
//{
|
||
// dUnitCell = _dataGridView.Rows[0].Cells[6] as DataGridViewComboBoxCell;
|
||
//}
|
||
//else
|
||
//{
|
||
// dUnitCell = _dataGridView.Rows[e.RowIndex].Cells[6] as DataGridViewComboBoxCell;
|
||
//}
|
||
|
||
//dUnitCell.DataSource = _dUnitList;
|
||
//dUnitCell.DisplayMember = "Name";
|
||
//dUnitCell.ValueMember = "Name";
|
||
}
|
||
private void dgvDrugs_CellLeave(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
//药品名称失去焦点时注销药品名称单元格的事件
|
||
if (e.ColumnIndex == 3)
|
||
{
|
||
if (dgvTextYP != null)
|
||
{
|
||
dgvTextYP.TextChanged -= new EventHandler(dgvTextYP_TextChanged);
|
||
dgvTextYP.PreviewKeyDown -= new PreviewKeyDownEventHandler(dgvTextYP_PreviewKeyDownEvent);
|
||
dgvTextYP.KeyPress -= new KeyPressEventHandler(dgvTxtName_KeyPress);
|
||
}
|
||
}
|
||
}
|
||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||
{
|
||
if (keyData == Keys.Enter)
|
||
{
|
||
dgvDrugs_KeyDown(_dataGridView, new KeyEventArgs(keyData));
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
private void frmFeesRecord_Paint(object sender, PaintEventArgs e)
|
||
{
|
||
this.HorizontalScroll.Value = x;
|
||
}
|
||
private void frmFeesRecord_Scroll(object sender, ScrollEventArgs e)
|
||
{
|
||
x = this.HorizontalScroll.Value;
|
||
}
|
||
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
|
||
{
|
||
//隔行换色
|
||
this.dgvDrugs.RowsDefaultCellStyle.BackColor = Color.White;//设置背景为白色
|
||
this.dgvDrugs.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(212)))), ((int)(((byte)(242)))), (((int)(((byte)242)))));//青色
|
||
}
|
||
private void dgvChargsRecord_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
|
||
{
|
||
//隔行换色
|
||
this.dgvChargsRecord.RowsDefaultCellStyle.BackColor = Color.White;//设置背景为白色
|
||
this.dgvChargsRecord.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(212)))), ((int)(((byte)(242)))), (((int)(((byte)242)))));//青色
|
||
}
|
||
#endregion
|
||
|
||
#region DataGridView验证
|
||
public DataGridViewTextBoxEditingControl dgvTxt = null; // 声明 一个文本 CellEdit
|
||
public DataGridViewTextBoxEditingControl dgvTextYP = null; // 声明 一个文本 CellEdit
|
||
private void dgvDrugs_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
|
||
{
|
||
//判断类型
|
||
if (_dataGridView.CurrentCell != null)
|
||
{
|
||
//if (dgvTxt != null)
|
||
//{
|
||
// dgvTxt.KeyPress -= new KeyPressEventHandler(dgvTxt_KeyPress); // 绑定事件
|
||
//}
|
||
if (_dataGridView.CurrentCell.ColumnIndex == 3)
|
||
{
|
||
dgvTextYP = (DataGridViewTextBoxEditingControl)e.Control; // 得到单元格
|
||
//dgvTextYP.KeyPress -= new KeyPressEventHandler(dgvTxtName_KeyPress); // 绑定事件
|
||
//dgvTextYP.KeyPress += new KeyPressEventHandler(dgvTxtName_KeyPress); // 绑定事件
|
||
dgvTextYP.TextChanged -= new EventHandler(dgvTextYP_TextChanged);
|
||
dgvTextYP.TextChanged += new EventHandler(dgvTextYP_TextChanged);
|
||
dgvTextYP.PreviewKeyDown -= new PreviewKeyDownEventHandler(dgvTextYP_PreviewKeyDownEvent);
|
||
dgvTextYP.PreviewKeyDown += new PreviewKeyDownEventHandler(dgvTextYP_PreviewKeyDownEvent);
|
||
//SetChargDrugPrice();
|
||
}
|
||
if (_dataGridView.CurrentCell.ColumnIndex == 5 || _dataGridView.CurrentCell.ColumnIndex == 6 || _dataGridView.CurrentCell.ColumnIndex == 7 || _dataGridView.CurrentCell.ColumnIndex == 7)
|
||
{
|
||
dgvTxt = (DataGridViewTextBoxEditingControl)e.Control; // 得到单元格
|
||
dgvTxt.KeyPress -= new KeyPressEventHandler(dgvTxt_KeyPress); // 绑定事件
|
||
dgvTxt.KeyPress += new KeyPressEventHandler(dgvTxt_KeyPress); // 绑定事件
|
||
//SetChargDrugPrice();
|
||
}
|
||
}
|
||
|
||
}
|
||
void dgvTxtName_KeyPress(object sender, KeyPressEventArgs e)
|
||
{
|
||
if (e.KeyChar == 34 || e.KeyChar == 39 || e.KeyChar == 47 || e.KeyChar == 44 || e.KeyChar == 58 || e.KeyChar == 59 || e.KeyChar == 60 || e.KeyChar == 62 || e.KeyChar == 63 || e.KeyChar == 91 || e.KeyChar == 92 || e.KeyChar == 93 || e.KeyChar == 123 || e.KeyChar == 124 || e.KeyChar == 125)
|
||
{
|
||
e.Handled = true;
|
||
}
|
||
}
|
||
void dgvTxt_KeyPress(object sender, KeyPressEventArgs e)
|
||
{
|
||
if (e.KeyChar < 48 || e.KeyChar > 57)
|
||
{
|
||
if (e.KeyChar != 46 && e.KeyChar != 8 && e.KeyChar != 13)
|
||
{
|
||
e.Handled = true;
|
||
}
|
||
}
|
||
TextBox tb = sender as TextBox;
|
||
if (e.KeyChar == 46)
|
||
{
|
||
int n = tb.Text.LastIndexOf(".");
|
||
if (n > 0) e.Handled = true;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 收费类型加载
|
||
private void btnTypeManager_Click(object sender, EventArgs e)
|
||
{
|
||
frmAnaesthesiaEvents fae = new frmAnaesthesiaEvents();
|
||
fae.Type = (FeeType == "护士") ? 5 : 4;
|
||
fae.ShowDialog();
|
||
BindAnaesthesiaEvents();
|
||
}
|
||
private void btnTemp_Click(object sender, EventArgs e)
|
||
{
|
||
_dataGridView.ClearSelection();
|
||
frmChargsTemplateNew frmChargSelect = new frmChargsTemplateNew();
|
||
frmChargSelect.TemplateType = FeeType;
|
||
frmChargSelect.FormClosed += (s, er) =>
|
||
{
|
||
if (frmChargSelect.Tag == null) return;
|
||
List<string> SelTemps = frmChargSelect.Tag as List<string>;
|
||
foreach (var item in SelTemps)
|
||
{
|
||
SetTempSelect(item);
|
||
}
|
||
AddNewNullRows();
|
||
dgvChargsRecord.ClearSelection();
|
||
SetChargDrugPrice();
|
||
};
|
||
frmChargSelect.ShowDialog();
|
||
}
|
||
|
||
private void SetTempSelect(string Temp)
|
||
{
|
||
ChargsTemplate chargsTemplate = BChargsTemplate.SelectSingle("TemplateName='" + Temp.ToString() + "'", null);
|
||
if (chargsTemplate == null) return;
|
||
List<Charges> chargs = BCharges.GetChargsListByCodes(chargsTemplate.ConnectId, chargsTemplate.DefaultValue);
|
||
if (chargs != null && chargs.Count > 0)
|
||
{
|
||
foreach (var item in chargs)
|
||
{
|
||
bool isOnly = true;
|
||
foreach (DataGridViewRow item1 in _dataGridView.Rows)
|
||
{
|
||
Charges temp = item1.Cells[0].Tag as Charges;
|
||
if (item1.Cells[0].Value != null && item.Id == (int?)item1.Cells[0].Value)
|
||
{
|
||
isOnly = false;
|
||
}
|
||
if (temp != null && temp.Code == item.Code)
|
||
{
|
||
isOnly = false;
|
||
}
|
||
}
|
||
if (isOnly == true)
|
||
{
|
||
SetDGV(item);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void SetDGV(Charges item)
|
||
{
|
||
int index;
|
||
if (dgvChargsRecord.Rows[dgvChargsRecord.Rows.Count - 1].Cells[3].Tag == null) index = dgvChargsRecord.Rows[dgvChargsRecord.Rows.Count - 1].Index;
|
||
else
|
||
index = dgvChargsRecord.Rows.Add();
|
||
dgvChargsRecord.Rows[index].Cells[1].Value = item.Class;
|
||
dgvChargsRecord.Rows[index].Cells[2].Value = item.Code;
|
||
dgvChargsRecord.Rows[index].Cells[3].Value = item.Name;
|
||
dgvChargsRecord.Rows[index].Cells[3].Tag = item;
|
||
dgvChargsRecord.Rows[index].Cells[4].Value = item.Bill;
|
||
dgvChargsRecord.Rows[index].Cells[5].Value = item.Price;
|
||
dgvChargsRecord.Rows[index].Cells[6].Value = item.Unit;
|
||
dgvChargsRecord.Rows[index].Cells[7].Value = item.Number;
|
||
|
||
double res = 0;
|
||
if (double.TryParse(item.Price.ToString(), out res))
|
||
{
|
||
double rowprice = res * (double.Parse(item.Number));
|
||
dgvChargsRecord.Rows[index].Cells[8].Value = rowprice;
|
||
}
|
||
|
||
}
|
||
|
||
SuperTabControl stc = new SuperTabControl();
|
||
private void BindAnaesthesiaEvents()
|
||
{
|
||
try
|
||
{
|
||
for (int i = TabSelDrugs.Tabs.Count - 1; i >= 0; i--)
|
||
{
|
||
TabSelDrugs.Tabs.RemoveAt(i);
|
||
}
|
||
string IsAutomatic = "4";
|
||
if (FeeType == "护士") IsAutomatic = "5";
|
||
string Remark = "药品";
|
||
if (tabDrugs.SelectedTab.Name == "P3") Remark = "耗材";
|
||
List<AnaesthesiaEvents> AnaesthesiaList = BAnaesthesiaEvents.Select(" IsAutomatic=" + IsAutomatic + " and Remark = '" + Remark + "' and IsValid=1 ", null, RecursiveType.None, 0);
|
||
foreach (AnaesthesiaEvents item in AnaesthesiaList)
|
||
{
|
||
SuperTabItem spt = stc.CreateTab(item.Name);
|
||
spt.Tag = item;
|
||
spt.SymbolColor = Color.White;
|
||
SuperTabControlPanel superTabControlPanel = new SuperTabControlPanel();
|
||
superTabControlPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||
superTabControlPanel.CanvasColor = Color.White;
|
||
superTabControlPanel.TabItem = spt;
|
||
spt.AttachedControl = superTabControlPanel;
|
||
TabSelDrugs.Controls.Add(superTabControlPanel);
|
||
TabSelDrugs.Tabs.Add(spt);
|
||
}
|
||
this.TabSelDrugs.SelectedTabChanged += new System.EventHandler<DevComponents.DotNetBar.SuperTabStripSelectedTabChangedEventArgs>(this.superTabControl1_SelectedTabChanged);
|
||
TabSelDrugs.SelectedTab = TabSelDrugs.Tabs[0] as SuperTabItem;
|
||
|
||
if (AnaesthesiaList.Count > 0)
|
||
superTabControl1_SelectedTabChanged(null, null);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicMethod.WriteLog(ex);
|
||
}
|
||
}
|
||
SuperTabItem Superitem;
|
||
private void superTabControl1_SelectedTabChanged(object sender, SuperTabStripSelectedTabChangedEventArgs e)
|
||
{
|
||
if (Superitem != null && Superitem == TabSelDrugs.SelectedTab) return;
|
||
Panel panel = null;
|
||
DataTable dt = new DataTable();
|
||
|
||
Superitem = TabSelDrugs.SelectedTab;
|
||
if (Superitem != null && Superitem.Tag != null)
|
||
{
|
||
AnaesthesiaEvents spt = Superitem.Tag as AnaesthesiaEvents;
|
||
SelectedTab = spt.Remark;
|
||
if (SelectedTab == "药品")
|
||
{
|
||
panel = (SuperTabControlPanel)Superitem.AttachedControl;
|
||
dt = BDrugs.GetDrugsByIds(spt.TheEventsId.ToString());
|
||
}
|
||
else
|
||
{
|
||
panel = (SuperTabControlPanel)Superitem.AttachedControl;
|
||
dt = BCharges.GetDrugsByIds(spt.TheEventsId.ToString());
|
||
}
|
||
}
|
||
FullCommonlyDrugs(dt, panel);
|
||
}
|
||
private void tabDrugs_SelectedTabChanged(object sender, SuperTabStripSelectedTabChangedEventArgs e)
|
||
{
|
||
DataTable dt = new DataTable();
|
||
_dataGridView = dgvDrugs;
|
||
if (tabDrugs.SelectedTab.Name == "P2")
|
||
{
|
||
_dataGridView = dgvDrugs;
|
||
}
|
||
if (tabDrugs.SelectedTab.Name == "P3")
|
||
{
|
||
_dataGridView = dgvChargsRecord;
|
||
}
|
||
SetDGVEvent(_dataGridView);
|
||
_dataGridView.Columns[1].ReadOnly = true;
|
||
//_dataGridView.Columns[2].ReadOnly = true;
|
||
|
||
AddNewNullRows();
|
||
SetChargDrugPrice();
|
||
|
||
//_dataGridView.CurrentCell = _dataGridView.Rows[_dataGridView.Rows.Count - 1].Cells[3];
|
||
//_dataGridView.BeginEdit(true);
|
||
|
||
if (dgvYP.Visible == true)
|
||
{
|
||
dgvYP.Visible = false;
|
||
}
|
||
BindAnaesthesiaEvents();
|
||
}
|
||
#endregion
|
||
|
||
#region 下拉DGV检索
|
||
//定位当前行索引
|
||
int index = 0;
|
||
/// <summary>
|
||
/// 向药品表添加数据
|
||
/// </summary>
|
||
/// <param name="e"></param>
|
||
private void SetYPContent(DataGridViewCellEventArgs e)
|
||
{
|
||
if (e != null)
|
||
{
|
||
index = e.RowIndex;
|
||
}
|
||
if (dgvYP.Rows[index].Cells["DrugName"].EditedFormattedValue.ToString() != "")
|
||
{
|
||
//dgvDosage.Rows.Clear();
|
||
_dataGridView.CurrentRow.Cells[1].Value = dgvYP.Rows[index].Cells["TypeName"].Value.ToString();
|
||
_dataGridView.CurrentRow.Cells[2].Value = dgvYP.Rows[index].Cells["Code"].Value.ToString();
|
||
_dataGridView.CurrentRow.Cells[3].Tag = BDrugs.SelectSingle(int.Parse(dgvYP.Rows[index].Cells["id"].Value.ToString()));
|
||
_dataGridView.CurrentRow.Cells[3].Value = dgvYP.Rows[index].Cells["DrugName"].Value.ToString();//药品名称
|
||
_dataGridView.CurrentRow.Cells[4].Value = dgvYP.Rows[index].Cells["Norm"].Value.ToString();
|
||
_dataGridView.CurrentRow.Cells[5].Value = dgvYP.Rows[index].Cells["Price"].Value.ToString();
|
||
_dataGridView.CurrentRow.Cells[6].Value = dgvYP.Rows[index].Cells["Unit"].Value.ToString();
|
||
_dataGridView.CurrentRow.Cells[7].Value = "1";
|
||
_dataGridView.CurrentRow.Cells[8].Value = dgvYP.Rows[index].Cells["Price"].Value.ToString();
|
||
index = 0;
|
||
dgvYP.Visible = false;
|
||
AddNewNullRows();
|
||
//_dataGridView.BeginEdit(false);
|
||
|
||
_dataGridView.CurrentCell = _dataGridView.Rows[_dataGridView.CurrentCell.RowIndex].Cells[7];
|
||
//_dataGridView.CurrentCell = _dataGridView.Rows[_dataGridView.CurrentCell.RowIndex + 1].Cells[3];
|
||
_dataGridView.BeginEdit(true);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 药品名称单元格字符串改变事件(根据输入查询药品)
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
void dgvTextYP_TextChanged(object sender, EventArgs e)
|
||
{
|
||
//显示并定位药品选择列表
|
||
if (dgvYP.Visible == false)
|
||
{
|
||
dgvYP.Visible = true;
|
||
GetControlPosition(dgvYP, _dataGridView.CurrentCell);
|
||
}
|
||
//药品名称单元格为空时,隐藏选择药品列表,否则为选择药品列表加载数据
|
||
if (dgvTextYP.Text == "")
|
||
{
|
||
dgvYP.Visible = false;
|
||
}
|
||
else
|
||
{
|
||
string str = dgvTextYP.Text.Trim();
|
||
if (tabDrugs.SelectedTab.Name == "P2")
|
||
{
|
||
DataTable dt = BDrugs.GetAllDrugsByCondition(str);
|
||
dgvYP.DataSource = dt;
|
||
}
|
||
if (tabDrugs.SelectedTab.Name == "P3")
|
||
{
|
||
DataTable dt = BCharges.GetAllChargesByCondition(str);
|
||
dgvYP.DataSource = dt;
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 获取DataGridView回车事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void dgvDrugs_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyData == Keys.Enter)
|
||
{
|
||
e.Handled = true;
|
||
//药品名称单元格回车时判断并填充药品信息
|
||
if (_dataGridView.CurrentCell.ColumnIndex == 3)
|
||
{
|
||
if (_dataGridView.CurrentRow.Cells[3].EditedFormattedValue.ToString() == "")
|
||
{
|
||
return;
|
||
}
|
||
SetYPContent(null);
|
||
}
|
||
//剂量单元格回车时填写剂量并将光标移到到下一行的药品名称单元格
|
||
else if (_dataGridView.CurrentCell.ColumnIndex == 7)
|
||
{
|
||
if (_dataGridView.CurrentRow.Cells[7].EditedFormattedValue.ToString() == "")
|
||
{
|
||
return;
|
||
}
|
||
index = 0;
|
||
_dataGridView.CurrentCell = _dataGridView.Rows[_dataGridView.CurrentCell.RowIndex + 1].Cells[3];
|
||
_dataGridView.BeginEdit(true);
|
||
SetChargDrugPrice();
|
||
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 药品名称单元格按键事件(判断输入上下箭头并处理)
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
void dgvTextYP_PreviewKeyDownEvent(object sender, PreviewKeyDownEventArgs e)
|
||
{
|
||
//药品名称单元格为空时,返回
|
||
if (_dataGridView.CurrentCell.EditedFormattedValue.ToString() == "")
|
||
{
|
||
return;
|
||
}
|
||
//显示并定位选择药品列表
|
||
if (dgvYP.Visible == false)
|
||
{
|
||
dgvYP.Visible = true;
|
||
GetControlPosition(dgvYP, _dataGridView.CurrentCell);
|
||
}
|
||
//判断按下上下键时,选择药品列表获得焦点并定位光标
|
||
if (e.KeyCode == Keys.Up)
|
||
{
|
||
dgvYP.Focus();
|
||
dgvYP.Rows[dgvYP.Rows.Count - 1].Selected = true;
|
||
dgvYP.CurrentCell = dgvYP.Rows[dgvYP.Rows.Count - 1].Cells[4];
|
||
}
|
||
if (e.KeyCode == Keys.Down)
|
||
{
|
||
if (dgvYP.Rows.Count > 0)
|
||
{
|
||
dgvYP.Focus();
|
||
dgvYP.Rows[1].Selected = true;
|
||
dgvYP.CurrentCell = dgvYP.Rows[1].Cells[4];
|
||
}
|
||
}
|
||
}
|
||
///<summary>
|
||
///获取单元格的位置并显示面板
|
||
///</summary>
|
||
///<param name="pnl"></param>
|
||
///<param name="cell"></param>
|
||
private void GetControlPosition(Control pnl, DataGridViewCell cell)
|
||
{
|
||
Rectangle rec = _dataGridView.GetCellDisplayRectangle(cell.ColumnIndex - 1, cell.RowIndex, false);
|
||
if (_dataGridView.Height - rec.Y - rec.Height - pnl.Height > 0)
|
||
{
|
||
pnl.Top = rec.Y + rec.Height + panel2.Height + 30;
|
||
}
|
||
else
|
||
{
|
||
pnl.Top = rec.Y - pnl.Height + panel2.Height + 30;
|
||
}
|
||
pnl.Left = TabSelDrugs.Width + rec.X;
|
||
pnl.Visible = true;
|
||
}
|
||
/// <summary>
|
||
/// 鼠标点击选择药品列表时,向使用药品表添加数据
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void dgvYP_CellClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
if (e.RowIndex >= 0)
|
||
{
|
||
SetYPContent(e);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 选择药品列表上点击上下键定位并移动光标
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void dgvYP_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Down)
|
||
{
|
||
if (dgvYP.CurrentRow.Index == dgvYP.Rows.Count - 1)
|
||
{
|
||
e.Handled = true;
|
||
dgvYP.CurrentCell = dgvYP.Rows[0].Cells[4];
|
||
dgvYP.Rows[0].Selected = true;
|
||
}
|
||
}
|
||
if (e.KeyCode == Keys.Up)
|
||
{
|
||
if (dgvYP.CurrentRow.Index == 0)
|
||
{
|
||
e.Handled = true;
|
||
dgvYP.CurrentCell = dgvYP.Rows[dgvYP.Rows.Count - 1].Cells[4];
|
||
dgvYP.Rows[dgvYP.Rows.Count - 1].Selected = true;
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 选择药品列表点击回车键向使用药品列表添加数据
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void dgvYP_KeyPress(object sender, KeyPressEventArgs e)
|
||
{
|
||
if (e.KeyChar.ToString() == "\r")
|
||
{
|
||
if (dgvYP.SelectedRows.Count > 0)
|
||
{
|
||
SetYPContent(null);
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 选择药品列表点击回车时先定位当前行的索引
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void dgvYP_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Enter)
|
||
{
|
||
index = dgvYP.CurrentRow.Index;
|
||
}
|
||
}
|
||
private void dgvDrugs_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
||
{
|
||
if (e.Exception.Message == "DataGridViewComboBoxCell 值无效。")
|
||
{
|
||
try
|
||
{
|
||
object value = _dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||
if (!((DataGridViewComboBoxCell)_dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]).Items.Contains(value))
|
||
{
|
||
((DataGridViewComboBoxCell)_dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]).Items.Add(value);
|
||
e.ThrowException = false;
|
||
}
|
||
}
|
||
catch (Exception)
|
||
{
|
||
e.ThrowException = false;
|
||
}
|
||
|
||
}
|
||
}
|
||
private void dgvChargsRecord_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
||
{
|
||
if (e.Exception.Message == "DataGridViewComboBoxCell 值无效。")
|
||
{
|
||
try
|
||
{
|
||
object value = _dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||
if (!((DataGridViewComboBoxCell)_dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]).Items.Contains(value))
|
||
{
|
||
((DataGridViewComboBoxCell)_dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]).Items.Add(value);
|
||
e.ThrowException = false;
|
||
}
|
||
}
|
||
catch (Exception)
|
||
{
|
||
e.ThrowException = false;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
#endregion
|
||
|
||
private PublicUI.UI.frmSelectPerson frmOperationDoctor;
|
||
private List<int> SelectOperationDoctorData = new List<int>(); //一助
|
||
private void TxtOperatorName_DoubleClick(object sender, EventArgs e)
|
||
{
|
||
frmOperationDoctor = new PublicUI.UI.frmSelectPerson();
|
||
frmOperationDoctor.PersonType = (FeeType == "护士") ? "医生" : "麻醉医生";
|
||
frmOperationDoctor.SelectDepartmentName = _record.ApplyDepartmentName;
|
||
frmOperationDoctor.SelectPersonData = SelectOperationDoctorData;
|
||
frmOperationDoctor.FormClosed += new FormClosedEventHandler(frmOperationDoctor_FormClosed);
|
||
frmOperationDoctor.ShowDialog();
|
||
}
|
||
|
||
void frmOperationDoctor_FormClosed(object sender, FormClosedEventArgs e)
|
||
{
|
||
TxtOperatorName.Text = "";
|
||
if (frmOperationDoctor.SelectPersonData.Count > 0)
|
||
{
|
||
SelectOperationDoctorData = frmOperationDoctor.SelectPersonData;
|
||
_worker = BPerson.SelectSingle(SelectOperationDoctorData[0]);
|
||
TxtOperatorName.Text = _worker.Name;
|
||
TxtOperatorName.Tag = _worker.Id;
|
||
}
|
||
}
|
||
|
||
private void bynPrint_Click(object sender, EventArgs e)
|
||
{
|
||
btnSave_Click(null, null);
|
||
if (PublicMethod.HospitalName.Contains("秦皇岛"))
|
||
{
|
||
PrintExcel2();
|
||
}
|
||
else
|
||
{
|
||
PrintExcel();
|
||
}
|
||
}
|
||
|
||
private void PrintExcel()
|
||
{
|
||
GoldPrinter.ExcelAccess excel = new GoldPrinter.ExcelAccess();
|
||
string strFileName = "麻醉收费单.xlt"; //模板文件名
|
||
if (FeeType == "护士") strFileName = "护士收费单.xlt";
|
||
string strExcelTemplateFile = Application.StartupPath;
|
||
strExcelTemplateFile += @"\Template\" + strFileName;
|
||
excel.Open(strExcelTemplateFile); //用模板文件
|
||
|
||
excel.SetCellText(2, "A", PublicMethod.HospitalName);
|
||
excel.SetCellText(4, "B", _record.InRoomTime.Value.ToString("yyyy-MM-dd"));
|
||
excel.SetCellText(4, "E", _record.ApplyDepartmentName.ToString());
|
||
excel.SetCellText(4, "H", _record.InHospitalNo);
|
||
excel.SetCellText(5, "B", _record.Name + " (" + _record.Sex + " " + _record.Age + ")");
|
||
excel.SetCellText(5, "H", _record.Identity);
|
||
|
||
PatientRecord Patient = PatientRecord.GetPatientRecord(_record.PatientId.Value);
|
||
if (FeeType == "麻醉")
|
||
{
|
||
excel.SetCellText(5, "E", DBManage.GetDictionaryValuesById(_record.Applydiagnose, "诊断"));
|
||
excel.SetCellText(38, "B", lblDrugs.Text);
|
||
excel.SetCellText(39, "B", _worker.Name);
|
||
excel.SetCellText(39, "D", Patient.AnesthesiaDoctor);
|
||
excel.SetCellText(39, "G", DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
|
||
}
|
||
else
|
||
{
|
||
excel.SetCellText(5, "E", DBManage.GetDictionaryValuesById(_record.Operation, "手术"));
|
||
excel.SetCellText(27, "B", Patient.OperationDoctor);
|
||
excel.SetCellText(27, "F", Patient.InstrumentNurse + " " + Patient.TourNurse);
|
||
excel.SetCellText(27, "I", Patient.AnesthesiaDoctor);
|
||
excel.SetCellText(28, "B", lblDrugs.Text);
|
||
}
|
||
|
||
int rowNum = 7;
|
||
for (int i = 0; i < dgvDrugs.Rows.Count; i++)
|
||
{
|
||
DataGridViewRow dr = dgvDrugs.Rows[i];
|
||
if (dr.Tag == null) continue;
|
||
FeesRecord temp = dr.Tag as FeesRecord;
|
||
if (temp != null)
|
||
{
|
||
excel.GetRange(rowNum, "A", rowNum, "I").Value = new string[]{
|
||
( dr.Cells[3].EditedFormattedValue.ToString()),"","","","",
|
||
( dr.Cells[4].EditedFormattedValue.ToString()),
|
||
dr.Cells[7].EditedFormattedValue.ToString(),
|
||
( dr.Cells[6].EditedFormattedValue.ToString() ) ,
|
||
(dr.Cells[8].EditedFormattedValue.ToString() ) };
|
||
rowNum++;
|
||
}
|
||
}
|
||
for (int i = 0; i < dgvChargsRecord.Rows.Count; i++)
|
||
{
|
||
DataGridViewRow dr = dgvChargsRecord.Rows[i];
|
||
if (dr.Tag == null) continue;
|
||
FeesRecord temp = dr.Tag as FeesRecord;
|
||
if (temp != null)
|
||
{
|
||
excel.GetRange(rowNum, "A", rowNum, "I").Value = new string[]{
|
||
( dr.Cells[3].EditedFormattedValue.ToString()),"","","","",
|
||
( temp.ChargSpec ),
|
||
dr.Cells[7].EditedFormattedValue.ToString(),
|
||
( dr.Cells[6].EditedFormattedValue.ToString() ) ,
|
||
(dr.Cells[8].EditedFormattedValue.ToString() )
|
||
};
|
||
rowNum++;
|
||
}
|
||
}
|
||
excel.Print();
|
||
this.Focus();
|
||
excel.Close();
|
||
}
|
||
|
||
private void PrintExcel2()
|
||
{
|
||
GoldPrinter.ExcelAccess excel = new GoldPrinter.ExcelAccess();
|
||
string strFileName = "麻醉收费单QHD.xlt"; //模板文件名
|
||
if (FeeType == "护士") strFileName = "护士收费单QHD.xlt";
|
||
string strExcelTemplateFile = Application.StartupPath;
|
||
strExcelTemplateFile += @"\Template\" + strFileName;
|
||
excel.Open(strExcelTemplateFile); //用模板文件
|
||
|
||
excel.SetCellText(2, "A", PublicMethod.HospitalName);
|
||
excel.SetCellText(4, "B", _record.InRoomTime.Value.ToString("yyyy-MM-dd"));
|
||
excel.SetCellText(4, "E", _record.ApplyDepartmentName.ToString());
|
||
excel.SetCellText(4, "H", _record.InHospitalNo);
|
||
excel.SetCellText(5, "B", _record.Name + " (" + _record.Sex + " " + _record.Age + ")");
|
||
excel.SetCellText(5, "H", _record.Identity);
|
||
|
||
PatientRecord Patient = PatientRecord.GetPatientRecord(_record.PatientId.Value);
|
||
if (FeeType == "麻醉")
|
||
{
|
||
excel.SetCellText(5, "E", DBManage.GetDictionaryValuesById(_record.Applydiagnose, "诊断"));
|
||
excel.SetCellText(38, "B", lblDrugs.Text);
|
||
excel.SetCellText(39, "B", _worker.Name);
|
||
excel.SetCellText(39, "D", Patient.AnesthesiaDoctor);
|
||
excel.SetCellText(39, "G", DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
|
||
}
|
||
else
|
||
{
|
||
excel.SetCellText(5, "E", DBManage.GetDictionaryValuesById(_record.Operation, "手术"));
|
||
excel.SetCellText(27, "B", Patient.OperationDoctor);
|
||
excel.SetCellText(27, "F", Patient.InstrumentNurse + " " + Patient.TourNurse);
|
||
excel.SetCellText(27, "H", Patient.AnesthesiaDoctor);
|
||
excel.SetCellText(28, "B", lblDrugs.Text);
|
||
}
|
||
|
||
int rowNum = 7;
|
||
for (int i = 0; i < dgvDrugs.Rows.Count; i++)
|
||
{
|
||
DataGridViewRow dr = dgvDrugs.Rows[i];
|
||
if (dr.Tag == null) continue;
|
||
FeesRecord temp = dr.Tag as FeesRecord;
|
||
if (temp != null)
|
||
{
|
||
excel.GetRange(rowNum, "A", rowNum, "H").Value = new string[]{
|
||
( dr.Cells[3].EditedFormattedValue.ToString()),"","","","",
|
||
( dr.Cells[4].EditedFormattedValue.ToString()),
|
||
dr.Cells[7].EditedFormattedValue.ToString(),
|
||
( dr.Cells[6].EditedFormattedValue.ToString() ) };
|
||
rowNum++;
|
||
}
|
||
}
|
||
for (int i = 0; i < dgvChargsRecord.Rows.Count; i++)
|
||
{
|
||
DataGridViewRow dr = dgvChargsRecord.Rows[i];
|
||
if (dr.Tag == null) continue;
|
||
FeesRecord temp = dr.Tag as FeesRecord;
|
||
if (temp != null)
|
||
{
|
||
excel.GetRange(rowNum, "A", rowNum, "H").Value = new string[]{
|
||
( dr.Cells[3].EditedFormattedValue.ToString()),"","","","",
|
||
( temp.ChargSpec ),
|
||
dr.Cells[7].EditedFormattedValue.ToString(),
|
||
( dr.Cells[6].EditedFormattedValue.ToString() )
|
||
};
|
||
rowNum++;
|
||
}
|
||
}
|
||
excel.Print();
|
||
this.Focus();
|
||
excel.Close();
|
||
}
|
||
|
||
private void buttonX1_Click(object sender, EventArgs e)
|
||
{
|
||
FeesRecordList = BFeesRecord.Select(" FeeIsDrug =1 and FeeType='" + FeeType + "' and OperationRecordId=" + _record.Id, null, RecursiveType.None, 0);
|
||
|
||
if (FeesRecordList.Count > 0)
|
||
{
|
||
DialogResult dialogResult = MessageBox.Show("用药收费记录已经保存过 是否重新加载药品列表?", "系统提示", MessageBoxButtons.YesNo);
|
||
if (dialogResult == DialogResult.Yes)
|
||
{
|
||
dgvDrugs.Rows.Clear();
|
||
FeesRecordList = BFeesRecord.Select(" FeeType='" + FeeType + "' and OperationRecordId=" + _record.Id, null, RecursiveType.None, 0);
|
||
BFeesRecord.Delete(" FeeIsDrug =1 and FeeType='" + FeeType + "' and OperationRecordId=" + _record.Id, null);
|
||
|
||
DocumentDAL.DeletePrintDocument3("第二类精神药品处方笺", _record.PatientId.Value, PublicMethod.OperatorNo);
|
||
DocumentDAL.DeletePrintDocument3("第一类精神药品处方笺", _record.PatientId.Value, PublicMethod.OperatorNo);
|
||
DocumentDAL.DeletePrintDocument3("麻醉药", _record.PatientId.Value, PublicMethod.OperatorNo);
|
||
LoadRecordDrugs();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
dgvDrugs.Rows.Clear();
|
||
LoadRecordDrugs();
|
||
}
|
||
SetChargDrugPrice();
|
||
AddNewNullRows();
|
||
}
|
||
|
||
private void dgvDrugs_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
if (dgvDrugs.CurrentRow.Cells[3].Value == null || dgvDrugs.CurrentRow.Cells[3].Value.ToString() == "")//药品名称
|
||
return;
|
||
if (dgvDrugs.CurrentRow.Cells[7].Value == null || dgvDrugs.CurrentRow.Cells[7].Value.ToString() == "")//药品名称
|
||
return;
|
||
FeesRecord drug = dgvDrugs.CurrentRow.Tag as FeesRecord;
|
||
if (drug == null)
|
||
{
|
||
MessageBox.Show("请先保存后再打印处方单!", "系统提示");
|
||
return;
|
||
}
|
||
frmPrescriptionDocument document = new frmPrescriptionDocument();
|
||
document.PatientId = _record.PatientId.Value;
|
||
document.fee = drug;
|
||
document.ShowDialog();
|
||
}
|
||
}
|
||
}
|