AIMS/AIMSControls/OperationAfter/frmOperationCharg2.cs
2023-08-16 22:32:16 +08:00

307 lines
11 KiB
C#

using AIMS.OperationAanesthesia;
using AIMS.PublicUI.UI;
using AIMSBLL;
using AIMSExtension;
using AIMSModel;
using DrawGraph;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIMS.OperationAfter.UI
{
public partial class frmOperationCharg2 : Form
{
DataTable operationApplys;
public string TemplateType = "麻醉";
public frmOperationCharg2()
{
InitializeComponent();
}
private void frmOperationChargCheck_Load(object sender, EventArgs e)
{
dgvOperation.AutoGenerateColumns = false;
dtpOpeTime.Value = DateTime.Now;
dtpEnd.Value = dtpOpeTime.Value;
ControlExtension.GetOperationSite(labelSite, CboOperationSite);
Initial();
}
private void btnOK_Click(object sender, EventArgs e)
{
DateTime beginTime = Convert.ToDateTime(dtpOpeTime.Value.ToShortDateString() + " 00:00:00");
DateTime endTime = Convert.ToDateTime(dtpEnd.Value.ToShortDateString() + " 23:59:59");
string sql = string.Empty;
if (!txtPatCaseNO.Text.Trim().Equals(""))
{
sql = " [StateId] in(6,8,9) and RecoverId=1 and MdrecNo like '%" + txtPatCaseNO.Text.Trim() + "%'";
}
else if (!txtPatName.Text.Trim().Equals(""))
{
sql = " [StateId] in(6,8,9) and RecoverId=1 and PatientName like'%" + txtPatName.Text.Trim() + "%'";
}
else
{
sql = string.Format(" [StateId] in(6,8,9) and RecoverId=1 and InRoomTime>'{0}' and InRoomTime<'{1}'", beginTime, endTime);
}
//sql += " order by RoomOrderBy asc";
operationApplys = BOperationRecord.GetAllOperationRecordInfo(sql);
if (CboOperationSite.Visible == true && CboOperationSite.SelectedIndex > 0)
{
operationApplys = AIMSExtension.PublicMethod.GetNewDataTable(operationApplys, " OperationSite ='" + CboOperationSite.SelectedValue + "' ", "");
}
LoadSelectDate();
dgvtEMPOperationInfos.Rows.Clear();
}
private void Initial()
{
btnOK_Click(null, null);
}
/// <summary>
/// 点击查询加载DGV数据
/// </summary>
public void LoadSelectDate()
{
dgvOperation.DataSource = operationApplys;
lblMessage.Text = "符合当前条件的记录数:" + operationApplys.Rows.Count;
}
private void tsbChangeOpe_Click(object sender, EventArgs e)
{
int OpeID = 0;
if (dgvOperation.SelectedRows.Count > 0)
{
OpeID = Convert.ToInt32(dgvOperation.SelectedRows[0].Cells[0].Value.ToString());
}
if (OpeID == 0) return;
}
private void toolStripButton10_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// 表格配置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSettingDGV_Click(object sender, EventArgs e)
{
}
private void dgvOperation_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgvOperation.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
dgvOperation.RowHeadersDefaultCellStyle.Font,
rectangle,
dgvOperation.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
private void btnBeforeDay_Click(object sender, EventArgs e)
{
dtpOpeTime.Value = dtpOpeTime.Value.AddDays(-1);
dtpEnd.Value = dtpEnd.Value.AddDays(-1);
btnOK_Click(null, null);
}
private void btnAfterDay_Click(object sender, EventArgs e)
{
dtpOpeTime.Value = dtpOpeTime.Value.AddDays(1);
dtpEnd.Value = dtpEnd.Value.AddDays(1);
btnOK_Click(null, null);
}
private void button1_Click(object sender, EventArgs e)
{
if (dgvOperation.CurrentRow == null)//药品名称
return;
int PatientId = int.Parse(dgvOperation.CurrentRow.Cells[2].Value.ToString());
OperationRecord _record = new OperationRecord();
BOperationRecord.getRecord(_record, PatientId, 1);
if (_record != null)
{
EMRExtension.OpenFeesRecord(_record, rdoZQ.Checked == true ? "麻醉" : "护士");
}
dgvtEMPOperationInfos.Rows.Clear();
SetChargDetalie(_record.Id.Value);
}
private void cboRoom_SelectedIndexChanged(object sender, EventArgs e)
{
btnOK_Click(null, null);
}
private void dgvOperation_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
int OpeID = 0;
if (dgvOperation.SelectedRows.Count > 0)
{
OpeID = Convert.ToInt32(dgvOperation.SelectedRows[0].Cells[0].Value.ToString());
}
if (OpeID == 0)
{
return;
}
dgvtEMPOperationInfos.Rows.Clear();
SetChargDetalie(OpeID);
}
private void SetChargDetalie(int _operationRecord)
{
List<FeesRecord> tEMPOperationInfoBackupss = BFeesRecord.Select("OperationRecordId='" + _operationRecord + "' and FeeType='" + TemplateType + "' ", null);
if (tEMPOperationInfoBackupss != null && tEMPOperationInfoBackupss.Count > 0)
{
foreach (var item in tEMPOperationInfoBackupss)
{
int index = dgvtEMPOperationInfos.Rows.Add();
dgvtEMPOperationInfos.Rows[index].Tag = item;
dgvtEMPOperationInfos.Rows[index].Cells[0].Value = item.Id;// 编号
dgvtEMPOperationInfos.Rows[index].Cells[1].Value = item.BillCode;
dgvtEMPOperationInfos.Rows[index].Cells[2].Value = item.ChargName + " " + item.ChargSpec;
dgvtEMPOperationInfos.Rows[index].Cells[3].Value = item.Unit;
dgvtEMPOperationInfos.Rows[index].Cells[4].Value = item.FeeNum;
dgvtEMPOperationInfos.Rows[index].Cells[5].Value = item.UnitPrice;
dgvtEMPOperationInfos.Rows[index].Cells[6].Value = item.ChargePrice;
dgvtEMPOperationInfos.Rows[index].Cells[7].Value = item.ExecWork;
dgvtEMPOperationInfos.Rows[index].Cells[8].Value = item.ExecTime;
if (item.Extend4 != null && item.Extend4 != "")
dgvtEMPOperationInfos.Rows[index].Cells[9].Value = "000" + item.Extend4;
//dgvtEMPOperationInfos.Rows[index].Cells["type"].Value = item.FeeTypeId;
}
}
}
private void rdoZQ_CheckedChanged(object sender, EventArgs e)
{
if (rdoZQ.Checked == true)
{
TemplateType = "麻醉";
dgvOperation.Columns["chagestate"].Visible = true;
dgvOperation.Columns["chargstatenurse"].Visible = false;
}
else
{
TemplateType = "护士";
dgvOperation.Columns["chargstatenurse"].Visible = true;
dgvOperation.Columns["chagestate"].Visible = false;
}
}
public int maxOrder = 0;
private void dgvtEMPOperationInfos_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
SolidBrush b = new SolidBrush(dgvtEMPOperationInfos.RowHeadersDefaultCellStyle.ForeColor);
e.Graphics.DrawString((maxOrder + e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.dgvtEMPOperationInfos.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
//隔行换色
this.dgvtEMPOperationInfos.RowsDefaultCellStyle.BackColor = Color.White;//设置背景为白色
this.dgvtEMPOperationInfos.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(212)))), ((int)(((byte)(242)))), (((int)(((byte)242)))));//青色
}
private bool CheckFormIsOpen(string Forms)
{
bool bResult = false;
foreach (Form frm in Application.OpenForms)
{
if (frm.Name == Forms)
{
bResult = true;
break;
}
}
return bResult;
}
private void dgvtEMPOperationInfos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (dgvtEMPOperationInfos.CurrentRow == null)//药品名称
return;
FeesRecord drug = dgvtEMPOperationInfos.CurrentRow.Tag as FeesRecord;
if (drug == null)
{
return;
}
frmPrescriptionDocument document = new frmPrescriptionDocument();
document.PatientId = drug.PatientId.Value;
document.fee = drug;
document.ShowDialog();
dgvtEMPOperationInfos.Rows.Clear();
SetChargDetalie(drug.OperationRecordId.Value);
}
private void checkBoxX1_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxX1.Checked == true)
{
foreach (DataGridViewRow item in dgvOperation.Rows)
{
item.Cells[6].Value = true;
}
}
else
{
foreach (DataGridViewRow item in dgvOperation.Rows)
{
item.Cells[6].Value = false;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
List<int> list = new List<int>();
foreach (DataGridViewRow item in dgvOperation.Rows)
{
bool isChoose = bool.Parse(item.Cells[6].EditedFormattedValue.ToString());
if (isChoose)
{
string SelectId = item.Cells[0].Value.ToString();// as string;
if (SelectId != "")
list.Add(Convert.ToInt32(SelectId));
}
}
if (list.Count > 0)
{
frmPrescriptionDocument document = new frmPrescriptionDocument();
document.RecordIds = list;
document.ShowDialog();
}
}
private void button3_Click(object sender, EventArgs e)
{
frmOperationCharg5 document = new frmOperationCharg5();
document.Show();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
frmOperationCharg3 document = new frmOperationCharg3();
document.Show();
}
}
}