using AIMS.OremrUserControl; using AIMSBLL; using AIMSExtension; using AIMSModel; using AxNsoOfficeLib; using DrawGraph; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Net; using System.Windows.Forms; namespace AIMS.OperationAanesthesia { public partial class frmSelectPatientGoodsBill : Form { public int SelPatientId; public int SelApplyId; public bool isMainOpen = false; public AIMS.OperationAanesthesia.frmInstrumentRecord tempfrmAnasRecord; public frmSelectPatientGoodsBill() { InitializeComponent(); } private void frmSelectPatientGoodsBill_Load(object sender, EventArgs e) { ControlExtension.GetOperationSiteRoom(labelSite, CboOperationSite, cboRoom); FillDgv(); this.cboRoom.SelectedIndexChanged += new System.EventHandler(this.cboRoom_SelectedIndexChanged); this.CboOperationSite.SelectedIndexChanged += new System.EventHandler(this.CboOperationSite_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; DataTable dt = new DataTable(); if (txtquery.Text.Trim() != "") dt = SelectPatient.GetSelectPatientDataTable(txtquery.Text); else dt = SelectPatient.GetSelectPatientDataTable(DateTime.Parse(dtpSelectPatientTime.Value.ToString("yyyy-MM-dd").ToString()), cboRoom.SelectedValue.ToString()); DataTable dt2 = new DataTable(); if (txtquery.Text.Trim() != "") dt2 = SelectPatient.GetRelieveLockingPatientDataTable(txtquery.Text); else dt2 = SelectPatient.GetRelieveLockingPatientDataTable(DateTime.Parse(dtpSelectPatientTime.Value.ToString("yyyy-MM-dd").ToString()), cboRoom.SelectedValue.ToString()); List list = new List(); for (int i = 0; i < ControlExtension.SiteRooms.Count; i++) { foreach (DataRow dr in dt.Rows) { if (dr["OperationRoom"].ToString() == ControlExtension.SiteRooms[i].Name && !list.Contains(ControlExtension.SiteRooms[i].Name)) { list.Add(ControlExtension.SiteRooms[i].Name); } } foreach (DataRow dr in dt2.Rows) { if (dr["OperationRoom"].ToString() == ControlExtension.SiteRooms[i].Name && !list.Contains(ControlExtension.SiteRooms[i].Name)) { list.Add(ControlExtension.SiteRooms[i].Name); } } } if (cboRoom.Text != "") { int i = 0, j = 0; foreach (DataRow dr in dt.Rows) { if (dr["OperationRoom"].ToString() != cboRoom.Text) continue; ucPatientCard uc = new ucPatientCard(dr); uc.InRoom += Uc_InRoom; uc.QxRoom += Uc_QxRoom; uc.Clicks += Uc_Clicks; if (uc.lblAnesDoctors.Text == "麻醉医生:" || uc.lblAnesDoctors.Text.Trim() == "麻醉医生") uc.buttonX1.Enabled = true; else uc.buttonX1.Enabled = false; uc.Location = new Point((uc.Width + 9) * j, (uc.Height + 10) * i + 30); panel3.Controls.Add(uc); j++; if (j == 5) { i++; j = 0; } } foreach (DataRow dr in dt2.Rows) { if (dr["OperationRoom"].ToString() != cboRoom.Text) continue; ucPatientCard uc = new ucPatientCard(dr); uc.buttonX1.Text = "器械清点"; uc.InRoom += Uc_InRoom; uc.QxRoom += Uc_QxRoom; uc.Clicks += Uc_Clicks; if (uc.lblAnesDoctors.Text == "麻醉医生:" || uc.lblAnesDoctors.Text.Trim() == "麻醉医生") uc.buttonX2.Enabled = true; else uc.buttonX2.Enabled = false; uc.Location = new Point((uc.Width + 9) * j, (uc.Height + 10) * i + 30); panel3.Controls.Add(uc); j++; if (j == 5) { i++; j = 0; } } } else { for (int i = 0; i < list.Count; i++) { int j = 0; int Pointx = 0; foreach (DataRow dr in dt.Rows) { if (dr["OperationRoom"].ToString() != list[i]) continue; ucPatientCard uc = new ucPatientCard(dr); uc.InRoom += Uc_InRoom; uc.QxRoom += Uc_QxRoom; uc.Clicks += Uc_Clicks; if (uc.lblAnesDoctors.Text == "麻醉医生:" || uc.lblAnesDoctors.Text.Trim() == "麻醉医生") uc.buttonX1.Enabled = true; else uc.buttonX1.Enabled = false; uc.Location = new Point((uc.Width + 9) * i, (uc.Height + 10) * j + 30); panel3.Controls.Add(uc); j++; Pointx = (uc.Width + 9) * i; } foreach (DataRow dr in dt2.Rows) { if (dr["OperationRoom"].ToString() != list[i]) continue; ucPatientCard uc = new ucPatientCard(dr); uc.buttonX1.Text = "器械清点"; uc.InRoom += Uc_InRoom; uc.QxRoom += Uc_QxRoom; uc.Clicks += Uc_Clicks; if (uc.lblAnesDoctors.Text == "麻醉医生:" || uc.lblAnesDoctors.Text.Trim() == "麻醉医生") uc.buttonX2.Enabled = true; else uc.buttonX2.Enabled = false; uc.Location = new Point((uc.Width + 9) * i, (uc.Height + 10) * j + 30); panel3.Controls.Add(uc); j++; Pointx = (uc.Width + 9) * i; } if (Pointx > 0) { DevComponents.DotNetBar.Controls.Line line1 = new DevComponents.DotNetBar.Controls.Line(); line1.Location = new System.Drawing.Point(Pointx - 10, 0); line1.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; line1.Size = new System.Drawing.Size(10, panel3.Height); line1.ForeColor = Color.DarkGray; line1.VerticalLine = true; panel3.Controls.Add(line1); } } } } public ucPatientCard SelUc; 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["OrderOperationTime"].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 = "拟施手术"; } if (txtRoom.Text != "") uc.buttonX2.Enabled = true; else uc.buttonX2.Enabled = false; buttonX1.Text = uc.buttonX1.Text; panel2.Visible = true; SelUc = uc; } 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, PatientId, applyId, int.Parse(RoomStr)); } private void SatrtOperation(ucPatientCard uc, int PatientId, int applyId, int RoomId) { try { string State = uc.buttonX1.Text; if (State == "转入术间") { OperationApply operA = BOperationApply.SelectSingle(applyId); if (operA.State == 11) { MessageBox.Show("当前手术已停止 ,请确认后重新选择!", "系统提示"); return; } if (operA.State == 5 || operA.State == 6) { MessageBox.Show("当前手术已开始 ,请确认后重新选择!", "系统提示"); FillDgv(); return; } if (uc.lblAnesDoctors.Text != "麻醉医生:" && uc.lblAnesDoctors.Text.Trim() != "麻醉医生") { MessageBox.Show("当前手术已安排麻醉师,请于麻醉师转入后操作", "系统提示"); return; } //DataTable dtOperationRecord = SelectPatient.GetTodayDoOpePatientDataTable(DateTime.Parse(dtpSelectPatientTime.Value.ToString("yyyy-MM-dd").ToString())); //foreach (DataRow row in dtOperationRecord.Rows) //{ // if (row["OperationRoomId"].ToString() == operA.OperationRoomId.ToString()) // { // MessageBox.Show("当前有未完成的手术占用手术间,请先选择解锁术中手术!", "系统提示"); // return; // } //} frmInstrumentRecord frmAnasRecord = null; if (tempfrmAnasRecord != null && tempfrmAnasRecord._record != null) { frmAnasRecord = tempfrmAnasRecord; frmAnasRecord.ClearRecordDate(); } else { frmAnasRecord = new frmInstrumentRecord(); } frmAnasRecord.PatientId = PatientId; frmAnasRecord.ApplyId = applyId; frmAnasRecord.NowRoom = AIMSBLL.BOperationRoom.SelectSingle(RoomId); frmAnasRecord.State = AIMSExtension.EditState.ADD; SelectPatient.UpdateApplyState(PatientId, applyId); //修改状态 uc.label2.Text = "手术中"; uc.label2.ForeColor = Color.Red; uc.buttonX1.Text = "器械清点"; uc.buttonX2.Text = "取消手术"; uc.buttonX1.Visible = true; uc.buttonX2.Visible = true; uc.BackColor = Color.OldLace; if (isMainOpen == false) { frmAnasRecord.ShowDialog(); FillDgv(); } else { //if (frmAnasRecord._record != null) // frmAnasRecord.ClearRecordDate(); this.Close(); } } else { frmInstrumentRecord frmAnasRecord = null; if (tempfrmAnasRecord != null && tempfrmAnasRecord._record != null) { frmAnasRecord = tempfrmAnasRecord; frmAnasRecord.ClearRecordDate(); } else { frmAnasRecord = new frmInstrumentRecord(); } frmAnasRecord.PatientId = PatientId; frmAnasRecord.ApplyId = applyId; frmAnasRecord.NowRoom = AIMSBLL.BOperationRoom.SelectSingle(RoomId); 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.lblAnesDoctors.Text != "麻醉医生:" && uc.lblAnesDoctors.Text.Trim() != "麻醉医生") { MessageBox.Show("当前手术已有麻醉师,请麻醉师进行操作!", "系统提示"); return; } 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(); frmInstrumentRecord frmAnasRecord = null; if (tempfrmAnasRecord != null && tempfrmAnasRecord._record != null) { frmAnasRecord = tempfrmAnasRecord; frmAnasRecord.ClearRecordDate(); } else { frmAnasRecord = new frmInstrumentRecord(); } 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 { //if (frmAnasRecord._record != null) // frmAnasRecord.ClearRecordDate(); this.Close(); } } catch { HelperDB.DbHelperSQL.RollbackTrans(); } } } } catch (Exception ex) { AIMSExtension.PublicMethod.WriteLog(ex); } } private void cboRoom_SelectedIndexChanged(object sender, EventArgs e) { if (cboRoom.SelectedIndex > 0) { PublicMethod.SelectRoom = Convert.ToInt32(cboRoom.SelectedValue); } else { PublicMethod.SelectRoom = -1; } 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(SelUc, SelPatientId, SelApplyId, (int.Parse(RoomStr))); } public OperationRoom GetOperationRoom(List list) { try { //得到计算机名 string strPcName = Dns.GetHostName(); //得到本机IP地址数组 IPHostEntry ipEntry = Dns.GetHostEntry(strPcName); //遍历数组 foreach (OperationRoom room in list) { foreach (var IPadd in ipEntry.AddressList) { //判断当前字符串是否为正确IP地址 if (PublicMethod.IsRightIP(IPadd.ToString())) { if (room.Ip == IPadd.ToString() || room.Ip2 == IPadd.ToString() || room.Ip3 == IPadd.ToString()) { return room; } } } } return null; } catch (Exception) { return null; } } private void btnQuery_Click(object sender, EventArgs e) { FillDgv(); } private void buttonX2_Click(object sender, EventArgs e) { string RoomStr = txtRoom.Tag.ToString(); if (RoomStr != "") { frmSeleteRoom seleteRoom = new frmSeleteRoom(); seleteRoom.NowRoomId = RoomStr; seleteRoom.ShowDialog(); RoomStr = seleteRoom.RoomId; if (RoomStr != null && RoomStr != "") { txtRoom.Text = seleteRoom.RoomName; txtRoom.Tag = int.Parse(RoomStr); BOperationRecord.Update("RoomId=@RoomId where OperationApplyId=@id ", new AIMSModel.ParameterList("@RoomId", int.Parse(RoomStr), "@id", SelApplyId)); BOperationApply.UpdateApplyRoom(SelApplyId, int.Parse(RoomStr), DateTime.Parse(txttime.Text)); BOperationApply.UpdteOperationOrder(DateTime.Parse(txttime.Text), int.Parse(RoomStr)); FillDgv(); panel2.Visible = true; MessageBox.Show("手术间切换成功!"); } } } private void CboOperationSite_SelectedIndexChanged(object sender, EventArgs e) { ControlExtension.SetOperationSiteRoom(CboOperationSite, cboRoom); FillDgv(); } } }