using DrawGraph; using AIMS.OremrUserControl; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using AIMSModel; using AIMSBLL; namespace AIMS.OperationDoing.AnasRecordBill.UI { public partial class frmSelectPatientNew : Form { public int SelPatientId; public int SelApplyId; public bool isMainOpen = false; public frmSelectPatientNew() { InitializeComponent(); } private void frmSelectPatientNew_Load(object sender, EventArgs e) { List rooms = BOperationRoom.GetOperationRooms("IsValid=1 and Site='手术室'"); rooms.Insert(0, new OperationRoom() { Id = -1, Name = "" }); cboRoom.DataSource = rooms; cboRoom.DisplayMember = "Name"; cboRoom.ValueMember = "Id"; FillDgv(); this.cboRoom.SelectedIndexChanged += new System.EventHandler(this.cboRoom_SelectedIndexChanged); } void dgv_DataError(object sender, DataGridViewDataErrorEventArgs e) { } private void btnNext_Click(object sender, EventArgs e) { dtpSelectPatientTime.Value = dtpSelectPatientTime.Value.AddDays(1); } private void btnFrontDay_Click(object sender, EventArgs e) { dtpSelectPatientTime.Value = dtpSelectPatientTime.Value.AddDays(-1); } private void dtpSelectPatientTime_ValueChanged(object sender, EventArgs e) { FillDgv(); } private void FillDgv() { panel3.Controls.Clear(); panel2.Visible = false; int i = 0, j = 0; DataTable dt = SelectPatient.GetSelectPatientDataTable (DateTime.Parse(dtpSelectPatientTime.Value.ToString("yyyy-MM-dd").ToString()), cboRoom.SelectedValue.ToString()); foreach (DataRow dr in dt.Rows) { ucPatientCard uc = new ucPatientCard(dr); uc.InRoom += Uc_InRoom; uc.QxRoom += Uc_QxRoom; uc.Clicks += Uc_Clicks; uc.Location = new Point((uc.Width + 9) * j, (uc.Height + 10) * i + 30); panel3.Controls.Add(uc); j++; if (j == 5) { i++; j = 0; } //防止显示全部卡顿 if (i >= 5) break; } DataTable dt2 = SelectPatient.GetRelieveLockingPatientDataTable (DateTime.Parse(dtpSelectPatientTime.Value.ToString("yyyy-MM-dd").ToString()), cboRoom.SelectedValue.ToString()); foreach (DataRow dr in dt2.Rows) { ucPatientCard uc = new ucPatientCard(dr); uc.InRoom += Uc_InRoom; uc.QxRoom += Uc_QxRoom; uc.Clicks += Uc_Clicks; uc.Location = new Point((uc.Width + 9) * j, (uc.Height + 10) * i + 30); panel3.Controls.Add(uc); j++; if (j == 5) { i++; j = 0; } //防止显示全部卡顿 if (i >= 10) break; } } private void Uc_Clicks(ucPatientCard uc, int PatientId, int applyId, DataRow dr) { SelPatientId = PatientId; SelApplyId = applyId; txtType.Text = dr["OperationType"].ToString(); txtNo.Text = dr["MdrecNo"].ToString(); txtname.Text = dr["PatientName"].ToString(); txtsex.Text = dr["sex"].ToString(); txtage.Text = dr["age"].ToString(); txtss.Text = dr["ApplyOperationInfoName"].ToString(); txtmzys.Text = dr["AnesthesiaDoctor"].ToString(); txttime.Text = dr["PlanOperationTime"].ToString(); txtdept.Text = dr["ApplyDepName"].ToString(); txtzdys.Text = dr["OperationDoctor"].ToString(); txths.Text = dr["InstrumentNurse"].ToString() + " " + dr["TourNurse"].ToString(); txtzd.Text = dr["ApplyDiagnoseInfoName"].ToString(); txtRoom.Text = dr["OperationRoom"].ToString(); txtRoom.Tag = dr["OperationRoomId"].ToString(); if (!txtType.Text.Contains("急")) txtType.ForeColor = Color.DarkGreen; else txtType.ForeColor = Color.Red; txtState.Text = dr["State"].ToString(); if (txtState.Text == "手术中" || txtState.Text == "手术结束") { label5.Text = "手术开始时间"; label23.Text = "术中诊断"; label25.Text = "实施手术"; } else { label5.Text = "申请预约时间"; label23.Text = "术前诊断"; label25.Text = "拟施手术"; } buttonX1.Text = uc.buttonX1.Text; panel2.Visible = true; } private void Uc_InRoom(ucPatientCard uc, int PatientId, int applyId) { string RoomStr = uc.Tag.ToString(); if (RoomStr == "") { frmSeleteRoom seleteRoom = new frmSeleteRoom(); seleteRoom.ShowDialog(); if (seleteRoom.RoomId != null) { RoomStr = seleteRoom.RoomId.ToString(); if (RoomStr != null && RoomStr != "") { OperationApply opeapply = BOperationApply.SelectSingle(applyId, RecursiveType.None, 0); opeapply.State = 4; opeapply.OperationRoomId = int.Parse(seleteRoom.RoomId); opeapply.PlanOperationTime = dtpSelectPatientTime.Value; opeapply.PlanOrder = BOperationApply.GetMaxPlanOrder(opeapply.PlanOperationTime.Value, opeapply.OperationRoomId.Value) + 1; BOperationApply.Update(opeapply); } } } if (RoomStr == "") return; SatrtOperation(uc.buttonX1.Text, PatientId, applyId, int.Parse(RoomStr)); } private void SatrtOperation(string State, int PatientId, int applyId, int RoomId) { try { if (State == "开始手术") { AIMS.OperationDoing.AnasRecordBill.UI.frmAnasRecordBillNew frmAnasRecord = new frmAnasRecordBillNew(); frmAnasRecord.PatientId = PatientId; frmAnasRecord.ApplyId = applyId; frmAnasRecord.NowRoom = AIMSBLL.BOperationRoom.SelectSingle(RoomId); frmAnasRecord.State = AIMSExtension.EditState.ADD; SelectPatient.UpdateApplyState(PatientId, applyId); //修改状态 if (isMainOpen == false) { frmAnasRecord.ShowDialog(); FillDgv(); } else { this.Close(); } } else { AIMS.OperationDoing.AnasRecordBill.UI.frmAnasRecordBillNew frmAnasRecord = new frmAnasRecordBillNew(); frmAnasRecord.PatientId = PatientId; frmAnasRecord.ApplyId = applyId; frmAnasRecord.NowRoom = AIMSBLL.BOperationRoom.SelectSingle(RoomId); if (State == "继续手术") { frmAnasRecord.State = AIMSExtension.EditState.EDIT; } else { frmAnasRecord.State = AIMSExtension.EditState.BROWSE; } if (isMainOpen == false) { frmAnasRecord.ShowDialog(); FillDgv(); } else { this.Close(); } } } catch (Exception ex) { AIMSExtension.PublicMethod.WriteLog(ex); } } private void Uc_QxRoom(ucPatientCard uc, int RecorId, int PatientId, int applyId) { try { if (uc.buttonX2.Text == "取消手术") { if (BOperationRecord.GetDataCount(RecorId, PatientId, 1) > 0) { MessageBox.Show("清除数据在进行取消转入操作!"); return; } if (MessageBox.Show("确认要取消手术吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { HelperDB.DbHelperSQL.BeginTrans(); BOperationApply.UpdateApplyState(applyId, 4); BOperationRecord.DeleteOperationRecordData(RecorId, PatientId, 1); HelperDB.DbHelperSQL.CommitTrans(); if (isMainOpen == false) { FillDgv(); } else { this.Close(); } } catch { HelperDB.DbHelperSQL.RollbackTrans(); } } } else { if (MessageBox.Show("确认要返回手术吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { HelperDB.DbHelperSQL.BeginTrans(); BOperationApply.UpdateApplyState(applyId, 6); BOperationRecord.UpdateState(PatientId, 1, 1); BOperationRecord.DeleteEvent(PatientId, 8); HelperDB.DbHelperSQL.CommitTrans(); AIMS.OperationDoing.AnasRecordBill.UI.frmAnasRecordBillNew frmAnasRecord = new frmAnasRecordBillNew(); frmAnasRecord.PatientId = PatientId; frmAnasRecord.ApplyId = applyId; frmAnasRecord.NowRoom = AIMSBLL.BOperationRoom.SelectSingle(int.Parse(uc.Tag.ToString())); frmAnasRecord.State = AIMSExtension.EditState.EDIT; frmAnasRecord._record = new OperationRecord(); frmAnasRecord._record.Id = PatientId; if (isMainOpen == false) { frmAnasRecord.ShowDialog(); FillDgv(); } else { this.Close(); } } catch { HelperDB.DbHelperSQL.RollbackTrans(); } } } } catch (Exception ex) { AIMSExtension.PublicMethod.WriteLog(ex); } } private void cboRoom_SelectedIndexChanged(object sender, EventArgs e) { FillDgv(); } private void buttonX1_Click(object sender, EventArgs e) { string RoomStr = txtRoom.Tag.ToString(); if (RoomStr == "") { frmSeleteRoom seleteRoom = new frmSeleteRoom(); seleteRoom.ShowDialog(); if (seleteRoom.RoomId != null) { RoomStr = seleteRoom.RoomId.ToString(); if (RoomStr != null && RoomStr != "") { OperationApply opeapply = BOperationApply.SelectSingle(SelApplyId, RecursiveType.None, 0); opeapply.State = 4; opeapply.OperationRoomId = int.Parse(seleteRoom.RoomId); opeapply.PlanOperationTime = dtpSelectPatientTime.Value; opeapply.PlanOrder = BOperationApply.GetMaxPlanOrder(opeapply.PlanOperationTime.Value, opeapply.OperationRoomId.Value) + 1; BOperationApply.Update(opeapply); } } } if (RoomStr == "") return; SatrtOperation(buttonX1.Text, SelPatientId, SelApplyId, (int.Parse(RoomStr))); } private void buttonX3_Click(object sender, EventArgs e) { AIMS.OperationFront.UI.frmOperationApplyDetail frmOperationApplyDetail = new AIMS.OperationFront.UI.frmOperationApplyDetail(); frmOperationApplyDetail.State = AIMSExtension.EditState.ADD; frmOperationApplyDetail.ShowDialog(); } } }